@valbuild/core 0.105.1 → 0.106.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -23,7 +23,7 @@ export type { ValidationFix } from "./schema/validation/ValidationFix.js";
23
23
  export { VAL_EXTENSION, type SourceArray } from "./source/index.js";
24
24
  export { derefPatch } from "./patch/deref.js";
25
25
  export { type SelectorSource, type SelectorOf, GenericSelector, } from "./selector/index.js";
26
- import { getSource, splitModulePath, splitModuleFilePath, resolvePath, safeResolvePath, splitModuleFilePathAndModulePath, joinModuleFilePathAndModulePath, parentOfSourcePath, patchPathToModulePath, splitJoinedSourcePaths, type ValModule } from "./module.js";
26
+ import { getSource, isValModule, splitModulePath, splitModuleFilePath, resolvePath, safeResolvePath, splitModuleFilePathAndModulePath, joinModuleFilePathAndModulePath, parentOfSourcePath, patchPathToModulePath, splitJoinedSourcePaths, type ValModule } from "./module.js";
27
27
  declare const ModuleFilePathSep = "?p=";
28
28
  export { ModuleFilePathSep };
29
29
  import { SelectorSource, getSchema } from "./selector/index.js";
@@ -80,6 +80,7 @@ declare const Internal: {
80
80
  getSchema: typeof getSchema;
81
81
  getValPath: typeof getValPath;
82
82
  getSource: typeof getSource;
83
+ isValModule: typeof isValModule;
83
84
  resolvePath: typeof resolvePath;
84
85
  safeResolvePath: typeof safeResolvePath;
85
86
  splitModuleFilePathAndModulePath: typeof splitModuleFilePathAndModulePath;
@@ -18,6 +18,16 @@ export type ReplaceRawStringWithString<T extends SelectorSource> = SelectorSourc
18
18
  export declare function define<T extends Schema<SelectorSource>>(id: string, // TODO: `/${string}`
19
19
  schema: T, source: ReplaceRawStringWithString<SelectorOfSchema<T>>): ValModule<SelectorOfSchema<T>>;
20
20
  export declare function getSource<T extends Source>(valModule: ValModule<T>): T;
21
+ /**
22
+ * Whether `value` is a Val module, i.e. something {@link define} produced.
23
+ *
24
+ * Checks for the three symbols `define` writes, rather than a class identity:
25
+ * a module may have been created by a different copy of `@valbuild/core` (the
26
+ * editor SPA and the host bundle each ship their own, and the CLI evaluates
27
+ * user modules inside a `node:vm` context). The symbols are created with
28
+ * `Symbol.for`, so they are shared across all of those; a constructor is not.
29
+ */
30
+ export declare function isValModule(value: unknown): value is ValModule<SelectorSource>;
21
31
  export declare function splitModuleFilePathAndModulePath(path: SourcePath | ModuleFilePath): [moduleId: ModuleFilePath, path: ModulePath];
22
32
  export declare function joinModuleFilePathAndModulePath(moduleFilePath: ModuleFilePath, modulePath: ModulePath): SourcePath;
23
33
  export declare function getSourceAtPath(modulePath: ModulePath, valModule: ValModule<SelectorSource> | Source): any;
@@ -3319,8 +3319,8 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
3319
3319
  if (_this2.keySchema) {
3320
3320
  var keyPath = createValPathOfItem(path, key);
3321
3321
  if (!keyPath) {
3322
- throw new Error("Internal error: could not create path at ".concat(!path && typeof path === "string" ? "<empty string>" : path, " for key validation")) // Should! never happen
3323
- ;
3322
+ throw new Error("Internal error: could not create path at ".concat(!path && typeof path === "string" ? "<empty string>" : path, " for key validation") // Should! never happen
3323
+ );
3324
3324
  }
3325
3325
  var keyError = _this2.keySchema["executeValidate"](keyPath, key);
3326
3326
  if (keyError) {
@@ -3681,8 +3681,8 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
3681
3681
  }
3682
3682
  var subPath = createValPathOfItem(path, validation.error.urlPath);
3683
3683
  if (!subPath) {
3684
- throw new Error("Internal error: could not create path at ".concat(!path && typeof path === "string" ? "<empty string>" : path, " for router validation")) // Should! never happen
3685
- ;
3684
+ throw new Error("Internal error: could not create path at ".concat(!path && typeof path === "string" ? "<empty string>" : path, " for router validation") // Should! never happen
3685
+ );
3686
3686
  }
3687
3687
  return [subPath, [{
3688
3688
  message: validation.error.message,
@@ -3858,6 +3858,19 @@ schema, source) {
3858
3858
  function getSource(valModule) {
3859
3859
  return valModule[GetSource];
3860
3860
  }
3861
+
3862
+ /**
3863
+ * Whether `value` is a Val module, i.e. something {@link define} produced.
3864
+ *
3865
+ * Checks for the three symbols `define` writes, rather than a class identity:
3866
+ * a module may have been created by a different copy of `@valbuild/core` (the
3867
+ * editor SPA and the host bundle each ship their own, and the CLI evaluates
3868
+ * user modules inside a `node:vm` context). The symbols are created with
3869
+ * `Symbol.for`, so they are shared across all of those; a constructor is not.
3870
+ */
3871
+ function isValModule(value) {
3872
+ return _typeof(value) === "object" && value !== null && GetSource in value && GetSchema in value && Path in value;
3873
+ }
3861
3874
  function splitModuleFilePathAndModulePath(path) {
3862
3875
  var pathOfSep = path.indexOf(ModuleFilePathSep);
3863
3876
  if (pathOfSep === -1) {
@@ -8561,6 +8574,7 @@ var Internal = {
8561
8574
  getSchema: getSchema,
8562
8575
  getValPath: getValPath,
8563
8576
  getSource: getSource,
8577
+ isValModule: isValModule,
8564
8578
  resolvePath: resolvePath,
8565
8579
  safeResolvePath: safeResolvePath,
8566
8580
  splitModuleFilePathAndModulePath: splitModuleFilePathAndModulePath,
@@ -3321,8 +3321,8 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
3321
3321
  if (_this2.keySchema) {
3322
3322
  var keyPath = createValPathOfItem(path, key);
3323
3323
  if (!keyPath) {
3324
- throw new Error("Internal error: could not create path at ".concat(!path && typeof path === "string" ? "<empty string>" : path, " for key validation")) // Should! never happen
3325
- ;
3324
+ throw new Error("Internal error: could not create path at ".concat(!path && typeof path === "string" ? "<empty string>" : path, " for key validation") // Should! never happen
3325
+ );
3326
3326
  }
3327
3327
  var keyError = _this2.keySchema["executeValidate"](keyPath, key);
3328
3328
  if (keyError) {
@@ -3683,8 +3683,8 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
3683
3683
  }
3684
3684
  var subPath = createValPathOfItem(path, validation.error.urlPath);
3685
3685
  if (!subPath) {
3686
- throw new Error("Internal error: could not create path at ".concat(!path && typeof path === "string" ? "<empty string>" : path, " for router validation")) // Should! never happen
3687
- ;
3686
+ throw new Error("Internal error: could not create path at ".concat(!path && typeof path === "string" ? "<empty string>" : path, " for router validation") // Should! never happen
3687
+ );
3688
3688
  }
3689
3689
  return [subPath, [{
3690
3690
  message: validation.error.message,
@@ -3860,6 +3860,19 @@ schema, source) {
3860
3860
  function getSource(valModule) {
3861
3861
  return valModule[GetSource];
3862
3862
  }
3863
+
3864
+ /**
3865
+ * Whether `value` is a Val module, i.e. something {@link define} produced.
3866
+ *
3867
+ * Checks for the three symbols `define` writes, rather than a class identity:
3868
+ * a module may have been created by a different copy of `@valbuild/core` (the
3869
+ * editor SPA and the host bundle each ship their own, and the CLI evaluates
3870
+ * user modules inside a `node:vm` context). The symbols are created with
3871
+ * `Symbol.for`, so they are shared across all of those; a constructor is not.
3872
+ */
3873
+ function isValModule(value) {
3874
+ return _typeof(value) === "object" && value !== null && GetSource in value && GetSchema in value && Path in value;
3875
+ }
3863
3876
  function splitModuleFilePathAndModulePath(path) {
3864
3877
  var pathOfSep = path.indexOf(ModuleFilePathSep);
3865
3878
  if (pathOfSep === -1) {
@@ -8563,6 +8576,7 @@ var Internal = {
8563
8576
  getSchema: getSchema,
8564
8577
  getValPath: getValPath,
8565
8578
  getSource: getSource,
8579
+ isValModule: isValModule,
8566
8580
  resolvePath: resolvePath,
8567
8581
  safeResolvePath: safeResolvePath,
8568
8582
  splitModuleFilePathAndModulePath: splitModuleFilePathAndModulePath,
@@ -3321,8 +3321,8 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
3321
3321
  if (_this2.keySchema) {
3322
3322
  var keyPath = createValPathOfItem(path, key);
3323
3323
  if (!keyPath) {
3324
- throw new Error("Internal error: could not create path at ".concat(!path && typeof path === "string" ? "<empty string>" : path, " for key validation")) // Should! never happen
3325
- ;
3324
+ throw new Error("Internal error: could not create path at ".concat(!path && typeof path === "string" ? "<empty string>" : path, " for key validation") // Should! never happen
3325
+ );
3326
3326
  }
3327
3327
  var keyError = _this2.keySchema["executeValidate"](keyPath, key);
3328
3328
  if (keyError) {
@@ -3683,8 +3683,8 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
3683
3683
  }
3684
3684
  var subPath = createValPathOfItem(path, validation.error.urlPath);
3685
3685
  if (!subPath) {
3686
- throw new Error("Internal error: could not create path at ".concat(!path && typeof path === "string" ? "<empty string>" : path, " for router validation")) // Should! never happen
3687
- ;
3686
+ throw new Error("Internal error: could not create path at ".concat(!path && typeof path === "string" ? "<empty string>" : path, " for router validation") // Should! never happen
3687
+ );
3688
3688
  }
3689
3689
  return [subPath, [{
3690
3690
  message: validation.error.message,
@@ -3860,6 +3860,19 @@ schema, source) {
3860
3860
  function getSource(valModule) {
3861
3861
  return valModule[GetSource];
3862
3862
  }
3863
+
3864
+ /**
3865
+ * Whether `value` is a Val module, i.e. something {@link define} produced.
3866
+ *
3867
+ * Checks for the three symbols `define` writes, rather than a class identity:
3868
+ * a module may have been created by a different copy of `@valbuild/core` (the
3869
+ * editor SPA and the host bundle each ship their own, and the CLI evaluates
3870
+ * user modules inside a `node:vm` context). The symbols are created with
3871
+ * `Symbol.for`, so they are shared across all of those; a constructor is not.
3872
+ */
3873
+ function isValModule(value) {
3874
+ return _typeof(value) === "object" && value !== null && GetSource in value && GetSchema in value && Path in value;
3875
+ }
3863
3876
  function splitModuleFilePathAndModulePath(path) {
3864
3877
  var pathOfSep = path.indexOf(ModuleFilePathSep);
3865
3878
  if (pathOfSep === -1) {
@@ -8563,6 +8576,7 @@ var Internal = {
8563
8576
  getSchema: getSchema,
8564
8577
  getValPath: getValPath,
8565
8578
  getSource: getSource,
8579
+ isValModule: isValModule,
8566
8580
  resolvePath: resolvePath,
8567
8581
  safeResolvePath: safeResolvePath,
8568
8582
  splitModuleFilePathAndModulePath: splitModuleFilePathAndModulePath,
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var dist_valbuildCore = require('./index-baa3109b.cjs.dev.js');
5
+ var dist_valbuildCore = require('./index-2cef45cc.cjs.dev.js');
6
6
  require('./result-bb1f436e.cjs.dev.js');
7
7
 
8
8
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var dist_valbuildCore = require('./index-4013c9f8.cjs.prod.js');
5
+ var dist_valbuildCore = require('./index-eaee0a0b.cjs.prod.js');
6
6
  require('./result-787e35f6.cjs.prod.js');
7
7
 
8
8
 
@@ -1,2 +1,2 @@
1
- export { A as ArraySchema, B as BooleanSchema, y as CODE_LANGUAGES, q as COLOR_FORMATS, C as ColorSchema, e as DEFAULT_APP_HOST, r as DEFAULT_COLOR_FORMAT, D as DEFAULT_CONTENT_HOST, j as DEFAULT_VAL_REMOTE_HOST, p as DateSchema, t as DateTimeSchema, F as FATAL_ERROR_TYPES, o as FileSchema, G as GenericSelector, n as ImageSchema, I as Internal, K as KeyOfSchema, L as LiteralSchema, M as ModuleFilePathSep, N as NumberSchema, O as ObjectSchema, R as RecordSchema, v as RichTextSchema, u as RouteSchema, S as Schema, l as StringSchema, U as UnionSchema, V as VAL_EXTENSION, g as computeValModuleShas, k as derefPatch, w as deserializeSchema, f as extractValModules, z as getSourcePathFromRoute, h as hasRemoteFileSchema, i as initVal, m as modules, x as previewScope } from './index-005f51a5.esm.js';
1
+ export { A as ArraySchema, B as BooleanSchema, y as CODE_LANGUAGES, q as COLOR_FORMATS, C as ColorSchema, e as DEFAULT_APP_HOST, r as DEFAULT_COLOR_FORMAT, D as DEFAULT_CONTENT_HOST, j as DEFAULT_VAL_REMOTE_HOST, p as DateSchema, t as DateTimeSchema, F as FATAL_ERROR_TYPES, o as FileSchema, G as GenericSelector, n as ImageSchema, I as Internal, K as KeyOfSchema, L as LiteralSchema, M as ModuleFilePathSep, N as NumberSchema, O as ObjectSchema, R as RecordSchema, v as RichTextSchema, u as RouteSchema, S as Schema, l as StringSchema, U as UnionSchema, V as VAL_EXTENSION, g as computeValModuleShas, k as derefPatch, w as deserializeSchema, f as extractValModules, z as getSourcePathFromRoute, h as hasRemoteFileSchema, i as initVal, m as modules, x as previewScope } from './index-193f19b4.esm.js';
2
2
  import './result-daff1cae.esm.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@valbuild/core",
3
- "version": "0.105.1",
3
+ "version": "0.106.0",
4
4
  "private": false,
5
5
  "description": "Val - supercharged hard-coded content",
6
6
  "repository": {
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var dist_valbuildCore = require('../../dist/index-baa3109b.cjs.dev.js');
5
+ var dist_valbuildCore = require('../../dist/index-2cef45cc.cjs.dev.js');
6
6
  var result = require('../../dist/result-bb1f436e.cjs.dev.js');
7
7
  var util = require('../../dist/util-b213092b.cjs.dev.js');
8
8
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var dist_valbuildCore = require('../../dist/index-4013c9f8.cjs.prod.js');
5
+ var dist_valbuildCore = require('../../dist/index-eaee0a0b.cjs.prod.js');
6
6
  var result = require('../../dist/result-787e35f6.cjs.prod.js');
7
7
  var util = require('../../dist/util-030d8a1f.cjs.prod.js');
8
8
 
@@ -1,5 +1,5 @@
1
- import { _ as _typeof, a as _slicedToArray, P as PatchError, s as splitModuleFilePathAndModulePath, b as _createClass, c as _classCallCheck, d as _toConsumableArray } from '../../dist/index-005f51a5.esm.js';
2
- export { P as PatchError } from '../../dist/index-005f51a5.esm.js';
1
+ import { _ as _typeof, a as _slicedToArray, P as PatchError, s as splitModuleFilePathAndModulePath, b as _createClass, c as _classCallCheck, d as _toConsumableArray } from '../../dist/index-193f19b4.esm.js';
2
+ export { P as PatchError } from '../../dist/index-193f19b4.esm.js';
3
3
  import { f as isNonEmpty, e as err, o as ok, m as map, g as flatMap, i as isErr, h as flatMapReduce, j as filterOrElse, k as mapErr, l as map$1, n as all, p as flatten, q as allT } from '../../dist/result-daff1cae.esm.js';
4
4
  import { p as pipe } from '../../dist/util-18613e99.esm.js';
5
5