@basmilius/apple-encoding 0.5.3 → 0.5.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.
Files changed (3) hide show
  1. package/LICENSE +1 -1
  2. package/dist/index.js +605 -2
  3. package/package.json +3 -5
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2024-2025 Bas Milius
3
+ Copyright (c) 2024-present Bas Milius
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/dist/index.js CHANGED
@@ -453,8 +453,611 @@ __export(exports_plist, {
453
453
  serialize: () => serialize,
454
454
  parse: () => parse
455
455
  });
456
- import { parse } from "@plist/binary.parse";
457
- import { serialize } from "@plist/binary.serialize";
456
+ // ../../node_modules/@plist/common/lib/esm/constants.js
457
+ var EPOCH2 = 978307200000;
458
+ var HEADER_BINARY = "bplist00";
459
+ var PlistFormat;
460
+ (function(PlistFormat2) {
461
+ PlistFormat2[PlistFormat2["BINARY"] = 0] = "BINARY";
462
+ PlistFormat2[PlistFormat2["XML"] = 1] = "XML";
463
+ PlistFormat2[PlistFormat2["OPENSTEP"] = 2] = "OPENSTEP";
464
+ })(PlistFormat || (PlistFormat = {}));
465
+ // ../../node_modules/@plist/binary.parse/lib/esm/index.js
466
+ var maxObjectSize = 100 * 1000 * 1000;
467
+ var maxObjectCount = 32768;
468
+ var DECODER_UTF8 = new TextDecoder("utf-8");
469
+ var DECODER_UTF16 = new TextDecoder("utf-16");
470
+ function readDouble(buffer, start = 0) {
471
+ return new DataView(buffer).getFloat64(start, false);
472
+ }
473
+ function readFloat(buffer, start = 0) {
474
+ return new DataView(buffer).getFloat32(start, false);
475
+ }
476
+ function readUInt8(buffer, start = 0) {
477
+ return new DataView(buffer).getUint8(start);
478
+ }
479
+ function readUInt16(buffer, start = 0) {
480
+ return new DataView(buffer).getUint16(start, false);
481
+ }
482
+ function readUInt32(buffer, start = 0) {
483
+ return new DataView(buffer).getUint32(start, false);
484
+ }
485
+ function readUInt64(buffer, start = 0) {
486
+ return new DataView(buffer).getBigUint64(start, false);
487
+ }
488
+ function readUInt(buffer) {
489
+ switch (buffer.byteLength) {
490
+ case 1:
491
+ return readUInt8(buffer);
492
+ case 2:
493
+ return readUInt16(buffer);
494
+ case 4:
495
+ return readUInt32(buffer);
496
+ case 8:
497
+ return readUInt64(buffer);
498
+ case 16:
499
+ return readUInt64(buffer, 8);
500
+ }
501
+ throw new Error(`Invalid unsigned int length: ${buffer.byteLength}`);
502
+ }
503
+ function readInt8(buffer, start = 0) {
504
+ return new DataView(buffer).getInt8(start);
505
+ }
506
+ function readInt16(buffer, start = 0) {
507
+ return new DataView(buffer).getInt16(start, false);
508
+ }
509
+ function readInt32(buffer, start = 0) {
510
+ return new DataView(buffer).getInt32(start, false);
511
+ }
512
+ function readInt64(buffer, start = 0) {
513
+ return new DataView(buffer).getBigInt64(start, false);
514
+ }
515
+ function readInt(buffer) {
516
+ switch (buffer.byteLength) {
517
+ case 1:
518
+ return readInt8(buffer);
519
+ case 2:
520
+ return readInt16(buffer);
521
+ case 4:
522
+ return readInt32(buffer);
523
+ case 8:
524
+ return readInt64(buffer);
525
+ case 16:
526
+ return readUInt64(buffer, 8);
527
+ }
528
+ throw new Error(`Invalid int length: ${buffer.byteLength}`);
529
+ }
530
+ function swapBytes(buffer) {
531
+ const array = new Uint8Array(buffer);
532
+ for (let i = 0;i < array.length; i += 2) {
533
+ const a = array[i];
534
+ array[i] = array[i + 1];
535
+ array[i + 1] = a;
536
+ }
537
+ return array.buffer;
538
+ }
539
+ var parse = (buffer) => {
540
+ const headerBytes = buffer.slice(0, HEADER_BINARY.length);
541
+ if (DECODER_UTF8.decode(headerBytes) !== HEADER_BINARY) {
542
+ throw new Error(`Invalid binary plist. Expected '${HEADER_BINARY}' at offset 0.`);
543
+ }
544
+ const trailer = buffer.slice(buffer.byteLength - 32, buffer.byteLength);
545
+ const offsetSize = readUInt8(trailer, 6);
546
+ const objectRefSize = readUInt8(trailer, 7);
547
+ const numObjects = Number(readUInt64(trailer, 8));
548
+ const topObject = Number(readUInt64(trailer, 16));
549
+ const offsetTableOffset = Number(readUInt64(trailer, 24));
550
+ if (numObjects > maxObjectCount) {
551
+ throw new Error("maxObjectCount exceeded");
552
+ }
553
+ const offsetTable = [];
554
+ for (let i = 0;i < numObjects; i++) {
555
+ const offsetBytes = buffer.slice(offsetTableOffset + i * offsetSize, offsetTableOffset + (i + 1) * offsetSize);
556
+ offsetTable[i] = Number(readUInt(offsetBytes));
557
+ }
558
+ function parseObject(tableOffset) {
559
+ const offset = offsetTable[tableOffset];
560
+ const type = readUInt8(buffer, offset);
561
+ const objType = (type & 240) >> 4;
562
+ const objInfo = type & 15;
563
+ switch (objType) {
564
+ case 0:
565
+ return parseSimple();
566
+ case 1:
567
+ return parseInteger();
568
+ case 8:
569
+ return parseUID();
570
+ case 2:
571
+ return parseReal();
572
+ case 3:
573
+ return parseDate();
574
+ case 4:
575
+ return parseData();
576
+ case 5:
577
+ return parsePlistString();
578
+ case 6:
579
+ return parsePlistString(true);
580
+ case 10:
581
+ return parseArray();
582
+ case 13:
583
+ return parseDictionary();
584
+ default:
585
+ throw new Error("Unhandled type 0x" + objType.toString(16));
586
+ }
587
+ function parseSimple() {
588
+ switch (objInfo) {
589
+ case 0:
590
+ return null;
591
+ case 8:
592
+ return false;
593
+ case 9:
594
+ return true;
595
+ case 15:
596
+ return null;
597
+ default:
598
+ throw new Error("Unhandled simple type 0x" + objType.toString(16));
599
+ }
600
+ }
601
+ function parseInteger() {
602
+ const length = Math.pow(2, objInfo);
603
+ if (length < maxObjectSize) {
604
+ const data = buffer.slice(offset + 1, offset + 1 + length);
605
+ return readInt(data);
606
+ }
607
+ throw new Error("Too little heap space available! Wanted to read " + length + " bytes, but only " + maxObjectSize + " are available.");
608
+ }
609
+ function parseUID() {
610
+ const length = objInfo + 1;
611
+ if (length < maxObjectSize) {
612
+ return {
613
+ CF$UID: readUInt(buffer.slice(offset + 1, offset + 1 + length))
614
+ };
615
+ }
616
+ throw new Error("Too little heap space available! Wanted to read " + length + " bytes, but only " + maxObjectSize + " are available.");
617
+ }
618
+ function parseReal() {
619
+ const length = Math.pow(2, objInfo);
620
+ if (length < maxObjectSize) {
621
+ const realBuffer = buffer.slice(offset + 1, offset + 1 + length);
622
+ if (length === 4) {
623
+ return readFloat(realBuffer);
624
+ } else if (length === 8) {
625
+ return readDouble(realBuffer);
626
+ }
627
+ throw new Error(`Invalid real length: ${length}`);
628
+ } else {
629
+ throw new Error("Too little heap space available! Wanted to read " + length + " bytes, but only " + maxObjectSize + " are available.");
630
+ }
631
+ }
632
+ function parseDate() {
633
+ if (objInfo != 3) {
634
+ console.error("Unknown date type :" + objInfo + ". Parsing anyway...");
635
+ }
636
+ const dateBuffer = buffer.slice(offset + 1, offset + 9);
637
+ return new Date(EPOCH2 + 1000 * readDouble(dateBuffer));
638
+ }
639
+ function parseData() {
640
+ let dataoffset = 1;
641
+ let length = objInfo;
642
+ if (objInfo == 15) {
643
+ const int_type = readInt8(buffer, offset + 1);
644
+ const intType = (int_type & 240) / 16;
645
+ if (intType != 1) {
646
+ console.error("0x4: UNEXPECTED LENGTH-INT TYPE! " + intType);
647
+ }
648
+ const intInfo = int_type & 15;
649
+ const intLength = Math.pow(2, intInfo);
650
+ dataoffset = 2 + intLength;
651
+ length = Number(readUInt(buffer.slice(offset + 2, offset + 2 + intLength)));
652
+ }
653
+ if (length < maxObjectSize) {
654
+ return buffer.slice(offset + dataoffset, offset + dataoffset + Number(length));
655
+ }
656
+ throw new Error("Too little heap space available! Wanted to read " + length + " bytes, but only " + maxObjectSize + " are available.");
657
+ }
658
+ function parsePlistString(isUtf16 = false) {
659
+ let length = objInfo;
660
+ let stroffset = 1;
661
+ if (objInfo == 15) {
662
+ const int_type = readUInt8(buffer, offset + 1);
663
+ const intType = (int_type & 240) / 16;
664
+ if (intType != 1) {
665
+ console.error("UNEXPECTED LENGTH-INT TYPE! " + intType);
666
+ }
667
+ const intInfo = int_type & 15;
668
+ const intLength = Math.pow(2, intInfo);
669
+ stroffset = 2 + intLength;
670
+ length = Number(readUInt(buffer.slice(offset + 2, offset + 2 + intLength)));
671
+ }
672
+ length *= isUtf16 ? 2 : 1;
673
+ if (length < maxObjectSize) {
674
+ let plistString = buffer.slice(offset + stroffset, offset + stroffset + length);
675
+ if (isUtf16) {
676
+ plistString = swapBytes(plistString);
677
+ return DECODER_UTF16.decode(plistString);
678
+ } else {
679
+ return DECODER_UTF8.decode(plistString);
680
+ }
681
+ }
682
+ throw new Error("Too little heap space available! Wanted to read " + length + " bytes, but only " + maxObjectSize + " are available.");
683
+ }
684
+ function parseArray() {
685
+ let length = objInfo;
686
+ let arrayoffset = 1;
687
+ if (objInfo == 15) {
688
+ const int_type = readUInt8(buffer, offset + 1);
689
+ const intType = (int_type & 240) / 16;
690
+ if (intType != 1) {
691
+ console.error("0xa: UNEXPECTED LENGTH-INT TYPE! " + intType);
692
+ }
693
+ const intInfo = int_type & 15;
694
+ const intLength = Math.pow(2, intInfo);
695
+ arrayoffset = 2 + intLength;
696
+ length = Number(readUInt(buffer.slice(offset + 2, offset + 2 + intLength)));
697
+ }
698
+ if (length * objectRefSize > maxObjectSize) {
699
+ throw new Error("Too little heap space available!");
700
+ }
701
+ const array = [];
702
+ for (let i = 0;i < length; i++) {
703
+ const objRef = Number(readUInt(buffer.slice(offset + arrayoffset + i * objectRefSize, offset + arrayoffset + (i + 1) * objectRefSize)));
704
+ array[i] = parseObject(objRef);
705
+ }
706
+ return array;
707
+ }
708
+ function parseDictionary() {
709
+ let length = objInfo;
710
+ let dictoffset = 1;
711
+ if (objInfo == 15) {
712
+ const int_type = readUInt8(buffer, offset + 1);
713
+ const intType = (int_type & 240) / 16;
714
+ if (intType != 1) {
715
+ console.error("0xD: UNEXPECTED LENGTH-INT TYPE! " + intType);
716
+ }
717
+ const intInfo = int_type & 15;
718
+ const intLength = Math.pow(2, intInfo);
719
+ dictoffset = 2 + intLength;
720
+ length = Number(readUInt(buffer.slice(offset + 2, offset + 2 + intLength)));
721
+ }
722
+ if (length * 2 * objectRefSize > maxObjectSize) {
723
+ throw new Error("Too little heap space available!");
724
+ }
725
+ const dict = {};
726
+ for (let i = 0;i < length; i++) {
727
+ const keyRef = Number(readUInt(buffer.slice(offset + dictoffset + i * objectRefSize, offset + dictoffset + (i + 1) * objectRefSize)));
728
+ const valRef = Number(readUInt(buffer.slice(offset + dictoffset + length * objectRefSize + i * objectRefSize, offset + dictoffset + length * objectRefSize + (i + 1) * objectRefSize)));
729
+ const key = parseObject(keyRef);
730
+ if (typeof key !== "string") {
731
+ throw new Error("Invalid key type.");
732
+ }
733
+ if (key === "__proto__") {
734
+ throw new Error("Attempted prototype pollution");
735
+ }
736
+ const val = parseObject(valRef);
737
+ dict[key] = val;
738
+ }
739
+ return dict;
740
+ }
741
+ }
742
+ return parseObject(topObject);
743
+ };
744
+ // ../../node_modules/@plist/binary.serialize/lib/esm/index.js
745
+ var encoder = new TextEncoder;
746
+ var nullBytes = new Uint8Array([0, 0, 0, 0, 0, 0]);
747
+ var fromHexString = (hexString) => Uint8Array.from(hexString.match(/.{1,2}/g).map((byte) => parseInt(byte, 16)));
748
+ var isUID = (value) => !!value && typeof value === "object" && Object.keys(value).length == 1 && typeof value.CF$UID === "number";
749
+ var toUTF16 = (string) => {
750
+ const buf = new ArrayBuffer(string.length * 2);
751
+ const bufView = new Uint16Array(buf);
752
+ for (let i = 0, strLen = string.length;i < strLen; i++) {
753
+ bufView[i] = string.charCodeAt(i);
754
+ }
755
+ return new Uint8Array(buf);
756
+ };
757
+ var concat2 = (first, second) => {
758
+ const third = new Uint8Array(first.length + second.length);
759
+ third.set(first);
760
+ third.set(second, first.length);
761
+ return third;
762
+ };
763
+ var writeUInt = (buffer, int2, size) => {
764
+ const output = new Uint8Array(buffer.length + size);
765
+ const dataView = new DataView(output.buffer);
766
+ output.set(buffer);
767
+ switch (size) {
768
+ case 1:
769
+ dataView.setUint8(buffer.length, Number(int2));
770
+ break;
771
+ case 2:
772
+ dataView.setUint16(buffer.length, Number(int2), false);
773
+ break;
774
+ case 4:
775
+ dataView.setUint32(buffer.length, Number(int2), false);
776
+ break;
777
+ case 8:
778
+ dataView.setBigUint64(buffer.length, BigInt(int2), false);
779
+ break;
780
+ default:
781
+ throw new Error("Unsupported int size");
782
+ }
783
+ return output;
784
+ };
785
+ var writeInt = (buffer, int2, size) => {
786
+ const output = new Uint8Array(buffer.length + size);
787
+ const dataView = new DataView(output.buffer);
788
+ output.set(buffer);
789
+ switch (size) {
790
+ case 1:
791
+ dataView.setInt8(buffer.length, Number(int2));
792
+ break;
793
+ case 2:
794
+ dataView.setInt16(buffer.length, Number(int2), false);
795
+ break;
796
+ case 4:
797
+ dataView.setInt32(buffer.length, Number(int2), false);
798
+ break;
799
+ case 8:
800
+ dataView.setBigInt64(buffer.length, BigInt(int2), false);
801
+ break;
802
+ default:
803
+ throw new Error("Unsupported int size");
804
+ }
805
+ return output;
806
+ };
807
+ var writeDouble = (buffer, double) => {
808
+ const output = new Uint8Array(buffer.length + 8);
809
+ const dataView = new DataView(output.buffer);
810
+ output.set(buffer);
811
+ dataView.setFloat64(buffer.length, double);
812
+ return output;
813
+ };
814
+ var serialize = (value) => {
815
+ let buffer = encoder.encode(HEADER_BINARY);
816
+ if (value instanceof Array && value.length === 1) {
817
+ value = value[0];
818
+ }
819
+ let entries = toEntries(value);
820
+ const idSizeInBytes = computeIdSizeInBytes(entries.length);
821
+ const offsets = [];
822
+ let offsetSizeInBytes;
823
+ let offsetTableOffset;
824
+ updateEntryIds();
825
+ entries.forEach((entry, entryIdx) => {
826
+ offsets[entryIdx] = buffer.byteLength;
827
+ if (typeof entry === "undefined" || entry === null) {
828
+ buffer = writeUInt(buffer, 0, 1);
829
+ } else {
830
+ write(entry);
831
+ }
832
+ });
833
+ writeOffsetTable();
834
+ writeTrailer();
835
+ return buffer.buffer;
836
+ function updateEntryIds() {
837
+ const strings = {};
838
+ let entryId = 0;
839
+ entries.forEach((entry) => {
840
+ if (entry.id) {
841
+ return;
842
+ }
843
+ if (typeof entry.value === "string") {
844
+ if (strings.hasOwnProperty(entry.value)) {
845
+ entry.type = "stringref";
846
+ entry.id = strings[entry.value];
847
+ } else {
848
+ strings[entry.value] = entry.id = entryId++;
849
+ }
850
+ } else {
851
+ entry.id = entryId++;
852
+ }
853
+ });
854
+ entries = entries.filter((entry) => {
855
+ return entry.type !== "stringref";
856
+ });
857
+ }
858
+ function writeTrailer() {
859
+ buffer = concat2(buffer, nullBytes);
860
+ buffer = concat2(buffer, new Uint8Array([offsetSizeInBytes, idSizeInBytes]));
861
+ buffer = writeUInt(buffer, BigInt(entries.length), 8);
862
+ buffer = writeUInt(buffer, BigInt("0"), 8);
863
+ buffer = writeUInt(buffer, BigInt(offsetTableOffset), 8);
864
+ }
865
+ function writeOffsetTable() {
866
+ offsetTableOffset = buffer.byteLength;
867
+ offsetSizeInBytes = computeOffsetSizeInBytes(offsetTableOffset);
868
+ offsets.forEach((offset) => {
869
+ buffer = writeUInt(buffer, offset, offsetSizeInBytes);
870
+ });
871
+ }
872
+ function write(entry) {
873
+ if (entry.type === "primitive") {
874
+ const value2 = entry.value;
875
+ switch (typeof value2) {
876
+ case "number":
877
+ case "bigint":
878
+ writeNumber(value2);
879
+ break;
880
+ case "string":
881
+ writeString(value2);
882
+ break;
883
+ case "boolean":
884
+ writeBoolean(value2);
885
+ break;
886
+ }
887
+ if (value2 instanceof Date) {
888
+ writeDate(value2);
889
+ } else if (value2 instanceof ArrayBuffer) {
890
+ writeData(value2);
891
+ } else if (isUID(value2)) {
892
+ writeUID(value2.CF$UID);
893
+ }
894
+ return;
895
+ }
896
+ switch (entry.type) {
897
+ case "dict":
898
+ writeDict(entry);
899
+ break;
900
+ case "array":
901
+ writeArray(entry);
902
+ break;
903
+ default:
904
+ throw new Error("unhandled entry type: " + entry.type);
905
+ }
906
+ }
907
+ function writeDate(value2) {
908
+ buffer = writeUInt(buffer, 51, 1);
909
+ const date = (value2.getTime() - EPOCH2) / 1000;
910
+ buffer = writeDouble(buffer, date);
911
+ }
912
+ function writeDict(entry) {
913
+ writeIntHeader(13, entry.entryKeys.length);
914
+ entry.entryKeys.forEach((entry2) => {
915
+ writeID(entry2.id);
916
+ });
917
+ entry.entryValues.forEach((entry2) => {
918
+ writeID(entry2.id);
919
+ });
920
+ }
921
+ function writeNumber(value2) {
922
+ if (typeof value2 === "bigint") {
923
+ const width = 16;
924
+ const hex = value2.toString(16);
925
+ const buf = fromHexString(hex.padStart(width * 2, "0").slice(0, width * 2));
926
+ buffer = writeUInt(buffer, 20, 1);
927
+ buffer = concat2(buffer, buf);
928
+ } else {
929
+ if (Number.isInteger(value2)) {
930
+ if (value2 < 0) {
931
+ buffer = writeUInt(buffer, 19, 1);
932
+ buffer = writeInt(buffer, value2, 8);
933
+ } else if (value2 <= 255) {
934
+ buffer = writeUInt(buffer, 16, 1);
935
+ buffer = writeUInt(buffer, value2, 1);
936
+ } else if (value2 <= 65535) {
937
+ buffer = writeUInt(buffer, 17, 1);
938
+ buffer = writeUInt(buffer, value2, 2);
939
+ } else if (value2 <= 4294967295) {
940
+ buffer = writeUInt(buffer, 18, 1);
941
+ buffer = writeUInt(buffer, value2, 4);
942
+ } else {
943
+ buffer = writeUInt(buffer, 19, 1);
944
+ buffer = writeUInt(buffer, value2, 8);
945
+ }
946
+ } else {
947
+ buffer = writeUInt(buffer, 35, 1);
948
+ buffer = writeDouble(buffer, value2);
949
+ }
950
+ }
951
+ }
952
+ function writeUID(uid) {
953
+ writeIntHeader(8, 0);
954
+ writeID(uid);
955
+ }
956
+ function writeArray(entry) {
957
+ writeIntHeader(10, entry.entries.length);
958
+ entry.entries.forEach((e) => {
959
+ writeID(e.id);
960
+ });
961
+ }
962
+ function writeBoolean(value2) {
963
+ buffer = writeUInt(buffer, value2 ? 9 : 8, 1);
964
+ }
965
+ function writeString(value2) {
966
+ if (mustBeUtf16(value2)) {
967
+ const utf16 = toUTF16(value2);
968
+ writeIntHeader(6, utf16.length / 2);
969
+ for (let i = 0;i < utf16.length; i += 2) {
970
+ const t = utf16[i + 0];
971
+ utf16[i + 0] = utf16[i + 1];
972
+ utf16[i + 1] = t;
973
+ }
974
+ buffer = concat2(buffer, utf16);
975
+ } else {
976
+ const utf8 = encoder.encode(value2);
977
+ writeIntHeader(5, utf8.length);
978
+ buffer = concat2(buffer, utf8);
979
+ }
980
+ }
981
+ function writeData(data) {
982
+ writeIntHeader(4, data.byteLength);
983
+ buffer = concat2(buffer, new Uint8Array(data));
984
+ }
985
+ function writeIntHeader(kind, value2) {
986
+ if (value2 < 15) {
987
+ buffer = writeUInt(buffer, (kind << 4) + value2, 1);
988
+ } else {
989
+ buffer = writeUInt(buffer, (kind << 4) + 15, 1);
990
+ writeNumber(value2);
991
+ }
992
+ }
993
+ function writeID(id) {
994
+ buffer = writeUInt(buffer, id, idSizeInBytes);
995
+ }
996
+ function mustBeUtf16(string) {
997
+ return encoder.encode(string).byteLength != string.length;
998
+ }
999
+ };
1000
+ var typeofPrimitive = ["string", "number", "boolean", "bigint"];
1001
+ function toEntries(value) {
1002
+ if (typeofPrimitive.includes(typeof value) || value instanceof ArrayBuffer || value instanceof Date || isUID(value)) {
1003
+ return [
1004
+ {
1005
+ type: "primitive",
1006
+ value
1007
+ }
1008
+ ];
1009
+ }
1010
+ if (value != null && typeof value === "object") {
1011
+ return Array.isArray(value) ? toEntriesArray(value) : toEntriesObject(value);
1012
+ }
1013
+ throw new Error("unhandled entry: " + value);
1014
+ }
1015
+ function toEntriesArray(array) {
1016
+ const entries = array.map(toEntries);
1017
+ return [
1018
+ {
1019
+ type: "array",
1020
+ value: undefined,
1021
+ entries: entries.map((entries2) => entries2[0])
1022
+ },
1023
+ ...entries.flat()
1024
+ ];
1025
+ }
1026
+ function toEntriesObject(dict) {
1027
+ const entryKeys = Object.keys(dict).map(toEntries).flat(1);
1028
+ const entryValues = Object.values(dict).map(toEntries);
1029
+ return [
1030
+ {
1031
+ type: "dict",
1032
+ value: undefined,
1033
+ entryKeys,
1034
+ entryValues: entryValues.map((entries) => entries[0])
1035
+ },
1036
+ ...entryKeys,
1037
+ ...entryValues.flat()
1038
+ ];
1039
+ }
1040
+ function computeOffsetSizeInBytes(maxOffset) {
1041
+ if (maxOffset < 256) {
1042
+ return 1;
1043
+ }
1044
+ if (maxOffset < 65536) {
1045
+ return 2;
1046
+ }
1047
+ if (maxOffset < 4294967296) {
1048
+ return 4;
1049
+ }
1050
+ return 8;
1051
+ }
1052
+ function computeIdSizeInBytes(numberOfIds) {
1053
+ if (numberOfIds < 256) {
1054
+ return 1;
1055
+ }
1056
+ if (numberOfIds < 65536) {
1057
+ return 2;
1058
+ }
1059
+ return 4;
1060
+ }
458
1061
  // src/rtsp.ts
459
1062
  var exports_rtsp = {};
460
1063
  __export(exports_rtsp, {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@basmilius/apple-encoding",
3
3
  "description": "Common encoding utilities for Apple Protocols.",
4
- "version": "0.5.3",
4
+ "version": "0.5.4",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "author": {
@@ -38,12 +38,10 @@
38
38
  "default": "./dist/index.js"
39
39
  }
40
40
  },
41
- "dependencies": {
42
- "@plist/binary.parse": "^1.1.0",
43
- "@plist/binary.serialize": "^1.1.0"
44
- },
45
41
  "devDependencies": {
46
42
  "@basmilius/tools": "^2.23.0",
43
+ "@plist/binary.parse": "^1.1.0",
44
+ "@plist/binary.serialize": "^1.1.0",
47
45
  "@types/bun": "^1.3.8"
48
46
  }
49
47
  }