@sjcx/vorma 0.0.0-pre.5 → 0.0.0-pre.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/build/cli.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { C as projectBrowserContracts, S as getClientViewEntries, _ as createCssPublicAssets, a as acquireOutputOwnership, b as toContentDigest, c as writeAndCheckApplicationGeneration, d as readTypescriptProjectRoots, f as runTypescriptOperation, g as containsRelativePath, h as resolveVormaConfig, i as publishApplicationArtifacts, l as collectPublicAssets, m as getGeneratedSourceDirectories, n as loadApplicationSourceLayout, o as checkOutputPath, p as withTypescriptProjects, r as preparePublicOutput, s as assembleApplicationGeneration, t as buildApplication, u as inspectProjects, v as createClientPublicUrlPlugin, x as CLIENT_SHARED_PACKAGES, y as encodeCanonicalJson } from "../build-BeUTL6eX.js";
2
+ import { C as projectBrowserContracts, S as getClientViewEntries, _ as createCssPublicAssets, a as acquireOutputOwnership, b as toContentDigest, c as writeAndCheckApplicationGeneration, d as readTypescriptProjectRoots, f as runTypescriptOperation, g as containsRelativePath, h as resolveVormaConfig, i as publishApplicationArtifacts, l as collectPublicAssets, m as getGeneratedSourceDirectories, n as loadApplicationSourceLayout, o as checkOutputPath, p as withTypescriptProjects, r as preparePublicOutput, s as assembleApplicationGeneration, t as buildApplication, u as inspectProjects, v as createClientPublicUrlPlugin, x as CLIENT_SHARED_PACKAGES, y as encodeCanonicalJson } from "../build-Dy9VE6xO.js";
3
3
  import { t as VORMA_BUILD_PLUGIN_NAME } from "../build-invocation-D7Fu8gBK.js";
4
4
  import { NodeChildProcessSpawner, NodeCrypto, NodeFileSystem, NodePath, NodeRuntime, NodeSocketServer, NodeStdio, NodeTerminal } from "@effect/platform-node-shared";
5
5
  import { Cause, Console, Deferred, Effect, Exit, Fiber, FileSystem, Layer, Path, Queue, Result, Schedule, Schema, ScopedRef, Stream } from "effect";
