@sjcx/vorma 0.0.0-pre.2 → 0.0.0-pre.4

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 (137) hide show
  1. package/dist/build/assemble-artifacts.d.ts +1 -1
  2. package/dist/build/bundle-client.d.ts +1 -1
  3. package/dist/build/cli.js +53 -44
  4. package/dist/build/compile-application.d.ts +2 -2
  5. package/dist/build/development-artifacts.d.ts +1 -1
  6. package/dist/build/development-build.d.ts +3 -6
  7. package/dist/build/development-server-process.d.ts +3 -3
  8. package/dist/build/development-work.d.ts +4 -3
  9. package/dist/build/generate-application.d.ts +4 -4
  10. package/dist/build/index.d.ts +2 -3
  11. package/dist/build/index.js +1 -1
  12. package/dist/build/inspect-projects.d.ts +3 -3
  13. package/dist/build/load-config.d.ts +17 -16
  14. package/dist/build/publish-artifacts.d.ts +1 -4
  15. package/dist/build/render-client-transport.d.ts +1 -1
  16. package/dist/build/render-server-generated.d.ts +1 -12
  17. package/dist/build/render-types.d.ts +1 -1
  18. package/dist/build/resolve-config.d.ts +6 -9
  19. package/dist/build/source-layout.d.ts +2 -2
  20. package/dist/build/typescript-projects.d.ts +5 -0
  21. package/dist/{build-DcP5_DUV.js → build-BeUTL6eX.js} +104 -301
  22. package/package.json +5 -36
  23. package/dist/build/compile-server.d.ts +0 -42
  24. package/dist/client/assembly.d.ts +0 -40
  25. package/dist/client/browser-http-client.d.ts +0 -10
  26. package/dist/client/client-loaders.d.ts +0 -93
  27. package/dist/client/commit.d.ts +0 -41
  28. package/dist/client/contracts.d.ts +0 -192
  29. package/dist/client/core.d.ts +0 -45
  30. package/dist/client/development.d.ts +0 -16
  31. package/dist/client/document-recovery.d.ts +0 -4
  32. package/dist/client/endpoints.d.ts +0 -54
  33. package/dist/client/errors.d.ts +0 -87
  34. package/dist/client/freshness.d.ts +0 -51
  35. package/dist/client/head.d.ts +0 -14
  36. package/dist/client/history.d.ts +0 -25
  37. package/dist/client/index.d.ts +0 -80
  38. package/dist/client/index.js +0 -150
  39. package/dist/client/links.d.ts +0 -48
  40. package/dist/client/materialize.d.ts +0 -21
  41. package/dist/client/modules.d.ts +0 -2
  42. package/dist/client/navigation.d.ts +0 -47
  43. package/dist/client/payload.d.ts +0 -54
  44. package/dist/client/prefetch.d.ts +0 -28
  45. package/dist/client/prepare.d.ts +0 -47
  46. package/dist/client/projections.d.ts +0 -26
  47. package/dist/client/queries.d.ts +0 -33
  48. package/dist/client/react/application.d.ts +0 -87
  49. package/dist/client/react/hooks.d.ts +0 -36
  50. package/dist/client/react/index.d.ts +0 -5
  51. package/dist/client/react/index.js +0 -3237
  52. package/dist/client/react/link.d.ts +0 -27
  53. package/dist/client/react/view.d.ts +0 -86
  54. package/dist/client/request.d.ts +0 -16
  55. package/dist/client/route-context.d.ts +0 -31
  56. package/dist/client/route-matching.d.ts +0 -22
  57. package/dist/client/route-synchronization.d.ts +0 -30
  58. package/dist/client/route-url.d.ts +0 -5
  59. package/dist/client/runtime.d.ts +0 -82
  60. package/dist/client/scroll.d.ts +0 -16
  61. package/dist/client/services.d.ts +0 -34
  62. package/dist/client/state.d.ts +0 -102
  63. package/dist/client/static-assets.d.ts +0 -3
  64. package/dist/client/stylesheets.d.ts +0 -7
  65. package/dist/client/transport-type-entries.d.ts +0 -2
  66. package/dist/client/types.d.ts +0 -152
  67. package/dist/client/view-definition.d.ts +0 -24
  68. package/dist/client/work-indicator.d.ts +0 -18
  69. package/dist/compile-Me8EOyMK.js +0 -870
  70. package/dist/development-B_rxuwY7.js +0 -128
  71. package/dist/hash-set-BPx3iXec.js +0 -141
  72. package/dist/href-Cqyax8Y0.js +0 -357
  73. package/dist/materialize-DZ7VSLFk.js +0 -739
  74. package/dist/metadata-BoPKo-G2.js +0 -32
  75. package/dist/primitives/tasks/index.d.ts +0 -1
  76. package/dist/primitives/tasks/index.js +0 -1
  77. package/dist/route-context-CtY_9U_W.js +0 -559
  78. package/dist/route-matching-D_uSG2P9.js +0 -33
  79. package/dist/search-parse-0f7oqVsG.js +0 -375
  80. package/dist/server/config/index.d.ts +0 -36
  81. package/dist/server/config/index.js +0 -30
  82. package/dist/server/development/metadata.d.ts +0 -11
  83. package/dist/server/document.d.ts +0 -37
  84. package/dist/server/form-data.d.ts +0 -21
  85. package/dist/server/graph/compile.d.ts +0 -118
  86. package/dist/server/graph/declarations.d.ts +0 -117
  87. package/dist/server/graph/literal-error-tag.d.ts +0 -14
  88. package/dist/server/graph/pattern-conflicts.d.ts +0 -36
  89. package/dist/server/graph/search-schema.d.ts +0 -13
  90. package/dist/server/graph/transport-schema.d.ts +0 -11
  91. package/dist/server/index.d.ts +0 -310
  92. package/dist/server/index.js +0 -2311
  93. package/dist/server/public-assets.d.ts +0 -18
  94. package/dist/server/runtime/application.d.ts +0 -15
  95. package/dist/server/runtime/assets.d.ts +0 -15
  96. package/dist/server/runtime/context.d.ts +0 -96
  97. package/dist/server/runtime/domain-errors.d.ts +0 -11
  98. package/dist/server/runtime/effects.d.ts +0 -83
  99. package/dist/server/runtime/execute.d.ts +0 -13
  100. package/dist/server/runtime/finalize.d.ts +0 -44
  101. package/dist/server/runtime/handler.d.ts +0 -106
  102. package/dist/server/runtime/head.d.ts +0 -22
  103. package/dist/server/runtime/payload.d.ts +0 -50
  104. package/dist/server/runtime/pipeline.d.ts +0 -27
  105. package/dist/server/runtime/plan.d.ts +0 -98
  106. package/dist/server/runtime/render-document.d.ts +0 -16
  107. package/dist/server/runtime/startup-error.d.ts +0 -11
  108. package/dist/server/runtime/transport-type-entries.d.ts +0 -2
  109. package/dist/server/runtime/vercel-deployment.d.ts +0 -2
  110. package/dist/server/url-pathname.d.ts +0 -13
  111. package/dist/static-assets-BrH3O0M8.js +0 -199
  112. package/dist/universal/generated-types.d.ts +0 -9
  113. package/dist/universal/href.d.ts +0 -17
  114. package/dist/universal/http-method.d.ts +0 -4
  115. package/dist/universal/json-transport.d.ts +0 -14
  116. package/dist/universal/null-prototype-record.d.ts +0 -7
  117. package/dist/universal/path-wire.d.ts +0 -71
  118. package/dist/universal/pattern-language.d.ts +0 -4
  119. package/dist/universal/protocol-schemas.d.ts +0 -99
  120. package/dist/universal/protocol.d.ts +0 -162
  121. package/dist/universal/search-grammar.d.ts +0 -7
  122. package/dist/universal/search-parse.d.ts +0 -22
  123. package/dist/universal/search-serialize.d.ts +0 -16
  124. package/dist/universal/search-shape.d.ts +0 -32
  125. package/dist/universal/static-assets.d.ts +0 -2
  126. package/dist/universal/transport-types/big-decimal.d.ts +0 -13
  127. package/dist/universal/transport-types/chunk.d.ts +0 -8
  128. package/dist/universal/transport-types/date-time-utc.d.ts +0 -13
  129. package/dist/universal/transport-types/date-time-zoned.d.ts +0 -13
  130. package/dist/universal/transport-types/duration.d.ts +0 -13
  131. package/dist/universal/transport-types/hash-map.d.ts +0 -8
  132. package/dist/universal/transport-types/hash-set.d.ts +0 -8
  133. package/dist/universal/transport-types/option.d.ts +0 -10
  134. package/dist/universal/transport-types/redacted.d.ts +0 -9
  135. package/dist/universal/value-transport.d.ts +0 -117
  136. package/dist/value-transport-Bst4Hk-n.js +0 -864
  137. /package/dist/{universal → build}/content-digest.d.ts +0 -0
