@sjcx/vorma 0.0.0-pre.1 → 0.0.0-pre.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (135) 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 +31 -38
  4. package/dist/build/compile-application.d.ts +2 -2
  5. package/dist/build/development-artifacts.d.ts +2 -1
  6. package/dist/build/development-build.d.ts +3 -6
  7. package/dist/build/development-work.d.ts +2 -3
  8. package/dist/build/generate-application.d.ts +2 -2
  9. package/dist/build/index.d.ts +2 -3
  10. package/dist/build/index.js +1 -1
  11. package/dist/build/inspect-projects.d.ts +3 -3
  12. package/dist/build/load-config.d.ts +0 -2
  13. package/dist/build/publish-artifacts.d.ts +1 -4
  14. package/dist/build/render-client-transport.d.ts +1 -1
  15. package/dist/build/render-server-generated.d.ts +1 -12
  16. package/dist/build/render-types.d.ts +1 -1
  17. package/dist/build/resolve-config.d.ts +2 -4
  18. package/dist/build/source-layout.d.ts +1 -1
  19. package/dist/{build-DcP5_DUV.js → build-sHSh5zaX.js} +67 -282
  20. package/package.json +5 -36
  21. package/dist/build/compile-server.d.ts +0 -42
  22. package/dist/client/assembly.d.ts +0 -40
  23. package/dist/client/browser-http-client.d.ts +0 -10
  24. package/dist/client/client-loaders.d.ts +0 -93
  25. package/dist/client/commit.d.ts +0 -41
  26. package/dist/client/contracts.d.ts +0 -192
  27. package/dist/client/core.d.ts +0 -45
  28. package/dist/client/development.d.ts +0 -16
  29. package/dist/client/document-recovery.d.ts +0 -4
  30. package/dist/client/endpoints.d.ts +0 -54
  31. package/dist/client/errors.d.ts +0 -87
  32. package/dist/client/freshness.d.ts +0 -51
  33. package/dist/client/head.d.ts +0 -14
  34. package/dist/client/history.d.ts +0 -25
  35. package/dist/client/index.d.ts +0 -80
  36. package/dist/client/index.js +0 -150
  37. package/dist/client/links.d.ts +0 -48
  38. package/dist/client/materialize.d.ts +0 -21
  39. package/dist/client/modules.d.ts +0 -2
  40. package/dist/client/navigation.d.ts +0 -47
  41. package/dist/client/payload.d.ts +0 -54
  42. package/dist/client/prefetch.d.ts +0 -28
  43. package/dist/client/prepare.d.ts +0 -47
  44. package/dist/client/projections.d.ts +0 -26
  45. package/dist/client/queries.d.ts +0 -33
  46. package/dist/client/react/application.d.ts +0 -87
  47. package/dist/client/react/hooks.d.ts +0 -36
  48. package/dist/client/react/index.d.ts +0 -5
  49. package/dist/client/react/index.js +0 -3237
  50. package/dist/client/react/link.d.ts +0 -27
  51. package/dist/client/react/view.d.ts +0 -86
  52. package/dist/client/request.d.ts +0 -16
  53. package/dist/client/route-context.d.ts +0 -31
  54. package/dist/client/route-matching.d.ts +0 -22
  55. package/dist/client/route-synchronization.d.ts +0 -30
  56. package/dist/client/route-url.d.ts +0 -5
  57. package/dist/client/runtime.d.ts +0 -82
  58. package/dist/client/scroll.d.ts +0 -16
  59. package/dist/client/services.d.ts +0 -34
  60. package/dist/client/state.d.ts +0 -102
  61. package/dist/client/static-assets.d.ts +0 -3
  62. package/dist/client/stylesheets.d.ts +0 -7
  63. package/dist/client/transport-type-entries.d.ts +0 -2
  64. package/dist/client/types.d.ts +0 -152
  65. package/dist/client/view-definition.d.ts +0 -24
  66. package/dist/client/work-indicator.d.ts +0 -18
  67. package/dist/compile-Me8EOyMK.js +0 -870
  68. package/dist/development-B_rxuwY7.js +0 -128
  69. package/dist/hash-set-BPx3iXec.js +0 -141
  70. package/dist/href-Cqyax8Y0.js +0 -357
  71. package/dist/materialize-DZ7VSLFk.js +0 -739
  72. package/dist/metadata-BoPKo-G2.js +0 -32
  73. package/dist/primitives/tasks/index.d.ts +0 -1
  74. package/dist/primitives/tasks/index.js +0 -1
  75. package/dist/route-context-CtY_9U_W.js +0 -559
  76. package/dist/route-matching-D_uSG2P9.js +0 -33
  77. package/dist/search-parse-0f7oqVsG.js +0 -375
  78. package/dist/server/config/index.d.ts +0 -36
  79. package/dist/server/config/index.js +0 -30
  80. package/dist/server/development/metadata.d.ts +0 -11
  81. package/dist/server/document.d.ts +0 -37
  82. package/dist/server/form-data.d.ts +0 -21
  83. package/dist/server/graph/compile.d.ts +0 -118
  84. package/dist/server/graph/declarations.d.ts +0 -117
  85. package/dist/server/graph/literal-error-tag.d.ts +0 -14
  86. package/dist/server/graph/pattern-conflicts.d.ts +0 -36
  87. package/dist/server/graph/search-schema.d.ts +0 -13
  88. package/dist/server/graph/transport-schema.d.ts +0 -11
  89. package/dist/server/index.d.ts +0 -310
  90. package/dist/server/index.js +0 -2311
  91. package/dist/server/public-assets.d.ts +0 -18
  92. package/dist/server/runtime/application.d.ts +0 -15
  93. package/dist/server/runtime/assets.d.ts +0 -15
  94. package/dist/server/runtime/context.d.ts +0 -96
  95. package/dist/server/runtime/domain-errors.d.ts +0 -11
  96. package/dist/server/runtime/effects.d.ts +0 -83
  97. package/dist/server/runtime/execute.d.ts +0 -13
  98. package/dist/server/runtime/finalize.d.ts +0 -44
  99. package/dist/server/runtime/handler.d.ts +0 -106
  100. package/dist/server/runtime/head.d.ts +0 -22
  101. package/dist/server/runtime/payload.d.ts +0 -50
  102. package/dist/server/runtime/pipeline.d.ts +0 -27
  103. package/dist/server/runtime/plan.d.ts +0 -98
  104. package/dist/server/runtime/render-document.d.ts +0 -16
  105. package/dist/server/runtime/startup-error.d.ts +0 -11
  106. package/dist/server/runtime/transport-type-entries.d.ts +0 -2
  107. package/dist/server/runtime/vercel-deployment.d.ts +0 -2
  108. package/dist/server/url-pathname.d.ts +0 -13
  109. package/dist/static-assets-BrH3O0M8.js +0 -199
  110. package/dist/universal/generated-types.d.ts +0 -9
  111. package/dist/universal/href.d.ts +0 -17
  112. package/dist/universal/http-method.d.ts +0 -4
  113. package/dist/universal/json-transport.d.ts +0 -14
  114. package/dist/universal/null-prototype-record.d.ts +0 -7
  115. package/dist/universal/path-wire.d.ts +0 -71
  116. package/dist/universal/pattern-language.d.ts +0 -4
  117. package/dist/universal/protocol-schemas.d.ts +0 -99
  118. package/dist/universal/protocol.d.ts +0 -162
  119. package/dist/universal/search-grammar.d.ts +0 -7
  120. package/dist/universal/search-parse.d.ts +0 -22
  121. package/dist/universal/search-serialize.d.ts +0 -16
  122. package/dist/universal/search-shape.d.ts +0 -32
  123. package/dist/universal/static-assets.d.ts +0 -2
  124. package/dist/universal/transport-types/big-decimal.d.ts +0 -13
  125. package/dist/universal/transport-types/chunk.d.ts +0 -8
  126. package/dist/universal/transport-types/date-time-utc.d.ts +0 -13
  127. package/dist/universal/transport-types/date-time-zoned.d.ts +0 -13
  128. package/dist/universal/transport-types/duration.d.ts +0 -13
  129. package/dist/universal/transport-types/hash-map.d.ts +0 -8
  130. package/dist/universal/transport-types/hash-set.d.ts +0 -8
  131. package/dist/universal/transport-types/option.d.ts +0 -10
  132. package/dist/universal/transport-types/redacted.d.ts +0 -9
  133. package/dist/universal/value-transport.d.ts +0 -117
  134. package/dist/value-transport-Bst4Hk-n.js +0 -864
  135. /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
