@speclynx/apidom-parser-adapter-json 2.13.1 → 3.0.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.
@@ -76,8 +76,9 @@ const parse = async source => {
76
76
  if (source.trim().length === 0) {
77
77
  return parseResult;
78
78
  }
79
- const pojo = JSON.parse(source);
79
+ let pojo = JSON.parse(source);
80
80
  const element = (0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_0__.refract)(pojo);
81
+ pojo = null; // allow GC to reclaim POJO
81
82
  element.classes.push('result');
82
83
  parseResult.push(element);
83
84
  return parseResult;
@@ -522,6 +523,53 @@ const analyze = (cst, {
522
523
 
523
524
  /***/ },
524
525
 
526
+ /***/ 8138
527
+ (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
528
+
529
+ "use strict";
530
+ __webpack_require__.r(__webpack_exports__);
531
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
532
+ /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
533
+ /* harmony export */ });
534
+ /* harmony import */ var _internal_clone_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(8575);
535
+ /* harmony import */ var _internal_curry1_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(8938);
536
+
537
+
538
+
539
+ /**
540
+ * Creates a deep copy of the source that can be used in place of the source
541
+ * object without retaining any references to it.
542
+ * The source object may contain (nested) `Array`s and `Object`s,
543
+ * `Number`s, `String`s, `Boolean`s and `Date`s.
544
+ * `Function`s are assigned by reference rather than copied.
545
+ *
546
+ * Dispatches to a `clone` method if present.
547
+ *
548
+ * Note that if the source object has multiple nodes that share a reference,
549
+ * the returned object will have the same structure, but the references will
550
+ * be pointed to the location within the cloned value.
551
+ *
552
+ * @func
553
+ * @memberOf R
554
+ * @since v0.1.0
555
+ * @category Object
556
+ * @sig {*} -> {*}
557
+ * @param {*} value The object or array to clone
558
+ * @return {*} A deeply cloned copy of `val`
559
+ * @example
560
+ *
561
+ * const objects = [{}, {}, {}];
562
+ * const objectsClone = R.clone(objects);
563
+ * objects === objectsClone; //=> false
564
+ * objects[0] === objectsClone[0]; //=> false
565
+ */
566
+ var clone = /*#__PURE__*/(0,_internal_curry1_js__WEBPACK_IMPORTED_MODULE_1__["default"])(function clone(value) {
567
+ return value != null && typeof value.clone === 'function' ? value.clone() : (0,_internal_clone_js__WEBPACK_IMPORTED_MODULE_0__["default"])(value, true);
568
+ });
569
+ /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (clone);
570
+
571
+ /***/ },
572
+
525
573
  /***/ 3654