@@ -1,38 +1,23 @@
1
- import { c as compileUiPattern, m as ARTIFACT_PROTOCOL, s as compileEndpointPattern, t as EFFECT_TRANSPORT_TYPES, y as FRAMEWORK_IDENTITY_PROTOCOL } from "./value-transport-Bst4Hk-n.js";
2
1
  import { t as VORMA_BUILD_PLUGIN_NAME } from "./build-invocation-D7Fu8gBK.js";
3
- import { c as findConflictingDynamicParameterNames, f as matchesHttpMethod, o as createNestedRouteChains } from "./compile-Me8EOyMK.js";
4
- import { VormaConfigSchema } from "./server/config/index.js";
5
2
  import { Effect, FileSystem, Option, Record, Result, Schema } from "effect";
6
- import { build } from "vite";
3
+ import { build, normalizePath } from "vite";
7
4
  import { blake3 } from "@noble/hashes/blake3.js";
8
5
  import { utf8ToBytes } from "@noble/hashes/utils.js";
9
6
  import { base32nopad } from "@scure/base";
10
- import { isAbsolute, join } from "node:path";
11
- import { RolldownMagicString, build as build$1 } from "rolldown";
7
+ import { ARTIFACT_PROTOCOL, FRAMEWORK_IDENTITY_PROTOCOL, matchesHttpMethod } from "@vorma/protocol";
8
+ import { RolldownMagicString } from "rolldown";
12
9
  import { readFile } from "node:fs/promises";
10
+ import { join } from "node:path";
13
11
  import * as Path$1 from "effect/Path";
14
12
  import { SyntaxKind, TokenFlags, isAsExpression, isCallExpression, isElementAccessExpression, isExportSpecifier, isIdentifier, isImportClause, isImportSpecifier, isNamespaceImport, isNoSubstitutionTemplateLiteral, isNonNullExpression, isParenthesizedExpression, isPropertyAccessExpression, isSatisfiesExpression, isStringLiteral, isTypeAssertion, isTypeNode } from "typescript/unstable/ast";
15
- import { API, ElementFlags, SignatureKind, SymbolFlags } from "typescript/unstable/async";
13
+ import { API, DiagnosticCategory, ElementFlags, SignatureKind, SymbolFlags } from "typescript/unstable/async";
16
14
  import { createTemplateHead, createTemplateMiddle, createTemplateTail } from "typescript/unstable/ast/factory";
15
+ import { compileEndpointPattern, compileUiPattern, createNestedRouteChains, findConflictingDynamicParameterNames, parseUrlPathname } from "@vorma/protocol/path";
16
+ import { VormaConfigSchema } from "@vorma/server/config";
17
17
  import * as FileSystem$1 from "effect/FileSystem";
18
+ import { EFFECT_TRANSPORT_TYPES } from "@vorma/protocol/transport";
18
19
  import { pid, platform } from "node:process";
19
20
  import { transform } from "lightningcss";
