@antelopejs/dms-frontend 0.7.1 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. package/README.md +4 -4
  2. package/dist/commands/build-action.d.ts +8 -5
  3. package/dist/commands/build-action.js +16 -41
  4. package/dist/commands/build.js +9 -15
  5. package/dist/commands/dev-action.d.ts +2 -0
  6. package/dist/commands/dev-action.js +14 -3
  7. package/dist/commands/dev.js +3 -1
  8. package/dist/commands/start-action.d.ts +2 -0
  9. package/dist/commands/start-action.js +65 -47
  10. package/dist/commands/start.js +8 -6
  11. package/dist/common.d.ts +1 -0
  12. package/dist/common.js +1 -0
  13. package/dist/config.d.ts +2 -0
  14. package/dist/config.js +9 -0
  15. package/dist/derived-outputs.d.ts +1 -5
  16. package/dist/derived-outputs.js +48 -35
  17. package/dist/dev-modules.d.ts +5 -0
  18. package/dist/dev-modules.js +88 -0
  19. package/dist/entry-weight.d.ts +24 -0
  20. package/dist/entry-weight.js +86 -0
  21. package/dist/fs-sync.d.ts +1 -0
  22. package/dist/fs-sync.js +6 -0
  23. package/dist/help.js +12 -4
  24. package/dist/index.js +4 -6
  25. package/dist/layer-watch.js +7 -2
  26. package/dist/layers.d.ts +2 -3
  27. package/dist/layers.js +1 -95
  28. package/dist/locale-files.d.ts +6 -0
  29. package/dist/locale-files.js +75 -0
  30. package/dist/manifest.d.ts +8 -8
  31. package/dist/manifest.js +17 -39
  32. package/dist/materialize.js +6 -0
  33. package/dist/module-set.d.ts +14 -12
  34. package/dist/module-set.js +39 -31
  35. package/dist/private-values.d.ts +3 -2
  36. package/dist/private-values.js +16 -5
  37. package/dist/project-modules-child.d.ts +13 -0
  38. package/dist/project-modules-child.js +26 -0
  39. package/dist/project-modules.d.ts +47 -0
  40. package/dist/project-modules.js +268 -0
  41. package/dist/workspace-setup.d.ts +3 -7
  42. package/dist/workspace-setup.js +79 -62
  43. package/dist/workspace.d.ts +8 -4
  44. package/dist/workspace.js +1 -1
  45. package/package.json +13 -8
  46. package/skills/dms-frontend/SKILL.md +2 -2
  47. package/templates/vue/app-runtime.ts +8 -1
  48. package/templates/vue/client-chunking.mjs +61 -0
  49. package/templates/vue/email-renderer.ts +6 -1
  50. package/templates/vue/entry-weight.mjs +132 -0
  51. package/templates/vue/frontend-build-loader.ts +1 -1
  52. package/templates/vue/frontend-module.ts +168 -1
  53. package/templates/vue/gitignore +1 -0
  54. package/templates/vue/main.ts +32 -2
  55. package/templates/vue/network-error.ts +3 -1
  56. package/templates/vue/package.json +3 -3
  57. package/templates/vue/patches/@vueuse__core@14.4.0.patch +24 -0
  58. package/templates/vue/pnpm-workspace.yaml +5 -0
  59. package/templates/vue/prepare-types.mjs +2 -7
  60. package/templates/vue/public-options.ts +19 -0
  61. package/templates/vue/server/auth/backend.mjs +20 -3
  62. package/templates/vue/server/auth/client-ip.mjs +64 -22
  63. package/templates/vue/server/auth/session.mjs +4 -11
  64. package/templates/vue/server/backend-proxies.mjs +13 -2
  65. package/templates/vue/server/backend-response.mjs +2 -13
  66. package/templates/vue/server/cli-report.mjs +42 -18
  67. package/templates/vue/server/client-manifest.mjs +34 -58
  68. package/templates/vue/server/dev-private-files.mjs +1 -1
  69. package/templates/vue/server/dev-styles.mjs +16 -5
  70. package/templates/vue/server/homepage.mjs +4 -1
  71. package/templates/vue/server/in-place-render.mjs +110 -0
  72. package/templates/vue/server/module-event.mjs +23 -8
  73. package/templates/vue/server/module-server.mjs +4 -4
  74. package/templates/vue/server/module-testing.mjs +5 -3
  75. package/templates/vue/server/page-props.mjs +10 -0
  76. package/templates/vue/server/proxy-compression.mjs +15 -8
  77. package/templates/vue/server/proxy-headers.mjs +12 -1
  78. package/templates/vue/server/proxy-redirects.mjs +66 -0
  79. package/templates/vue/server/proxy-transfers.mjs +110 -0
  80. package/templates/vue/server/public-endpoints.mjs +2 -2
  81. package/templates/vue/server/public-options.mjs +49 -0
  82. package/templates/vue/server/request-routing.mjs +20 -0
  83. package/templates/vue/server/web-body.mjs +24 -0
  84. package/templates/vue/server-module.ts +19 -7
  85. package/templates/vue/server.mjs +98 -78
  86. package/templates/vue/sfc-global-types.mjs +119 -0
  87. package/templates/vue/ssr-renderer.ts +27 -1
  88. package/templates/vue/ui-kbd.mjs +45 -0
  89. package/templates/vue/vite.config.ts +104 -47
  90. package/templates/vue/vite.email.config.ts +6 -3
  91. package/templates/vue/vite.server.config.ts +5 -2
  92. package/dist/commands/snapshot-action.d.ts +0 -6
  93. package/dist/commands/snapshot-action.js +0 -53
  94. package/dist/commands/snapshot.d.ts +0 -2
  95. package/dist/commands/snapshot.js +0 -55
  96. package/dist/snapshot.d.ts +0 -25
  97. package/dist/snapshot.js +0 -90
  98. package/templates/vue/server/backend-wake.mjs +0 -129
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.InvalidLocaleFileError = void 0;
4
+ exports.readLocaleFile = readLocaleFile;
5
+ const node_fs_1 = require("node:fs");
6
+ const message_compiler_1 = require("@intlify/message-compiler");
7
+ class InvalidLocaleFileError extends Error {
8
+ constructor(path, reason) {
9
+ super(`Invalid locale file ${path}: ${reason}`);
10
+ this.path = path;
11
+ this.reason = reason;
12
+ this.name = "InvalidLocaleFileError";
13
+ }
14
+ }
15
+ exports.InvalidLocaleFileError = InvalidLocaleFileError;
16
+ const LITERAL_ESCAPES = {
17
+ "@": "{'@'}",
18
+ "{": "{'{'}",
19
+ "}": "{'}'}",
20
+ "|": "{'|'}",
21
+ };
22
+ function reservedCharacterAt(message, offset) {
23
+ for (let index = Math.min(offset, message.length - 1); index >= 0; index--) {
24
+ if (message[index] in LITERAL_ESCAPES)
25
+ return message[index];
26
+ }
27
+ return null;
28
+ }
29
+ function describeProblem({ key, message, error }) {
30
+ const where = `${key}: ${error.message} in ${JSON.stringify(message)}`;
31
+ const character = reservedCharacterAt(message, error.location?.start.offset ?? message.length);
32
+ if (!character) {
33
+ return `${where}. Write ${Object.values(LITERAL_ESCAPES).join(", ")} for a literal ${Object.keys(LITERAL_ESCAPES).join(", ")}.`;
34
+ }
35
+ const fixed = message.replaceAll(character, LITERAL_ESCAPES[character]);
36
+ return `${where}. Write a literal ${character} as ${LITERAL_ESCAPES[character]}: ${JSON.stringify(fixed)}.`;
37
+ }
38
+ function firstCompileError(message) {
39
+ let first;
40
+ (0, message_compiler_1.baseCompile)(message, {
41
+ location: true,
42
+ onError: (error) => {
43
+ first ??= error;
44
+ },
45
+ });
46
+ return first;
47
+ }
48
+ function messageProblems(value, key) {
49
+ if (typeof value === "string") {
50
+ const error = firstCompileError(value);
51
+ return error ? [{ key, message: value, error }] : [];
52
+ }
53
+ if (typeof value !== "object" || value === null)
54
+ return [];
55
+ return Object.entries(value).flatMap(([child, nested]) => messageProblems(nested, key ? `${key}.${child}` : child));
56
+ }
57
+ function readLocaleFile(path) {
58
+ let value;
59
+ try {
60
+ value = JSON.parse((0, node_fs_1.readFileSync)(path, "utf8"));
61
+ }
62
+ catch (error) {
63
+ const reason = error instanceof Error ? error.message : String(error);
64
+ throw new InvalidLocaleFileError(path, reason);
65
+ }
66
+ const problems = messageProblems(value, "");
67
+ if (problems.length) {
68
+ const reason = [
69
+ `${problems.length} message(s) vue-i18n cannot compile:`,
70
+ ...problems.map(describeProblem),
71
+ ].join("\n");
72
+ throw new InvalidLocaleFileError(path, reason);
73
+ }
74
+ return value;
75
+ }
@@ -18,6 +18,7 @@ export declare class ManifestRefusedError extends CliError {
18
18
  }