526
574
  (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
527
575
 
@@ -586,6 +634,146 @@ function _arrayFromIterator(iter) {
586
634
 
587
635
  /***/ },
588
636
 
637
+ /***/ 8575
638
+ (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
639
+
640
+ "use strict";
641
+ __webpack_require__.r(__webpack_exports__);
642
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
643
+ /* harmony export */ "default": () => (/* binding */ _clone)
644
+ /* harmony export */ });
645
+ /* harmony import */ var _cloneRegExp_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1254);
646
+ /* harmony import */ var _type_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(963);
647
+
648
+
649
+
650
+ /**
651
+ * Copies an object.
652
+ *
653
+ * @private
654
+ * @param {*} value The value to be copied
655
+ * @param {Boolean} deep Whether or not to perform deep cloning.
656
+ * @return {*} The copied value.
657
+ */
658
+ function _clone(value, deep, map) {
659
+ map || (map = new _ObjectMap());
660
+
661
+ // this avoids the slower switch with a quick if decision removing some milliseconds in each run.
662
+ if (_isPrimitive(value)) {
663
+ return value;
664
+ }
665
+ var copy = function copy(copiedValue) {
666
+ // Check for circular and same references on the object graph and return its corresponding clone.
667
+ var cachedCopy = map.get(value);
668
+ if (cachedCopy) {
669
+ return cachedCopy;
670
+ }
671
+ map.set(value, copiedValue);
672
+ for (var key in value) {
673
+ if (Object.prototype.hasOwnProperty.call(value, key)) {
674
+ copiedValue[key] = deep ? _clone(value[key], true, map) : value[key];
675
+ }
676
+ }
677
+ return copiedValue;
678
+ };
679
+ switch ((0,_type_js__WEBPACK_IMPORTED_MODULE_1__["default"])(value)) {
680
+ case 'Object':
681
+ return copy(Object.create(Object.getPrototypeOf(value)));
682
+ case 'Array':
683
+ return copy(Array(value.length));
684
+ case 'Date':
685
+ return new Date(value.valueOf());
686
+ case 'RegExp':
687
+ return (0,_cloneRegExp_js__WEBPACK_IMPORTED_MODULE_0__["default"])(value);
688
+ case 'Int8Array':
689
+ case 'Uint8Array':
690
+ case 'Uint8ClampedArray':
691
+ case 'Int16Array':
692
+ case 'Uint16Array':
693
+ case 'Int32Array':
694
+ case 'Uint32Array':
695
+ case 'Float32Array':
696
+ case 'Float64Array':
697
+ case 'BigInt64Array':
698
+ case 'BigUint64Array':
699
+ return value.slice();
700
+ default:
701
+ return value;
702
+ }
703
+ }
704
+ function _isPrimitive(param) {
705
+ var type = typeof param;
706
+ return param == null || type != 'object' && type != 'function';
707
+ }
708
+ var _ObjectMap = /*#__PURE__*/function () {
709
+ function _ObjectMap() {
710
+ this.map = {};
711
+ this.length = 0;
712
+ }
713
+ _ObjectMap.prototype.set = function (key, value) {
714
+ var hashedKey = this.hash(key);
715
+ var bucket = this.map[hashedKey];
716
+ if (!bucket) {
717
+ this.map[hashedKey] = bucket = [];
718
+ }
719
+ bucket.push([key, value]);
720
+ this.length += 1;
721
+ };
722
+ _ObjectMap.prototype.hash = function (key) {
723
+ var hashedKey = [];
724
+ for (var value in key) {
725
+ hashedKey.push(Object.prototype.toString.call(key[value]));
726
+ }
727
+ return hashedKey.join();
728
+ };
729
+ _ObjectMap.prototype.get = function (key) {
730
+ /**
731
+ * depending on the number of objects to be cloned is faster to just iterate over the items in the map just because the hash function is so costly,
732
+ * on my tests this number is 180, anything above that using the hash function is faster.
733
+ */
734
+ if (this.length <= 180) {
735
+ for (var p in this.map) {
736
+ var bucket = this.map[p];
737
+ for (var i = 0; i < bucket.length; i += 1) {
738
+ var element = bucket[i];
739
+ if (element[0] === key) {
740
+ return element[1];
741
+ }
742
+ }
743
+ }
744
+ return;
745
+ }
746
+ var hashedKey = this.hash(key);
747
+ var bucket = this.map[hashedKey];
748
+ if (!bucket) {
749
+ return;
750
+ }
751
+ for (var i = 0; i < bucket.length; i += 1) {
752
+ var element = bucket[i];
753
+ if (element[0] === key) {
754
+ return element[1];
755
+ }
756
+ }
757
+ };
758
+ return _ObjectMap;
759
+ }();
760
+
761
+ /***/ },
762
+
763
+ /***/ 1254
764
+ (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
765
+
766
+ "use strict";
767
+ __webpack_require__.r(__webpack_exports__);
768
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
769
+ /* harmony export */ "default": () => (/* binding */ _cloneRegExp)
770
+ /* harmony export */ });
771
+ function _cloneRegExp(pattern) {
772
+ return new RegExp(pattern.source, pattern.flags ? pattern.flags : (pattern.global ? 'g' : '') + (pattern.ignoreCase ? 'i' : '') + (pattern.multiline ? 'm' : '') + (pattern.sticky ? 'y' : '') + (pattern.unicode ? 'u' : '') + (pattern.dotAll ? 's' : ''));
773
+ }
774
+
775
+ /***/ },
776
+
589
777
  /***/ 8938
590
778
  (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
591
779
 
@@ -5137,6 +5325,105 @@ class KeyValuePair {
5137
5325
 
5138
5326
  /***/ },
5139
5327
 
5328
+ /***/ 1844
5329
+ (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
5330
+
5331
+ "use strict";
5332
+ __webpack_require__.r(__webpack_exports__);
5333
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
5334
+ /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
5335
+ /* harmony export */ });
5336
+ /* harmony import */ var ramda__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(8138);
5337
+
5338
+ /**
5339
+ * Lightweight meta container for Element metadata.
5340
+ *
5341
+ * Data is stored as own properties on the instance; methods live on the prototype.
5342
+ * `Object.keys()`, `Object.entries()`, etc. only see data properties.
5343
+ *
5344
+ * @public
5345
+ */
5346
+ class Metadata {
5347
+ // Set via prototype assignment in registration.ts to avoid circular dependency
5348
+
5349
+ get(name) {
5350
+ return this[name];
5351
+ }
5352
+ set(name, value) {
5353
+ this[name] = value;
5354
+ }
5355
+ hasKey(name) {
5356
+ return Object.hasOwn(this, name);
5357
+ }
5358
+ keys() {
5359
+ return Object.keys(this);
5360
+ }
5361
+ remove(name) {
5362
+ delete this[name];
5363
+ }
5364
+ get isEmpty() {
5365
+ return Object.keys(this).length === 0;
5366
+ }
5367
+ get isFrozen() {
5368
+ return Object.isFrozen(this);
5369
+ }
5370
+ freeze() {
5371
+ for (const value of Object.values(this)) {
5372
+ if (value instanceof this.Element) {
5373
+ value.freeze();
5374
+ } else if (Array.isArray(value) || value !== null && typeof value === 'object') {
5375
+ Object.freeze(value);
5376
+ }
5377
+ }
5378
+ Object.freeze(this);
5379
+ }
5380
+
5381
+ /**
5382
+ * Creates a shallow clone. Same references, new container.
5383
+ */
5384
+ cloneShallow() {
5385
+ const clone = new Metadata();
5386
+ Object.assign(clone, this);
5387
+ return clone;
5388
+ }
5389
+
5390
+ /**
5391
+ * Merges another Metadata into a new instance.
5392
+ * Arrays are concatenated, all other values are overwritten by source.
5393
+ */
5394
+ merge(source) {
5395
+ const result = this.cloneShallow();
5396
+ for (const [key, value] of Object.entries(source)) {
5397
+ const existing = result.get(key);
5398
+ if (Array.isArray(existing) && Array.isArray(value)) {
5399
+ result.set(key, [...existing, ...value]);
5400
+ } else {
5401
+ result.set(key, value);
5402
+ }
5403
+ }
5404
+ return result;
5405
+ }
5406
+
5407
+ /**
5408
+ * Creates a deep clone. Elements are deep cloned,
5409
+ * all other values are deep cloned via ramda clone.
5410
+ */
5411
+ cloneDeep() {
5412
+ const copy = new Metadata();
5413
+ for (const [key, value] of Object.entries(this)) {
5414
+ if (value instanceof this.Element) {
5415
+ copy.set(key, this.cloneDeepElement(value));
5416
+ } else {
5417
+ copy.set(key, (0,ramda__WEBPACK_IMPORTED_MODULE_0__["default"])(value));
5418
+ }
5419
+ }
5420
+ return copy;
5421
+ }
5422
+ }
5423
+ /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Metadata);
5424
+
5425
+ /***/ },
5426
+
5140
5427
  /***/ 5156