3
  import { build } 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,35 +685,6 @@ 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
689
  /** The build reads no Vorma directory, in either entry directory, as application source. */
838
690
  function getGeneratedSourceDirectories(config) {
@@ -849,9 +701,8 @@ function getVormaOwnedPaths(input) {
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. */
@@ -892,7 +743,6 @@ function resolveVormaConfig(input) {
892
743
  publicAssetsSourceDirectory: path.resolve(configDirectory, config.publicAssetsDir),
893
744
  viteConfigFilePath: path.resolve(configDirectory, config.viteConfigFile),
894
745
  ...config.criticalCssEntry === void 0 ? {} : { criticalCssEntryFilePath: path.resolve(configDirectory, config.criticalCssEntry) },
895
- serverExternalPackages: config.serverExternalPackages === void 0 ? [] : config.serverExternalPackages,
896
746
  publicAssetsBasePath: yield* Effect.fromResult(parsePublicAssetsBasePath(config.publicAssetsBasePath)),
897
747
  bodySsr: config.bodySsr,
898
748
  dev: config.dev,
@@ -980,7 +830,17 @@ function withTypescriptProjects(input) {
980
830
  }), (snapshot) => Effect.promise(() => snapshot.dispose())),
981
831
  ...input
982
832
  });
983
- return yield* Result.isFailure(projects) ? Effect.fail(projects.failure) : input.useFn(projects.success);
833
+ if (Result.isFailure(projects)) return yield* Effect.fail(projects.failure);
834
+ const errors = (yield* runTypescriptOperation(() => {
835
+ return Promise.all([projects.success.server.program.getConfigFileParsingDiagnostics(), projects.success.client.program.getConfigFileParsingDiagnostics()]);
836
+ })).flat().filter((diagnostic) => {
837
+ return diagnostic.category === DiagnosticCategory.Error;
838
+ });
839
+ if (errors.length > 0) return yield* Effect.fail({
840
+ _tag: "TypescriptProjectError",
841
+ message: errors.map((error) => `${error.fileName}: TS${error.code}: ${error.text}`).join("\n")
842
+ });
843
+ return yield* input.useFn(projects.success);
984
844
  }));