19
19
  export declare function describeManifestVersion(version: unknown): CliProblem;
20
20
  export declare class BackendResponseError extends CliError {
21
+ readonly status: number;
21
22
  constructor(subject: string, url: string | URL, response: Pick<Response, "status" | "statusText">);
22
23
  }
23
24
  export declare class NoCachedManifestError extends CliError {
@@ -29,19 +30,18 @@ export interface ManifestCacheEntry {
29
30
  fetchedAt: string;
30
31
  }
31
32
  export declare function readCachedManifest(workspaceDir: string): ManifestCacheEntry | undefined;
32
- export declare function writeCachedManifest(workspaceDir: string, manifest: Manifest, privateValues: PrivateValues, fetchedAt?: string): void;
33
- export type PrivateValues = "keep" | "drop";
34
- export type ManifestCacheUse = "fallback" | "offline" | "never";
33
+ export declare function writeCachedManifest(workspaceDir: string, manifest: Manifest, fetchedAt?: string): void;
34
+ export type ManifestCacheUse = "fallback" | "offline";
35
+ export interface ManifestRequest {
36
+ clientUrl?: string;
37
+ bootstrapSecret?: string;
38
+ }
35
39
  export interface ResolvedManifest {
36
40
  manifest: Manifest;
37
41
  fromCache: boolean;
38
42
  fetchedAt?: string;
39
43
  }
40
- export declare function resolveManifest(workspaceDir: string, backendUrl: string, cacheUse: ManifestCacheUse, { clientUrl, bootstrapSecret, privateValues, }?: {
41
- clientUrl?: string;
42
- bootstrapSecret?: string;
43
- privateValues?: PrivateValues;
44
- }): Promise<ResolvedManifest>;
44
+ export declare function resolveManifest(workspaceDir: string, backendUrl: string, cacheUse: ManifestCacheUse, { clientUrl, bootstrapSecret }?: ManifestRequest): Promise<ResolvedManifest>;
45
45
  export declare function assertCachedLayerPathsExist(modules: ServedWithPath[], fetchedAt?: string): void;
46
46
  export type ServedWithPath = ManifestModule & {
47
47
  path: string;
package/dist/manifest.js CHANGED
@@ -14,7 +14,6 @@ const node_fs_1 = require("node:fs");
14
14
  const node_path_1 = require("node:path");
15
15
  const cli_1 = require("@antelopejs/core/cli");
16
16
  const config_1 = require("./config");
17
- const private_values_1 = require("./private-values");
18
17
  const output_1 = require("./output");
19
18
  const workspace_1 = require("./workspace");
20
19
  class ManifestUnauthorizedError extends cli_1.CliError {
@@ -162,6 +161,7 @@ class BackendResponseError extends cli_1.CliError {
162
161
  };
163
162
  super(problem);
164
163
  this.name = "BackendResponseError";
164
+ this.status = status;
165
165
  }
166
166
  }
167
167
  exports.BackendResponseError = BackendResponseError;
@@ -194,12 +194,11 @@ async function fetchManifest(backendUrl, clientUrl, bootstrapSecret) {
194
194
  if (incompatible.length) {
195
195
  throw new ManifestRefusedError(`Frontend manifest contains incompatible renderer modules: ${incompatible.map((module) => module.name).join(", ")}`);
196
196
  }
197
- const resolved = {
198
- pack: manifest.archive,
199
- modules: manifest.modules,
200
- };
197
+ const resolved = { modules: manifest.modules };
201
198
  if (manifest.settling)
202
199
  resolved.settling = true;
200
+ if (manifest.originRewrites)
201
+ resolved.originRewrites = manifest.originRewrites;
203
202
  return resolved;
204
203
  }
205
204
  const MANIFEST_CACHE_FILE = ".manifest-cache.json";
@@ -217,19 +216,15 @@ function readCachedManifest(workspaceDir) {
217
216
  return undefined;
218
217
  }
219
218
  }