5141
5428
  (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
5142
5429
 
@@ -5571,6 +5858,275 @@ class ObjectSlice {
5571
5858
  }
5572
5859
  /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (ObjectSlice);
5573
5860
 
5861
+ /***/ },
5862
+
5863
+ /***/ 3772
5864
+ (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
5865
+
5866
+ "use strict";
5867
+ __webpack_require__.r(__webpack_exports__);
5868
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
5869
+ /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
5870
+ /* harmony export */ });
5871
+ /* harmony import */ var _speclynx_apidom_error__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(4641);
5872
+
5873
+
5874
+ /**
5875
+ * @public
5876
+ */
5877
+
5878
+ /**
5879
+ * @public
5880
+ */
5881
+ class CloneError extends _speclynx_apidom_error__WEBPACK_IMPORTED_MODULE_0__["default"] {
5882
+ value;
5883
+ constructor(message, structuredOptions) {
5884
+ super(message, structuredOptions);
5885
+ if (typeof structuredOptions !== 'undefined') {
5886
+ this.value = structuredOptions.value;
5887
+ }
5888
+ }
5889
+ }
5890
+ /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (CloneError);
5891
+
5892
+ /***/ },
5893
+
5894
+ /***/ 5018
5895
+ (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
5896
+
5897
+ "use strict";
5898
+ __webpack_require__.r(__webpack_exports__);
5899
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
5900
+ /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
5901
+ /* harmony export */ });
5902
+ /* harmony import */ var _CloneError_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(3772);
5903
+
5904
+ /**
5905
+ * @public
5906
+ */
5907
+ class DeepCloneError extends _CloneError_mjs__WEBPACK_IMPORTED_MODULE_0__["default"] {}
5908
+ /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (DeepCloneError);
5909
+
5910
+ /***/ },
5911
+
5912
+ /***/ 3686
5913
+ (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
5914
+
5915
+ "use strict";
5916
+ __webpack_require__.r(__webpack_exports__);
5917
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
5918
+ /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
5919
+ /* harmony export */ });
5920
+ /* harmony import */ var _CloneError_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(3772);
5921
+
5922
+ /**
5923
+ * @public
5924
+ */
5925
+ class ShallowCloneError extends _CloneError_mjs__WEBPACK_IMPORTED_MODULE_0__["default"] {}
5926
+ /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (ShallowCloneError);
5927
+
5928
+ /***/ },
5929
+
5930
+ /***/ 2111
5931
+ (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
5932
+
5933
+ "use strict";
5934
+ __webpack_require__.r(__webpack_exports__);
5935
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
5936
+ /* harmony export */ CloneError: () => (/* reexport safe */ _errors_CloneError_mjs__WEBPACK_IMPORTED_MODULE_8__["default"]),
5937
+ /* harmony export */ DeepCloneError: () => (/* reexport safe */ _errors_DeepCloneError_mjs__WEBPACK_IMPORTED_MODULE_6__["default"]),
5938
+ /* harmony export */ ShallowCloneError: () => (/* reexport safe */ _errors_ShallowCloneError_mjs__WEBPACK_IMPORTED_MODULE_7__["default"]),
5939
+ /* harmony export */ cloneDeep: () => (/* binding */ cloneDeep),
5940
+ /* harmony export */ cloneShallow: () => (/* binding */ cloneShallow)
5941
+ /* harmony export */ });
5942
+ /* harmony import */ var ramda__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(8138);
5943
+ /* harmony import */ var _ObjectSlice_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(8504);
5944
+ /* harmony import */ var _KeyValuePair_mjs__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(6663);
5945
+ /* harmony import */ var _predicates_index_mjs__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(8252);
5946
+ /* harmony import */ var _predicates_index_mjs__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(5162);
5947
+ /* harmony import */ var _elements_SourceMap_mjs__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(5810);
5948
+ /* harmony import */ var _errors_DeepCloneError_mjs__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(5018);
5949
+ /* harmony import */ var _errors_ShallowCloneError_mjs__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(3686);
5950
+ /* harmony import */ var _errors_CloneError_mjs__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(3772);
5951
+
5952
+
5953
+
5954
+
5955
+
5956
+
5957
+
5958
+ /**
5959
+ * @public
5960
+ */
5961
+ /**
5962
+ * @public
5963
+ */
5964
+ const cloneDeepElement = (element, options) => {
5965
+ const {
5966
+ visited = new WeakMap()
5967
+ } = options;
5968
+ const passThroughOptions = {
5969
+ ...options,
5970
+ visited
5971
+ };
5972
+
5973
+ // detect cycle and return memoized value
5974
+ if (visited.has(element)) {
5975
+ return visited.get(element);
5976
+ }
5977
+ const copy = cloneShallowElement(element);
5978
+ visited.set(element, copy);
5979
+ const {
5980
+ content
5981
+ } = element;
5982
+ if (Array.isArray(content)) {
5983
+ copy.content = content.map(el => cloneDeepElement(el, passThroughOptions));
5984
+ } else if ((0,_predicates_index_mjs__WEBPACK_IMPORTED_MODULE_4__.isElement)(content)) {
5985
+ copy.content = cloneDeepElement(content, passThroughOptions);
5986
+ } else if (content instanceof _KeyValuePair_mjs__WEBPACK_IMPORTED_MODULE_2__["default"]) {
5987
+ copy.content = cloneDeepKeyValuePair(content, passThroughOptions);
5988
+ } else {
5989
+ copy.content = content;
5990
+ }
5991
+ return copy;
5992
+ };
5993
+ const cloneDeepKeyValuePair = (kvp, options) => {
5994
+ const {
5995
+ visited = new WeakMap()
5996
+ } = options;
5997
+ const passThroughOptions = {
5998
+ ...options,
5999
+ visited
6000
+ };
6001
+ if (visited.has(kvp)) {
6002
+ return visited.get(kvp);
6003
+ }
6004
+ const {
6005
+ key,
6006
+ value
6007
+ } = kvp;
6008
+ const keyCopy = key !== undefined ? cloneDeepElement(key, passThroughOptions) : undefined;
6009
+ const valueCopy = value !== undefined ? cloneDeepElement(value, passThroughOptions) : undefined;
6010
+ const copy = new _KeyValuePair_mjs__WEBPACK_IMPORTED_MODULE_2__["default"](keyCopy, valueCopy);
6011
+ visited.set(kvp, copy);
6012
+ return copy;
6013
+ };
6014
+ const cloneDeepObjectSlice = (slice, options) => {
6015
+ const {
6016
+ visited = new WeakMap()
6017
+ } = options;
6018
+ const passThroughOptions = {
6019
+ ...options,
6020
+ visited
6021
+ };
6022
+ if (visited.has(slice)) {
6023
+ return visited.get(slice);
6024
+ }
6025
+ const items = [...slice].map(element => cloneDeepElement(element, passThroughOptions));
6026
+ const copy = new _ObjectSlice_mjs__WEBPACK_IMPORTED_MODULE_1__["default"](items);
6027
+ visited.set(slice, copy);
6028
+ return copy;
6029
+ };
6030
+
6031
+ /**
6032
+ * Creates a deep clone of an ApiDOM Element, KeyValuePair, or ObjectSlice.
6033
+ * Handles cycles by memoizing visited objects.
6034
+ * @public
6035
+ */
6036
+ const cloneDeep = (value, options = {}) => {
6037
+ if (value instanceof _KeyValuePair_mjs__WEBPACK_IMPORTED_MODULE_2__["default"]) {
6038
+ return cloneDeepKeyValuePair(value, options);
6039
+ }
6040
+ if (value instanceof _ObjectSlice_mjs__WEBPACK_IMPORTED_MODULE_1__["default"]) {
6041
+ return cloneDeepObjectSlice(value, options);
6042
+ }
6043
+ if ((0,_predicates_index_mjs__WEBPACK_IMPORTED_MODULE_4__.isElement)(value)) {
6044
+ return cloneDeepElement(value, options);
6045
+ }
6046
+ throw new _errors_DeepCloneError_mjs__WEBPACK_IMPORTED_MODULE_6__["default"]("Value provided to cloneDeep function couldn't be cloned", {
6047
+ value
6048
+ });
6049
+ };
6050
+ cloneDeep.safe = value => {
6051
+ try {
6052
+ return cloneDeep(value);
6053
+ } catch {
6054
+ return value;
6055
+ }
6056
+ };
6057
+ const cloneShallowKeyValuePair = keyValuePair => {
6058
+ const {
6059
+ key,
6060
+ value
6061
+ } = keyValuePair;
6062
+ return new _KeyValuePair_mjs__WEBPACK_IMPORTED_MODULE_2__["default"](key, value);
6063
+ };
6064
+ const cloneShallowObjectSlice = objectSlice => {
6065
+ const items = [...objectSlice];
6066
+ return new _ObjectSlice_mjs__WEBPACK_IMPORTED_MODULE_1__["default"](items);
6067
+ };
6068
+ const cloneShallowElement = element => {
6069
+ const Ctor = element.constructor;
6070
+ const copy = new Ctor();
6071
+ copy.element = element.element;
6072
+ if (!element.isMetaEmpty) {
6073
+ copy.meta = element.meta.cloneDeep();
6074
+ }
6075
+ if (!element.isAttributesEmpty) {
6076
+ copy.attributes = cloneDeep(element.attributes);
6077
+ }
6078
+ if ((0,_predicates_index_mjs__WEBPACK_IMPORTED_MODULE_3__.hasElementSourceMap)(element)) {
6079
+ _elements_SourceMap_mjs__WEBPACK_IMPORTED_MODULE_5__["default"].transfer(element, copy);
6080
+ }
6081
+ if ((0,_predicates_index_mjs__WEBPACK_IMPORTED_MODULE_3__.hasElementStyle)(element)) {
6082
+ copy.style = (0,ramda__WEBPACK_IMPORTED_MODULE_0__["default"])(element.style);
6083
+ }
6084
+ const {
6085
+ content
6086
+ } = element;
6087
+ if ((0,_predicates_index_mjs__WEBPACK_IMPORTED_MODULE_4__.isElement)(content)) {
6088
+ copy.content = cloneShallowElement(content);
6089
+ } else if (Array.isArray(content)) {
6090
+ copy.content = [...content];
6091
+ } else if (content instanceof _KeyValuePair_mjs__WEBPACK_IMPORTED_MODULE_2__["default"]) {
6092
+ copy.content = cloneShallowKeyValuePair(content);
6093
+ } else {
6094
+ copy.content = content;
6095
+ }
6096
+ return copy;
6097
+ };
6098
+
6099
+ /**
6100
+ * Creates a shallow clone of an ApiDOM Element, KeyValuePair, or ObjectSlice.
6101
+ * The element itself is cloned, but content references are shared.
6102
+ * Meta and attributes are deep cloned to preserve semantic information.
6103
+ * @public
6104
+ */
6105
+ const cloneShallow = value => {
6106
+ if (value instanceof _KeyValuePair_mjs__WEBPACK_IMPORTED_MODULE_2__["default"]) {
6107
+ return cloneShallowKeyValuePair(value);
6108
+ }
6109
+ if (value instanceof _ObjectSlice_mjs__WEBPACK_IMPORTED_MODULE_1__["default"]) {
6110
+ return cloneShallowObjectSlice(value);
6111
+ }
6112
+ if ((0,_predicates_index_mjs__WEBPACK_IMPORTED_MODULE_4__.isElement)(value)) {
6113
+ return cloneShallowElement(value);
6114
+ }
6115
+ throw new _errors_ShallowCloneError_mjs__WEBPACK_IMPORTED_MODULE_7__["default"]("Value provided to cloneShallow function couldn't be cloned", {
6116
+ value
6117
+ });
6118
+ };
6119
+ cloneShallow.safe = value => {
6120
+ try {
6121
+ return cloneShallow(value);
6122
+ } catch {
6123
+ return value;
6124
+ }
6125
+ };
6126
+
6127
+
6128
+
6129
+
5574
6130
  /***/ },