20
- //#region src/universal/content-digest.ts
21
- /** BLAKE3 content identity, encoded as lowercase base32 without padding. */
22
- function toContentDigest(source) {
23
- return encodeContentDigest(blake3(typeof source === "string" ? utf8ToBytes(source) : source));
24
- }
25
- /** Encodes an already computed BLAKE3 digest. */
26
- function encodeContentDigest(digest) {
27
- return base32nopad.encode(digest).toLowerCase();
28
- }
29
- /** Canonical object ordering; array order carries framework semantics. */
30
- function encodeCanonicalJson(value) {
31
- if (Array.isArray(value)) return `[${value.map(encodeCanonicalJson).join(",")}]`;
32
- if (value !== null && typeof value === "object") return `{${Object.entries(value).sort(([left], [right]) => left < right ? -1 : left > right ? 1 : 0).map(([key, item]) => `${JSON.stringify(key)}:${encodeCanonicalJson(item)}`).join(",")}}`;
33
- return JSON.stringify(value);
34
- }
35
- //#endregion
36
21
  //#region src/build/browser-contracts.ts
37
22
  /**
38
23
  * The static contracts on which browser code and learned routing depend.
@@ -91,138 +76,20 @@ function getClientViewEntries(generation) {
91
76
  });
92
77
  }
93
78
  //#endregion
94
- //#region src/build/contained-path.ts
95
- /** True when a `path.relative` result names the root or a descendant of it. */
96
- function containsRelativePath(input) {
97
- return input.relativePath === "" || !input.absolute && input.relativePath !== ".." && !input.relativePath.startsWith(`..${input.separator}`);
98
- }
99
- /**
100
- * True when a module specifier names a package or one of its subpaths.
101
- * Relative, absolute, builtin, scheme, drive-letter, and virtual-module
102
- * specifiers never match; only the caller decides which of those to exclude
103
- * first.
104
- */
105
- function matchesPackageSpecifier(input) {
106
- return input.source === input.packageName || input.source.startsWith(`${input.packageName}/`);
107
- }
108
- /**
109
- * A `path.relative` result with platform separators converted to POSIX
110
- * separators, for generated module specifiers, output keys, and build
111
- * identities, which are POSIX even when the build runs on Windows.
112
- */
113
- function toPosixRelativePath(input) {
114
- return input.path.relative(input.from, input.to).split(input.path.sep).join("/");
79
+ //#region src/build/content-digest.ts
80
+ /** BLAKE3 content identity, encoded as lowercase base32 without padding. */
81
+ function toContentDigest(source) {
82
+ return encodeContentDigest(blake3(typeof source === "string" ? utf8ToBytes(source) : source));
115
83
  }
116
- //#endregion
117
- //#region src/build/compile-server.ts
118
- /** Log codes reporting a specifier the compiler could not resolve. */
119
- const UNRESOLVED_LOG_CODE = /^UNRESOLVED/;
120
- const TERMINAL_STYLE = new RegExp(`${String.fromCharCode(27)}\\[[\\d;]*m`, "g");
121
- /** The plain first line of a compiler message, with the module it concerns. */
122
- function toLogSummary(log) {
123
- const plain = log.message.replace(TERMINAL_STYLE, "");
124
- const [firstLine] = plain.split("\n");
125
- const summary = firstLine === void 0 ? plain : firstLine;
126
- return log.id === void 0 ? summary : `${summary} (${log.id})`;
84
+ /** Encodes an already computed BLAKE3 digest. */
85
+ function encodeContentDigest(digest) {
86
+ return base32nopad.encode(digest).toLowerCase();
127
87
  }
128
- /**
129
- * Compiles the configured server entry and internal runtime
130
- * entry together into ECMAScript modules that run
131
- * without a TypeScript loader, a Vorma installation, or a bundler in the
132
- * target process. The compilation rewrites nothing in the application's
133
- * source. Effect remains a runtime peer shared with the containing application.
134
- *
135
- * Rolldown uses the configured server TypeScript project. The client's Vite
136
- * configuration does not configure server compilation.
137
- *
138
- * Production bytes must depend on the sources alone, so the debug comments
139
- * that name module paths relative to the build directory are off: the
140
- * checkout's location must not reach the artifact. Symlink resolution stays on
141
- * because an isolated package store reaches a package's own dependencies only
142
- * through the real path. Development source maps retain authored locations.
143
- */
144
- function compileServerApplication(input) {
145
- return Effect.gen(function* () {
146
- const { generation } = input;
147
- const { config } = generation;
148
- const diagnostics = [];
149
- const unresolvedImports = [];
150
- let inputFilePaths = [];
151
- const output = yield* Effect.tryPromise(() => {
152
- return build$1({
153
- input: {
154
- entry: config.serverEntryFilePath,
155
- runtime: config.generatedBuildFilePath
156
- },
157
- preserveEntrySignatures: "strict",
158
- cwd: config.serverProjectDirectory,
159
- platform: "node",
160
- tsconfig: config.serverTsconfigFilePath,
161
- write: false,
162
- plugins: [{
163
- name: "vorma:server-inputs",
164
- generateBundle() {
165
- inputFilePaths = [...this.getModuleIds()].filter(isAbsolute);
166
- }
167
- }],
168
- external: (source, _importer, isResolved) => {
169
- return !isResolved && (matchesPackageSpecifier({
170
- source,
171
- packageName: "effect"
172
- }) || config.serverExternalPackages.some((packageName) => {
173
- return matchesPackageSpecifier({
174
- source,
175
- packageName
176
- });
177
- }));
178
- },
179
- experimental: { attachDebugInfo: "none" },
180
- onLog: (level, log) => {
181
- const code = log.code === void 0 ? "" : log.code;
182
- if (UNRESOLVED_LOG_CODE.test(code)) {
183
- unresolvedImports.push(toLogSummary(log));
184
- return;
185
- }
186
- diagnostics.push({
187
- level,
188
- code,
189
- message: toLogSummary(log)
190
- });
191
- },
192
- output: {
193
- dir: config.serverGeneratedDirectory,
194
- format: "es",
195
- entryFileNames: (chunk) => {
196
- return chunk.name === "runtime" ? ARTIFACT_PROTOCOL.compiledRuntimeFileName : ARTIFACT_PROTOCOL.compiledServerEntryFileName;
197
- },
198
- chunkFileNames: "[name]-[hash].mjs",
199
- sourcemap: input.sourcemap
200
- }
201
- });
202
- }).pipe(Effect.uninterruptible);
203
- if (unresolvedImports.length > 0) return yield* Effect.fail(`The compiled server graph has unresolved imports: ${unresolvedImports.join("; ")}`);
204
- const compiled = [];
205
- for (const emitted of output.output) {
206
- if (emitted.type !== "chunk") return yield* Effect.fail(`The server compilation emitted a file that is not a module: ${emitted.fileName}`);
207
- if (!/^[^./][^/]*\.mjs$/.test(emitted.fileName)) return yield* Effect.fail(`The server compilation emitted a file outside its flat module directory: ${emitted.fileName}`);
208
- compiled.push({
209
- fileName: emitted.fileName,
210
- source: emitted.code
211
- });
212
- }
213
- const emittedFileNames = new Set(compiled.map((file) => file.fileName));
214
- for (const entryFileName of [ARTIFACT_PROTOCOL.compiledServerEntryFileName, ARTIFACT_PROTOCOL.compiledRuntimeFileName]) if (!emittedFileNames.has(entryFileName)) return yield* Effect.fail(`The server compilation did not emit ${entryFileName}`);
215
- return {
216
- files: compiled,
217
- diagnostics,
218
- inputFilePaths
219
- };
220
- }).pipe(Effect.mapError((cause) => {
221
- return {
222
- _tag: "ServerCompilationIssue",
223
- cause
224
- };
225
- }));
88
+ /** Canonical object ordering; array order carries framework semantics. */
89
+ function encodeCanonicalJson(value) {
90
+ if (Array.isArray(value)) return `[${value.map(encodeCanonicalJson).join(",")}]`;
91
+ if (value !== null && typeof value === "object") return `{${Object.entries(value).sort(([left], [right]) => left < right ? -1 : left > right ? 1 : 0).map(([key, item]) => `${JSON.stringify(key)}:${encodeCanonicalJson(item)}`).join(",")}}`;
92
+ return JSON.stringify(value);
226
93
  }
227
94
  //#endregion
228
95
  //#region src/build/client-public-urls.ts
@@ -420,6 +287,20 @@ function stripQueryAndFragment(fileName) {
420
287
  return index === -1 ? fileName : fileName.slice(0, index);
421
288
  }
422
289
  //#endregion
290
+ //#region src/build/contained-path.ts
291
+ /** True when a `path.relative` result names the root or a descendant of it. */
292
+ function containsRelativePath(input) {
293
+ return input.relativePath === "" || !input.absolute && input.relativePath !== ".." && !input.relativePath.startsWith(`..${input.separator}`);
294
+ }
295
+ /**
296
+ * A `path.relative` result with platform separators converted to POSIX
297
+ * separators, for generated module specifiers, output keys, and build
298
+ * identities, which are POSIX even when the build runs on Windows.
299
+ */
300
+ function toPosixRelativePath(input) {
301
+ return input.path.relative(input.from, input.to).split(input.path.sep).join("/");
302
+ }
303
+ //#endregion
423
304
  //#region src/build/compare-text.ts
424
305
  /** Compares source-derived text by Unicode code units, independent of host locale. */
425
306
  function compareSourceText(input) {
@@ -804,54 +685,24 @@ async function createTypeRenderer(input) {
804
685
  };
805
686
  }
806
687
  //#endregion
807
- //#region src/server/url-pathname.ts
808
- const URL_PATHNAME_PARSER_ORIGIN = "https://vorma.invalid";
809
- function parseHref(input) {
810
- return new URL(input.value, input.base);
811
- }
812
- /** Parses the exact pathname representation used for request classification. */
813
- function parseUrlPathname(value) {
814
- const parsed = Result.try({
815
- try: () => parseHref({
816
- value,
817
- base: URL_PATHNAME_PARSER_ORIGIN
818
- }),
819
- catch: (cause) => makeUrlPathnameParseError({
820
- value,
821
- cause
822
- })
823
- });
824
- if (Result.isFailure(parsed)) return Result.fail(parsed.failure);
825
- if (!value.startsWith("/") || parsed.success.origin !== URL_PATHNAME_PARSER_ORIGIN || parsed.success.pathname !== value || parsed.success.search !== "" || parsed.success.hash !== "") return Result.fail(makeUrlPathnameParseError({ value }));
826
- return Result.succeed(value);
827
- }
828
- function makeUrlPathnameParseError(input) {
829
- return {
830
- _tag: "UrlPathnameParseError",
831
- value: input.value,
832
- ...input.cause === void 0 ? {} : { cause: input.cause }
833
- };
834
- }
835
- //#endregion
836
688
  //#region src/build/resolve-config.ts
837
- /** The build reads no Vorma directory, in either entry directory, as application source. */
689
+ /** The build excludes both projects' generated directories from application source. */
838
690
  function getGeneratedSourceDirectories(config) {
839
691
  return [config.serverGeneratedDirectory, config.clientGeneratedDirectory];
840
692
  }
841
- /** Derives generated source, public assets, and build coordination from the entry directories. */
693
+ /** Derives generated source, public assets, and build coordination from the tsconfig directories. */
842
694
  function getVormaOwnedPaths(input) {
843
695
  const { path } = input;
844
696
  const name = ARTIFACT_PROTOCOL.vormaDirectoryName;
845
- const clientGeneratedDirectory = path.join(input.clientEntryDirectory, name);
846
- const serverGeneratedDirectory = path.join(input.serverEntryDirectory, name);
697
+ const clientGeneratedDirectory = path.join(input.clientProjectDirectory, name);
698
+ const serverGeneratedDirectory = path.join(input.serverProjectDirectory, name);
847
699
  return {
848
700
  publicDirectory: path.join(clientGeneratedDirectory, ARTIFACT_PROTOCOL.publicDirectoryName),
849
701
  ignoreFilePaths: [.../* @__PURE__ */ new Set([serverGeneratedDirectory, clientGeneratedDirectory])].map((directory) => path.join(directory, ARTIFACT_PROTOCOL.ignoreFileName)),
850
702
  serverGeneratedDirectory,
851
703
  clientGeneratedDirectory,
852
- generatedBuildFilePath: path.join(serverGeneratedDirectory, ARTIFACT_PROTOCOL.generatedBuildFileName),
853
- generatedServerContractsFilePath: path.join(serverGeneratedDirectory, ARTIFACT_PROTOCOL.generatedServerContractsFileName),
854
- compiledServerEntryFilePath: path.join(serverGeneratedDirectory, ARTIFACT_PROTOCOL.compiledServerEntryFileName)
704
+ generatedRegistrationFilePath: path.join(serverGeneratedDirectory, ARTIFACT_PROTOCOL.registrationFileName),
705
+ generatedServerContractsFilePath: path.join(serverGeneratedDirectory, ARTIFACT_PROTOCOL.generatedServerContractsFileName)
855
706
  };
856
707
  }
857
708
  /** Resolves every configured path once against the configuration file's directory. */
@@ -877,14 +728,12 @@ function resolveVormaConfig(input) {
877
728
  message: `configFilePath must be absolute, got ${JSON.stringify(input.configFilePath)}`
878
729
  });
879
730
  const configDirectory = path.dirname(path.normalize(input.configFilePath));
880
- const serverEntryFilePath = path.resolve(configDirectory, config.serverEntry);
881
731
  const serverTsconfigFilePath = path.resolve(configDirectory, config.serverTsconfigFile);
882
732
  const clientEntryFilePath = path.resolve(configDirectory, config.clientEntry);
883
733
  const clientTsconfigFilePath = path.resolve(configDirectory, config.clientTsconfigFile);
884
734
  return {
885
735
  configFilePath: path.normalize(input.configFilePath),
886
736
  configDirectory,
887
- serverEntryFilePath,
888
737
  serverTsconfigFilePath,
889
738
  serverProjectDirectory: path.dirname(serverTsconfigFilePath),
890
739
  clientEntryFilePath,
@@ -892,14 +741,13 @@ function resolveVormaConfig(input) {
892
741
  publicAssetsSourceDirectory: path.resolve(configDirectory, config.publicAssetsDir),
893
742
  viteConfigFilePath: path.resolve(configDirectory, config.viteConfigFile),
894
743
  ...config.criticalCssEntry === void 0 ? {} : { criticalCssEntryFilePath: path.resolve(configDirectory, config.criticalCssEntry) },
895
- serverExternalPackages: config.serverExternalPackages === void 0 ? [] : config.serverExternalPackages,
896
744
  publicAssetsBasePath: yield* Effect.fromResult(parsePublicAssetsBasePath(config.publicAssetsBasePath)),
897
745
  bodySsr: config.bodySsr,
898
746
  dev: config.dev,
899
747
  ...getVormaOwnedPaths({
900
748
  path,
901
- serverEntryDirectory: path.dirname(serverEntryFilePath),
902
- clientEntryDirectory: path.dirname(clientEntryFilePath)
749
+ serverProjectDirectory: path.dirname(serverTsconfigFilePath),
750
+ clientProjectDirectory: path.dirname(clientTsconfigFilePath)
903
751
  })
904
752
  };
905
753
  });
@@ -940,6 +788,9 @@ function readTypescriptProjectRoots(input) {
940
788
  }
941
789
  /** Checks actual compiler membership after generation, including restrictive files/include/exclude settings. */
942
790
  function checkGeneratedTypeInclusion(input) {
791
+ const serverFiles = input.serverFiles.filter((file) => !input.knownRootFiles?.server.has(normalizePath(file)));
792
+ const clientFiles = input.clientFiles.filter((file) => !input.knownRootFiles?.client.has(normalizePath(file)));
793
+ if (serverFiles.length === 0 && clientFiles.length === 0) return Effect.void;
943
794
  return withTypescriptProjects({
944
795
  ...input,
945
796
  useFn: (projects) => {
@@ -948,11 +799,11 @@ function checkGeneratedTypeInclusion(input) {
948
799
  const missing = [];
949
800
  for (const [project, files, config] of [[
950
801
  projects.server,
951
- input.serverFiles,
802
+ serverFiles,
952
803
  input.serverTsconfigFilePath
953
804
  ], [
954
805
  projects.client,
955
- input.clientFiles,
806
+ clientFiles,
956
807
  input.clientTsconfigFilePath
957
808
  ]]) for (const file of files) if (await project.program.getSourceFileMetadata(file) === void 0) missing.push({
958
809
  project: config,
@@ -962,7 +813,7 @@ function checkGeneratedTypeInclusion(input) {
962
813
  });
963
814
  return yield* missing.length === 0 ? Effect.void : Effect.fail({
964
815
  _tag: "TypescriptProjectError",
965
- message: missing.map(({ project, file }) => `${project} does not include generated type file ${file}. Include the entry's _vorma directory in that TypeScript project.`).join("\n")
816
+ message: missing.map(({ project, file }) => `${project} does not include generated type file ${file}. Include the _vorma directory beside that tsconfig in its TypeScript project.`).join("\n")
966
817
  });
967
818
  });
968
819
  }
@@ -980,7 +831,17 @@ function withTypescriptProjects(input) {
980
831
  }), (snapshot) => Effect.promise(() => snapshot.dispose())),
981
832
  ...input
982
833
  });
