alinea 2.0.0-preview.0 → 2.0.0-preview.2

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 (237) hide show
  1. package/dist/.init/content/pages/welcome.json +1 -1
  2. package/dist/LICENSES.md +134 -80
  3. package/dist/adapter/next/DevRemote.d.ts +3 -0
  4. package/dist/adapter/next/DevRemote.js +37 -0
  5. package/dist/adapter/next/ForwardCredentials.d.ts +1 -0
  6. package/dist/adapter/next/ForwardCredentials.js +17 -0
  7. package/dist/adapter/next/cms.js +86 -38
  8. package/dist/adapter/next/context.d.ts +1 -1
  9. package/dist/adapter/next/context.js +11 -3
  10. package/dist/adapter/next/handler.d.ts +2 -0
  11. package/dist/adapter/next/handler.js +23 -16
  12. package/dist/adapter/next/with-alinea.js +18 -16
  13. package/dist/backend/Handler.d.ts +14 -13
  14. package/dist/backend/Handler.js +70 -36
  15. package/dist/backend/resolver/ParsePreview.d.ts +8 -4
  16. package/dist/backend/resolver/ParsePreview.js +40 -43
  17. package/dist/backend/router/Router.d.ts +1 -0
  18. package/dist/backend/router/Router.js +21 -15
  19. package/dist/bundled.d.ts +369 -99
  20. package/dist/chunks/chunk-6UT4N4CO.js +919 -0
  21. package/dist/chunks/{chunk-LUBOGJCG.js → chunk-6V4TAD2N.js} +1 -1
  22. package/dist/chunks/{chunk-TL7ZW6BX.js → chunk-A3XXZBOQ.js} +2535 -2999
  23. package/dist/chunks/chunk-AC5ATYI3.js +1434 -0
  24. package/dist/chunks/{chunk-7ORQ7BYK.js → chunk-KMLLLZ6X.js} +202 -269
  25. package/dist/chunks/{chunk-IWN3T3FL.js → chunk-O7XWTMCB.js} +1 -1
  26. package/dist/chunks/{chunk-53DZYORR.js → chunk-PAYSVIYI.js} +76 -176
  27. package/dist/chunks/{chunk-YK3OSMDM.js → chunk-S4AU6SRS.js} +188 -158
  28. package/dist/chunks/{chunk-EQ3TDHYD.js → chunk-UVOEM4AH.js} +6 -3
  29. package/dist/chunks/{chunk-I7X64JTZ.js → chunk-VXZM6V4P.js} +4 -4
  30. package/dist/cli/Generate.js +3 -13
  31. package/dist/cli/Serve.js +7 -3
  32. package/dist/cli/bin.js +8 -5
  33. package/dist/cli/generate/CompileConfig.js +3 -2
  34. package/dist/cli/generate/CopyStaticFiles.js +2 -3
  35. package/dist/cli/generate/DevDB.d.ts +1 -1
  36. package/dist/cli/generate/DevDB.js +3 -5
  37. package/dist/cli/serve/CreateLocalServer.d.ts +1 -1
  38. package/dist/cli/serve/CreateLocalServer.js +3 -2
  39. package/dist/cli/serve/DevServer.d.ts +3 -2
  40. package/dist/cli/serve/DevServer.js +60 -3
  41. package/dist/cli/serve/ServeContext.d.ts +1 -0
  42. package/dist/cli/serve/StartServer.d.ts +1 -0
  43. package/dist/cli/serve/StartServer.js +6 -1
  44. package/dist/cli/util/EnsureLibs.js +2 -2
  45. package/dist/cli/util/EnsureNode.js +2 -2
  46. package/dist/cloud/CloudRemote.d.ts +2 -1
  47. package/dist/cloud/CloudRemote.js +3 -2
  48. package/dist/components/Breadcrumbs.js +8 -8
  49. package/dist/components/Button.js +6 -6
  50. package/dist/components/Calendar.js +11 -11
  51. package/dist/components/Checkbox.js +7 -7
  52. package/dist/components/CheckboxGroup.js +6 -6
  53. package/dist/components/ColorSwatch.js +6 -6
  54. package/dist/components/ColorSwatchPicker.js +6 -6
  55. package/dist/components/ComboBox.js +17 -17
  56. package/dist/components/DateField.js +9 -9
  57. package/dist/components/DatePicker.js +10 -10
  58. package/dist/components/DateRangePicker.js +14 -14
  59. package/dist/components/Dialog.js +6 -6
  60. package/dist/components/Disclosure.js +13 -13
  61. package/dist/components/DropZone.js +6 -6
  62. package/dist/components/Label.js +16 -16
  63. package/dist/components/Link.js +6 -6
  64. package/dist/components/List.js +34 -34
  65. package/dist/components/Menu.js +10 -10
  66. package/dist/components/Modal.js +8 -8
  67. package/dist/components/MultipleSelect.js +33 -33
  68. package/dist/components/NumberField.d.ts +2 -1
  69. package/dist/components/NumberField.js +21 -11
  70. package/dist/components/Popover.js +6 -6
  71. package/dist/components/ProgressCircle.js +10 -10
  72. package/dist/components/RadioGroup.js +6 -6
  73. package/dist/components/SearchField.js +11 -11
  74. package/dist/components/Select.js +13 -13
  75. package/dist/components/Surface.js +3 -3
  76. package/dist/components/Switch.js +6 -6
  77. package/dist/components/Table.js +13 -13
  78. package/dist/components/Tabs.js +8 -8
  79. package/dist/components/TagGroup.js +7 -7
  80. package/dist/components/TextField.js +10 -10
  81. package/dist/components/TimeField.js +6 -6
  82. package/dist/components/Toggle.js +6 -6
  83. package/dist/components/Toolbar.js +7 -7
  84. package/dist/components/Tooltip.js +10 -10
  85. package/dist/components/Tree.js +9 -9
  86. package/dist/core/BlobTransport.d.ts +5 -0
  87. package/dist/core/BlobTransport.js +79 -0
  88. package/dist/core/Client.d.ts +2 -1
  89. package/dist/core/Client.js +17 -12
  90. package/dist/core/Config.d.ts +4 -0
  91. package/dist/core/Config.js +6 -0
  92. package/dist/core/Connection.d.ts +4 -3
  93. package/dist/core/Connection.js +7 -0
  94. package/dist/core/Graph.d.ts +3 -4
  95. package/dist/core/ListRow.d.ts +2 -0
  96. package/dist/core/OrderBy.d.ts +7 -3
  97. package/dist/core/TextDoc.d.ts +11 -0
  98. package/dist/core/Trace.d.ts +8 -0
  99. package/dist/core/Trace.js +32 -0
  100. package/dist/core/Type.d.ts +7 -1
  101. package/dist/core/db/CommitRequest.d.ts +0 -3
  102. package/dist/core/db/CommitRequest.js +0 -9
  103. package/dist/core/db/EntryDB.js +1 -1
  104. package/dist/core/db/EntryIndex.d.ts +12 -2
  105. package/dist/core/db/EntryIndex.js +131 -22
  106. package/dist/core/db/EntryResolver.js +104 -29
  107. package/dist/core/db/EntryTransaction.d.ts +1 -2
  108. package/dist/core/db/EntryTransaction.js +29 -22
  109. package/dist/core/db/LocalDB.d.ts +5 -5
  110. package/dist/core/db/LocalDB.js +27 -12
  111. package/dist/core/field/RichTextField.d.ts +30 -3
  112. package/dist/core/field/RichTextField.js +124 -56
  113. package/dist/core/media/MediaAltField.d.ts +1 -0
  114. package/dist/core/media/MediaAltField.js +9 -1
  115. package/dist/core/media/MediaLocation.d.ts +5 -2
  116. package/dist/core/media/MediaLocation.js +6 -7
  117. package/dist/core/media/MediaTypes.js +11 -0
  118. package/dist/core/source/CombinedSource.d.ts +2 -2
  119. package/dist/core/source/CombinedSource.js +6 -3
  120. package/dist/core/source/FSSource.d.ts +4 -3
  121. package/dist/core/source/FSSource.js +59 -27
  122. package/dist/core/source/GithubSource.d.ts +2 -2
  123. package/dist/core/source/GithubSource.js +21 -9
  124. package/dist/core/source/IndexedDBSource.d.ts +2 -2
  125. package/dist/core/source/IndexedDBSource.js +3 -1
  126. package/dist/core/source/MemorySource.d.ts +2 -2
  127. package/dist/core/source/MemorySource.js +3 -1
  128. package/dist/core/source/OverlaySource.d.ts +12 -0
  129. package/dist/core/source/OverlaySource.js +50 -0
  130. package/dist/core/source/Source.d.ts +5 -2
  131. package/dist/core/source/Source.js +3 -3
  132. package/dist/core/util/Async.d.ts +8 -2
  133. package/dist/core/util/Async.js +67 -0
  134. package/dist/core/util/EntryFilenames.d.ts +2 -2
  135. package/dist/core/util/EntryFilenames.js +3 -3
  136. package/dist/dashboard/App.css +158 -0
  137. package/dist/dashboard/App.js +2 -2
  138. package/dist/dashboard/app/AccessDenied.js +3 -3
  139. package/dist/dashboard/app/ActivityStatus.js +15 -15
  140. package/dist/dashboard/app/AppShell.js +1 -1
  141. package/dist/dashboard/app/AuthView.js +11 -11
  142. package/dist/dashboard/app/CompactField.js +10 -10
  143. package/dist/dashboard/app/DashboardErrorBoundary.js +5 -5
  144. package/dist/dashboard/app/DashboardLayout.js +22 -19
  145. package/dist/dashboard/app/EntryHeader.js +12 -12
  146. package/dist/dashboard/app/EntryReferences.js +9 -9
  147. package/dist/dashboard/app/EntrySidebar.d.ts +1 -1
  148. package/dist/dashboard/app/EntrySidebar.js +17 -16
  149. package/dist/dashboard/app/EntrySidebarPreview.d.ts +1 -1
  150. package/dist/dashboard/app/EntrySidebarPreview.js +19 -14
  151. package/dist/dashboard/app/EntryTranslationBanner.js +7 -7
  152. package/dist/dashboard/app/Explorer.js +51 -43
  153. package/dist/dashboard/app/ExplorerCards.js +34 -34
  154. package/dist/dashboard/app/ExplorerFileCard.js +18 -18
  155. package/dist/dashboard/app/ExplorerList.js +13 -13
  156. package/dist/dashboard/app/ExplorerModal.js +3 -3
  157. package/dist/dashboard/app/ExplorerTable.js +76 -61
  158. package/dist/dashboard/app/ExternalLinkPicker.js +15 -4
  159. package/dist/dashboard/app/LinkPicker.js +8 -8
  160. package/dist/dashboard/app/LocaleMenu.js +12 -12
  161. package/dist/dashboard/app/SidebarLayout.d.ts +8 -0
  162. package/dist/dashboard/app/SidebarLayout.js +1169 -0
  163. package/dist/dashboard/app/SidebarTree.js +46 -46
  164. package/dist/dashboard/app/WorkspaceMenu.js +17 -17
  165. package/dist/dashboard/app/WorkspaceRoots.js +23 -23
  166. package/dist/dashboard/app/editor/FileEditor.d.ts +2 -1
  167. package/dist/dashboard/app/editor/FileEditor.js +41 -32
  168. package/dist/dashboard/app/editor/FilePreview.js +4 -4
  169. package/dist/dashboard/app/editor/MediaAltField.view.d.ts +1 -1
  170. package/dist/dashboard/app/editor/MediaAltField.view.js +6 -9
  171. package/dist/dashboard/app/modals/CreateEntry.js +4 -4
  172. package/dist/dashboard/app/pages/EntryPage.js +57 -31
  173. package/dist/dashboard/app/pages/UsersPage.js +33 -33
  174. package/dist/dashboard/app/ui/DashboardModal.js +23 -23
  175. package/dist/dashboard/app/ui/Rail.js +3 -3
  176. package/dist/dashboard/app/ui/Sidebar.js +2 -2
  177. package/dist/dashboard/atoms/auth.js +2 -0
  178. package/dist/dashboard/atoms/dashboard.d.ts +9 -0
  179. package/dist/dashboard/atoms/dashboard.js +17 -0
  180. package/dist/dashboard/atoms/editor.d.ts +7 -1
  181. package/dist/dashboard/atoms/editor.js +4 -1
  182. package/dist/dashboard/atoms/entry.d.ts +48 -2
  183. package/dist/dashboard/atoms/entry.js +222 -17
  184. package/dist/dashboard/atoms/explorer.js +4 -9
  185. package/dist/dashboard/atoms/preview.d.ts +3 -0
  186. package/dist/dashboard/atoms/preview.js +18 -1
  187. package/dist/dashboard/atoms/root.d.ts +4 -1
  188. package/dist/dashboard/atoms/root.js +96 -157
  189. package/dist/dashboard/hooks.d.ts +4 -2
  190. package/dist/dashboard/hooks.js +9 -5
  191. package/dist/dashboard/icons.d.ts +1 -0
  192. package/dist/dashboard/icons.js +10 -0
  193. package/dist/field/check/CheckField.view.js +2 -2
  194. package/dist/field/code/CodeField.view.js +12 -12
  195. package/dist/field/date/DateField.view.js +12 -2
  196. package/dist/field/link/FileLink.d.ts +2 -2
  197. package/dist/field/link/FileLink.js +5 -3
  198. package/dist/field/link/ImageLink.d.ts +1 -1
  199. package/dist/field/link/ImageLink.js +1 -1
  200. package/dist/field/link/Link.js +2 -2
  201. package/dist/field/link/LinkField.view.js +155 -128
  202. package/dist/field/list/ListField.view.js +22 -33
  203. package/dist/field/metadata/MetadataField.view.js +19 -19
  204. package/dist/field/number/NumberField.d.ts +2 -0
  205. package/dist/field/number/NumberField.view.js +4 -2
  206. package/dist/field/richtext/PickTextLink.d.ts +7 -0
  207. package/dist/field/richtext/PickTextLink.js +104 -2
  208. package/dist/field/richtext/ReferenceLink.d.ts +4 -1
  209. package/dist/field/richtext/ReferenceLink.js +18 -4
  210. package/dist/field/richtext/RichTextDocument.d.ts +7 -2
  211. package/dist/field/richtext/RichTextDocument.js +34 -5
  212. package/dist/field/richtext/RichTextExtensions.d.ts +3 -1
  213. package/dist/field/richtext/RichTextExtensions.js +2704 -7467
  214. package/dist/field/richtext/RichTextField.d.ts +4 -0
  215. package/dist/field/richtext/RichTextField.story.d.ts +4 -0
  216. package/dist/field/richtext/RichTextField.view.js +43 -20
  217. package/dist/field/richtext/RichTextInsertMenu.js +281 -495
  218. package/dist/field/richtext/RichTextToolbar.d.ts +5 -2
  219. package/dist/field/richtext/RichTextToolbar.js +38 -3
  220. package/dist/field/richtext/Toolbar.d.ts +19 -1
  221. package/dist/field/richtext/Toolbar.js +18 -13
  222. package/dist/field/richtext/extensions/Anchor.js +1 -1
  223. package/dist/field/richtext/extensions/Link.js +1 -1
  224. package/dist/field/richtext/extensions/Small.js +1 -1
  225. package/dist/field/select/SelectField.view.js +8 -6
  226. package/dist/index.css +227 -16
  227. package/dist/next.cjs +18 -16
  228. package/dist/next.d.ts +2 -1
  229. package/dist/next.edge.d.ts +2 -1
  230. package/dist/picker/entry/EntryPicker.js +9 -35
  231. package/dist/preview/PreviewPayload.js +35 -250
  232. package/dist/ui/RichText.d.ts +1 -0
  233. package/dist/ui/RichText.js +29 -2
  234. package/package.json +6 -3
  235. package/dist/cli/util/ExternalPlugin.d.ts +0 -2
  236. package/dist/cli/util/ExternalPlugin.js +0 -919
  237. package/dist/chunks/{chunk-JFROOUG6.js → chunk-NIVGVRDS.js} +17 -17