5575
6131
 
5576
6132
  /***/ 4660
@@ -6618,7 +7174,7 @@ class CollectionElement extends _Element_mjs__WEBPACK_IMPORTED_MODULE_0__["defau
6618
7174
  * Search the tree recursively and find the element with the matching ID.
6619
7175
  */
6620
7176
  getById(id) {
6621
- return this.find(item => item.id.toValue() === id).first;
7177
+ return this.find(item => item.id === id).first;
6622
7178
  }
6623
7179
 
6624
7180
  /**
@@ -6648,18 +7204,24 @@ class CollectionElement extends _Element_mjs__WEBPACK_IMPORTED_MODULE_0__["defau
6648
7204
  "use strict";
6649
7205
  __webpack_require__.r(__webpack_exports__);
6650
7206
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
7207
+ /* harmony export */ Metadata: () => (/* reexport safe */ _Metadata_mjs__WEBPACK_IMPORTED_MODULE_1__["default"]),
6651
7208
  /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
6652
7209
  /* harmony export */ });
6653
7210
  /* harmony import */ var ramda__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(3654);
6654
- /* harmony import */ var _KeyValuePair_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(6663);
6655
- /* harmony import */ var _ObjectSlice_mjs__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(8504);
7211
+ /* harmony import */ var _Metadata_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1844);
7212
+ /* harmony import */ var _KeyValuePair_mjs__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(6663);
7213
+ /* harmony import */ var _ObjectSlice_mjs__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(8504);
6656
7214
 