@@ -41,7 +41,7 @@ function assembleDevelopmentArtifacts(input) {
41
41
  const clientViews = Object.fromEntries(getClientViewEntries(generation).map((view) => {
42
42
  return [view.pattern, {
43
43
  ...toModule(view.id),
44
- exportNames: view.exportNames
44
+ exportName: view.exportName
45
45
  }];
46
46
  }));
47
47
  return { metadata: {
@@ -274,9 +274,6 @@ function startDevelopmentClient(inputs, port, recordChangeFn) {
274
274
  let configurationRevision = 0;
275
275
  let coordinatedRestart = false;
276
276
  let views = inputs.views;
277
- const virtualSources = new Map(views.flatMap((view) => {
278
- return view.source === void 0 ? [] : [[view.id, view.source]];
279
- }));
280
277
  let declared = false;
281
278
  let inspection;
282
279
  let finishInspectionFn;
@@ -352,13 +349,12 @@ function startDevelopmentClient(inputs, port, recordChangeFn) {
352
349
  },
353
350
  resolveId(source) {
354
351
  if (source === "\0vorma:development-browser") return source;
355
- if (virtualSources.has(source)) return source;
356
352
  return source === FRAMEWORK_IDENTITY_PROTOCOL.moduleSpecifiers.clientTransportTypes ? inputs.clientTransport.filePath : null;
357
353
  },
358
354
  async load(id) {
359
355
  if (id === "\0vorma:development-browser") return renderDevelopmentBrowserSource();
360
356
  if (inputs.clientSourceTexts[id.split("?", 1)[0] ?? id] !== void 0) await inspection;
361
- return virtualSources.get(id) ?? null;
357
+ return null;
362
358
  },
363
359
  async hotUpdate() {
364
360
  if (await inspection) return [];
@@ -465,18 +461,11 @@ function startDevelopmentClient(inputs, port, recordChangeFn) {
465
461
  const publicAssetsChanged = JSON.stringify(inputs.publicFilemap) !== JSON.stringify(next.publicFilemap);
466
462
  inputs = next;
467
463
  views = next.views;
468
- const previousVirtualIds = new Set(virtualSources.keys());
469
- virtualSources.clear();
470
- for (const view of views) if (view.source !== void 0) virtualSources.set(view.id, view.source);
471
464
  publicUrls.api.updateInputFn(getPublicUrlInput(next));
472
465
  publicCss.updatePublicAssetsFn(next);
473
466
  for (const environment of Object.values(server.environments)) {
474
467
  const graph = environment.moduleGraph;
475
468
  for (const filePath of replacedFiles) for (const module of graph.getModulesByFile(filePath) ?? []) graph.invalidateModule(module);
476
- for (const id of previousVirtualIds) {
477
- const module = graph.getModuleById(id);
478
- if (module !== void 0) graph.invalidateModule(module);
479
- }
480
469
  if (publicAssetsChanged) {
481
470
  for (const module of graph.idToModuleMap.values()) if (module.type === "css") graph.invalidateModule(module);
482
471
  }
@@ -4,8 +4,7 @@ export declare const CLIENT_SHARED_PACKAGES: string[];
4
4
  export type ClientViewEntry = {
5
5
  readonly pattern: string;
6
6
  readonly id: string;
7
- readonly exportNames: ReadonlyArray<string>;
8
- readonly source: string | undefined;
7
+ readonly exportName: string;
9
8
  };
10
- /** Keeps value identity checks inside the selected route's normal module load. */
9
+ /** Projects each validated view declaration into one browser entry. */
11
10
  export declare function getClientViewEntries(generation: ApplicationGeneration): ReadonlyArray<ClientViewEntry>;
@@ -18,7 +18,6 @@ export type ApplicationModel = {
18
18
  readonly uiLoaders: ReadonlyArray<InspectedUiLoader>;
19
19
  readonly endpoints: ReadonlyArray<InspectedEndpoint>;
20
20
  readonly clientViews: ReadonlyArray<InspectedClientView>;
21
- readonly clientViewCandidates: ReadonlyMap<string, ReadonlyArray<InspectedClientView>>;
22
21
  /** The authored view modules in stable order, for generated type imports. */
23
22
  readonly clientViewModules: ReadonlyArray<string>;
24
23
  readonly clientApplication: DeclarationSource;
@@ -35,6 +34,10 @@ export type ApplicationModelIssue = {
35
34
  readonly patterns: ReadonlyArray<string>;
36
35
  readonly sources: ReadonlyArray<DeclarationSource>;
37
36
  readonly cause: ConflictingDynamicParameterNameError;
37
+ } | {
38
+ readonly _tag: "DuplicateClientView";
39
+ readonly pattern: string;
40
+ readonly sources: ReadonlyArray<DeclarationSource>;
38
41
  };
39
42
  /** Joins the inspected declarations and views into one validated model. */
40
43
  export declare function compileApplicationModel(inspection: InspectedProjects): Result.Result<ApplicationModel, ReadonlyArray<ApplicationModelIssue>>;
@@ -21,7 +21,7 @@ export declare function assembleDevelopmentArtifacts(input: {
21
21
  depUrls: ReadonlyArray<string>;
22
22
  cssBundleUrls: ReadonlyArray<string>;
23
23
  staticAssetUrls: ReadonlyArray<string>;
24
- exportNames: readonly string[];
24
+ exportName: string;
25
25
  };
26
26
  };
27
27
  criticalCss: string;
@@ -1,2 +1,2 @@
1
- import { t as buildApplication } from "../build-BeUTL6eX.js";
1
+ import { t as buildApplication } from "../build-Dy9VE6xO.js";
2
2
  export { buildApplication };
@@ -22,13 +22,12 @@ export type InspectedEndpointError = {
22
22
  };
23
23
  export type InspectedEndpoint = DeclarationSource & {
24
24
  readonly kind: "Endpoint";
25
- readonly operation: "query" | "mutation" | "stream";
25
+ readonly operation: "query" | "mutation";
26
26
  readonly method: HttpMethod;
27
27
  readonly pattern: string;
28
28
  readonly input: string | undefined;
29
29
  readonly inputTransport: InputTransportKind;
30
- readonly output: string | undefined;
31
- readonly event: string | undefined;
30
+ readonly output: string;
32
31
  readonly errors: ReadonlyArray<InspectedEndpointError>;
33
32
  };
34
33
  export type InspectedServerDeclaration = InspectedUiLoader | InspectedEndpoint;
@@ -34,8 +34,7 @@ function projectBrowserContracts(inspection) {
34
34
  operation: declaration.operation,
35
35
  inputTransport: declaration.inputTransport,
36
36
  input: declaration.inputTransport === "formData" ? "FormData" : declaration.input ?? "undefined",
37
- output: declaration.output ?? "undefined",
38
- event: declaration.event ?? "undefined",
37
+ output: declaration.output,
39
38
  errors: Object.fromEntries(declaration.errors.map((error) => {
40
39
  return [error.tag, error.fields];
41
40
  }))
@@ -55,24 +54,14 @@ const CLIENT_SHARED_PACKAGES = [
55
54
  "react",
56
55
  "react-dom"
57
56
  ];
58
- /** Keeps value identity checks inside the selected route's normal module load. */
57
+ /** Projects each validated view declaration into one browser entry. */
59
58
  function getClientViewEntries(generation) {
60
- return [...generation.model.clientViewCandidates].flatMap(([pattern, candidates], index) => {
61
- const first = candidates[0];
62
- if (first === void 0) return [];
63
- if (candidates.every((candidate) => candidate.filePath === first.filePath)) return [{
64
- pattern,
65
- id: first.filePath,
66
- exportNames: candidates.map((candidate) => candidate.exportName),
67
- source: void 0
68
- }];
69
- const exportNames = candidates.map((_candidate, candidateIndex) => `candidate${candidateIndex}`);
70
- return [{
71
- pattern,
72
- id: `\0vorma:view-candidates:${index}`,
73
- exportNames,
74
- source: candidates.map((candidate, candidateIndex) => `export { ${JSON.stringify(candidate.exportName)} as ${exportNames[candidateIndex]} } from ${JSON.stringify(candidate.filePath)};`).join("\n")
75
- }];
59
+ return generation.model.clientViews.map((view) => {
60
+ return {
61
+ pattern: view.pattern,
62
+ id: view.filePath,
63
+ exportName: view.exportName
64
+ };
76
65
  });
77
66
  }
78
67
  //#endregion
@@ -1178,7 +1167,6 @@ async function inspectEndpoint(input) {
1178
1167
  literals[name] = literal.success;
1179
1168
  }
1180
1169
  const operation = literals.kind;
1181
- if (operation === "stream") return Result.fail(makeIssue(source, "StreamEndpoint is an unimplemented declaration scaffold and cannot be built. Mount native Effect streaming handlers on the application's server."));
1182
1170
  if (operation !== "query" && operation !== "mutation") return Result.fail(makeIssue(source, `unknown endpoint kind ${operation}`));
1183
1171
  const method = literals.method;
1184
1172
  if (!matchesHttpMethod(method)) return Result.fail(makeIssue(source, `unknown endpoint method ${method}`));
@@ -1200,22 +1188,19 @@ async function inspectEndpoint(input) {
1200
1188
  type: inputType
1201
1189
  });
1202
1190
  if (Result.isFailure(endpointInput)) return Result.fail(endpointInput.failure);
1203
- const output = await renderOptionalContract({
1191
+ const outputType = await readPropertyType({
1204
1192
  checker,
1193
+ type: input.types,
1194
+ name: "output"
1195
+ });
1196
+ if (outputType === void 0) return Result.fail(makeIssue(source, "an endpoint must have an output contract"));
1197
+ const output = await renderContract({
1205
1198
  renderer,
1206
1199
  source,
1207
1200
  field: "output",
1208
- types: input.types
1201
+ type: outputType
1209
1202
  });
1210
1203
  if (Result.isFailure(output)) return Result.fail(output.failure);
1211
- const event = await renderOptionalContract({
1212
- checker,
1213
- renderer,
1214
- source,
1215
- field: "event",
1216
- types: input.types
1217
- });
1218
- if (Result.isFailure(event)) return Result.fail(event.failure);
1219
1204
  const errors = await inspectEndpointErrors({
1220
1205
  checker,
1221
1206
  renderer,
@@ -1232,7 +1217,6 @@ async function inspectEndpoint(input) {
1232
1217
  input: endpointInput.success,
1233
1218
  inputTransport,
1234
1219
  output: output.success,
1235
- event: event.success,
1236
1220
  errors: errors.success
1237
1221
  });
1238
1222
  }
@@ -1544,6 +1528,11 @@ function compileApplicationModel(inspection) {
1544
1528
  view
1545
1529
  });
1546
1530
  }
1531
+ for (const [pattern, sources] of viewSources) if (sources.length > 1) issues.push({
1532
+ _tag: "DuplicateClientView",
1533
+ pattern,
1534
+ sources
1535
+ });
1547
1536
  const endpointSources = /* @__PURE__ */ new Map();
1548
1537
  for (const endpoint of endpoints) {
1549
1538
  const registered = compileEndpointPattern(endpoint.pattern);
@@ -1599,10 +1588,6 @@ function compileApplicationModel(inspection) {
1599
1588
  uiLoaders: [...loaderSources.values()].flatMap((sources) => sources.slice(0, 1)),
1600
1589
  endpoints: [...endpointSources.values()].flatMap((sources) => sources.slice(0, 1)),
1601
1590
  clientViews: [...viewSources.values()].flatMap((sources) => sources.slice(0, 1)),
1602
- clientViewCandidates: new Map([...viewSources.values()].flatMap((sources) => {
1603
- const first = sources[0];
1604
- return first === void 0 ? [] : [[first.pattern, sources]];
1605
- })),
1606
1591
  clientViewModules: [...new Set(clientViews.map((view) => view.filePath))].sort((left, right) => compareSourceText({
1607
1592
  left,
1608
1593
  right
@@ -1922,8 +1907,7 @@ function renderGeneratedClientContracts(input) {
1922
1907
  return renderTypeEntry(`${endpoint.method} ${endpoint.pattern}`, {
1923
1908
  kind: JSON.stringify(endpoint.operation),
1924
1909
  input: endpoint.inputTransport === "formData" ? "FormData" : endpoint.input ?? "undefined",
1925
- output: endpoint.output ?? "undefined",
1926
- event: endpoint.event ?? "undefined",
1910
+ output: endpoint.output,
1927
1911
  errors: renderErrorTypes(endpoint.errors)
1928
1912
  });
1929
1913
  });
@@ -2600,7 +2584,7 @@ function assembleApplicationArtifacts(input) {
2600
2584
  const clientViews = Object.fromEntries(Object.entries(client.clientViews).map(([pattern, module]) => {
2601
2585
  return [pattern, {
2602
2586
  ...addCssAssetUrls(module),
2603
- exportNames: module.exportNames
2587
+ exportName: module.exportName
2604
2588
  }];
2605
2589
  }));
2606
2590
  const files = [...byFile.values()].sort((left, right) => compareSourceText({
@@ -2764,7 +2748,7 @@ function bundleClient(generation) {
2764
2748
  const module = entries.get(view.id);
2765
2749
  return module === void 0 ? Effect.fail(`Vite did not preserve the view module ${view.id}`) : Effect.succeed([view.pattern, {
2766
2750
  ...module,
2767
- exportNames: view.exportNames
2751
+ exportName: view.exportName
2768
2752
  }]);
2769
2753
  }).pipe(Effect.map(Object.fromEntries));
2770
2754
  return {
@@ -2856,9 +2840,6 @@ function toJavascriptAssetUrl(input) {
2856
2840
  async function runClientBuild(generation, publicCss, viewEntries) {
2857
2841
  const manifestFiles = /* @__PURE__ */ new Set();
2858
2842
  const immutableFiles = /* @__PURE__ */ new Set();
2859
- const virtualViewSources = new Map(viewEntries.flatMap((entry) => {
2860
- return entry.source === void 0 ? [] : [[entry.id, entry.source]];
2861
- }));
2862
2843
  let criticalCss = "";
2863
2844
  let criticalCssFileName;
2864
2845
  const captured = {};
@@ -2900,12 +2881,8 @@ async function runClientBuild(generation, publicCss, viewEntries) {
2900
2881
  });
2901
2882
  },
2902
2883
  resolveId(source) {
2903
- if (virtualViewSources.has(source)) return source;
2904
2884
  return source === FRAMEWORK_IDENTITY_PROTOCOL.moduleSpecifiers.clientTransportTypes ? generation.clientTransport.filePath : null;
2905
2885
  },
2906
- load(id) {
2907
- return virtualViewSources.get(id) ?? null;
2908
- },
2909
2886
  config(config) {
2910
2887
  const workerPlugins = config.worker?.plugins;
2911
2888
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sjcx/vorma",
3
- "version": "0.0.0-pre.5",
3
+ "version": "0.0.0-pre.6",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "license": "MIT",
@@ -22,8 +22,8 @@
22
22
  "@effect/platform-node-shared": "^4.0.0-rc.115",
23
23
  "@noble/hashes": "^2.4.0",
24
24
  "@scure/base": "^2.4.0",
25
- "@vorma/primitives": "npm:@sjcx/vorma-primitives@0.0.0-pre.5",
26
- "@vorma/protocol": "npm:@sjcx/vorma-protocol@0.0.0-pre.5",
25
+ "@vorma/primitives": "npm:@sjcx/vorma-primitives@0.0.0-pre.6",
26
+ "@vorma/protocol": "npm:@sjcx/vorma-protocol@0.0.0-pre.6",
27
27
  "chokidar": "^5.0.0",
28
28
  "lightningcss": "^1.33.0",
29
29
  "rolldown": "^1.2.6",