220
- function writeCachedManifest(workspaceDir, manifest, privateValues, fetchedAt = new Date().toISOString()) {
219
+ function writeCachedManifest(workspaceDir, manifest, fetchedAt = new Date().toISOString()) {
221
220
  const entry = { manifest, fetchedAt };
222
- const write = privateValues === "keep" ? config_1.writeSecretBearingFile : config_1.writeShareableFile;
223
- write((0, node_path_1.join)(workspaceDir, MANIFEST_CACHE_FILE), `${JSON.stringify(entry, null, 2)}\n`);
221
+ (0, config_1.writeSecretBearingFile)((0, node_path_1.join)(workspaceDir, MANIFEST_CACHE_FILE), `${JSON.stringify(entry, null, 2)}\n`);
224
222
  }
225
- async function resolveManifest(workspaceDir, backendUrl, cacheUse, { clientUrl, bootstrapSecret, privateValues = "keep", } = {}) {
223
+ async function resolveManifest(workspaceDir, backendUrl, cacheUse, { clientUrl, bootstrapSecret } = {}) {
226
224
  if (cacheUse !== "offline") {
227
225
  try {
228
- const served = await fetchManifest(backendUrl, clientUrl, bootstrapSecret);
229
- const manifest = privateValues === "keep"
230
- ? served
231
- : { ...served, modules: (0, private_values_1.withoutPrivateValues)(served.modules) };
232
- writeCachedManifest(workspaceDir, manifest, privateValues);
226
+ const manifest = await fetchManifest(backendUrl, clientUrl, bootstrapSecret);
227
+ writeCachedManifest(workspaceDir, manifest);
233
228
  return { manifest, fromCache: false };
234
229
  }
235
230
  catch (err) {
@@ -240,37 +235,20 @@ async function resolveManifest(workspaceDir, backendUrl, cacheUse, { clientUrl,
240
235
  const cached = readCachedManifest(workspaceDir);
241
236
  if (!cached)
242
237
  throw err;
243
- if (cacheUse === "never")
244
- throw cacheNotUsed(err, backendUrl, cached);
245
- return fromCachedEntry(workspaceDir, cached, privateValues);
238
+ return fromCachedEntry(cached);
246
239
  }
247
240
  }
248
241
  const cached = readCachedManifest(workspaceDir);
249
242
  if (!cached)
250
243
  throw new NoCachedManifestError();
251
- return fromCachedEntry(workspaceDir, cached, privateValues);
252
- }
253
- function cacheNotUsed(failure, backendUrl, cached) {
254
- const problem = failure instanceof cli_1.CliError
255
- ? failure.problem
256
- : { title: errorMessage(failure) };
257
- const cache = `A manifest${(0, output_1.cachedAge)(cached.fetchedAt)} exists; a build uses it only with --offline.`;
258
- return new cli_1.CliError({
259
- ...problem,
260
- reason: problem.reason ? `${problem.reason} ${cache}` : cache,
261
- fixes: [
262
- ...(problem.fixes ?? []),
263
- `Or build from the cache on purpose: ajs dms build -b ${displayUrl(backendUrl)} --offline`,
264
- ],
265
- }, { cause: failure });
244
+ return fromCachedEntry(cached);
266
245
  }
267
- function fromCachedEntry(workspaceDir, cached, privateValues) {
268
- let { manifest } = cached;
269
- if (privateValues === "drop") {
270
- manifest = { ...manifest, modules: (0, private_values_1.withoutPrivateValues)(manifest.modules) };
271
- writeCachedManifest(workspaceDir, manifest, "drop", cached.fetchedAt);
272
- }
273
- return { manifest, fromCache: true, fetchedAt: cached.fetchedAt };
246
+ function fromCachedEntry(cached) {
247
+ return {
248
+ manifest: cached.manifest,
249
+ fromCache: true,
250
+ fetchedAt: cached.fetchedAt,
251
+ };
274
252
  }
275
253
  function assertCachedLayerPathsExist(modules, fetchedAt) {
276
254
  const missing = modules.filter((mod) => !(0, node_fs_1.existsSync)(mod.path));
@@ -70,6 +70,12 @@ function copyLayerSource(src, dest) {
70
70
  filter: (srcPath) => !(0, fs_sync_1.isBlocklistedCopyPath)(src, srcPath),
71
71
  });
72
72
  sanitizeLayerPackage((0, node_path_1.join)(dest, "package.json"));
73
+ sanitizeBuildDeclaration((0, node_path_1.join)(dest, config_1.FRONTEND_BUILD_ENTRY));
74
+ }
75
+ function sanitizeBuildDeclaration(file) {
76
+ if (!(0, node_fs_1.existsSync)(file))
77
+ return;
78
+ (0, fs_sync_1.applyContent)((0, fs_sync_1.sanitizedBuildDeclaration)((0, node_fs_1.readFileSync)(file, "utf-8")), file);
73
79
  }
74
80
  function sanitizeLayerPackage(pkgPath) {
75
81
  if (!(0, node_fs_1.existsSync)(pkgPath))
@@ -1,5 +1,8 @@
1
1
  import { type ManifestModule } from "./workspace";
2
2
  export declare const MODULE_SET_POLL_INTERVAL_MS = 3000;
3
+ export declare const OWN_RELEASE: {
4
+ version: string;
5
+ };
3
6
  export type ModuleSetMember = Pick<ManifestModule, "name" | "path" | "priority" | "publicEndpoints" | "backendProxies">;
4
7
  export type BootstrapSecretSource = () => string | undefined;
5
8
  export interface ModuleSetFollowOptions {
@@ -13,15 +16,14 @@ export interface ModuleSetFollowOptions {
13
16
  }
14
17
  export declare function moduleSetFingerprint(modules: readonly ModuleSetMember[]): string;
15
18
  export declare function followModuleSet(options: ModuleSetFollowOptions): () => void;
16
- export declare function reportFrontendReady(backendUrl: string, moduleNames: readonly string[], bootstrapSecret?: string): Promise<boolean>;
17
- export type BuildDrift = {
18
- status: "matches";
19
- served: string;
20
- } | {
21
- status: "drifted";
22
- served: string;
23
- } | {
24
- status: "unknown";
25
- reason: string;
26
- };
27
- export declare function compareWithBackend(backendUrl: string, builtDigest: string, digestOf: (modules: readonly ManifestModule[]) => string, bootstrapSecret?: string): Promise<BuildDrift>;
19
+ export interface ServedModule {
20
+ name: string;
21
+ version?: string;
22
+ }
23
+ export interface ReadyRetry {
24
+ firstDelayMs: number;
25
+ maxDelayMs: number;
26
+ timeoutMs: number;
27
+ }
28
+ export declare function reportFrontendReady(backendUrl: string, modules: readonly ServedModule[], bootstrapSecret?: string): Promise<boolean>;
29
+ export declare function reportFrontendReadyOnceAnswered(backendUrl: string, modules: readonly ServedModule[], bootstrapSecret?: string, retry?: ReadyRetry): Promise<boolean>;
@@ -1,17 +1,18 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MODULE_SET_POLL_INTERVAL_MS = void 0;
3
+ exports.OWN_RELEASE = exports.MODULE_SET_POLL_INTERVAL_MS = void 0;
4
4
  exports.moduleSetFingerprint = moduleSetFingerprint;
5
5
  exports.followModuleSet = followModuleSet;
6
6
  exports.reportFrontendReady = reportFrontendReady;
7
- exports.compareWithBackend = compareWithBackend;
7
+ exports.reportFrontendReadyOnceAnswered = reportFrontendReadyOnceAnswered;
8
+ const promises_1 = require("node:timers/promises");
8
9
  const manifest_1 = require("./manifest");
9
10
  const workspace_1 = require("./workspace");
10
11
  exports.MODULE_SET_POLL_INTERVAL_MS = 3000;
11
12
  const READY_ENDPOINT = "/dms/frontend/ready";
12
13
  const READY_TIMEOUT_MS = 5000;
13
14
  const JSON_CONTENT_TYPE = "application/json";
14
- const OWN_RELEASE = require("../package.json");
15
+ exports.OWN_RELEASE = require("../package.json");
15
16
  function moduleSetFingerprint(modules) {
16
17
  return JSON.stringify([...modules]
17
18
  .sort((left, right) => left.name.localeCompare(right.name))
@@ -63,40 +64,47 @@ function followModuleSet(options) {
63
64
  clearTimeout(timer);
64
65
  };
65
66
  }
66
- async function reportFrontendReady(backendUrl, moduleNames, bootstrapSecret) {
67
+ const READY_WAKE_TIMEOUT_MS = 90_000;
68
+ const READY_FIRST_RETRY_MS = 2_000;
69
+ const READY_MAX_RETRY_MS = 60_000;
70
+ const SERVER_ERROR = 500;
71
+ const DEFAULT_READY_RETRY = {
72
+ firstDelayMs: READY_FIRST_RETRY_MS,
73
+ maxDelayMs: READY_MAX_RETRY_MS,
74
+ timeoutMs: READY_WAKE_TIMEOUT_MS,
75
+ };
76
+ async function postReadyReport(backendUrl, modules, bootstrapSecret, timeoutMs) {
77
+ const response = await fetch((0, manifest_1.backendEndpoint)(backendUrl, READY_ENDPOINT), {
78
+ method: "POST",
79
+ headers: {
80
+ ...(0, workspace_1.bootstrapHeaders)(bootstrapSecret),
81
+ "content-type": JSON_CONTENT_TYPE,
82
+ },
83
+ body: JSON.stringify({ modules, version: exports.OWN_RELEASE.version }),
84
+ signal: AbortSignal.timeout(timeoutMs),
85
+ });
86
+ await response.body?.cancel();
87
+ return response;
88
+ }
89
+ async function reportFrontendReady(backendUrl, modules, bootstrapSecret) {
67
90
  try {
68
- const response = await fetch((0, manifest_1.backendEndpoint)(backendUrl, READY_ENDPOINT), {
69
- method: "POST",
70
- headers: {
71
- ...(0, workspace_1.bootstrapHeaders)(bootstrapSecret),
72
- "content-type": JSON_CONTENT_TYPE,
73
- },
74
- body: JSON.stringify({
75
- modules: moduleNames,
76
- version: OWN_RELEASE.version,
77
- }),
78
- signal: AbortSignal.timeout(READY_TIMEOUT_MS),
79
- });
91
+ const response = await postReadyReport(backendUrl, modules, bootstrapSecret, READY_TIMEOUT_MS);
80
92
  return response.ok;
81
93
  }
82
94
  catch {
83
95
  return false;
84
96
  }
85
97
  }
86
- const DRIFT_CHECK_TIMEOUT_MS = 10_000;
87
- async function compareWithBackend(backendUrl, builtDigest, digestOf, bootstrapSecret) {
88
- try {
89
- const manifest = await Promise.race([
90
- (0, manifest_1.fetchManifest)(backendUrl, undefined, bootstrapSecret),
91
- new Promise((_resolve, reject) => setTimeout(() => reject(new Error("the backend did not answer in time")), DRIFT_CHECK_TIMEOUT_MS).unref()),
92
- ]);
93
- const served = digestOf(manifest.modules);
94
- return { status: served === builtDigest ? "matches" : "drifted", served };
95
- }
96
- catch (error) {
97
- return {
98
- status: "unknown",
99
- reason: error instanceof Error ? error.message : String(error),
100
- };
98
+ async function reportFrontendReadyOnceAnswered(backendUrl, modules, bootstrapSecret, retry = DEFAULT_READY_RETRY) {
99
+ for (let delayMs = retry.firstDelayMs;;) {
100
+ try {
101
+ const response = await postReadyReport(backendUrl, modules, bootstrapSecret, retry.timeoutMs);
102
+ if (response.status < SERVER_ERROR)
103
+ return response.ok;
104
+ }
105
+ catch {
106
+ }
107
+ await (0, promises_1.setTimeout)(delayMs, undefined, { ref: false });
108
+ delayMs = Math.min(retry.maxDelayMs, delayMs * 2);
101
109
  }
102
110
  }
@@ -1,5 +1,6 @@
1
- import type { FrontendModuleOptions, ManifestModule } from "./workspace";
2
- export declare function withoutPrivateValues(modules: readonly ManifestModule[]): ManifestModule[];
1
+ import type { FrontendModuleOptions } from "./workspace";
2
+ export declare function emptiedOptions(options: FrontendModuleOptions): FrontendModuleOptions;
3
+ export declare function filledOptions(shape: FrontendModuleOptions, values: FrontendModuleOptions | undefined): FrontendModuleOptions;
3
4
  export declare const PRIVATE_OPTIONS_VARIABLE = "DMS_PRIVATE_OPTIONS";
4
5
  export interface UnfilledPrivateValue {
5
6
  module: string;
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PRIVATE_OPTIONS_VARIABLE = void 0;
4
- exports.withoutPrivateValues = withoutPrivateValues;
4
+ exports.emptiedOptions = emptiedOptions;
5
+ exports.filledOptions = filledOptions;
5
6
  exports.parsePrivateOptions = parsePrivateOptions;
6
7
  exports.unfilledPrivateValues = unfilledPrivateValues;
7
8
  const config_1 = require("./config");
@@ -17,10 +18,20 @@ function emptied(value) {
17
18
  function emptiedOptions(options) {
18
19
  return Object.fromEntries(Object.entries(options).map(([key, value]) => [key, emptied(value)]));
19
20
  }
20
- function withoutPrivateValues(modules) {
21
- return modules.map((module) => module.privateOptions
22
- ? { ...module, privateOptions: emptiedOptions(module.privateOptions) }
23
- : { ...module });
21
+ function filled(shape, value) {
22
+ if (typeof shape === "string")
23
+ return typeof value === "string" ? value : "";
24
+ if (Array.isArray(shape))
25
+ return shape.map((item, index) => filled(item, Array.isArray(value) ? value[index] : undefined));
26
+ if (shape !== null && typeof shape === "object")
27
+ return filledOptions(shape, isOptions(value) ? value : undefined);
28
+ return shape;
29
+ }
30
+ function filledOptions(shape, values) {
31
+ return Object.fromEntries(Object.entries(shape).map(([key, value]) => [
32
+ key,
33
+ filled(value, values?.[key]),
34
+ ]));
24
35
  }
25
36
  exports.PRIVATE_OPTIONS_VARIABLE = "DMS_PRIVATE_OPTIONS";
26
37
  function isOptions(value) {
@@ -0,0 +1,13 @@
1
+ import { CliError, type Ui } from "@antelopejs/core/cli";
2
+ import { type ProjectFrontendModule } from "./project-modules";
3
+ type MessageArgs = Parameters<Ui["message"]>;
4
+ export type ProjectModulesReply = {
5
+ messages: MessageArgs[];
6
+ } & ({
7
+ modules: ProjectFrontendModule[];
8
+ } | {
9
+ problem: CliError["problem"];
10
+ } | {
11
+ failure: string;
12
+ });
13
+ export {};
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const cli_1 = require("@antelopejs/core/cli");
4
+ const project_modules_1 = require("./project-modules");
5
+ process.once("message", async (options) => {
6
+ const messages = [];
7
+ (0, cli_1.getProcessUi)().message = (...args) => {
8
+ messages.push(args);
9
+ };
10
+ let reply;
11
+ try {
12
+ reply = { messages, modules: await (0, project_modules_1.readProjectFrontendModules)(options) };
13
+ }
14
+ catch (error) {
15
+ reply =
16
+ error instanceof cli_1.CliError
17
+ ? { messages, problem: error.problem }
18
+ : {
19
+ messages,
20
+ failure: error instanceof Error
21
+ ? (error.stack ?? error.message)
22
+ : String(error),
23
+ };
24
+ }
25
+ process.send?.(reply, () => process.disconnect());
26
+ });
@@ -0,0 +1,47 @@
1
+ import type { BackendProxyDeclaration, FrontendModuleOptions, PublicEndpointDeclaration, ResolvedLayer } from "./workspace";
2
+ export declare const FRONTEND_DECLARATION_FIELD = "dmsFrontend";
3
+ export interface FrontendRegistration {
4
+ name: string;
5
+ sourcePath: string;
6
+ renderer: {
7
+ name: string;
8
+ version: string;
9
+ };
10
+ priority?: number;
11
+ configKey?: string;
12
+ options?: FrontendModuleOptions;
13
+ privateOptions?: FrontendModuleOptions;
14
+ authEstablishEndpoints?: string[];
15
+ publicEndpoints?: PublicEndpointDeclaration[];
16
+ backendProxies?: BackendProxyDeclaration[];
17
+ }
18
+ export interface FrontendModuleContext {
19
+ dev: boolean;
20
+ }
21
+ interface ModuleSource {
22
+ type: string;
23
+ path?: string;
24
+ package?: string;
25
+ }
26
+ interface ProjectModule {
27
+ source: ModuleSource;
28
+ config: unknown;
29
+ folder?: string;
30
+ }
31
+ interface ProjectConfig {
32
+ cacheFolder: string;
33
+ modules: Record<string, ProjectModule>;
34
+ }
35
+ export interface ProjectFrontendModule {
36
+ layer: ResolvedLayer;
37
+ version?: string;
38
+ }
39
+ export interface ProjectModulesOptions {
40
+ projectDir: string;
41
+ environment: string;
42
+ dev?: boolean;
43
+ }
44
+ export declare function loadProjectConfig(projectDir: string, environment: string): Promise<ProjectConfig>;
45
+ export declare function readShippingVersion(sourcePath: string): string | undefined;
46
+ export declare function readProjectFrontendModules(options: ProjectModulesOptions): Promise<ProjectFrontendModule[]>;
47
+ export {};