6657
7215
 
6658
7216
 
7217
+ // shared singleton for frozen elements with no meta — avoids allocation on every access
7218
+ const FROZEN_EMPTY_METADATA = Object.freeze(new _Metadata_mjs__WEBPACK_IMPORTED_MODULE_1__["default"]());
7219
+
6659
7220
  /**
6660
7221
  * Valid content types for an Element.
6661
7222
  * @public
6662
7223
  */
7224
+
6663
7225
  /**
6664
7226
  * Base Element class that all ApiDOM elements extend.
6665
7227
  *
@@ -6757,7 +7319,7 @@ class Element {
6757
7319
  _attributes;
6758
7320
 
6759
7321
  // ============================================================
6760
- // Prototype-assigned properties (set in elements.ts)
7322
+ // Prototype-assigned properties (set in registration.ts)
6761
7323
  // Using 'declare' allows TypeScript to know about these
6762
7324
  // without generating runtime code.
6763
7325
  // ============================================================
@@ -6818,13 +7380,13 @@ class Element {
6818
7380
  }
6819
7381
 
6820
7382
  // KeyValuePair
6821
- if (value instanceof _KeyValuePair_mjs__WEBPACK_IMPORTED_MODULE_1__["default"]) {
7383
+ if (value instanceof _KeyValuePair_mjs__WEBPACK_IMPORTED_MODULE_2__["default"]) {
6822
7384
  this._content = value;
6823
7385
  return;
6824
7386
  }
6825
7387
 
6826
7388
  // ObjectSlice - extract elements array
6827
- if (value instanceof _ObjectSlice_mjs__WEBPACK_IMPORTED_MODULE_2__["default"]) {
7389
+ if (value instanceof _ObjectSlice_mjs__WEBPACK_IMPORTED_MODULE_3__["default"]) {
6828
7390
  this._content = value.elements;
6829
7391
  return;
6830
7392
  }
@@ -6845,24 +7407,22 @@ class Element {
6845
7407
 
6846
7408
  /**
6847
7409
  * Metadata about this element (id, classes, title, description, links).
6848
- * Lazily creates an ObjectElement if not set.
7410
+ * Lazily creates a Metadata instance if not set.
6849
7411
  */