@@ -0,0 +1,919 @@
1
+ // node_modules/fp16/lib/utils.js
2
+ var float32Buffer = new ArrayBuffer(4);
3
+ var float32View = new DataView(float32Buffer);
4
+ var float16Precision = 10;
5
+ var float16Emax = 15;
6
+ var float16Emin = -14;
7
+ var float32Precision = 23;
8
+ var float32Emax = 127;
9
+ var float32Emin = -126;
10
+
11
+ // node_modules/fp16/lib/getFloat16.js
12
+ function getFloat16(view, offset, littleEndian) {
13
+ const value = view.getUint16(offset, littleEndian);
14
+ const sign = value & 32768;
15
+ const exponent = value & 31744;
16
+ const mantissa = value & 1023;
17
+ if (exponent === 0) {
18
+ if (mantissa === 0) {
19
+ return sign ? -0 : 0;
20
+ } else {
21
+ let e = 127 - 14;
22
+ let m = mantissa;
23
+ while ((m & 1024) === 0) {
24
+ e--;
25
+ m <<= 1;
26
+ }
27
+ m &= ~1024;
28
+ const i = sign << 16 | e << 23 | m << 13;
29
+ float32View.setInt32(0, i, littleEndian);
30
+ return float32View.getFloat32(0, littleEndian);
31
+ }
32
+ } else if (exponent === 31744) {
33
+ if (mantissa === 0) {
34
+ return sign ? -Infinity : Infinity;
35
+ } else {
36
+ return NaN;
37
+ }
38
+ } else {
39
+ const e = exponent + 114688 << 13;
40
+ const m = mantissa << 13;
41
+ const i = sign << 16 | e | m;
42
+ float32View.setInt32(0, i, littleEndian);
43
+ return float32View.getFloat32(0, littleEndian);
44
+ }
45
+ }
46
+
47
+ // node_modules/fp16/lib/setFloat16.js
48
+ function setFloat16(view, offset, value, littleEndian) {
49
+ if (isNaN(value)) {
50
+ return view.setUint16(offset, 32256, littleEndian);
51
+ } else if (value === Infinity) {
52
+ return view.setUint16(offset, 31744, littleEndian);
53
+ } else if (value === -Infinity) {
54
+ return view.setUint16(offset, 64512, littleEndian);
55
+ } else if (Object.is(value, 0)) {
56
+ return view.setUint16(offset, 0, littleEndian);
57
+ } else if (Object.is(value, -0)) {
58
+ return view.setUint16(offset, 32768, littleEndian);
59
+ }
60
+ float32View.setFloat32(0, value, littleEndian);
61
+ const i32 = float32View.getInt32(0, littleEndian);
62
+ const sign = i32 & 1 << 31;
63
+ const exponent = i32 & 2139095040;
64
+ const mantissa = i32 & 8388607;
65
+ const exponentValue = (exponent >>> float32Precision) - float32Emax;
66
+ const e = exponentValue + float16Emax;
67
+ if (float16Emax < exponentValue) {
68
+ return view.setUint16(offset, sign >>> 16 | 31744, littleEndian);
69
+ }
70
+ if (exponentValue < float16Emin) {
71
+ if (14 - e > 24) {
72
+ return view.setUint16(0, sign >>> 16, littleEndian);
73
+ } else {
74
+ const c = mantissa | 8388608;
75
+ const m = c >>> 14 - e;
76
+ const r2 = 1 << 13 - e;
77
+ if (c & r2 && c & 3 * r2 - 1) {
78
+ return view.setUint16(offset, sign >>> 16 | m + 1, littleEndian);
79
+ } else {
80
+ return view.setUint16(offset, sign >>> 16 | m, littleEndian);
81
+ }
82
+ }
83
+ }
84
+ const r = 4096;
85
+ let i16 = sign >>> 16 | e << 10 | mantissa >> 13;
86
+ if (mantissa & r && mantissa & 3 * r - 1) {
87
+ return view.setUint16(offset, i16 + 1, littleEndian);
88
+ } else {
89
+ return view.setUint16(offset, i16, littleEndian);
90
+ }
91
+ }
92
+
93
+ // node_modules/fp16/lib/precision.js
94
+ var float64Buffer = new ArrayBuffer(8);
95
+ var float64View = new DataView(float64Buffer);
96
+ var Precision = {
97
+ Exact: 0,
98
+ Inexact: 1,
99
+ Underflow: 2,
100
+ Overflow: 3
101
+ };
102
+ function getFloat16Precision(value) {
103
+ if (isNaN(value) || value === 0) {
104
+ return Precision.Exact;
105
+ } else if (value === Infinity || value === -Infinity) {
106
+ return Precision.Exact;
107
+ }
108
+ float64View.setFloat64(0, value);
109
+ const a = float64View.getInt32(0);
110
+ const b = float64View.getInt32(4);
111
+ const exponent = a & 2146435072;
112
+ const exponentValue = (exponent >>> 20) - 1023;
113
+ if (float16Emax < exponentValue) {
114
+ return Precision.Overflow;
115
+ } else if (exponentValue < float16Emin - float16Precision) {
116
+ return Precision.Underflow;
117
+ }
118
+ const significantBits = getSignificantBits(a & 1048575, b);
119
+ if (float16Precision < significantBits) {
120
+ return Precision.Inexact;
121
+ }
122
+ if (exponentValue < float16Emin) {
123
+ if (float16Emin - exponentValue <= float16Precision - significantBits) {
124
+ return Precision.Exact;
125
+ } else {
126
+ return Precision.Inexact;
127
+ }
128
+ } else {
129
+ return Precision.Exact;
130
+ }
131
+ }
132
+ function getFloat32Precision(value) {
133
+ if (isNaN(value) || value === 0) {
134
+ return Precision.Exact;
135
+ } else if (value === Infinity || value === -Infinity) {
136
+ return Precision.Exact;
137
+ }
138
+ float64View.setFloat64(0, value);
139
+ const a = float64View.getInt32(0);
140
+ const b = float64View.getInt32(4);
141
+ const exponent = a & 2146435072;
142
+ const exponentValue = (exponent >>> 20) - 1023;
143
+ if (float32Emax < exponentValue) {
144
+ return Precision.Overflow;
145
+ } else if (exponentValue < float32Emin - float32Precision) {
146
+ return Precision.Underflow;
147
+ }
148
+ const significantBits = getSignificantBits(a & 1048575, b);
149
+ if (float32Precision < significantBits) {
150
+ return Precision.Inexact;
151
+ }
152
+ if (exponentValue < float32Emin) {
153
+ if (float32Emin - exponentValue <= float32Precision - significantBits) {
154
+ return Precision.Exact;
155
+ } else {
156
+ return Precision.Inexact;
157
+ }
158
+ } else {
159
+ return Precision.Exact;
160
+ }
161
+ }
162
+ function getSignificantBits(a, b) {
163
+ if (b) {
164
+ let offsetB = 0;
165
+ for (let shiftedB = b; shiftedB; shiftedB <<= 1) {
166
+ offsetB++;
167
+ }
168
+ return offsetB + 20;
169
+ } else {
170
+ let offsetA = 0;
171
+ for (let shiftedA = a << 12; shiftedA; shiftedA <<= 1) {
172
+ offsetA++;
173
+ }
174
+ return offsetA;
175
+ }
176
+ }
177
+
178
+ // node_modules/microcbor/lib/options.js
179
+ var FloatSize = {
180
+ f16: 16,
181
+ f32: 32,
182
+ f64: 64
183
+ };
184
+
185
+ // node_modules/microcbor/lib/utils.js
186
+ var maxSafeInteger = BigInt(Number.MAX_SAFE_INTEGER);
187
+ var minSafeInteger = BigInt(Number.MIN_SAFE_INTEGER);
188
+ var UnsafeIntegerError = class extends RangeError {
189
+ constructor(message, value) {
190
+ super(message);
191
+ this.value = value;
192
+ }
193
+ };
194
+ var AssertError = class extends Error {
195
+ constructor(message, props) {
196
+ super(message);
197
+ this.message = message;
198
+ this.props = props;
199
+ }
200
+ };
201
+ function assert(condition, message = "assertion failed", props) {
202
+ if (!condition) {
203
+ throw new AssertError(message, props);
204
+ }
205
+ }
206
+
207
+ // node_modules/microcbor/lib/Encoder.js
208
+ var __classPrivateFieldSet = function(receiver, state, value, kind, f) {
209
+ if (kind === "m") throw new TypeError("Private method is not writable");
210
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
211
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
212
+ return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
213
+ };
214
+ var __classPrivateFieldGet = function(receiver, state, kind, f) {
215
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
216
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
217
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
218
+ };
219
+ var _Encoder_instances;
220
+ var _Encoder_closed;
221
+ var _Encoder_flush;
222
+ var Encoder = class _Encoder {
223
+ constructor(options = {}) {
224
+ _Encoder_instances.add(this);
225
+ _Encoder_closed.set(this, void 0);
226
+ this.encoder = new TextEncoder();
227
+ this.allowUndefined = options.allowUndefined ?? true;
228
+ this.minFloatSize = options.minFloatSize ?? 16;
229
+ this.chunkRecycling = options.chunkRecycling ?? false;
230
+ this.chunkSize = options.chunkSize ?? _Encoder.defaultChunkSize;
231
+ assert(this.chunkSize >= 8, "expected chunkSize >= 8");
232
+ this.buffer = new ArrayBuffer(this.chunkSize);
233
+ this.view = new DataView(this.buffer);
234
+ this.array = new Uint8Array(this.buffer, 0, this.chunkSize);
235
+ this.offset = 0;
236
+ __classPrivateFieldSet(this, _Encoder_closed, false, "f");
237
+ }
238
+ get closed() {
239
+ return __classPrivateFieldGet(this, _Encoder_closed, "f");
240
+ }
241
+ *allocate(size) {
242
+ assert(size <= 8, "expected size <= 8");
243
+ if (this.buffer.byteLength < this.offset + size) {
244
+ yield __classPrivateFieldGet(this, _Encoder_instances, "m", _Encoder_flush).call(this);
245
+ }
246
+ }
247
+ *float16(value) {
248
+ yield* this.allocate(2);
249
+ setFloat16(this.view, this.offset, value);
250
+ this.offset += 2;
251
+ }
252
+ *float32(value) {
253
+ yield* this.allocate(4);
254
+ this.view.setFloat32(this.offset, value);
255
+ this.offset += 4;
256
+ }
257
+ *float64(value) {
258
+ yield* this.allocate(8);
259
+ this.view.setFloat64(this.offset, value);
260
+ this.offset += 8;
261
+ }
262
+ *uint8(value) {
263
+ yield* this.allocate(1);
264
+ this.view.setUint8(this.offset, value);
265
+ this.offset += 1;
266
+ }
267
+ *uint16(value) {
268
+ yield* this.allocate(2);
269
+ this.view.setUint16(this.offset, value);
270
+ this.offset += 2;
271
+ }
272
+ *uint32(value) {
273
+ yield* this.allocate(4);
274
+ this.view.setUint32(this.offset, value);
275
+ this.offset += 4;
276
+ }
277
+ *uint64(value) {
278
+ yield* this.allocate(8);
279
+ this.view.setBigUint64(this.offset, BigInt(value));
280
+ this.offset += 8;
281
+ }
282
+ *encodeTypeAndArgument(type, argument) {
283
+ const additionalInformation = _Encoder.getAdditionalInformation(argument);
284
+ yield* this.uint8(type << 5 | additionalInformation);
285
+ switch (additionalInformation) {
286
+ case 24:
287
+ return yield* this.uint8(argument);
288
+ case 25:
289
+ return yield* this.uint16(argument);
290
+ case 26:
291
+ return yield* this.uint32(argument);
292
+ case 27:
293
+ return yield* this.uint64(argument);
294
+ }
295
+ }
296
+ *encodeNumber(value) {
297
+ if (Object.is(value, 0)) {
298
+ yield* this.encodeInteger(value);
299
+ } else if (Object.is(value, -0)) {
300
+ yield* this.encodeFloat(value);
301
+ } else if (Math.floor(value) === value && Number.MIN_SAFE_INTEGER <= value && value <= Number.MAX_SAFE_INTEGER) {
302
+ yield* this.encodeInteger(value);
303
+ } else {
304
+ yield* this.encodeFloat(value);
305
+ }
306
+ }
307
+ *encodeInteger(value) {
308
+ if (value < 0) {
309
+ yield* this.encodeTypeAndArgument(1, -value - 1);
310
+ } else {
311
+ yield* this.encodeTypeAndArgument(0, value);
312
+ }
313
+ }
314
+ *encodeFloat(value) {
315
+ if (this.minFloatSize === FloatSize.f16 && getFloat16Precision(value) === Precision.Exact) {
316
+ yield* this.uint8(224 | 25);
317
+ yield* this.float16(value);
318
+ } else if (this.minFloatSize <= FloatSize.f32 && getFloat32Precision(value) === Precision.Exact) {
319
+ yield* this.uint8(224 | 26);
320
+ yield* this.float32(value);
321
+ } else {
322
+ yield* this.uint8(224 | 27);
323
+ yield* this.float64(value);
324
+ }
325
+ }
326
+ *encodeString(value) {
327
+ const bytes = this.encoder.encode(value);
328
+ yield* this.encodeTypeAndArgument(3, bytes.byteLength);
329
+ yield* this.writeBytes(bytes);
330
+ }
331
+ *encodeBytes(value) {
332
+ yield* this.encodeTypeAndArgument(2, value.byteLength);
333
+ yield* this.writeBytes(value);
334
+ }
335
+ *writeBytes(value) {
336
+ let start = 0;
337
+ while (start < value.byteLength) {
338
+ if (this.offset >= this.buffer.byteLength) {
339
+ yield __classPrivateFieldGet(this, _Encoder_instances, "m", _Encoder_flush).call(this);
340
+ }
341
+ const capacity = this.buffer.byteLength - this.offset;
342
+ const remaining = value.byteLength - start;
343
+ const chunkLength = Math.min(capacity, remaining);
344
+ this.array.set(value.subarray(start, start + chunkLength), this.offset);
345
+ start += chunkLength;
346
+ this.offset += chunkLength;
347
+ }
348
+ }
349
+ *encodeValue(value) {
350
+ if (__classPrivateFieldGet(this, _Encoder_closed, "f")) {
351
+ return;
352
+ }
353
+ if (value === false) {
354
+ yield* this.uint8(244);
355
+ } else if (value === true) {
356
+ yield* this.uint8(245);
357
+ } else if (value === null) {
358
+ yield* this.uint8(246);
359
+ } else if (value === void 0) {
360
+ if (this.allowUndefined) {
361
+ yield* this.uint8(247);
362
+ } else {
363
+ throw new TypeError("`undefined` is not allowed");
364
+ }
365
+ } else if (typeof value === "number") {
366
+ yield* this.encodeNumber(value);
367
+ } else if (typeof value === "string") {
368
+ yield* this.encodeString(value);
369
+ } else if (value instanceof Uint8Array) {
370
+ yield* this.encodeBytes(value);
371
+ } else if (Array.isArray(value)) {
372
+ yield* this.encodeTypeAndArgument(4, value.length);
373
+ for (const element of value) {
374
+ yield* this.encodeValue(element);
375
+ }
376
+ } else {
377
+ const entries = Object.entries(value).map(([key, value2]) => [this.encoder.encode(key), value2]).sort(_Encoder.compareEntries);
378
+ yield* this.encodeTypeAndArgument(5, entries.length);
379
+ for (const [key, value2] of entries) {
380
+ yield* this.encodeTypeAndArgument(3, key.byteLength);
381
+ yield* this.writeBytes(key);
382
+ yield* this.encodeValue(value2);
383
+ }
384
+ }
385
+ }
386
+ *flush() {
387
+ if (__classPrivateFieldGet(this, _Encoder_closed, "f")) {
388
+ return;
389
+ }
390
+ if (this.offset > 0) {
391
+ yield __classPrivateFieldGet(this, _Encoder_instances, "m", _Encoder_flush).call(this);
392
+ }
393
+ }
394
+ // Per the deterministic CBOR spec, we're supposed to sort keys
395
+ // the byte-wise lexicographic order of the key's CBOR encoding
396
+ // - ie lower major types come before higher major types.
397
+ // One thing we know for sure about strings is that a string with
398
+ // a smaller length will sort byte-wise before a string
399
+ // with a longer length, since strings are encoded with a length
400
+ // prefix (either in the additionalInformation bits, if < 24, or
401
+ // in the next serveral bytes, but in all cases the order holds).
402
+ static compareEntries([a], [b]) {
403
+ if (a.byteLength < b.byteLength)
404
+ return -1;
405
+ if (b.byteLength < a.byteLength)
406
+ return 1;
407
+ for (let i = 0; i < a.byteLength; i++) {
408
+ if (a[i] < b[i])
409
+ return -1;
410
+ if (b[i] < a[i])
411
+ return 1;
412
+ }
413
+ return 0;
414
+ }
415
+ static getAdditionalInformation(argument) {
416
+ if (argument < 24) {
417
+ return argument;
418
+ } else if (argument < 256) {
419
+ return 24;
420
+ } else if (argument < 65536) {
421
+ return 25;
422
+ } else if (argument < 4294967296) {
423
+ return 26;
424
+ } else {
425
+ return 27;
426
+ }
427
+ }
428
+ };
429
+ _Encoder_closed = /* @__PURE__ */ new WeakMap(), _Encoder_instances = /* @__PURE__ */ new WeakSet(), _Encoder_flush = function _Encoder_flush2() {
430
+ if (this.chunkRecycling) {
431
+ const chunk = new Uint8Array(this.buffer, 0, this.offset);
432
+ this.offset = 0;
433
+ return chunk;
434
+ } else {
435
+ const chunk = new Uint8Array(this.offset);
436
+ chunk.set(new Uint8Array(this.buffer, 0, this.offset));
437
+ this.offset = 0;
438
+ return chunk;
439
+ }
440
+ };
441
+ Encoder.defaultChunkSize = 4096;
442
+ function encode(value, options = {}) {
443
+ const encoder = new Encoder({ ...options, chunkRecycling: false });
444
+ let byteLength = 0;
445
+ const chunks = [];
446
+ for (const chunk of encoder.encodeValue(value)) {
447
+ chunks.push(chunk);
448
+ byteLength += chunk.byteLength;
449
+ }
450
+ for (const chunk of encoder.flush()) {
451
+ chunks.push(chunk);
452
+ byteLength += chunk.byteLength;
453
+ }
454
+ const data = new Uint8Array(byteLength);
455
+ let offset = 0;
456
+ for (const chunk of chunks) {
457
+ data.set(chunk, offset);
458
+ offset += chunk.length;
459
+ }
460
+ return data;
461
+ }
462
+
463
+ // node_modules/microcbor/lib/Decoder.js
464
+ var __classPrivateFieldSet2 = function(receiver, state, value, kind, f) {
465
+ if (kind === "m") throw new TypeError("Private method is not writable");
466
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
467
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
468
+ return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
469
+ };
470
+ var __classPrivateFieldGet2 = function(receiver, state, kind, f) {
471
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
472
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
473
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
474
+ };
475
+ var _Decoder_offset;
476
+ var _Decoder_view;
477
+ var Decoder = class {
478
+ constructor(data, options = {}) {
479
+ this.data = data;
480
+ _Decoder_offset.set(this, void 0);
481
+ _Decoder_view.set(this, void 0);
482
+ this.constant = (size, f) => () => {
483
+ const value = f();
484
+ __classPrivateFieldSet2(this, _Decoder_offset, __classPrivateFieldGet2(this, _Decoder_offset, "f") + size, "f");
485
+ return value;
486
+ };
487
+ this.float16 = this.constant(2, () => getFloat16(__classPrivateFieldGet2(this, _Decoder_view, "f"), __classPrivateFieldGet2(this, _Decoder_offset, "f")));
488
+ this.float32 = this.constant(4, () => __classPrivateFieldGet2(this, _Decoder_view, "f").getFloat32(__classPrivateFieldGet2(this, _Decoder_offset, "f")));
489
+ this.float64 = this.constant(8, () => __classPrivateFieldGet2(this, _Decoder_view, "f").getFloat64(__classPrivateFieldGet2(this, _Decoder_offset, "f")));
490
+ this.uint8 = this.constant(1, () => __classPrivateFieldGet2(this, _Decoder_view, "f").getUint8(__classPrivateFieldGet2(this, _Decoder_offset, "f")));
491
+ this.uint16 = this.constant(2, () => __classPrivateFieldGet2(this, _Decoder_view, "f").getUint16(__classPrivateFieldGet2(this, _Decoder_offset, "f")));
492
+ this.uint32 = this.constant(4, () => __classPrivateFieldGet2(this, _Decoder_view, "f").getUint32(__classPrivateFieldGet2(this, _Decoder_offset, "f")));
493
+ this.uint64 = this.constant(8, () => __classPrivateFieldGet2(this, _Decoder_view, "f").getBigUint64(__classPrivateFieldGet2(this, _Decoder_offset, "f")));
494
+ __classPrivateFieldSet2(this, _Decoder_offset, 0, "f");
495
+ __classPrivateFieldSet2(this, _Decoder_view, new DataView(data.buffer, data.byteOffset, data.byteLength), "f");
496
+ this.allowUndefined = options.allowUndefined ?? true;
497
+ this.minFloatSize = options.minFloatSize ?? 16;
498
+ }
499
+ getOffset() {
500
+ return __classPrivateFieldGet2(this, _Decoder_offset, "f");
501
+ }
502
+ decodeBytes(length) {
503
+ const value = new Uint8Array(length);
504
+ value.set(this.data.subarray(__classPrivateFieldGet2(this, _Decoder_offset, "f"), __classPrivateFieldGet2(this, _Decoder_offset, "f") + length), 0);
505
+ __classPrivateFieldSet2(this, _Decoder_offset, __classPrivateFieldGet2(this, _Decoder_offset, "f") + length, "f");
506
+ return value;
507
+ }
508
+ decodeString(length) {
509
+ const value = new TextDecoder().decode(this.data.subarray(__classPrivateFieldGet2(this, _Decoder_offset, "f"), __classPrivateFieldGet2(this, _Decoder_offset, "f") + length));
510
+ __classPrivateFieldSet2(this, _Decoder_offset, __classPrivateFieldGet2(this, _Decoder_offset, "f") + length, "f");
511
+ return value;
512
+ }
513
+ getArgument(additionalInformation) {
514
+ if (additionalInformation < 24) {
515
+ return { value: additionalInformation };
516
+ } else if (additionalInformation === 24) {
517
+ return { value: this.uint8() };
518
+ } else if (additionalInformation === 25) {
519
+ return { value: this.uint16() };
520
+ } else if (additionalInformation === 26) {
521
+ return { value: this.uint32() };
522
+ } else if (additionalInformation === 27) {
523
+ const uint64 = this.uint64();
524
+ const value = maxSafeInteger < uint64 ? Infinity : Number(uint64);
525
+ return { value, uint64 };
526
+ } else if (additionalInformation === 31) {
527
+ throw new Error("microcbor does not support decoding indefinite-length items");
528
+ } else {
529
+ throw new Error("invalid argument encoding");
530
+ }
531
+ }
532
+ decodeValue() {
533
+ const initialByte = this.uint8();
534
+ const majorType = initialByte >> 5;
535
+ const additionalInformation = initialByte & 31;
536
+ if (majorType === 0) {
537
+ const { value, uint64 } = this.getArgument(additionalInformation);
538
+ if (uint64 !== void 0 && maxSafeInteger < uint64) {
539
+ throw new UnsafeIntegerError("cannot decode integers greater than 2^53-1", uint64);
540
+ } else {
541
+ return value;
542
+ }
543
+ } else if (majorType === 1) {
544
+ const { value, uint64 } = this.getArgument(additionalInformation);
545
+ if (uint64 !== void 0 && -1n - uint64 < minSafeInteger) {
546
+ throw new UnsafeIntegerError("cannot decode integers less than -2^53+1", -1n - uint64);
547
+ } else {
548
+ return -1 - value;
549
+ }
550
+ } else if (majorType === 2) {
551
+ const { value: length } = this.getArgument(additionalInformation);
552
+ return this.decodeBytes(length);
553
+ } else if (majorType === 3) {
554
+ const { value: length } = this.getArgument(additionalInformation);
555
+ return this.decodeString(length);
556
+ } else if (majorType === 4) {
557
+ const { value: length } = this.getArgument(additionalInformation);
558
+ const value = new Array(length);
559
+ for (let i = 0; i < length; i++) {
560
+ value[i] = this.decodeValue();
561
+ }
562
+ return value;
563
+ } else if (majorType === 5) {
564
+ const { value: length } = this.getArgument(additionalInformation);
565
+ const value = {};
566
+ for (let i = 0; i < length; i++) {
567
+ const key = this.decodeValue();
568
+ if (typeof key !== "string") {
569
+ throw new Error("microcbor only supports string keys in objects");
570
+ }
571
+ value[key] = this.decodeValue();
572
+ }
573
+ return value;
574
+ } else if (majorType === 6) {
575
+ throw new Error("microcbor does not support tagged data items");
576
+ } else if (majorType === 7) {
577
+ switch (additionalInformation) {
578
+ case 20:
579
+ return false;
580
+ case 21:
581
+ return true;
582
+ case 22:
583
+ return null;
584
+ case 23:
585
+ if (this.allowUndefined) {
586
+ return void 0;
587
+ } else {
588
+ throw new TypeError("`undefined` not allowed");
589
+ }
590
+ case 24:
591
+ throw new Error("microcbor does not support decoding unassigned simple values");
592
+ case 25:
593
+ if (this.minFloatSize <= 16) {
594
+ return this.float16();
595
+ } else {
596
+ throw new Error("cannot decode float16 type - below provided minFloatSize");
597
+ }
598
+ case 26:
599
+ if (this.minFloatSize <= 32) {
600
+ return this.float32();
601
+ } else {
602
+ throw new Error("cannot decode float32 type - below provided minFloatSize");
603
+ }
604
+ case 27:
605
+ return this.float64();
606
+ case 31:
607
+ throw new Error("microcbor does not support decoding indefinite-length items");
608
+ default:
609
+ throw new Error("invalid simple value");
610
+ }
611
+ } else {
612
+ throw new Error("invalid major type");
613
+ }
614
+ }
615
+ };
616
+ _Decoder_offset = /* @__PURE__ */ new WeakMap(), _Decoder_view = /* @__PURE__ */ new WeakMap();
617
+ function decode(data, options = {}) {
618
+ return new Decoder(data, options).decodeValue();
619
+ }
620
+
621
+ // node_modules/microcbor/lib/encodeAsyncIterable.js
622
+ async function* encodeAsyncIterable(source, options = {}) {
623
+ const encoder = new Encoder(options);
624
+ for await (const value of source) {
625
+ yield* encoder.encodeValue(value);
626
+ }
627
+ yield* encoder.flush();
628
+ }
629
+
630
+ // node_modules/microcbor/lib/decodeAsyncIterable.js
631
+ var _a;
632
+ var Decoder2 = class {
633
+ constructor(source, options = {}) {
634
+ this.offset = 0;
635
+ this.byteLength = 0;
636
+ this.chunks = [];
637
+ this.constantBuffer = new ArrayBuffer(8);
638
+ this.constantView = new DataView(this.constantBuffer);
639
+ this.touchedChunks = /* @__PURE__ */ new WeakSet();
640
+ this.freedChunks = /* @__PURE__ */ new WeakSet();
641
+ this[_a] = () => this;
642
+ this.constant = (size, f) => {
643
+ return async () => {
644
+ await this.allocate(size);
645
+ const array = new Uint8Array(this.constantBuffer, 0, size);
646
+ this.fill(array);
647
+ return f(this.constantView);
648
+ };
649
+ };
650
+ this.float16 = this.constant(2, (view) => getFloat16(view, 0));
651
+ this.float32 = this.constant(4, (view) => view.getFloat32(0));
652
+ this.float64 = this.constant(8, (view) => view.getFloat64(0));
653
+ this.uint8 = this.constant(1, (view) => view.getUint8(0));
654
+ this.uint16 = this.constant(2, (view) => view.getUint16(0));
655
+ this.uint32 = this.constant(4, (view) => view.getUint32(0));
656
+ this.uint64 = this.constant(8, (view) => view.getBigUint64(0));
657
+ this.onFree = options.onFree;
658
+ this.allowUndefined = options.allowUndefined ?? true;
659
+ this.minFloatSize = options.minFloatSize ?? 16;
660
+ this.iter = source[Symbol.asyncIterator]();
661
+ }
662
+ async allocate(size) {
663
+ if (this.byteLength < size && this.onFree !== void 0) {
664
+ for (const chunk of this.chunks) {
665
+ if (this.touchedChunks.has(chunk) && !this.freedChunks.has(chunk)) {
666
+ this.freedChunks.add(chunk);
667
+ this.onFree(chunk);
668
+ }
669
+ }
670
+ }
671
+ while (this.byteLength < size) {
672
+ const { done, value } = await this.iter.next();
673
+ if (done) {
674
+ throw new Error("stream ended prematurely");
675
+ } else {
676
+ this.chunks.push(value);
677
+ this.byteLength += value.byteLength;
678
+ if (this.byteLength < size && this.onFree !== void 0 && !this.freedChunks.has(value)) {
679
+ this.freedChunks.add(value);
680
+ this.onFree(value);
681
+ }
682
+ }
683
+ }
684
+ }
685
+ fill(target) {
686
+ if (this.byteLength < target.byteLength) {
687
+ throw new Error("internal error - please file a bug report!");
688
+ }
689
+ let byteLength = 0;
690
+ let deleteCount = 0;
691
+ for (let i = 0; byteLength < target.byteLength; i++) {
692
+ const chunk = this.chunks[i];
693
+ if (!this.touchedChunks.has(chunk)) {
694
+ this.touchedChunks.add(chunk);
695
+ }
696
+ const capacity = target.byteLength - byteLength;
697
+ const length = chunk.byteLength - this.offset;
698
+ if (length <= capacity) {
699
+ target.set(chunk.subarray(this.offset), byteLength);
700
+ byteLength += length;
701
+ deleteCount += 1;
702
+ this.offset = 0;
703
+ this.byteLength -= length;
704
+ } else {
705
+ target.set(chunk.subarray(this.offset, this.offset + capacity), byteLength);
706
+ byteLength += capacity;
707
+ this.offset += capacity;
708
+ this.byteLength -= capacity;
709
+ }
710
+ }
711
+ if (this.onFree !== void 0) {
712
+ for (let i = 0; i < deleteCount; i++) {
713
+ const chunk = this.chunks[i];
714
+ if (!this.freedChunks.has(chunk)) {
715
+ this.freedChunks.add(chunk);
716
+ this.onFree(chunk);
717
+ }
718
+ }
719
+ }
720
+ this.chunks.splice(0, deleteCount);
721
+ }
722
+ async decodeBytes(length) {
723
+ await this.allocate(length);
724
+ const array = new Uint8Array(length);
725
+ this.fill(array);
726
+ return array;
727
+ }
728
+ async decodeString(length) {
729
+ await this.allocate(length);
730
+ const data = new Uint8Array(length);
731
+ this.fill(data);
732
+ return new TextDecoder().decode(data);
733
+ }
734
+ async getArgument(additionalInformation) {
735
+ if (additionalInformation < 24) {
736
+ return { value: additionalInformation };
737
+ } else if (additionalInformation === 24) {
738
+ return { value: await this.uint8() };
739
+ } else if (additionalInformation === 25) {
740
+ return { value: await this.uint16() };
741
+ } else if (additionalInformation === 26) {
742
+ return { value: await this.uint32() };
743
+ } else if (additionalInformation === 27) {
744
+ const uint64 = await this.uint64();
745
+ const value = maxSafeInteger < uint64 ? Infinity : Number(uint64);
746
+ return { value, uint64 };
747
+ } else if (additionalInformation === 31) {
748
+ throw new Error("microcbor does not support decoding indefinite-length items");
749
+ } else {
750
+ throw new Error("invalid argument encoding");
751
+ }
752
+ }
753
+ async next() {
754
+ while (this.byteLength === 0) {
755
+ const { done, value: value2 } = await this.iter.next();
756
+ if (done) {
757
+ return { done: true, value: void 0 };
758
+ } else if (value2.byteLength > 0) {
759
+ this.chunks.push(value2);
760
+ this.byteLength += value2.byteLength;
761
+ }
762
+ }
763
+ const value = await this.decodeValue();
764
+ return { done: false, value };
765
+ }
766
+ async decodeValue() {
767
+ const initialByte = await this.uint8();
768
+ const majorType = initialByte >> 5;
769
+ const additionalInformation = initialByte & 31;
770
+ if (majorType === 0) {
771
+ const { value, uint64 } = await this.getArgument(additionalInformation);
772
+ if (uint64 !== void 0 && maxSafeInteger < uint64) {
773
+ throw new UnsafeIntegerError("cannot decode integers greater than 2^53-1", uint64);
774
+ } else {
775
+ return value;
776
+ }
777
+ } else if (majorType === 1) {
778
+ const { value, uint64 } = await this.getArgument(additionalInformation);
779
+ if (uint64 !== void 0 && -1n - uint64 < minSafeInteger) {
780
+ throw new UnsafeIntegerError("cannot decode integers less than -2^53+1", -1n - uint64);
781
+ } else {
782
+ return -1 - value;
783
+ }
784
+ } else if (majorType === 2) {
785
+ const { value: length } = await this.getArgument(additionalInformation);
786
+ return await this.decodeBytes(length);
787
+ } else if (majorType === 3) {
788
+ const { value: length } = await this.getArgument(additionalInformation);
789
+ return await this.decodeString(length);
790
+ } else if (majorType === 4) {
791
+ const { value: length } = await this.getArgument(additionalInformation);
792
+ const value = new Array(length);
793
+ for (let i = 0; i < length; i++) {
794
+ value[i] = await this.decodeValue();
795
+ }
796
+ return value;
797
+ } else if (majorType === 5) {
798
+ const { value: length } = await this.getArgument(additionalInformation);
799
+ const value = {};
800
+ for (let i = 0; i < length; i++) {
801
+ const key = await this.decodeValue();
802
+ if (typeof key !== "string") {
803
+ throw new Error("microcbor only supports string keys in objects");
804
+ }
805
+ value[key] = await this.decodeValue();
806
+ }
807
+ return value;
808
+ } else if (majorType === 6) {
809
+ throw new Error("microcbor does not support tagged data items");
810
+ } else if (majorType === 7) {
811
+ switch (additionalInformation) {
812
+ case 20:
813
+ return false;
814
+ case 21:
815
+ return true;
816
+ case 22:
817
+ return null;
818
+ case 23:
819
+ if (this.allowUndefined) {
820
+ return void 0;
821
+ } else {
822
+ throw new TypeError("`undefined` not allowed");
823
+ }
824
+ case 24:
825
+ throw new Error("microcbor does not support decoding unassigned simple values");
826
+ case 25:
827
+ if (this.minFloatSize <= 16) {
828
+ return this.float16();
829
+ } else {
830
+ throw new Error("cannot decode float16 type - below provided minFloatSize");
831
+ }
832
+ case 26:
833
+ if (this.minFloatSize <= 32) {
834
+ return this.float32();
835
+ } else {
836
+ throw new Error("cannot decode float32 type - below provided minFloatSize");
837
+ }
838
+ case 27:
839
+ return await this.float64();
840
+ case 31:
841
+ throw new Error("microcbor does not support decoding indefinite-length items");
842
+ default:
843
+ throw new Error("invalid simple value");
844
+ }
845
+ } else {
846
+ throw new Error("invalid major type");
847
+ }
848
+ }
849
+ };
850
+ _a = Symbol.asyncIterator;
851
+ async function* decodeAsyncIterable(source, options = {}) {
852
+ yield* new Decoder2(source, options);
853
+ }
854
+
855
+ // node_modules/microcbor/lib/decodeIterable.js
856
+ var _a2;
857
+ _a2 = Symbol.iterator;
858
+
859
+ // node_modules/microcbor/lib/CBORDecoderStream.js
860
+ var CBORDecoderStream = class extends TransformStream {
861
+ constructor(options = {}) {
862
+ let readableController;
863
+ const readable = new ReadableStream({
864
+ start(controller) {
865
+ readableController = controller;
866
+ }
867
+ });
868
+ const chunks = /* @__PURE__ */ new WeakMap();
869
+ async function pipe(controller) {
870
+ const decoder = new Decoder2(readable.values(), {
871
+ ...options,
872
+ onFree: (chunk) => chunks.get(chunk)?.resolve()
873
+ });
874
+ for await (const value of decoder) {
875
+ controller.enqueue(value);
876
+ }
877
+ }
878
+ super({
879
+ start(controller) {
880
+ pipe(controller).catch((err) => controller.error(err));
881
+ },
882
+ transform(chunk) {
883
+ return new Promise((resolve) => {
884
+ chunks.set(chunk, { resolve });
885
+ readableController.enqueue(chunk);
886
+ });
887
+ },
888
+ flush() {
889
+ readableController.close();
890
+ }
891
+ });
892
+ }
893
+ };
894
+
895
+ // node_modules/microcbor/lib/CBOREncoderStream.js
896
+ var CBOREncoderStream = class extends TransformStream {
897
+ constructor(options = {}) {
898
+ const encoder = new Encoder({ ...options, chunkRecycling: false });
899
+ super({
900
+ transform(value, controller) {
901
+ for (const chunk of encoder.encodeValue(value)) {
902
+ controller.enqueue(chunk);
903
+ }
904
+ },
905
+ flush(controller) {
906
+ for (const chunk of encoder.flush()) {
907
+ controller.enqueue(chunk);
908
+ }
909
+ }
910
+ });
911
+ }
912
+ };
913
+
914
+ export {
915
+ encode,
916
+ decode,
917
+ encodeAsyncIterable,
918
+ decodeAsyncIterable
919
+ };