@valbuild/server 0.155.0 → 0.156.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/browser/dist/valbuild-server-browser.cjs.dev.js +2 -2
  3. package/browser/dist/valbuild-server-browser.cjs.prod.js +2 -2
  4. package/browser/dist/valbuild-server-browser.esm.js +2 -2
  5. package/dist/{ValOpsMemory-f000531b.cjs.prod.js → ValOpsMemory-6155aa9b.cjs.prod.js} +36 -4
  6. package/dist/{ValOpsMemory-1a0bc2dc.esm.js → ValOpsMemory-a00c3187.esm.js} +36 -4
  7. package/dist/{ValOpsMemory-6e829758.cjs.dev.js → ValOpsMemory-c1453e6a.cjs.dev.js} +36 -4
  8. package/dist/{createPrettierFormatter-5d830bdf.cjs.dev.js → createPrettierFormatter-8e60f596.cjs.prod.js} +1 -1
  9. package/dist/{createPrettierFormatter-b31bfbe5.cjs.prod.js → createPrettierFormatter-a9109288.cjs.dev.js} +1 -1
  10. package/dist/{createPrettierFormatter-ce478de1.esm.js → createPrettierFormatter-fb68e363.esm.js} +1 -1
  11. package/dist/{createValRuntime-f55300a0.esm.js → createValRuntime-4371c69b.esm.js} +6 -4
  12. package/dist/{createValRuntime-a519939b.cjs.prod.js → createValRuntime-5eb0336d.cjs.prod.js} +6 -4
  13. package/dist/{createValRuntime-1c7d891e.cjs.dev.js → createValRuntime-82f38747.cjs.dev.js} +6 -4
  14. package/dist/declarations/src/internal/index.d.ts +14 -0
  15. package/dist/declarations/src/proposalMerge/foldContent.d.ts +45 -0
  16. package/dist/declarations/src/proposalMerge/project.d.ts +124 -0
  17. package/dist/declarations/src/proposalMerge/threeWay.d.ts +51 -0
  18. package/dist/declarations/src/proposalMerge/validate.d.ts +16 -0
  19. package/dist/foldContent-2c218a30.cjs.dev.js +216 -0
  20. package/dist/foldContent-54f2c87c.cjs.prod.js +216 -0
  21. package/dist/foldContent-f065c19f.esm.js +214 -0
  22. package/dist/{inTabFetch-dae5dd87.esm.js → inTabFetch-22fc6815.esm.js} +1 -1
  23. package/dist/{inTabFetch-3d8ceb84.cjs.prod.js → inTabFetch-4efbd411.cjs.prod.js} +1 -1
  24. package/dist/{inTabFetch-75753a09.cjs.dev.js → inTabFetch-f5eedbd0.cjs.dev.js} +1 -1
  25. package/dist/{proposalJsonEntries-2cd6f6fe.esm.js → jsonValuesModule-12fc4bb0.esm.js} +2 -128
  26. package/dist/{proposalJsonEntries-d21900d4.cjs.dev.js → jsonValuesModule-6cf73937.cjs.prod.js} +2 -130
  27. package/dist/{proposalJsonEntries-d4623810.cjs.prod.js → jsonValuesModule-ed68a9de.cjs.dev.js} +2 -130
  28. package/dist/merge-5a8fc685.cjs.prod.js +1596 -0
  29. package/dist/merge-a21a9c78.cjs.dev.js +1596 -0
  30. package/dist/merge-eca8ec38.esm.js +1566 -0
  31. package/dist/proposalJsonEntries-4fcfab08.cjs.prod.js +135 -0
  32. package/dist/proposalJsonEntries-878ad5b6.cjs.dev.js +135 -0
  33. package/dist/proposalJsonEntries-e1b07915.esm.js +128 -0
  34. package/dist/{publishKit-395b92e5.cjs.prod.js → publishKit-0ec427f3.cjs.prod.js} +19 -22
  35. package/dist/{publishKit-04b6d255.esm.js → publishKit-a40062cd.esm.js} +11 -14
  36. package/dist/{publishKit-de4baed6.cjs.dev.js → publishKit-ffcaf2af.cjs.dev.js} +19 -22
  37. package/dist/{valRuntime-e922e372.cjs.prod.js → valRuntime-175e2032.cjs.prod.js} +21 -995
  38. package/dist/{valRuntime-7fd12e16.esm.js → valRuntime-18d4c693.esm.js} +11 -982
  39. package/dist/{valRuntime-d3cc6e0d.cjs.dev.js → valRuntime-c4b2e906.cjs.dev.js} +21 -995
  40. package/dist/valbuild-server.cjs.dev.js +45 -462
  41. package/dist/valbuild-server.cjs.prod.js +45 -462
  42. package/dist/valbuild-server.esm.js +15 -431
  43. package/internal/browser/dist/valbuild-server-internal-browser.cjs.dev.js +2 -2
  44. package/internal/browser/dist/valbuild-server-internal-browser.cjs.prod.js +2 -2
  45. package/internal/browser/dist/valbuild-server-internal-browser.esm.js +2 -2
  46. package/internal/dist/valbuild-server-internal.cjs.dev.js +20 -2
  47. package/internal/dist/valbuild-server-internal.cjs.prod.js +20 -2
  48. package/internal/dist/valbuild-server-internal.esm.js +20 -3
  49. package/package.json +3 -3