6850
7412
  get meta() {
6851
7413
  if (!this._meta) {
6852
- if (this.isFrozen) {
6853
- const meta = new this.ObjectElement();
6854
- meta.freeze();
6855
- return meta;
6856
- }
6857
- this._meta = new this.ObjectElement();
7414
+ if (this.isFrozen) return FROZEN_EMPTY_METADATA;
7415
+ this._meta = new _Metadata_mjs__WEBPACK_IMPORTED_MODULE_1__["default"]();
6858
7416
  }
6859
7417
  return this._meta;
6860
7418
  }
6861
7419
  set meta(value) {
6862
- if (value instanceof Element) {
7420
+ if (value instanceof _Metadata_mjs__WEBPACK_IMPORTED_MODULE_1__["default"]) {
6863
7421
  this._meta = value;
6864
- } else {
6865
- this.meta.set(value ?? {});
7422
+ } else if (value && typeof value === 'object') {
7423
+ const meta = new _Metadata_mjs__WEBPACK_IMPORTED_MODULE_1__["default"]();
7424
+ Object.assign(meta, value);
7425
+ this._meta = meta;
6866
7426
  }
6867
7427
  }
6868
7428
 
@@ -6895,10 +7455,8 @@ class Element {
6895
7455
 
6896
7456
  /** Unique identifier for this element. */
6897
7457
  get id() {
6898
- if (this.isFrozen) {
6899
- return this.getMetaProperty('id', '');
6900
- }
6901
7458
  if (!this.hasMetaProperty('id')) {
7459
+ if (this.isFrozen) return '';
6902
7460
  this.setMetaProperty('id', '');
6903
7461
  }
6904
7462
  return this.meta.get('id');
@@ -6909,10 +7467,8 @@ class Element {
6909
7467
 
6910
7468
  /** CSS-like class names. */
6911
7469
  get classes() {
6912
- if (this.isFrozen) {
6913
- return this.getMetaProperty('classes', []);
6914
- }
6915
7470
  if (!this.hasMetaProperty('classes')) {
7471
+ if (this.isFrozen) return [];
6916
7472
  this.setMetaProperty('classes', []);
6917
7473
  }
6918
7474
  return this.meta.get('classes');
@@ -6923,11 +7479,13 @@ class Element {
6923
7479
 
6924
7480
  /** Hyperlinks associated with this element. */
6925
7481
  get links() {
6926
- if (this.isFrozen) {
6927
- return this.getMetaProperty('links', []);
6928
- }
6929
7482
  if (!this.hasMetaProperty('links')) {
6930
- this.setMetaProperty('links', []);
7483
+ if (this.isFrozen) {
7484
+ const empty = new this.ArrayElement();
7485
+ empty.freeze();
7486
+ return empty;
7487
+ }
7488
+ this.setMetaProperty('links', new this.ArrayElement());
6931
7489
  }
6932
7490
  return this.meta.get('links');
6933
7491
  }
@@ -6947,7 +7505,7 @@ class Element {
6947
7505
  if (Array.isArray(content)) {
6948
7506
  return content;
6949
7507
  }
6950
- if (content instanceof _KeyValuePair_mjs__WEBPACK_IMPORTED_MODULE_1__["default"]) {
7508
+ if (content instanceof _KeyValuePair_mjs__WEBPACK_IMPORTED_MODULE_2__["default"]) {
6951
7509
  const children = [];
6952
7510
  if (content.key) children.push(content.key);
6953
7511
  if (content.value) children.push(content.value);
@@ -6977,7 +7535,6 @@ class Element {
6977
7535
 
6978
7536
  // Freeze meta and attributes
6979
7537
  if (this._meta) {
6980
- this._meta.parent = this;
6981
7538
  this._meta.freeze();
6982
7539
  }
6983
7540
  if (this._attributes) {
@@ -7012,7 +7569,7 @@ class Element {
7012
7569
  if (_content instanceof Element) {
7013
7570
  return _content.toValue();
7014
7571
  }
7015
- if (_content instanceof _KeyValuePair_mjs__WEBPACK_IMPORTED_MODULE_1__["default"]) {
7572
+ if (_content instanceof _KeyValuePair_mjs__WEBPACK_IMPORTED_MODULE_2__["default"]) {
7016
7573
  return _content.toValue();
7017
7574
  }
7018
7575
  if (Array.isArray(_content)) {
@@ -7068,7 +7625,7 @@ class Element {
7068
7625
  * @throws Error if this element has no ID
7069
7626
  */
7070
7627
  toRef(path) {
7071
- const idValue = this.id.toValue();
7628
+ const idValue = this.id;
7072
7629
  if (idValue === '') {
7073
7630
  throw new Error('Cannot create reference to an element without an ID');
7074
7631
  }
@@ -7080,26 +7637,16 @@ class Element {
7080
7637
  }
7081
7638
 
7082
7639
  /**
7083
- * Gets a meta property.
7640
+ * Gets a meta property value.
7084
7641
  *
7085
7642
  * When the property doesn't exist:
7086
- * - With defaultValue: returns a new refracted element instance (not cached)
7643
+ * - With defaultValue: returns the provided default value
7087
7644
  * - Without defaultValue: returns undefined
7088
- *
7089
- * Note: Each call with a default creates a new instance. Use setMetaProperty
7090
- * first if you need reference equality across multiple accesses.
7091
7645
  */
7092
7646
 
7093
7647
  getMetaProperty(name, defaultValue) {
7094
7648
  if (!this.hasMetaProperty(name)) {
7095
- if (defaultValue === undefined) {
7096
- return undefined;
7097
- }
7098
- const element = this.refract(defaultValue);
7099
- if (element && this.isFrozen) {
7100
- element.freeze();
7101
- }
7102
- return element;
7649
+ return defaultValue;
7103
7650
  }
7104
7651
  return this.meta.get(name);
7105
7652
  }
@@ -7112,20 +7659,17 @@ class Element {
7112
7659
  }
7113
7660
 
7114
7661
  /**
7115
- * Has meta property.
7662
+ * Checks whether a meta property exists.
7116
7663
  */
7117
7664
  hasMetaProperty(name) {
7118
- if (!this.isMetaEmpty) {
7119
- return this.meta.hasKey(name);
7120
- }
7121
- return false;
7665
+ return this._meta !== undefined && this._meta.hasKey(name);
7122
7666
  }
7123
7667
 
7124
7668
  /**
7125
7669
  * Checks if meta is empty.
7126
7670
  */
7127
7671
  get isMetaEmpty() {
7128
- return this._meta === undefined || this.meta.isEmpty;
7672
+ return this._meta === undefined || this._meta.isEmpty;
7129
7673
  }
7130
7674
 
7131
7675
  /**
@@ -7151,7 +7695,7 @@ class Element {
7151
7695
  }
7152
7696
 
7153
7697
  /**
7154
- * Has attributes property.
7698
+ * Checks whether an attributes property exists.
7155
7699
  */
7156
7700
  hasAttributesProperty(name) {
7157
7701
  if (!this.isAttributesEmpty) {
@@ -7170,6 +7714,7 @@ class Element {
7170
7714
 
7171
7715
  // Re-export types for convenience
7172
7716
 
7717
+
7173
7718
  /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Element);
7174
7719
 
7175
7720
  /***/ },
@@ -7608,6 +8153,10 @@ __webpack_require__.r(__webpack_exports__);
7608
8153
  /* harmony import */ var _elements_Style_mjs__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(9686);
7609
8154
  /* harmony import */ var _ObjectSlice_mjs__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(8504);
7610
8155
  /* harmony import */ var _KeyValuePair_mjs__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(6663);
8156
+ /* harmony import */ var _Metadata_mjs__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(1844);
8157
+ /* harmony import */ var _clone_index_mjs__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(2111);
8158
+
8159
+
7611
8160
 
7612
8161
 
7613
8162
 
@@ -7667,14 +8216,16 @@ function refract(value) {
7667
8216
  }
7668
8217
 
7669
8218
  // Set up prototype assignments for circular dependency resolution.
7670
- // These allow Element instances to create ObjectElement, MemberElement, RefElement
7671
- // without importing them directly (which would cause circular imports).
8219
+ // These allow Element and Metadata instances to reference classes they can't import
8220
+ // directly (which would cause circular imports).
7672
8221
  // Using 'declare' in the class definitions enables type-safe access to these properties.
7673
8222
  _primitives_Element_mjs__WEBPACK_IMPORTED_MODULE_0__["default"].prototype.ObjectElement = _primitives_ObjectElement_mjs__WEBPACK_IMPORTED_MODULE_8__["default"];
7674
8223
  _primitives_Element_mjs__WEBPACK_IMPORTED_MODULE_0__["default"].prototype.ArrayElement = _primitives_ArrayElement_mjs__WEBPACK_IMPORTED_MODULE_6__["default"];
7675
8224
  _primitives_Element_mjs__WEBPACK_IMPORTED_MODULE_0__["default"].prototype.RefElement = _elements_RefElement_mjs__WEBPACK_IMPORTED_MODULE_10__["default"];
7676
8225
  _primitives_Element_mjs__WEBPACK_IMPORTED_MODULE_0__["default"].prototype.MemberElement = _primitives_MemberElement_mjs__WEBPACK_IMPORTED_MODULE_7__["default"];
7677
8226
  _primitives_Element_mjs__WEBPACK_IMPORTED_MODULE_0__["default"].prototype.refract = refract;
8227
+ _Metadata_mjs__WEBPACK_IMPORTED_MODULE_18__["default"].prototype.Element = _primitives_Element_mjs__WEBPACK_IMPORTED_MODULE_0__["default"];
8228
+ _Metadata_mjs__WEBPACK_IMPORTED_MODULE_18__["default"].prototype.cloneDeepElement = element => (0,_clone_index_mjs__WEBPACK_IMPORTED_MODULE_19__.cloneDeep)(element);
7678
8229
 
7679
8230
  /**
7680
8231
  * Contains all of the element classes, and related structures and methods
@@ -7739,7 +8290,13 @@ class JSONSerialiser {
7739
8290
  element: element.element
7740
8291
  };
7741
8292
  if (!element.isMetaEmpty) {
7742
- payload.meta = this.serialiseObject(element.meta);
8293
+ const serialisedMeta = this.serialiseMeta(element);
8294
+ if (serialisedMeta) {
8295
+ payload.meta = serialisedMeta.meta;
8296
+ if (serialisedMeta.rawKeys.length > 0) {
8297
+ payload.__meta_raw__ = serialisedMeta.rawKeys;
8298
+ }
8299
+ }
7743
8300
  }
7744
8301
  if (!element.isAttributesEmpty) {
7745
8302
  payload.attributes = this.serialiseObject(element.attributes);
@@ -7786,7 +8343,7 @@ class JSONSerialiser {
7786
8343
  element.element = value.element;
7787
8344
  }
7788
8345
 
7789
- // Extract __mappings__ and __styles__ without mutating input, filter remaining meta
8346
+ // Extract special meta keys without mutating input, filter remaining meta
7790
8347
  let mappingsDoc;
7791
8348
  let stylesDoc;
7792
8349
  let metaToDeserialize = value.meta;
@@ -7800,8 +8357,15 @@ class JSONSerialiser {
7800
8357
  stylesDoc = __styles__;
7801
8358
  metaToDeserialize = Object.keys(rest).length > 0 ? rest : undefined;
7802
8359
  }
8360
+
8361
+ // determine which meta keys were raw primitives before serialization
8362
+ const rawKeys = value.__meta_raw__ ? new Set(value.__meta_raw__) : undefined;
7803
8363
  if (metaToDeserialize) {
7804
- this.deserialiseObject(metaToDeserialize, element.meta);
8364
+ for (const [key, doc] of Object.entries(metaToDeserialize)) {
8365
+ const deserialized = this.deserialise(doc);
8366
+ // unwrap keys that were raw primitives before serialization
8367
+ element.setMetaProperty(key, rawKeys?.has(key) ? deserialized.toValue() : deserialized);
8368
+ }
7805
8369
  }
7806
8370
 
7807
8371
  // Restore source position from __mappings__
@@ -7864,6 +8428,27 @@ class JSONSerialiser {
7864
8428
  }
7865
8429
  return content;
7866
8430
  }
8431
+ serialiseMeta(element) {
8432
+ const meta = {};
8433
+ const rawKeys = [];
8434
+ let hasEntries = false;
8435
+ for (const [key, value] of Object.entries(element.meta)) {
8436
+ if (value instanceof this.namespace.elements.Element) {
8437
+ meta[key] = this.serialise(value);
8438
+ hasEntries = true;
8439
+ } else if (value !== undefined) {
8440
+ // refract primitives to maintain JSON Refract spec compatibility
8441
+ const refracted = element.refract(value);
8442
+ meta[key] = this.serialise(refracted);
8443
+ rawKeys.push(key);
8444
+ hasEntries = true;
8445
+ }
8446
+ }
8447
+ return hasEntries ? {
8448
+ meta,
8449
+ rawKeys
8450
+ } : undefined;
8451
+ }
7867
8452
  serialiseObject(obj) {
7868
8453
  const result = {};
7869
8454
  obj.forEach((value, key) => {
@@ -7940,6 +8525,36 @@ class ApiDOMError extends Error {
7940
8525
 
7941
8526
  /***/ },
7942
8527
 
8528
+ /***/ 4641
8529
+ (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
8530
+
8531
+ "use strict";
8532
+ __webpack_require__.r(__webpack_exports__);
8533
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8534
+ /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
8535
+ /* harmony export */ });
8536
+ /* harmony import */ var _ApiDOMError_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(6126);
8537
+
8538
+ /**
8539
+ * @public
8540
+ */
8541
+ class ApiDOMStructuredError extends _ApiDOMError_mjs__WEBPACK_IMPORTED_MODULE_0__["default"] {
8542
+ constructor(message, structuredOptions) {
8543
+ super(message, structuredOptions);
8544
+ if (structuredOptions != null && typeof structuredOptions === 'object') {
8545
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
8546
+ const {
8547
+ cause,
8548
+ ...causelessOptions
8549
+ } = structuredOptions;
8550
+ Object.assign(this, causelessOptions);
8551
+ }
8552
+ }
8553
+ }
8554
+ /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (ApiDOMStructuredError);
8555
+
8556
+ /***/ },
8557
+
7943
8558
  /***/ 8397
7944
8559
  (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
7945
8560