985
845
  }
986
846
  });
@@ -1523,12 +1383,11 @@ async function inspectClientProject(input) {
1523
1383
  sourceTexts
1524
1384
  });
1525
1385
  }
1526
- /** Whether a symbol is the `getPublicUrl` declared by `vorma/client`, however the module reached it. */
1386
+ /** Whether a symbol is the `getPublicUrl` declared by `@vorma/client`, however the module reached it. */
1527
1387
  async function matchesPublicUrlSymbol(input) {
1528
1388
  const symbol = (input.symbol.flags & SymbolFlags.Alias) !== 0 ? await input.checker.getAliasedSymbol(input.symbol) : input.symbol;
1529
1389
  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");
1390
+ return (await symbol.getJsDocTags(input.checker)).some((tag) => tag.name === "vormaPublicAsset");
1532
1391
  }
1533
1392
  /** 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
1393
  async function collectPublicUrlSites(input) {
@@ -1889,7 +1748,7 @@ function collectPublicAssets(config) {
1889
1748
  source: [
1890
1749
  "// Code generated by Vorma. DO NOT EDIT.",
1891
1750
  "",
1892
- "import \"vorma/client\";",
1751
+ "import \"@vorma/client\";",
1893
1752
  "",
1894
1753
  renderAssetKeyDeclaration({
1895
1754
  assets,
@@ -1897,7 +1756,7 @@ function collectPublicAssets(config) {
1897
1756
  prefix: "export type PublicAssetKey ="
1898
1757
  }),
1899
1758
  "",
1900
- "declare module \"vorma/client\" {",
1759
+ "declare module \"@vorma/client\" {",
1901
1760
  " interface ClientApplicationContracts {",
1902
1761
  " readonly assets: PublicAssetKey;",
1903
1762
  " }",
@@ -1926,14 +1785,6 @@ function atAssetPath(input) {
1926
1785
  }
1927
1786
  //#endregion
1928
1787
  //#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
1788
  /** One namespace import per source file that exports a registered declaration, in a stable order. */