983
- return yield* Result.isFailure(projects) ? Effect.fail(projects.failure) : input.useFn(projects.success);
834
+ if (Result.isFailure(projects)) return yield* Effect.fail(projects.failure);
835
+ const errors = (yield* runTypescriptOperation(() => {
836
+ return Promise.all([projects.success.server.program.getConfigFileParsingDiagnostics(), projects.success.client.program.getConfigFileParsingDiagnostics()]);
837
+ })).flat().filter((diagnostic) => {
838
+ return diagnostic.category === DiagnosticCategory.Error;
839
+ });
840
+ if (errors.length > 0) return yield* Effect.fail({
841
+ _tag: "TypescriptProjectError",
842
+ message: errors.map((error) => `${error.fileName}: TS${error.code}: ${error.text}`).join("\n")
843
+ });
844
+ return yield* input.useFn(projects.success);
984
845
  }));
985
846
  }
986
847
  });
@@ -1523,12 +1384,11 @@ async function inspectClientProject(input) {
1523
1384
  sourceTexts
1524
1385
  });
1525
1386
  }
1526
- /** Whether a symbol is the `getPublicUrl` declared by `vorma/client`, however the module reached it. */
1387
+ /** Whether a symbol is the `getPublicUrl` declared by `@vorma/client`, however the module reached it. */
1527
1388
  async function matchesPublicUrlSymbol(input) {
1528
1389
  const symbol = (input.symbol.flags & SymbolFlags.Alias) !== 0 ? await input.checker.getAliasedSymbol(input.symbol) : input.symbol;
1529
1390
  if (symbol.name !== "getPublicUrl") return false;
1530
- const declaration = symbol.declarations[0];
1531
- return declaration !== void 0 && String(declaration.path).endsWith("/vorma/dist/client/index.d.ts");
1391
+ return (await symbol.getJsDocTags(input.checker)).some((tag) => tag.name === "vormaPublicAsset");
1532
1392
  }