@@ -1,7 +1,5 @@
1
- import { result, pipe } from '@valbuild/core/fp';
2
1
  import ts from 'typescript';
3
- import { r as resolveExistingJsonPath } from './jsonValuesPatch-13acc674.esm.js';
4
- import { a as proposalSnapshot, i as isObject, d as isJsonValue } from './createPrettierFormatter-ce478de1.esm.js';
2
+ import { result, pipe } from '@valbuild/core/fp';
5
3
 
6
4
  class ValSyntaxError {
7
5
  constructor(message, node) {
@@ -353,128 +351,4 @@ function getImportPathFromThunk(thunk) {
353
351
  return null;
354
352
  }
355
353
 
356
- /*
357
- * The half of a proposal's snapshot that needs the compiler: which
358
- * `*.val.json` a saved entry is, read from its module's `.val.ts`. Apart from
359
- * `./proposal` so that a reader serving published content -- which never has
360
- * a saved entry -- does not evaluate TypeScript to start
361
- * (`readerSnapshot` loads this only when there is one).
362
- */
363
-
364
- /**
365
- * The `.jsonValues()` entries the proposal saved, by module and key.
366
- *
367
- * An entry's content is not in its module's Source -- that holds a marker per
368
- * entry -- but in the entry's own `*.val.json`, and a save writes that file:
369
- * it reaches the proposal's address as saved TEXT ({@link ValProposal.files}),
370
- * not as Source. So the snapshot alone shows the build's entries. This is the
371
- * other half: each saved `*.val.json`, read as the entry its module names.
372
- *
373
- * Which entry a file is comes from the module's `.val.ts`, whose
374
- * `c.json(() => import("..."))` thunks name the files -- the saved text if
375
- * the save rewrote it, else the build's own (`projectSource`). An entry whose
376
- * module cannot be read that way is left to the build, as before: this adds
377
- * what it can find and never fails the address.
378
- */
379
- function proposalJsonEntries(proposal, projectSource) {
380
- const found = new Map();
381
- const savedJson = Object.keys(proposal.files).filter(path => path.endsWith(".val.json"));
382
- if (savedJson.length === 0) return found;
383
- const savedJsonPaths = new Set(savedJson);
384
- for (const [moduleFilePath, source] of Object.entries(proposal.modules)) {
385
- if (!holdsJsonMarkers(source)) continue;
386
- const relative = moduleFilePath.replace(/^\//, "");
387
- const text = proposal.files[relative] ?? (projectSource === null || projectSource === void 0 ? void 0 : projectSource[relative]);
388
- if (text === undefined) continue;
389
- const entries = jsonEntryPaths(relative, text);
390
- if (entries === null) continue;
391
- const byKey = new Map();
392
- for (const [key, importPath] of entries) {
393
- const jsonPath = resolveExistingJsonPath(moduleFilePath, importPath).replace(/^\//, "");
394
- if (!savedJsonPaths.has(jsonPath)) continue;
395
- const content = parseJson(proposal.files[jsonPath]);
396
- if (content !== undefined) byKey.set(key, content);
397
- }
398
- if (byKey.size > 0) found.set(moduleFilePath, byKey);
399
- }
400
- return found;
401
- }
402
-
403
- /**
404
- * The snapshot as a page reads it: {@link proposalSnapshot}, with each saved
405
- * `.jsonValues()` entry's content in place of its marker -- the shape a draft
406
- * already has, where the entries it edits hold content and the rest are
407
- * markers the readers resolve from the build. See {@link proposalJsonEntries}.
408
- *
409
- * For the readers only. Val's own server keeps the markers
410
- * ({@link proposalSnapshot}): its patching works on them, and it takes the
411
- * saved entries separately.
412
- */
413
- function proposalSnapshotForReaders(proposal, projectSource) {
414
- const snapshot = proposalSnapshot(proposal);
415
- for (const [moduleFilePath, entries] of proposalJsonEntries(proposal, projectSource)) {
416
- const source = snapshot[moduleFilePath];
417
- if (!isObject(source)) continue;
418
- const filled = {};
419
- for (const [key, value] of Object.entries(source)) {
420
- if (isJsonValue(value)) filled[key] = value;
421
- }
422
- for (const [key, content] of entries) {
423
- // Own keys only: an entry may be named `toString`.
424
- if (Object.prototype.hasOwnProperty.call(filled, key)) {
425
- filled[key] = content;
426
- }
427
- }
428
- snapshot[moduleFilePath] = filled;
429
- }
430
- return snapshot;
431
- }
432
-
433
- /** A record of `.jsonValues()` markers (`{ _type: "json" }`), at least one. */
434
- function holdsJsonMarkers(source) {
435
- return isObject(source) && Object.values(source).some(value => isObject(value) && value["_type"] === "json");
436
- }
437
-
438
- /** Each entry key's import path, from a `.jsonValues()` module's text. */
439
- function jsonEntryPaths(fileName, text) {
440
- try {
441
- const analysis = analyzeValModule(ts.createSourceFile(fileName, text, ts.ScriptTarget.ES2015, true));
442
- if (result.isErr(analysis)) return null;
443
- const paths = new Map();
444
- for (const [key, entry] of analyzeJsonValuesEntries(analysis.value.source)) {
445
- paths.set(key, entry.importPath);
446
- }
447
- return paths;
448
- } catch {
449
- // Not a module this can read: its entries stay the build's.
450
- return null;
451
- }
452
- }
453
- function parseJson(text) {
454
- if (text === undefined) return undefined;
455
- try {
456
- const value = JSON.parse(text);
457
- return isMutableJsonValue(value) ? value : undefined;
458
- } catch {
459
- return undefined;
460
- }
461
- }
462
-
463
- /** {@link isJsonValue}, for the mutable JSON a server patches. */
464
- function isMutableJsonValue(value) {
465
- if (value === null || typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
466
- return true;
467
- }
468
- if (Array.isArray(value)) {
469
- return value.every(isMutableJsonValue);
470
- }
471
- return isObject(value) && Object.values(value).every(isMutableJsonValue);
472
- }
473
-
474
- var proposalJsonEntries$1 = /*#__PURE__*/Object.freeze({
475
- __proto__: null,
476
- proposalJsonEntries: proposalJsonEntries,
477
- proposalSnapshotForReaders: proposalSnapshotForReaders
478
- });
479
-
480
- export { analyzeValModule as a, formatSyntaxError as b, analyzeJsonValuesEntries as c, formatSyntaxErrorTree as d, findObjectPropertyAssignment as e, flatMapErrors as f, findObjectPropertyAssignmentToRemove as g, evaluateExpression as h, proposalJsonEntries as i, evaluateModuleSource as j, jsonValuesRecordKeys as k, proposalJsonEntries$1 as l, proposalSnapshotForReaders as p, shallowValidateExpression as s, validateInitializers as v };
354
+ export { ValSyntaxError as V, analyzeValModule as a, formatSyntaxError as b, analyzeJsonValuesEntries as c, formatSyntaxErrorTree as d, findObjectPropertyAssignment as e, flatMapErrors as f, findObjectPropertyAssignmentToRemove as g, evaluateExpression as h, evaluateModuleSource as i, jsonValuesRecordKeys as j, shallowValidateExpression as s, validateInitializers as v };
@@ -1,9 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var fp = require('@valbuild/core/fp');
4
3
  var ts = require('typescript');
5
- var jsonValuesPatch = require('./jsonValuesPatch-88bc661d.cjs.dev.js');
6
- var createPrettierFormatter = require('./createPrettierFormatter-5d830bdf.cjs.dev.js');
4
+ var fp = require('@valbuild/core/fp');
7
5
 
8
6
  function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
9
7
 
@@ -359,130 +357,7 @@ function getImportPathFromThunk(thunk) {
359
357
  return null;
360
358
  }
361
359
 
362
- /*
363
- * The half of a proposal's snapshot that needs the compiler: which
364
- * `*.val.json` a saved entry is, read from its module's `.val.ts`. Apart from
365
- * `./proposal` so that a reader serving published content -- which never has
366
- * a saved entry -- does not evaluate TypeScript to start
367
- * (`readerSnapshot` loads this only when there is one).
368
- */
369
-
370
- /**
371
- * The `.jsonValues()` entries the proposal saved, by module and key.
372
- *
373
- * An entry's content is not in its module's Source -- that holds a marker per
374
- * entry -- but in the entry's own `*.val.json`, and a save writes that file:
375
- * it reaches the proposal's address as saved TEXT ({@link ValProposal.files}),
376
- * not as Source. So the snapshot alone shows the build's entries. This is the
377
- * other half: each saved `*.val.json`, read as the entry its module names.
378
- *
379
- * Which entry a file is comes from the module's `.val.ts`, whose
380
- * `c.json(() => import("..."))` thunks name the files -- the saved text if
381
- * the save rewrote it, else the build's own (`projectSource`). An entry whose
382
- * module cannot be read that way is left to the build, as before: this adds
383
- * what it can find and never fails the address.
384
- */
385
- function proposalJsonEntries(proposal, projectSource) {
386
- const found = new Map();
387
- const savedJson = Object.keys(proposal.files).filter(path => path.endsWith(".val.json"));
388
- if (savedJson.length === 0) return found;
389
- const savedJsonPaths = new Set(savedJson);
390
- for (const [moduleFilePath, source] of Object.entries(proposal.modules)) {
391
- if (!holdsJsonMarkers(source)) continue;
392
- const relative = moduleFilePath.replace(/^\//, "");
393
- const text = proposal.files[relative] ?? (projectSource === null || projectSource === void 0 ? void 0 : projectSource[relative]);
394
- if (text === undefined) continue;
395
- const entries = jsonEntryPaths(relative, text);
396
- if (entries === null) continue;
397
- const byKey = new Map();
398
- for (const [key, importPath] of entries) {
399
- const jsonPath = jsonValuesPatch.resolveExistingJsonPath(moduleFilePath, importPath).replace(/^\//, "");
400
- if (!savedJsonPaths.has(jsonPath)) continue;
401
- const content = parseJson(proposal.files[jsonPath]);
402
- if (content !== undefined) byKey.set(key, content);
403
- }
404
- if (byKey.size > 0) found.set(moduleFilePath, byKey);
405
- }
406
- return found;
407
- }
408
-
409
- /**
410
- * The snapshot as a page reads it: {@link proposalSnapshot}, with each saved
411
- * `.jsonValues()` entry's content in place of its marker -- the shape a draft
412
- * already has, where the entries it edits hold content and the rest are
413
- * markers the readers resolve from the build. See {@link proposalJsonEntries}.
414
- *
415
- * For the readers only. Val's own server keeps the markers
416
- * ({@link proposalSnapshot}): its patching works on them, and it takes the
417
- * saved entries separately.
418
- */
419
- function proposalSnapshotForReaders(proposal, projectSource) {
420
- const snapshot = createPrettierFormatter.proposalSnapshot(proposal);
421
- for (const [moduleFilePath, entries] of proposalJsonEntries(proposal, projectSource)) {
422
- const source = snapshot[moduleFilePath];
423
- if (!createPrettierFormatter.isObject(source)) continue;
424
- const filled = {};
425
- for (const [key, value] of Object.entries(source)) {
426
- if (createPrettierFormatter.isJsonValue(value)) filled[key] = value;
427
- }
428
- for (const [key, content] of entries) {
429
- // Own keys only: an entry may be named `toString`.
430
- if (Object.prototype.hasOwnProperty.call(filled, key)) {
431
- filled[key] = content;
432
- }
433
- }
434
- snapshot[moduleFilePath] = filled;
435
- }
436
- return snapshot;
437
- }
438
-
439
- /** A record of `.jsonValues()` markers (`{ _type: "json" }`), at least one. */
440
- function holdsJsonMarkers(source) {
441
- return createPrettierFormatter.isObject(source) && Object.values(source).some(value => createPrettierFormatter.isObject(value) && value["_type"] === "json");
442
- }
443
-
444
- /** Each entry key's import path, from a `.jsonValues()` module's text. */
445
- function jsonEntryPaths(fileName, text) {
446
- try {
447
- const analysis = analyzeValModule(ts__default["default"].createSourceFile(fileName, text, ts__default["default"].ScriptTarget.ES2015, true));
448
- if (fp.result.isErr(analysis)) return null;
449
- const paths = new Map();
450
- for (const [key, entry] of analyzeJsonValuesEntries(analysis.value.source)) {
451
- paths.set(key, entry.importPath);
452
- }
453
- return paths;
454
- } catch {
455
- // Not a module this can read: its entries stay the build's.
456
- return null;
457
- }
458
- }
459
- function parseJson(text) {
460
- if (text === undefined) return undefined;
461
- try {
462
- const value = JSON.parse(text);
463
- return isMutableJsonValue(value) ? value : undefined;
464
- } catch {
465
- return undefined;
466
- }
467
- }
468
-
469
- /** {@link isJsonValue}, for the mutable JSON a server patches. */
470
- function isMutableJsonValue(value) {
471
- if (value === null || typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
472
- return true;
473
- }
474
- if (Array.isArray(value)) {
475
- return value.every(isMutableJsonValue);
476
- }
477
- return createPrettierFormatter.isObject(value) && Object.values(value).every(isMutableJsonValue);
478
- }
479
-
480
- var proposalJsonEntries$1 = /*#__PURE__*/Object.freeze({
481
- __proto__: null,
482
- proposalJsonEntries: proposalJsonEntries,
483
- proposalSnapshotForReaders: proposalSnapshotForReaders
484
- });
485
-
360
+ exports.ValSyntaxError = ValSyntaxError;
486
361
  exports.analyzeJsonValuesEntries = analyzeJsonValuesEntries;
487
362
  exports.analyzeValModule = analyzeValModule;
488
363
  exports.evaluateExpression = evaluateExpression;
@@ -493,8 +368,5 @@ exports.flatMapErrors = flatMapErrors;
493
368
  exports.formatSyntaxError = formatSyntaxError;
494
369
  exports.formatSyntaxErrorTree = formatSyntaxErrorTree;
495
370
  exports.jsonValuesRecordKeys = jsonValuesRecordKeys;
496
- exports.proposalJsonEntries = proposalJsonEntries;
497
- exports.proposalJsonEntries$1 = proposalJsonEntries$1;
498
- exports.proposalSnapshotForReaders = proposalSnapshotForReaders;
499
371
  exports.shallowValidateExpression = shallowValidateExpression;
500
372
  exports.validateInitializers = validateInitializers;
@@ -1,9 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var fp = require('@valbuild/core/fp');
4
3
  var ts = require('typescript');
5
- var jsonValuesPatch = require('./jsonValuesPatch-92798812.cjs.prod.js');
6
- var createPrettierFormatter = require('./createPrettierFormatter-b31bfbe5.cjs.prod.js');
4
+ var fp = require('@valbuild/core/fp');
7
5
 
8
6
  function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
9
7
 
@@ -359,130 +357,7 @@ function getImportPathFromThunk(thunk) {
359
357
  return null;
360
358
  }
361
359
 
362
- /*
363
- * The half of a proposal's snapshot that needs the compiler: which
364
- * `*.val.json` a saved entry is, read from its module's `.val.ts`. Apart from
365
- * `./proposal` so that a reader serving published content -- which never has
366
- * a saved entry -- does not evaluate TypeScript to start
367
- * (`readerSnapshot` loads this only when there is one).
368
- */
369
-
370
- /**
371
- * The `.jsonValues()` entries the proposal saved, by module and key.
372
- *
373
- * An entry's content is not in its module's Source -- that holds a marker per
374
- * entry -- but in the entry's own `*.val.json`, and a save writes that file:
375
- * it reaches the proposal's address as saved TEXT ({@link ValProposal.files}),
376
- * not as Source. So the snapshot alone shows the build's entries. This is the
377
- * other half: each saved `*.val.json`, read as the entry its module names.
378
- *
379
- * Which entry a file is comes from the module's `.val.ts`, whose
380
- * `c.json(() => import("..."))` thunks name the files -- the saved text if
381
- * the save rewrote it, else the build's own (`projectSource`). An entry whose
382
- * module cannot be read that way is left to the build, as before: this adds
383
- * what it can find and never fails the address.
384
- */
385
- function proposalJsonEntries(proposal, projectSource) {
386
- const found = new Map();
387
- const savedJson = Object.keys(proposal.files).filter(path => path.endsWith(".val.json"));
388
- if (savedJson.length === 0) return found;
389
- const savedJsonPaths = new Set(savedJson);
390
- for (const [moduleFilePath, source] of Object.entries(proposal.modules)) {
391
- if (!holdsJsonMarkers(source)) continue;
392
- const relative = moduleFilePath.replace(/^\//, "");
393
- const text = proposal.files[relative] ?? (projectSource === null || projectSource === void 0 ? void 0 : projectSource[relative]);
394
- if (text === undefined) continue;
395
- const entries = jsonEntryPaths(relative, text);
396
- if (entries === null) continue;
397
- const byKey = new Map();
398
- for (const [key, importPath] of entries) {
399
- const jsonPath = jsonValuesPatch.resolveExistingJsonPath(moduleFilePath, importPath).replace(/^\//, "");
400
- if (!savedJsonPaths.has(jsonPath)) continue;
401
- const content = parseJson(proposal.files[jsonPath]);
402
- if (content !== undefined) byKey.set(key, content);
403
- }
404
- if (byKey.size > 0) found.set(moduleFilePath, byKey);
405
- }
406
- return found;
407
- }
408
-
409
- /**
410
- * The snapshot as a page reads it: {@link proposalSnapshot}, with each saved
411
- * `.jsonValues()` entry's content in place of its marker -- the shape a draft
412
- * already has, where the entries it edits hold content and the rest are
413
- * markers the readers resolve from the build. See {@link proposalJsonEntries}.
414
- *
415
- * For the readers only. Val's own server keeps the markers
416
- * ({@link proposalSnapshot}): its patching works on them, and it takes the
417
- * saved entries separately.
418
- */
419
- function proposalSnapshotForReaders(proposal, projectSource) {
420
- const snapshot = createPrettierFormatter.proposalSnapshot(proposal);
421
- for (const [moduleFilePath, entries] of proposalJsonEntries(proposal, projectSource)) {
422
- const source = snapshot[moduleFilePath];
423
- if (!createPrettierFormatter.isObject(source)) continue;
424
- const filled = {};
425
- for (const [key, value] of Object.entries(source)) {
426
- if (createPrettierFormatter.isJsonValue(value)) filled[key] = value;
427
- }
428
- for (const [key, content] of entries) {
429
- // Own keys only: an entry may be named `toString`.
430
- if (Object.prototype.hasOwnProperty.call(filled, key)) {
431
- filled[key] = content;
432
- }
433
- }
434
- snapshot[moduleFilePath] = filled;
435
- }
436
- return snapshot;
437
- }
438
-
439
- /** A record of `.jsonValues()` markers (`{ _type: "json" }`), at least one. */
440
- function holdsJsonMarkers(source) {
441
- return createPrettierFormatter.isObject(source) && Object.values(source).some(value => createPrettierFormatter.isObject(value) && value["_type"] === "json");
442
- }
443
-
444
- /** Each entry key's import path, from a `.jsonValues()` module's text. */
445
- function jsonEntryPaths(fileName, text) {
446
- try {
447
- const analysis = analyzeValModule(ts__default["default"].createSourceFile(fileName, text, ts__default["default"].ScriptTarget.ES2015, true));
448
- if (fp.result.isErr(analysis)) return null;
449
- const paths = new Map();
450
- for (const [key, entry] of analyzeJsonValuesEntries(analysis.value.source)) {
451
- paths.set(key, entry.importPath);
452
- }
453
- return paths;
454
- } catch {
455
- // Not a module this can read: its entries stay the build's.
456
- return null;
457
- }
458
- }
459
- function parseJson(text) {
460
- if (text === undefined) return undefined;
461
- try {
462
- const value = JSON.parse(text);
463
- return isMutableJsonValue(value) ? value : undefined;
464
- } catch {
465
- return undefined;
466
- }
467
- }
468
-
469
- /** {@link isJsonValue}, for the mutable JSON a server patches. */
470
- function isMutableJsonValue(value) {
471
- if (value === null || typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
472
- return true;
473
- }
474
- if (Array.isArray(value)) {
475
- return value.every(isMutableJsonValue);
476
- }
477
- return createPrettierFormatter.isObject(value) && Object.values(value).every(isMutableJsonValue);
478
- }
479
-
480
- var proposalJsonEntries$1 = /*#__PURE__*/Object.freeze({
481
- __proto__: null,
482
- proposalJsonEntries: proposalJsonEntries,
483
- proposalSnapshotForReaders: proposalSnapshotForReaders
484
- });
485
-
360
+ exports.ValSyntaxError = ValSyntaxError;
486
361
  exports.analyzeJsonValuesEntries = analyzeJsonValuesEntries;
487
362
  exports.analyzeValModule = analyzeValModule;
488
363
  exports.evaluateExpression = evaluateExpression;
@@ -493,8 +368,5 @@ exports.flatMapErrors = flatMapErrors;
493
368
  exports.formatSyntaxError = formatSyntaxError;
494
369
  exports.formatSyntaxErrorTree = formatSyntaxErrorTree;
495
370
  exports.jsonValuesRecordKeys = jsonValuesRecordKeys;
496
- exports.proposalJsonEntries = proposalJsonEntries;
497
- exports.proposalJsonEntries$1 = proposalJsonEntries$1;
498
- exports.proposalSnapshotForReaders = proposalSnapshotForReaders;
499
371
  exports.shallowValidateExpression = shallowValidateExpression;
500
372
  exports.validateInitializers = validateInitializers;