1938
1789
  function createModuleNamespaces(input) {
1939
1790
  const identifiers = /* @__PURE__ */ new Map();
@@ -1969,28 +1820,23 @@ function renderGeneratedBuildModule(input) {
1969
1820
  "// Code generated by Vorma. DO NOT EDIT.",
1970
1821
  "",
1971
1822
  ...modules.imports.map((moduleImport) => {
1972
- return `import * as ${moduleImport.identifier} from ${JSON.stringify(moduleImport.specifier)};`;
1823
+ const specifier = moduleImport.specifier.split("/").map(encodeURIComponent).join("/");
1824
+ return `import * as ${moduleImport.identifier} from ${JSON.stringify(specifier)};`;
1973
1825
  }),
1974
1826
  "",
1975
1827
  "/** Every registerable declaration that the server project exports, in source order. */",
1976
- ...input.declarations.length === 0 ? ["export const registeredDeclarations = [] as const;"] : [
1828
+ ...input.declarations.length === 0 ? ["export const registeredDeclarations = [];"] : [
1977
1829
  "export const registeredDeclarations = [",
1978
1830
  ...input.declarations.map((declaration) => {
1979
1831
  return `\t${modules.getIdentifier(declaration.filePath)}[${JSON.stringify(declaration.exportName)}],`;
1980
1832
  }),
1981
- "] as const;"
1833
+ "];"
1982
1834
  ],
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
1835
  ""
1990
1836
  ].join("\n")
1991
1837
  };
1992
1838
  }
