@hyperjump/json-schema 0.18.3 → 0.18.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -648,70 +648,7 @@ define(['exports'], (function (exports) { 'use strict';
648
648
  return resolvedUrl;
649
649
  };
650
650
 
651
- const CHAR_BACKWARD_SLASH = 47;
652
-
653
- const pathRelative$1 = (from, to) => {
654
- if (from === to) {
655
- return "";
656
- }
657
-
658
- let toStart = 1;
659
- const fromLen = from.length - 1;
660
- const toLen = to.length - toStart;
661
-
662
- // Compare paths to find the longest common path from root
663
- const length = fromLen < toLen ? fromLen : toLen;
664
- let lastCommonSep = -1;
665
- let i = 0;
666
- for (; i < length; i++) {
667
- const fromCode = from.charCodeAt(i + 1);
668
- if (fromCode !== to.charCodeAt(toStart + i)) {
669
- break;
670
- } else if (fromCode === CHAR_BACKWARD_SLASH) {
671
- lastCommonSep = i;
672
- }
673
- }
674
-
675
- if (toLen > length) {
676
- if (to.charCodeAt(toStart + i) === CHAR_BACKWARD_SLASH) {
677
- return to.slice(toStart + i + 1);
678
- }
679
- if (i === 0) {
680
- return to.slice(toStart + i);
681
- }
682
- }
683
- if (fromLen > length) {
684
- if (from.charCodeAt(i + 1) === CHAR_BACKWARD_SLASH) {
685
- lastCommonSep = i;
686
- } else if (length === 0) {
687
- lastCommonSep = 0;
688
- }
689
- }
690
-
691
- let out = "";
692
- // Generate the relative path based on the path difference between `to` and `from`
693
- for (i = lastCommonSep + 2; i <= from.length; ++i) {
694
- if (i === from.length || from.charCodeAt(i) === CHAR_BACKWARD_SLASH) {
695
- out += out.length === 0 ? ".." : "/..";
696
- }
697
- }
698
-
699
- toStart += lastCommonSep;
700
-
701
- // Lastly, append the rest of the destination (`to`) path that comes after
702
- // the common path parts
703
- if (out.length > 0) {
704
- return `${out}${to.slice(toStart, to.length)}`;
705
- }
706
-
707
- if (to.charCodeAt(toStart) === CHAR_BACKWARD_SLASH) {
708
- ++toStart;
709
- }
710
-
711
- return to.slice(toStart, to.length);
712
- };
713
-
714
- var common$1 = { jsonTypeOf: jsonTypeOf$2, splitUrl: splitUrl$4, safeResolveUrl: safeResolveUrl$1, pathRelative: pathRelative$1 };
651
+ var common$1 = { jsonTypeOf: jsonTypeOf$2, splitUrl: splitUrl$4, safeResolveUrl: safeResolveUrl$1 };
715
652
 
716
653
  const nil$2 = "";
717
654
 
@@ -1217,7 +1154,7 @@ define(['exports'], (function (exports) { 'use strict';
1217
1154
 
1218
1155
  var fetch_browser = fetch;
1219
1156
 
1220
- const { jsonTypeOf, splitUrl: splitUrl$3, safeResolveUrl, pathRelative } = common$1;
1157
+ const { jsonTypeOf, splitUrl: splitUrl$3, safeResolveUrl } = common$1;
1221
1158
 
1222
1159
 
1223
1160
 
@@ -1447,73 +1384,10 @@ define(['exports'], (function (exports) { 'use strict';
1447
1384
 
1448
1385
  const length = (doc) => value(doc).length;
1449
1386
 
1450
- const toSchemaDefaultOptions = {
1451
- parentId: "",
1452
- parentDialect: "",
1453
- includeEmbedded: true
1454
- };
1455
- const toSchema = (schemaDoc, options = {}) => {
1456
- const fullOptions = { ...toSchemaDefaultOptions, ...options };
1457
-
1458
- const schema = JSON.parse(JSON.stringify(schemaDoc.schema, (key, value) => {
1459
- if (!reference.isReference(value)) {
1460
- return value;
1461
- }
1462
-
1463
- const refValue = reference.value(value);
1464
- const embeddedDialect = refValue.$schema || schemaDoc.schemaVersion;
1465
- const embeddedToken = getConfig(embeddedDialect, "embeddedToken");
1466
- if (!fullOptions.includeEmbedded && embeddedToken in refValue) {
1467
- return;
1468
- } else {
1469
- return reference.value(value);
1470
- }
1471
- }));
1472
-
1473
- const dynamicAnchorToken = getConfig(schemaDoc.schemaVersion, "dynamicAnchorToken");
1474
- Object.entries(schemaDoc.dynamicAnchors)
1475
- .forEach(([anchor, uri]) => {
1476
- const pointer = splitUrl$3(uri)[1];
1477
- lib$3.assign(pointer, schema, {
1478
- [dynamicAnchorToken]: anchor,
1479
- ...lib$3.get(pointer, schema)
1480
- });
1481
- });
1482
-
1483
- const anchorToken = getConfig(schemaDoc.schemaVersion, "anchorToken");
1484
- Object.entries(schemaDoc.anchors)
1485
- .filter(([anchor]) => anchor !== "")
1486
- .forEach(([anchor, pointer]) => {
1487
- lib$3.assign(pointer, schema, {
1488
- [anchorToken]: anchor,
1489
- ...lib$3.get(pointer, schema)
1490
- });
1491
- });
1492
-
1493
- const baseToken = getConfig(schemaDoc.schemaVersion, "baseToken");
1494
- const id = relativeUri(fullOptions.parentId, schemaDoc.id);
1495
- const dialect = fullOptions.parentDialect === schemaDoc.schemaVersion ? "" : schemaDoc.schemaVersion;
1496
- return {
1497
- ...(id && { [baseToken]: id }),
1498
- ...(dialect && { $schema: dialect }),
1499
- ...schema
1500
- };
1501
- };
1502
-
1503
- const relativeUri = (from, to) => {
1504
- if (to.startsWith("file://")) {
1505
- const pathToSchema = from.slice(7, from.lastIndexOf("/"));
1506
- return from === "" ? "" : pathRelative(pathToSchema, to.slice(7));
1507
- } else {
1508
- return to;
1509
- }
1510
- };
1511
-
1512
1387
  var schema$5 = {
1513
1388
  setConfig, getConfig,
1514
1389
  add: add$1, get, markValidated,
1515
- uri, value, getAnchorPointer, typeOf, has, step, keys, entries, map, length,
1516
- toSchema
1390
+ uri, value, getAnchorPointer, typeOf, has, step, keys, entries, map, length
1517
1391
  };
1518
1392
  schema$5.setConfig;
1519
1393
  schema$5.getConfig;
@@ -1530,7 +1404,6 @@ define(['exports'], (function (exports) { 'use strict';
1530
1404
  schema$5.entries;
1531
1405
  schema$5.map;
1532
1406
  schema$5.length;
1533
- schema$5.toSchema;
1534
1407
 
1535
1408
  class InvalidSchemaError$1 extends Error {
1536
1409
  constructor(output) {