1533
1393
  /** Every call of `getPublicUrl` in one file. A use that is not a direct call with a string literal cannot be replaced by the build. */
1534
1394
  async function collectPublicUrlSites(input) {
@@ -1889,7 +1749,7 @@ function collectPublicAssets(config) {
1889
1749
  source: [
1890
1750
  "// Code generated by Vorma. DO NOT EDIT.",
1891
1751
  "",
1892
- "import \"vorma/client\";",
1752
+ "import \"@vorma/client\";",
1893
1753
  "",
1894
1754
  renderAssetKeyDeclaration({
1895
1755
  assets,
@@ -1897,7 +1757,7 @@ function collectPublicAssets(config) {
1897
1757
  prefix: "export type PublicAssetKey ="
1898
1758
  }),
1899
1759
  "",
1900
- "declare module \"vorma/client\" {",
1760
+ "declare module \"@vorma/client\" {",
1901
1761
  " interface ClientApplicationContracts {",
1902
1762
  " readonly assets: PublicAssetKey;",
1903
1763
  " }",
@@ -1926,14 +1786,6 @@ function atAssetPath(input) {
1926
1786
  }
1927
1787
  //#endregion
1928
1788
  //#region src/build/render-server-generated.ts
1929
- /**
1930
- * The URL of the published public directory relative to a compiled server
1931
- * module. Every compiled module sits directly in the server entry's Vorma
1932
- * directory, so one relative URL locates the bytes from all of them.
1933
- */
1934
- function getPublicDirectoryRelativeUrl(input) {
1935
- return `${input.path.relative(input.serverGeneratedDirectory, input.publicDirectory).split(input.path.sep).map((segment) => encodeURIComponent(segment)).join("/")}/`;
1936
- }
1937
1789
  /** One namespace import per source file that exports a registered declaration, in a stable order. */
1938
1790
  function createModuleNamespaces(input) {
1939
1791
  const identifiers = /* @__PURE__ */ new Map();
@@ -1969,28 +1821,23 @@ function renderGeneratedBuildModule(input) {
1969
1821
  "// Code generated by Vorma. DO NOT EDIT.",
1970
1822
  "",
1971
1823
  ...modules.imports.map((moduleImport) => {
1972
- return `import * as ${moduleImport.identifier} from ${JSON.stringify(moduleImport.specifier)};`;
1824
+ const specifier = moduleImport.specifier.split("/").map(encodeURIComponent).join("/");
1825
+ return `import * as ${moduleImport.identifier} from ${JSON.stringify(specifier)};`;
1973
1826
  }),
1974
1827
  "",
1975
1828
  "/** Every registerable declaration that the server project exports, in source order. */",
1976
- ...input.declarations.length === 0 ? ["export const registeredDeclarations = [] as const;"] : [
1829
+ ...input.declarations.length === 0 ? ["export const registeredDeclarations = [];"] : [
1977
1830
  "export const registeredDeclarations = [",
1978
1831
  ...input.declarations.map((declaration) => {
1979
1832
  return `\t${modules.getIdentifier(declaration.filePath)}[${JSON.stringify(declaration.exportName)}],`;
1980
1833
  }),
1981
- "] as const;"
1834
+ "];"
1982
1835
  ],
1983
- "",
1984
- "/** Resolves public files relative to this compiled deployment. */",
1985
- "export const publicAssetDirectoryUrl = new URL(",
1986
- `\t${JSON.stringify(input.publicDirectoryRelativeUrl)},`,
1987
- " import.meta.url,",
1988
- ").href;",
1989
1836
  ""
1990
1837
  ].join("\n")
1991
1838
  };
1992
1839
  }
1993
- /** Renders the declaration that augments `vorma/server` with this application's patterns, search types, and asset keys. */
1840
+ /** Renders the declaration that augments `@vorma/server` with this application's patterns, search types, and asset keys. */
1994
1841
  function renderGeneratedServerContracts(input) {
1995
1842
  const serverModuleSpecifier = JSON.stringify(FRAMEWORK_IDENTITY_PROTOCOL.moduleSpecifiers.server);
1996
1843
  const routeSearchTypes = input.model.segments.map((segment) => {
@@ -2178,7 +2025,9 @@ function renderGeneratedClientTransport(input) {
2178
2025
  ...entries.length === 0 ? [] : [`import { ${entries.join(", ")} } from ${moduleSpecifier};`],
2179
2026
  `import type { TransportTypeEntry } from ${moduleSpecifier};`,
2180
2027
  "",
2181
- `export const transportTypeEntries = [${entries.join(", ")}] satisfies ReadonlyArray<TransportTypeEntry>;`,
2028
+ "export function getTransportTypeEntries(): ReadonlyArray<TransportTypeEntry> {",
2029
+ ` return [${entries.join(", ")}];`,
2030
+ "}",
2182
2031
  ""
2183
2032
  ].join("\n")
2184
2033
  };
@@ -2186,7 +2035,7 @@ function renderGeneratedClientTransport(input) {
2186
2035
  //#endregion
2187
2036
  //#region src/build/generate-application.ts
2188
2037
  /** Writes correlated generated sources and verifies their native TypeScript inclusion. */
2189
- function writeAndCheckApplicationGeneration(generation) {
2038
+ function writeAndCheckApplicationGeneration(generation, knownRootFiles) {
2190
2039
  return Effect.gen(function* () {
2191
2040
  yield* Effect.all([writeApplicationGeneration(generation), writeGeneratedServerApplication({ generation })], {
2192
2041
  concurrency: 2,
@@ -2194,6 +2043,7 @@ function writeAndCheckApplicationGeneration(generation) {
2194
2043
  });
2195
2044
  yield* checkGeneratedTypeInclusion({
2196
2045
  ...generation.config,
2046
+ ...knownRootFiles === void 0 ? {} : { knownRootFiles },
2197
2047
  serverFiles: [generation.config.generatedServerContractsFilePath],
2198
2048
  clientFiles: [generation.clientContracts.filePath, generation.publicAssets.types.filePath]
2199
2049
  });
@@ -2273,7 +2123,7 @@ function writeApplicationGeneration(generation) {
2273
2123
  ];
2274
2124
  const plannedSourceFiles = [
2275
2125
  ...outputs.map((output) => output.filePath),
2276
- generation.config.generatedBuildFilePath,
2126
+ generation.config.generatedRegistrationFilePath,
2277
2127
  generation.config.generatedServerContractsFilePath
2278
2128
  ];
2279
2129
  return Effect.forEach([...generation.config.ignoreFilePaths.map((filePath) => {
@@ -2295,7 +2145,7 @@ function writeApplicationGeneration(generation) {
2295
2145
  })));
2296
2146
  }
2297
2147
  /** Matches the generated source files the build owns by name, so a name an earlier build used and this one does not is removed. */
2298
- const GENERATED_SOURCE_FILE_NAME = /\.gen\.(d\.)?ts$/;
2148
+ const GENERATED_SOURCE_FILE_NAME = /(?:\.gen\.(?:d\.)?ts|\.mjs)$/;
2299
2149
  function removeStaleGeneratedSource(input) {
2300
2150
  return Effect.gen(function* () {
2301
2151
  const fileSystem = yield* FileSystem$1.FileSystem;
@@ -2321,7 +2171,7 @@ function removeStaleGeneratedSource(input) {
2321
2171
  }
2322
2172
  /**
2323
2173
  * Writes the internal registration module and the application
2324
- * contract types before server compilation.
2174
+ * contract types before application startup.
2325
2175
  */
2326
2176
  function writeGeneratedServerApplication(input) {
2327
2177
  return Effect.gen(function* () {
@@ -2329,12 +2179,7 @@ function writeGeneratedServerApplication(input) {
2329
2179
  const { config, model, inspection } = input.generation;
2330
2180
  const buildModule = renderGeneratedBuildModule({
2331
2181
  declarations: model.serverDeclarations,
2332
- publicDirectoryRelativeUrl: getPublicDirectoryRelativeUrl({
2333
- path,
2334
- serverGeneratedDirectory: config.serverGeneratedDirectory,
2335
- publicDirectory: config.publicDirectory
2336
- }),
2337
- filePath: config.generatedBuildFilePath,
2182
+ filePath: config.generatedRegistrationFilePath,
2338
2183
  path
2339
2184
  });
2340
2185
  const contracts = renderGeneratedServerContracts({
@@ -2484,36 +2329,19 @@ function preparePublicOutput(config) {
2484
2329
  yield* fileSystem.makeDirectory(directory, { recursive: true });
2485
2330
  });
2486
2331
  }
2487
- /** Publishes compiled server modules and private metadata for the completed browser build. */
2332
+ /** Publishes private metadata for the completed browser build. */
2488
2333
  function publishApplicationArtifacts(input) {
2489
2334
  return Effect.gen(function* () {
2490
2335
  const fileSystem = yield* FileSystem$1.FileSystem;
2491
2336
  const path = yield* Path$1.Path;
2492
2337
  const config = input.generation.config;
2493
- if (input.server !== void 0) yield* removeCompiledServerModules(config.serverGeneratedDirectory);
2494
- const files = (input.server?.files ?? []).map((file) => {
2495
- return {
2496
- filePath: path.join(config.serverGeneratedDirectory, file.fileName),
2497
- source: file.source
2498
- };
2499
- });
2500
- yield* Effect.forEach(files, (file) => {
2501
- return Effect.gen(function* () {
2502
- yield* fileSystem.makeDirectory(path.dirname(file.filePath), { recursive: true });
2503
- yield* typeof file.source === "string" ? fileSystem.writeFileString(file.filePath, file.source) : fileSystem.writeFile(file.filePath, file.source);
2504
- });
2505
- }, {
2506
- concurrency: 16,
2507
- discard: true
2508
- });
2509
2338
  const metadataPath = path.join(config.serverGeneratedDirectory, ARTIFACT_PROTOCOL.productionMetadataFileName);
2510
2339
  const temporaryPath = `${metadataPath}.tmp`;
2511
2340
  yield* fileSystem.writeFileString(temporaryPath, JSON.stringify(input.artifacts.metadata));
2512
2341
  yield* fileSystem.rename(temporaryPath, metadataPath);
2513
2342
  return {
2514
2343
  clientBuildId: input.artifacts.metadata.clientBuildId,
2515
- publicDirectory: config.publicDirectory,
2516
- serverEntryPath: config.compiledServerEntryFilePath
2344
+ publicDirectory: config.publicDirectory
2517
2345
  };
2518
2346
  }).pipe(Effect.mapError((cause) => {
2519
2347
  return {
@@ -2522,27 +2350,6 @@ function publishApplicationArtifacts(input) {
2522
2350
  };
2523
2351
  }));
2524
2352
  }
2525
- /** Generated TypeScript source shares this directory and is not compiled output. */
2526
- function removeCompiledServerModules(directory) {
2527
- return Effect.gen(function* () {
2528
- const fileSystem = yield* FileSystem$1.FileSystem;
2529
- const path = yield* Path$1.Path;
2530
- if (!(yield* fileSystem.exists(directory))) return;
2531
- const fileNames = (yield* fileSystem.readDirectory(directory)).filter((fileName) => {
2532
- return fileName.endsWith(ARTIFACT_PROTOCOL.compiledServerModuleExtension);
2533
- });
2534
- yield* Effect.forEach(fileNames, (fileName) => {
2535
- const filePath = path.join(directory, fileName);
2536
- return checkOutputPath({
2537
- filePath,
2538
- rootDirectory: directory
2539
- }).pipe(Effect.andThen(fileSystem.remove(filePath)));
2540
- }, {
2541
- concurrency: 16,
2542
- discard: true
2543
- });
2544
- });
2545
- }
2546
2353
  //#endregion
2547
2354
  //#region src/build/source-layout.ts
2548
2355
  /** Loads the configured source layout before any application module executes. */
@@ -2551,10 +2358,15 @@ function loadApplicationSourceLayout(config) {
2551
2358
  const fileSystem = yield* FileSystem$1.FileSystem;
2552
2359
  const path = yield* Path$1.Path;
2553
2360
  const requiredPaths = {
2554
- serverEntryFilePath: {
2555
- field: "serverEntry",
2556
- path: config.serverEntryFilePath,
2557
- expectedType: "File"
2361
+ serverRootDirectory: {
2362
+ field: "serverTsconfigFile",
2363
+ path: path.dirname(config.serverTsconfigFilePath),
2364
+ expectedType: "Directory"
2365
+ },
2366
+ clientRootDirectory: {
2367
+ field: "clientTsconfigFile",
2368
+ path: path.dirname(config.clientTsconfigFilePath),
2369
+ expectedType: "Directory"
2558
2370
  },
2559
2371
  serverTsconfigFilePath: {
2560
2372
  field: "serverTsconfigFile",
@@ -2619,17 +2431,21 @@ function loadApplicationSourceLayout(config) {
2619
2431
  _tag: "ApplicationSourceLayoutIssues",
2620
2432
  issues
2621
2433
  });
2622
- const { criticalCssEntryFilePath, ...canonical } = canonicalPaths.success;
2434
+ const { serverRootDirectory, clientRootDirectory, criticalCssEntryFilePath, ...canonical } = canonicalPaths.success;
2435
+ if (serverRootDirectory === clientRootDirectory) return yield* Effect.fail({
2436
+ _tag: "ApplicationSourceLayoutIssues",
2437
+ issues: [{
2438
+ field: "clientTsconfigFile",
2439
+ path: config.clientTsconfigFilePath,
2440
+ expectedType: "File",
2441
+ message: `serverTsconfigFile and clientTsconfigFile must be in different directories. Both project roots resolve to ${serverRootDirectory} and would share the same _vorma output.`
2442
+ }]
2443
+ });
2623
2444
  const canonicalConfig = {
2624
2445
  ...config,
2625
2446
  ...canonical,
2626
2447
  serverProjectDirectory: path.dirname(canonical.serverTsconfigFilePath),
2627
- ...criticalCssEntryFilePath === void 0 ? {} : { criticalCssEntryFilePath },
2628
- ...getVormaOwnedPaths({
2629
- path,
2630
- serverEntryDirectory: path.dirname(canonical.serverEntryFilePath),
2631
- clientEntryDirectory: path.dirname(canonical.clientEntryFilePath)
2632
- })
2448
+ ...criticalCssEntryFilePath === void 0 ? {} : { criticalCssEntryFilePath }
2633
2449
  };
2634
2450
  const publicSource = canonicalConfig.publicAssetsSourceDirectory;
2635
2451
  const publicOutput = canonicalConfig.publicDirectory;
@@ -3207,27 +3023,14 @@ function buildApplication(input) {
3207
3023
  yield* preparePublicOutput(resolved);
3208
3024
  const generation = yield* prepareApplicationGeneration(resolved);
3209
3025
  yield* writeAndCheckApplicationGeneration(generation);
3210
- const { artifacts, server } = yield* Effect.all({
3211
- artifacts: bundleClient(generation).pipe(Effect.flatMap((client) => {
3212
- return assembleApplicationArtifacts({
3213
- generation,
3214
- client
3215
- });
3216
- })),
3217
- server: compileServerApplication({
3218
- generation,
3219
- sourcemap: false
3220
- })
3221
- }, { concurrency: 2 });
3222
- yield* Effect.forEach(server.diagnostics, (diagnostic) => {
3223
- return Effect.logWarning(`Server compilation ${diagnostic.level}${diagnostic.code === "" ? "" : ` (${diagnostic.code})`}: ${diagnostic.message}`);
3224
- }, { discard: true });
3225
3026
  return yield* publishApplicationArtifacts({
3226
3027
  generation,
3227
- artifacts,
3228
- server
3028
+ artifacts: yield* assembleApplicationArtifacts({
3029
+ generation,
3030
+ client: yield* bundleClient(generation)
3031
+ })
3229
3032
  });
3230
3033
  }));
3231
3034
  }
3232
3035
  //#endregion
3233
- export { encodeCanonicalJson as C, projectBrowserContracts as S, createClientPublicUrlPlugin as _, acquireOutputOwnership as a, CLIENT_SHARED_PACKAGES as b, writeAndCheckApplicationGeneration as c, readTypescriptProjectRoots as d, runTypescriptOperation as f, createCssPublicAssets as g, resolveVormaConfig as h, publishApplicationArtifacts as i, collectPublicAssets as l, getGeneratedSourceDirectories as m, loadApplicationSourceLayout as n, checkOutputPath as o, withTypescriptProjects as p, preparePublicOutput as r, assembleApplicationGeneration as s, buildApplication as t, inspectProjects as u, compileServerApplication as v, toContentDigest as w, getClientViewEntries as x, containsRelativePath as y };
3036
+ export { projectBrowserContracts as C, getClientViewEntries as S, createCssPublicAssets as _, acquireOutputOwnership as a, toContentDigest as b, writeAndCheckApplicationGeneration as c, readTypescriptProjectRoots as d, runTypescriptOperation as f, containsRelativePath as g, resolveVormaConfig as h, publishApplicationArtifacts as i, collectPublicAssets as l, getGeneratedSourceDirectories as m, loadApplicationSourceLayout as n, checkOutputPath as o, withTypescriptProjects as p, preparePublicOutput as r, assembleApplicationGeneration as s, buildApplication as t, inspectProjects as u, createClientPublicUrlPlugin as v, CLIENT_SHARED_PACKAGES as x, encodeCanonicalJson as y };