1993
- /** Renders the declaration that augments `vorma/server` with this application's patterns, search types, and asset keys. */
1839
+ /** Renders the declaration that augments `@vorma/server` with this application's patterns, search types, and asset keys. */
1994
1840
  function renderGeneratedServerContracts(input) {
1995
1841
  const serverModuleSpecifier = JSON.stringify(FRAMEWORK_IDENTITY_PROTOCOL.moduleSpecifiers.server);
1996
1842
  const routeSearchTypes = input.model.segments.map((segment) => {
@@ -2273,7 +2119,7 @@ function writeApplicationGeneration(generation) {
2273
2119
  ];
2274
2120
  const plannedSourceFiles = [
2275
2121
  ...outputs.map((output) => output.filePath),
2276
- generation.config.generatedBuildFilePath,
2122
+ generation.config.generatedRegistrationFilePath,
2277
2123
  generation.config.generatedServerContractsFilePath
2278
2124
  ];
2279
2125
  return Effect.forEach([...generation.config.ignoreFilePaths.map((filePath) => {
@@ -2295,7 +2141,7 @@ function writeApplicationGeneration(generation) {
2295
2141
  })));
2296
2142
  }
2297
2143
  /** 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$/;
2144
+ const GENERATED_SOURCE_FILE_NAME = /(?:\.gen\.(?:d\.)?ts|\.mjs)$/;
2299
2145
  function removeStaleGeneratedSource(input) {
2300
2146
  return Effect.gen(function* () {
2301
2147
  const fileSystem = yield* FileSystem$1.FileSystem;
@@ -2321,7 +2167,7 @@ function removeStaleGeneratedSource(input) {
2321
2167
  }
2322
2168
  /**
2323
2169
  * Writes the internal registration module and the application
2324
- * contract types before server compilation.
2170
+ * contract types before application startup.
2325
2171
  */
2326
2172
  function writeGeneratedServerApplication(input) {
2327
2173
  return Effect.gen(function* () {
@@ -2329,12 +2175,7 @@ function writeGeneratedServerApplication(input) {
2329
2175
  const { config, model, inspection } = input.generation;
2330
2176
  const buildModule = renderGeneratedBuildModule({
2331
2177
  declarations: model.serverDeclarations,
2332
- publicDirectoryRelativeUrl: getPublicDirectoryRelativeUrl({
2333
- path,
2334
- serverGeneratedDirectory: config.serverGeneratedDirectory,
2335
- publicDirectory: config.publicDirectory
2336
- }),
2337
- filePath: config.generatedBuildFilePath,
2178
+ filePath: config.generatedRegistrationFilePath,
2338
2179
  path
2339
2180
  });
2340
2181
  const contracts = renderGeneratedServerContracts({
@@ -2484,36 +2325,19 @@ function preparePublicOutput(config) {
2484
2325
  yield* fileSystem.makeDirectory(directory, { recursive: true });
2485
2326
  });
2486
2327
  }
2487
- /** Publishes compiled server modules and private metadata for the completed browser build. */
2328
+ /** Publishes private metadata for the completed browser build. */
2488
2329
  function publishApplicationArtifacts(input) {
2489
2330
  return Effect.gen(function* () {
2490
2331
  const fileSystem = yield* FileSystem$1.FileSystem;
2491
2332
  const path = yield* Path$1.Path;
2492
2333
  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
2334
  const metadataPath = path.join(config.serverGeneratedDirectory, ARTIFACT_PROTOCOL.productionMetadataFileName);
2510
2335
  const temporaryPath = `${metadataPath}.tmp`;
2511
2336
  yield* fileSystem.writeFileString(temporaryPath, JSON.stringify(input.artifacts.metadata));
2512
2337
  yield* fileSystem.rename(temporaryPath, metadataPath);
2513
2338
  return {
2514
2339
  clientBuildId: input.artifacts.metadata.clientBuildId,
2515
- publicDirectory: config.publicDirectory,
2516
- serverEntryPath: config.compiledServerEntryFilePath
2340
+ publicDirectory: config.publicDirectory
2517
2341
  };
2518
2342
  }).pipe(Effect.mapError((cause) => {
2519
2343
  return {
@@ -2522,27 +2346,6 @@ function publishApplicationArtifacts(input) {
2522
2346
  };
2523
2347
  }));
2524
2348
  }
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
2349
  //#endregion
2547
2350
  //#region src/build/source-layout.ts
2548
2351
  /** Loads the configured source layout before any application module executes. */
@@ -2624,12 +2427,7 @@ function loadApplicationSourceLayout(config) {
2624
2427
  ...config,
2625
2428
  ...canonical,
2626
2429
  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
- })
2430
+ ...criticalCssEntryFilePath === void 0 ? {} : { criticalCssEntryFilePath }
2633
2431
  };
2634
2432
  const publicSource = canonicalConfig.publicAssetsSourceDirectory;
2635
2433
  const publicOutput = canonicalConfig.publicDirectory;
@@ -3207,27 +3005,14 @@ function buildApplication(input) {
3207
3005
  yield* preparePublicOutput(resolved);
3208
3006
  const generation = yield* prepareApplicationGeneration(resolved);
3209
3007
  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
3008
  return yield* publishApplicationArtifacts({
3226
3009
  generation,
3227
- artifacts,
3228
- server
3010
+ artifacts: yield* assembleApplicationArtifacts({
3011
+ generation,
3012
+ client: yield* bundleClient(generation)
3013
+ })
3229
3014
  });
3230
3015
  }));
3231
3016
  }
3232
3017
  //#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 };
3018
+ 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 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sjcx/vorma",
3
- "version": "0.0.0-pre.1",
3
+ "version": "0.0.0-pre.3",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "license": "MIT",
@@ -13,26 +13,6 @@
13
13
  "types": "./dist/build/index.d.ts",
14
14
  "import": "./dist/build/index.js"
15
15
  },
16
- "./client": {
17
- "types": "./dist/client/index.d.ts",
18
- "import": "./dist/client/index.js"
19
- },
20
- "./client/react": {
21
- "types": "./dist/client/react/index.d.ts",
22
- "import": "./dist/client/react/index.js"
23
- },
24
- "./primitives/tasks": {
25
- "types": "./dist/primitives/tasks/index.d.ts",
26
- "import": "./dist/primitives/tasks/index.js"
27
- },
28
- "./server": {
29
- "types": "./dist/server/index.d.ts",
30
- "import": "./dist/server/index.js"
31
- },
32
- "./server/config": {
33
- "types": "./dist/server/config/index.d.ts",
34
- "import": "./dist/server/config/index.js"
35
- },
36
16
  "./vite": {
37
17
  "types": "./dist/vite/index.d.ts",
38
18
  "import": "./dist/vite/index.js"
@@ -42,36 +22,25 @@
42
22
  "@effect/platform-node-shared": "^4.0.0-rc.115",
43
23
  "@noble/hashes": "^2.4.0",
44
24
  "@scure/base": "^2.4.0",
45
- "@vorma/primitives": "npm:@sjcx/vorma-primitives@0.0.0-pre.1",
25
+ "@vorma/primitives": "npm:@sjcx/vorma-primitives@0.0.0-pre.3",
26
+ "@vorma/protocol": "npm:@sjcx/vorma-protocol@0.0.0-pre.3",
46
27
  "chokidar": "^5.0.0",
47
28
  "lightningcss": "^1.33.0",
48
29
  "rolldown": "^1.2.6",
49
30
  "typescript": "^7.0.2"
50
31
  },
51
32
  "peerDependencies": {
52
- "@effect/atom-react": ">=4.0.0-0",
53
- "@types/react": "*",
33
+ "@vorma/server": "*",
54
34
  "effect": ">=4.0.0-rc.115",
55
- "react": "*",
56
- "react-dom": "*",
57
35
  "vite": "*"
58
36
  },
59
37
  "peerDependenciesMeta": {
60
- "@effect/atom-react": {
61
- "optional": true
62
- },
63
- "@types/react": {
38
+ "@vorma/server": {
64
39
  "optional": true
65
40
  },
66
41
  "effect": {
67
42
  "optional": true
68
43
  },
69
- "react": {
70
- "optional": true
71
- },
72
- "react-dom": {
73
- "optional": true
74
- },
75
44
  "vite": {
76
45
  "optional": true
77
46
  }
@@ -1,42 +0,0 @@
1
- import { Effect } from "effect";
2
- import type { ApplicationGeneration } from "./generate-application.ts";
3
- export type ServerCompilationIssue = {
4
- readonly _tag: "ServerCompilationIssue";
5
- readonly cause: unknown;
6
- };
7
- /** A compiler report that does not prevent publication. */
8
- export type ServerCompilationDiagnostic = {
9
- readonly level: string;
10
- readonly code: string;
11
- readonly message: string;
12
- };
13
- export type CompiledServer = {
14
- /** Every compiled module of the flat server output, entry included. */
15
- readonly files: ReadonlyArray<{
16
- readonly fileName: string;
17
- readonly source: string;
18
- }>;
19
- readonly diagnostics: ReadonlyArray<ServerCompilationDiagnostic>;
20
- /** Native compiler inputs, including modules removed by tree shaking. */
21
- readonly inputFilePaths: ReadonlyArray<string>;
22
- };
23
- /**
24
- * Compiles the configured server entry and internal runtime
25
- * entry together into ECMAScript modules that run
26
- * without a TypeScript loader, a Vorma installation, or a bundler in the
27
- * target process. The compilation rewrites nothing in the application's
28
- * source. Effect remains a runtime peer shared with the containing application.
29
- *
30
- * Rolldown uses the configured server TypeScript project. The client's Vite
31
- * configuration does not configure server compilation.
32
- *
33
- * Production bytes must depend on the sources alone, so the debug comments
34
- * that name module paths relative to the build directory are off: the
35
- * checkout's location must not reach the artifact. Symlink resolution stays on
36
- * because an isolated package store reaches a package's own dependencies only
37
- * through the real path. Development source maps retain authored locations.
38
- */
39
- export declare function compileServerApplication(input: {
40
- readonly generation: ApplicationGeneration;
41
- readonly sourcemap: "inline" | false;
42
- }): Effect.Effect<CompiledServer, ServerCompilationIssue>;