@holoscript/core 6.0.4 → 7.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.
Files changed (236) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1 -1
  3. package/dist/compiler/index.d.ts +82 -0
  4. package/dist/constants.d.ts +3 -2
  5. package/dist/coordinators/index.d.ts +189 -0
  6. package/dist/index.d.ts +501 -19
  7. package/dist/paper-0c-spike/index.d.ts +29 -0
  8. package/dist/reconstruction/index.d.ts +78 -0
  9. package/dist/tools/index.d.ts +22 -1
  10. package/dist/traitDocs/traitDocs.d.ts +69 -0
  11. package/dist/traits/index.d.ts +61 -0
  12. package/package.json +105 -57
  13. package/dist/GLTFPipeline-DEN36VNK.js +0 -12
  14. package/dist/GLTFPipeline-YPCAK236.cjs +0 -33
  15. package/dist/HoloScriptPlusParser-BN6KVRCM.js +0 -692
  16. package/dist/HoloScriptPlusParser-NC5FE6AL.cjs +0 -697
  17. package/dist/USDZExporter-NTMBNTDB.js +0 -707
  18. package/dist/USDZExporter-UWGWNMMD.cjs +0 -709
  19. package/dist/chunk-27LWW5FU.cjs +0 -410
  20. package/dist/chunk-2CWOLHTE.js +0 -69
  21. package/dist/chunk-33LSUQDD.cjs +0 -835
  22. package/dist/chunk-3FJCK5XA.js +0 -2232
  23. package/dist/chunk-3FXV5S25.cjs +0 -633
  24. package/dist/chunk-3FYZOR7S.cjs +0 -69
  25. package/dist/chunk-3SAK5KFL.cjs +0 -83
  26. package/dist/chunk-4XSNJCLC.cjs +0 -1859
  27. package/dist/chunk-54FHG2MX.js +0 -655
  28. package/dist/chunk-56IF4NTA.js +0 -56
  29. package/dist/chunk-5BGSECRJ.cjs +0 -2237
  30. package/dist/chunk-5GLCTO44.js +0 -161
  31. package/dist/chunk-5O6TQC6M.cjs +0 -1871
  32. package/dist/chunk-5OEOHAAW.cjs +0 -682
  33. package/dist/chunk-5TOFIR6L.js +0 -407
  34. package/dist/chunk-5WUNN6ZN.cjs +0 -428
  35. package/dist/chunk-6TZPZCOJ.cjs +0 -1404
  36. package/dist/chunk-6UEHYZ7V.cjs +0 -773
  37. package/dist/chunk-6XSERL6L.js +0 -5678
  38. package/dist/chunk-72EQECGT.cjs +0 -908
  39. package/dist/chunk-7AGYRWKW.cjs +0 -507
  40. package/dist/chunk-7LCYLPW2.cjs +0 -663
  41. package/dist/chunk-A7PIMZGU.js +0 -263
  42. package/dist/chunk-ATSKSYVE.cjs +0 -51683
  43. package/dist/chunk-B5TCIAPQ.cjs +0 -117
  44. package/dist/chunk-BF2235SI.cjs +0 -5714
  45. package/dist/chunk-BKIGPPVM.js +0 -629
  46. package/dist/chunk-BND3ST2K.cjs +0 -662
  47. package/dist/chunk-BU7VWW2K.js +0 -2522
  48. package/dist/chunk-BWFJEM5A.js +0 -5419
  49. package/dist/chunk-CAUCGUEA.cjs +0 -130
  50. package/dist/chunk-CBJSLA2E.cjs +0 -5423
  51. package/dist/chunk-CDPGV4DN.js +0 -114
  52. package/dist/chunk-CLYEIWA5.cjs +0 -408
  53. package/dist/chunk-CS2EMTGF.js +0 -1966
  54. package/dist/chunk-DMG7C4H2.js +0 -975
  55. package/dist/chunk-DXJQDCFL.js +0 -468
  56. package/dist/chunk-E3FWRT3Z.js +0 -608
  57. package/dist/chunk-E3UALNFA.js +0 -421
  58. package/dist/chunk-EONILVMF.js +0 -762
  59. package/dist/chunk-EQV4R3EV.cjs +0 -769
  60. package/dist/chunk-F3HH56EB.cjs +0 -5538
  61. package/dist/chunk-F4IULT7N.js +0 -1488
  62. package/dist/chunk-FF3Q7ADR.js +0 -380
  63. package/dist/chunk-FFKU7BTK.cjs +0 -1046
  64. package/dist/chunk-FHQVYCH2.js +0 -70
  65. package/dist/chunk-FSF7EQVA.cjs +0 -1974
  66. package/dist/chunk-G4VZTCIB.js +0 -659
  67. package/dist/chunk-G7CT3EMP.cjs +0 -1002
  68. package/dist/chunk-GGHSW2NN.js +0 -51334
  69. package/dist/chunk-GVUR45UF.cjs +0 -777
  70. package/dist/chunk-H5Z7NASB.js +0 -9662
  71. package/dist/chunk-HE7ULERA.cjs +0 -697
  72. package/dist/chunk-HJJLD366.js +0 -1169
  73. package/dist/chunk-HPS76H7Q.js +0 -309
  74. package/dist/chunk-HQUEA5R6.cjs +0 -424
  75. package/dist/chunk-HYNTS5CP.js +0 -422
  76. package/dist/chunk-I6XZ5DZF.cjs +0 -488
  77. package/dist/chunk-IBDG74G2.cjs +0 -1219
  78. package/dist/chunk-IFNQFCTM.js +0 -3098
  79. package/dist/chunk-IHOUYQIA.js +0 -406
  80. package/dist/chunk-ILRBGFVD.cjs +0 -72
  81. package/dist/chunk-IWI6J7FX.js +0 -421
  82. package/dist/chunk-K3JDKWGI.cjs +0 -270
  83. package/dist/chunk-K6EKD26I.js +0 -630
  84. package/dist/chunk-KCQ5NDYC.cjs +0 -3172
  85. package/dist/chunk-KED34ILP.js +0 -832
  86. package/dist/chunk-KSGXLT74.cjs +0 -457
  87. package/dist/chunk-L4G4RLXX.js +0 -767
  88. package/dist/chunk-LDP5OK6G.js +0 -1216
  89. package/dist/chunk-LGGRPKTV.cjs +0 -735
  90. package/dist/chunk-LK5IAVH6.cjs +0 -1173
  91. package/dist/chunk-LSW7P7ML.js +0 -3675
  92. package/dist/chunk-LXJ4667L.cjs +0 -3874
  93. package/dist/chunk-LZ266PCM.cjs +0 -4499
  94. package/dist/chunk-MD6KDHVE.cjs +0 -237
  95. package/dist/chunk-MEASWI2Y.js +0 -126
  96. package/dist/chunk-MPXBVFHQ.js +0 -768
  97. package/dist/chunk-N5FTS757.cjs +0 -415
  98. package/dist/chunk-NCUKG4SK.cjs +0 -3075
  99. package/dist/chunk-NDQNIJEH.js +0 -1715
  100. package/dist/chunk-NOZZ46QU.js +0 -168
  101. package/dist/chunk-OFKWH2IP.js +0 -449
  102. package/dist/chunk-PHENW4MQ.js +0 -65
  103. package/dist/chunk-PMGODDJA.cjs +0 -319
  104. package/dist/chunk-Q4QX3AET.cjs +0 -1505
  105. package/dist/chunk-Q56TT7IL.js +0 -483
  106. package/dist/chunk-Q5JT3YML.cjs +0 -129
  107. package/dist/chunk-Q5SJOGHQ.cjs +0 -4256
  108. package/dist/chunk-QGKNANZ3.js +0 -3071
  109. package/dist/chunk-QLEAOI3Q.cjs +0 -424
  110. package/dist/chunk-R7MA7QWV.js +0 -732
  111. package/dist/chunk-RVYPEYPX.js +0 -678
  112. package/dist/chunk-S2N5TNMA.js +0 -1855
  113. package/dist/chunk-S565K7NK.js +0 -752
  114. package/dist/chunk-SDAMZIRE.js +0 -765
  115. package/dist/chunk-T36DDXSF.js +0 -4250
  116. package/dist/chunk-T4NKMBDL.js +0 -5474
  117. package/dist/chunk-T7LEXZUZ.cjs +0 -2526
  118. package/dist/chunk-TEWCN33Y.js +0 -694
  119. package/dist/chunk-TQSZUOW5.cjs +0 -793
  120. package/dist/chunk-TSH3MSQU.cjs +0 -129
  121. package/dist/chunk-UERJ3YJV.js +0 -504
  122. package/dist/chunk-UPJBDCVF.js +0 -1395
  123. package/dist/chunk-V3NN3HPP.js +0 -4462
  124. package/dist/chunk-VJ3L7CHT.cjs +0 -169
  125. package/dist/chunk-WB4Z63GG.js +0 -229
  126. package/dist/chunk-WDW67DZB.cjs +0 -9728
  127. package/dist/chunk-WGMEAYBG.js +0 -126
  128. package/dist/chunk-X4ZF6CNE.cjs +0 -473
  129. package/dist/chunk-X6SEAXAX.cjs +0 -3681
  130. package/dist/chunk-XCWFGZAA.js +0 -1043
  131. package/dist/chunk-XD6IYDUX.js +0 -903
  132. package/dist/chunk-XG23EUQX.cjs +0 -1717
  133. package/dist/chunk-XRKWN5PL.cjs +0 -173
  134. package/dist/chunk-XUILI4KB.cjs +0 -430
  135. package/dist/chunk-XUTX5CBW.js +0 -126
  136. package/dist/chunk-XWPNTWDN.cjs +0 -755
  137. package/dist/chunk-XXINBTZK.cjs +0 -633
  138. package/dist/chunk-YCXFCXDS.js +0 -1868
  139. package/dist/chunk-YQK5JNFK.js +0 -3725
  140. package/dist/chunk-YYXH45E2.js +0 -426
  141. package/dist/chunk-Z34RLXRA.cjs +0 -612
  142. package/dist/chunk-ZP4D3CSX.cjs +0 -72
  143. package/dist/cli/holoscript-runner.cjs +0 -2259
  144. package/dist/cli/holoscript-runner.js +0 -2234
  145. package/dist/codebase/index.cjs +0 -336
  146. package/dist/codebase/index.js +0 -331
  147. package/dist/compiler/agent-inference.cjs +0 -28
  148. package/dist/compiler/agent-inference.js +0 -5
  149. package/dist/compiler/android-xr.cjs +0 -19
  150. package/dist/compiler/android-xr.js +0 -9
  151. package/dist/compiler/android.cjs +0 -20
  152. package/dist/compiler/android.js +0 -10
  153. package/dist/compiler/ar.cjs +0 -20
  154. package/dist/compiler/ar.js +0 -8
  155. package/dist/compiler/babylon.cjs +0 -17
  156. package/dist/compiler/babylon.js +0 -11
  157. package/dist/compiler/coco.cjs +0 -27
  158. package/dist/compiler/coco.js +0 -4
  159. package/dist/compiler/domain-block-utils.cjs +0 -602
  160. package/dist/compiler/domain-block-utils.js +0 -8
  161. package/dist/compiler/dtdl.cjs +0 -24
  162. package/dist/compiler/dtdl.js +0 -8
  163. package/dist/compiler/gltf-pipeline.cjs +0 -39
  164. package/dist/compiler/gltf-pipeline.js +0 -4
  165. package/dist/compiler/godot.cjs +0 -15
  166. package/dist/compiler/godot.js +0 -9
  167. package/dist/compiler/incremental.cjs +0 -29
  168. package/dist/compiler/incremental.js +0 -4
  169. package/dist/compiler/index.cjs +0 -2578
  170. package/dist/compiler/index.js +0 -2383
  171. package/dist/compiler/ios.cjs +0 -20
  172. package/dist/compiler/ios.js +0 -10
  173. package/dist/compiler/multi-layer.cjs +0 -20
  174. package/dist/compiler/multi-layer.js +0 -11
  175. package/dist/compiler/nodetoy.cjs +0 -23
  176. package/dist/compiler/nodetoy.js +0 -4
  177. package/dist/compiler/openxr.cjs +0 -15
  178. package/dist/compiler/openxr.js +0 -9
  179. package/dist/compiler/playcanvas.cjs +0 -16
  180. package/dist/compiler/playcanvas.js +0 -10
  181. package/dist/compiler/r3f.cjs +0 -34
  182. package/dist/compiler/r3f.js +0 -12
  183. package/dist/compiler/remotion.cjs +0 -23
  184. package/dist/compiler/remotion.js +0 -4
  185. package/dist/compiler/reproducibility.cjs +0 -39
  186. package/dist/compiler/reproducibility.js +0 -4
  187. package/dist/compiler/sdf.cjs +0 -21
  188. package/dist/compiler/sdf.js +0 -9
  189. package/dist/compiler/semantic-scene.cjs +0 -31
  190. package/dist/compiler/semantic-scene.js +0 -4
  191. package/dist/compiler/state.cjs +0 -17
  192. package/dist/compiler/state.js +0 -7
  193. package/dist/compiler/trait-composition.cjs +0 -26
  194. package/dist/compiler/trait-composition.js +0 -5
  195. package/dist/compiler/unity.cjs +0 -15
  196. package/dist/compiler/unity.js +0 -9
  197. package/dist/compiler/unreal.cjs +0 -19
  198. package/dist/compiler/unreal.js +0 -9
  199. package/dist/compiler/urdf.cjs +0 -45
  200. package/dist/compiler/urdf.js +0 -9
  201. package/dist/compiler/usd-physics.cjs +0 -23
  202. package/dist/compiler/usd-physics.js +0 -6
  203. package/dist/compiler/visionos.cjs +0 -15
  204. package/dist/compiler/visionos.js +0 -9
  205. package/dist/compiler/vrchat.cjs +0 -19
  206. package/dist/compiler/vrchat.js +0 -9
  207. package/dist/compiler/vrr.cjs +0 -21
  208. package/dist/compiler/vrr.js +0 -9
  209. package/dist/compiler/wasm.cjs +0 -33
  210. package/dist/compiler/wasm.js +0 -9
  211. package/dist/compiler/webgpu.cjs +0 -15
  212. package/dist/compiler/webgpu.js +0 -9
  213. package/dist/debugger.cjs +0 -21
  214. package/dist/debugger.js +0 -8
  215. package/dist/entries/interop.cjs +0 -62
  216. package/dist/entries/interop.js +0 -5
  217. package/dist/entries/scripting.cjs +0 -68
  218. package/dist/entries/scripting.js +0 -11
  219. package/dist/index.cjs +0 -40921
  220. package/dist/index.js +0 -37763
  221. package/dist/math/vec3.cjs +0 -57
  222. package/dist/math/vec3.js +0 -4
  223. package/dist/ml-dsa-PHCWUBPX.cjs +0 -1178
  224. package/dist/ml-dsa-WYLJHJO6.js +0 -1178
  225. package/dist/parser.cjs +0 -27
  226. package/dist/parser.js +0 -10
  227. package/dist/playwright-5OSAPTNH.js +0 -98660
  228. package/dist/playwright-RL6GY4F7.cjs +0 -98673
  229. package/dist/runtime.cjs +0 -16
  230. package/dist/runtime.js +0 -7
  231. package/dist/storage/index.cjs +0 -37
  232. package/dist/storage/index.js +0 -4
  233. package/dist/traits/index.cjs +0 -14649
  234. package/dist/traits/index.js +0 -12243
  235. package/dist/type-checker.cjs +0 -18
  236. package/dist/type-checker.js +0 -5
@@ -1,655 +0,0 @@
1
- // src/storage/IPFSTypes.ts
2
- var IPFSUploadError = class extends Error {
3
- constructor(message, provider, originalError) {
4
- super(message);
5
- this.provider = provider;
6
- this.originalError = originalError;
7
- this.name = "IPFSUploadError";
8
- }
9
- };
10
- var IPFSPinError = class extends Error {
11
- constructor(message, cid, originalError) {
12
- super(message);
13
- this.cid = cid;
14
- this.originalError = originalError;
15
- this.name = "IPFSPinError";
16
- }
17
- };
18
- var FileSizeExceededError = class extends Error {
19
- constructor(fileSize, maxSize) {
20
- super(`File size ${fileSize} bytes exceeds maximum ${maxSize} bytes`);
21
- this.fileSize = fileSize;
22
- this.maxSize = maxSize;
23
- this.name = "FileSizeExceededError";
24
- }
25
- };
26
-
27
- // src/storage/IPFSProviders.ts
28
- var PinataProvider = class {
29
- constructor(apiKey, apiSecret) {
30
- this.baseUrl = "https://api.pinata.cloud";
31
- this.apiKey = apiKey;
32
- this.apiSecret = apiSecret || "";
33
- }
34
- async upload(files, options) {
35
- const formData = new FormData();
36
- for (const file of files) {
37
- const blob = new Blob([file.content]);
38
- formData.append("file", blob, file.path);
39
- }
40
- const metadata = {
41
- name: options.metadata?.name || options.name,
42
- keyvalues: options.metadata?.keyvalues || {}
43
- };
44
- formData.append("pinataMetadata", JSON.stringify(metadata));
45
- const pinataOptions = {
46
- cidVersion: 1
47
- };
48
- formData.append("pinataOptions", JSON.stringify(pinataOptions));
49
- const response = await fetch(`${this.baseUrl}/pinning/pinFileToIPFS`, {
50
- method: "POST",
51
- headers: {
52
- pinata_api_key: this.apiKey,
53
- pinata_secret_api_key: this.apiSecret
54
- },
55
- body: formData
56
- });
57
- if (!response.ok) {
58
- const error = await response.text();
59
- throw new Error(`Pinata upload failed: ${error}`);
60
- }
61
- const data = await response.json();
62
- return {
63
- cid: data.IpfsHash,
64
- size: data.PinSize
65
- };
66
- }
67
- async pin(cid, name) {
68
- const response = await fetch(`${this.baseUrl}/pinning/pinByHash`, {
69
- method: "POST",
70
- headers: {
71
- "Content-Type": "application/json",
72
- pinata_api_key: this.apiKey,
73
- pinata_secret_api_key: this.apiSecret
74
- },
75
- body: JSON.stringify({
76
- hashToPin: cid,
77
- pinataMetadata: {
78
- name: name || cid
79
- }
80
- })
81
- });
82
- if (!response.ok) {
83
- const error = await response.text();
84
- throw new Error(`Pinata pin failed: ${error}`);
85
- }
86
- }
87
- async unpin(cid) {
88
- const response = await fetch(`${this.baseUrl}/pinning/unpin/${cid}`, {
89
- method: "DELETE",
90
- headers: {
91
- pinata_api_key: this.apiKey,
92
- pinata_secret_api_key: this.apiSecret
93
- }
94
- });
95
- if (!response.ok) {
96
- const error = await response.text();
97
- throw new Error(`Pinata unpin failed: ${error}`);
98
- }
99
- }
100
- async getPinStatus(cid) {
101
- const response = await fetch(
102
- `${this.baseUrl}/data/pinList?hashContains=${cid}&status=pinned,pinning`,
103
- {
104
- headers: {
105
- pinata_api_key: this.apiKey,
106
- pinata_secret_api_key: this.apiSecret
107
- }
108
- }
109
- );
110
- if (!response.ok) {
111
- return "unpinned";
112
- }
113
- const data = await response.json();
114
- if (data.count === 0) {
115
- return "unpinned";
116
- }
117
- const pin = data.rows[0];
118
- return pin.status === "pinned" ? "pinned" : "pinning";
119
- }
120
- async listPins() {
121
- const response = await fetch(`${this.baseUrl}/data/pinList?status=pinned`, {
122
- headers: {
123
- pinata_api_key: this.apiKey,
124
- pinata_secret_api_key: this.apiSecret
125
- }
126
- });
127
- if (!response.ok) {
128
- throw new Error("Failed to list pins");
129
- }
130
- const data = await response.json();
131
- return data.rows.map((pin) => ({
132
- // @ts-expect-error
133
- cid: pin.ipfs_pin_hash,
134
- // @ts-expect-error
135
- name: pin.metadata?.name || pin.ipfs_pin_hash,
136
- // @ts-expect-error
137
- size: pin.size,
138
- // @ts-expect-error
139
- status: pin.status,
140
- // @ts-expect-error
141
- created: new Date(pin.date_pinned)
142
- }));
143
- }
144
- async verifyCID(cid) {
145
- try {
146
- const status = await this.getPinStatus(cid);
147
- return status === "pinned" || status === "pinning";
148
- } catch {
149
- return false;
150
- }
151
- }
152
- };
153
- var NFTStorageProvider = class {
154
- constructor(apiKey) {
155
- this.baseUrl = "https://api.nft.storage";
156
- this.apiKey = apiKey;
157
- }
158
- async upload(files, options) {
159
- const formData = new FormData();
160
- for (const file of files) {
161
- const blob = new Blob([file.content]);
162
- formData.append("file", blob, file.path);
163
- }
164
- const response = await fetch(`${this.baseUrl}/upload`, {
165
- method: "POST",
166
- headers: {
167
- Authorization: `Bearer ${this.apiKey}`
168
- },
169
- body: formData
170
- });
171
- if (!response.ok) {
172
- const error = await response.text();
173
- throw new Error(`NFT.Storage upload failed: ${error}`);
174
- }
175
- const data = await response.json();
176
- return {
177
- cid: data.value.cid,
178
- size: data.value.size
179
- };
180
- }
181
- async pin(cid, name) {
182
- }
183
- async unpin(cid) {
184
- const response = await fetch(`${this.baseUrl}/${cid}`, {
185
- method: "DELETE",
186
- headers: {
187
- Authorization: `Bearer ${this.apiKey}`
188
- }
189
- });
190
- if (!response.ok) {
191
- const error = await response.text();
192
- throw new Error(`NFT.Storage unpin failed: ${error}`);
193
- }
194
- }
195
- async getPinStatus(cid) {
196
- const response = await fetch(`${this.baseUrl}/${cid}`, {
197
- headers: {
198
- Authorization: `Bearer ${this.apiKey}`
199
- }
200
- });
201
- if (!response.ok) {
202
- return "unpinned";
203
- }
204
- const data = await response.json();
205
- return data.pin?.status === "pinned" ? "pinned" : "pinning";
206
- }
207
- async listPins() {
208
- const response = await fetch(`${this.baseUrl}`, {
209
- headers: {
210
- Authorization: `Bearer ${this.apiKey}`
211
- }
212
- });
213
- if (!response.ok) {
214
- throw new Error("Failed to list pins");
215
- }
216
- const data = await response.json();
217
- return data.value.map((item) => ({
218
- // @ts-expect-error
219
- cid: item.cid,
220
- // @ts-expect-error
221
- name: item.name || item.cid,
222
- // @ts-expect-error
223
- size: item.size,
224
- // @ts-expect-error
225
- status: item.pin?.status || "pinned",
226
- // @ts-expect-error
227
- created: new Date(item.created)
228
- }));
229
- }
230
- async verifyCID(cid) {
231
- try {
232
- const status = await this.getPinStatus(cid);
233
- return status === "pinned" || status === "pinning";
234
- } catch {
235
- return false;
236
- }
237
- }
238
- };
239
- var InfuraProvider = class {
240
- constructor(projectId, projectSecret) {
241
- this.baseUrl = "https://ipfs.infura.io:5001/api/v0";
242
- this.projectId = projectId;
243
- this.projectSecret = projectSecret || "";
244
- }
245
- getAuthHeader() {
246
- const auth = Buffer.from(`${this.projectId}:${this.projectSecret}`).toString("base64");
247
- return `Basic ${auth}`;
248
- }
249
- async upload(files, options) {
250
- const formData = new FormData();
251
- for (const file of files) {
252
- const blob = new Blob([file.content]);
253
- formData.append("file", blob, file.path);
254
- }
255
- const response = await fetch(`${this.baseUrl}/add?wrap-with-directory=true`, {
256
- method: "POST",
257
- headers: {
258
- Authorization: this.getAuthHeader()
259
- },
260
- body: formData
261
- });
262
- if (!response.ok) {
263
- const error = await response.text();
264
- throw new Error(`Infura upload failed: ${error}`);
265
- }
266
- const text = await response.text();
267
- const lines = text.trim().split("\n");
268
- const lastLine = JSON.parse(lines[lines.length - 1]);
269
- let totalSize = 0;
270
- for (const line of lines) {
271
- const data = JSON.parse(line);
272
- totalSize += data.Size || 0;
273
- }
274
- return {
275
- cid: lastLine.Hash,
276
- size: totalSize
277
- };
278
- }
279
- async pin(cid, name) {
280
- const response = await fetch(`${this.baseUrl}/pin/add?arg=${cid}`, {
281
- method: "POST",
282
- headers: {
283
- Authorization: this.getAuthHeader()
284
- }
285
- });
286
- if (!response.ok) {
287
- const error = await response.text();
288
- throw new Error(`Infura pin failed: ${error}`);
289
- }
290
- }
291
- async unpin(cid) {
292
- const response = await fetch(`${this.baseUrl}/pin/rm?arg=${cid}`, {
293
- method: "POST",
294
- headers: {
295
- Authorization: this.getAuthHeader()
296
- }
297
- });
298
- if (!response.ok) {
299
- const error = await response.text();
300
- throw new Error(`Infura unpin failed: ${error}`);
301
- }
302
- }
303
- async getPinStatus(cid) {
304
- const response = await fetch(`${this.baseUrl}/pin/ls?arg=${cid}`, {
305
- headers: {
306
- Authorization: this.getAuthHeader()
307
- }
308
- });
309
- if (!response.ok) {
310
- return "unpinned";
311
- }
312
- const data = await response.json();
313
- return data.Keys && data.Keys[cid] ? "pinned" : "unpinned";
314
- }
315
- async listPins() {
316
- const response = await fetch(`${this.baseUrl}/pin/ls`, {
317
- headers: {
318
- Authorization: this.getAuthHeader()
319
- }
320
- });
321
- if (!response.ok) {
322
- throw new Error("Failed to list pins");
323
- }
324
- const data = await response.json();
325
- return Object.entries(data.Keys || {}).map(([cid, info]) => ({
326
- cid,
327
- name: cid,
328
- size: 0,
329
- // Infura doesn't provide size in pin list
330
- status: "pinned"
331
- }));
332
- }
333
- async verifyCID(cid) {
334
- try {
335
- const response = await fetch(`${this.baseUrl}/cat?arg=${cid}`, {
336
- method: "POST",
337
- headers: {
338
- Authorization: this.getAuthHeader()
339
- }
340
- });
341
- return response.ok;
342
- } catch {
343
- return false;
344
- }
345
- }
346
- };
347
-
348
- // src/storage/IPFSService.ts
349
- var IPFSService = class {
350
- constructor(options) {
351
- this.fallbackProviders = [];
352
- this.defaultGateway = "https://ipfs.io/ipfs";
353
- this.cdnGateway = "https://cloudflare-ipfs.com/ipfs";
354
- this.options = {
355
- ...options,
356
- fallbackProviders: options.fallbackProviders || [],
357
- enableCDN: options.enableCDN ?? true,
358
- maxFileSize: options.maxFileSize || 100 * 1024 * 1024,
359
- // 100MB
360
- chunkSize: options.chunkSize || 5 * 1024 * 1024,
361
- // 5MB
362
- maxRetries: options.maxRetries || 3,
363
- retryDelay: options.retryDelay || 1e3,
364
- gatewayUrl: options.gatewayUrl || this.defaultGateway,
365
- apiSecret: options.apiSecret
366
- };
367
- this.primaryProvider = this.createProvider(
368
- this.options.provider,
369
- this.options.apiKey,
370
- this.options.apiSecret
371
- );
372
- for (const fallback of this.options.fallbackProviders) {
373
- const provider = this.createProvider(fallback.provider, fallback.apiKey, fallback.apiSecret);
374
- this.fallbackProviders.push(provider);
375
- }
376
- }
377
- /**
378
- * Create provider instance
379
- */
380
- createProvider(type, apiKey, apiSecret) {
381
- switch (type) {
382
- case "pinata":
383
- return new PinataProvider(apiKey, apiSecret);
384
- case "nft.storage":
385
- return new NFTStorageProvider(apiKey);
386
- case "infura":
387
- return new InfuraProvider(apiKey, apiSecret);
388
- default:
389
- throw new Error(`Unknown IPFS provider: ${type}`);
390
- }
391
- }
392
- /**
393
- * Upload files to IPFS
394
- *
395
- * Returns CID and gateway URLs. Automatically retries on failure and falls back
396
- * to backup providers if primary fails.
397
- *
398
- * @param options Upload options
399
- * @returns Upload result with CID and URLs
400
- * @throws {FileSizeExceededError} If file size exceeds maximum
401
- * @throws {IPFSUploadError} If upload fails on all providers
402
- */
403
- async upload(options) {
404
- const startTime = Date.now();
405
- const totalSize = options.files.reduce((sum, file) => {
406
- const size = file.content instanceof Buffer || file.content instanceof Uint8Array ? file.content.length : Buffer.from(file.content).length;
407
- return sum + size;
408
- }, 0);
409
- if (totalSize > this.options.maxFileSize) {
410
- throw new FileSizeExceededError(totalSize, this.options.maxFileSize);
411
- }
412
- const needsChunking = totalSize > this.options.chunkSize;
413
- try {
414
- const result = await this.uploadWithRetry(
415
- this.primaryProvider,
416
- this.options.provider,
417
- options,
418
- needsChunking
419
- );
420
- return this.buildUploadResult(result.cid, result.size, startTime, options.pin ?? true);
421
- } catch (primaryError) {
422
- console.warn(`Primary provider ${this.options.provider} failed:`, primaryError);
423
- for (let i = 0; i < this.fallbackProviders.length; i++) {
424
- const provider = this.fallbackProviders[i];
425
- const providerType = this.options.fallbackProviders[i].provider;
426
- try {
427
- const result = await this.uploadWithRetry(provider, providerType, options, needsChunking);
428
- return this.buildUploadResult(result.cid, result.size, startTime, options.pin ?? true);
429
- } catch (error) {
430
- console.warn(`Fallback provider ${providerType} failed:`, error);
431
- continue;
432
- }
433
- }
434
- throw new IPFSUploadError(
435
- "Upload failed on all providers",
436
- this.options.provider,
437
- primaryError
438
- );
439
- }
440
- }
441
- /**
442
- * Upload with retry logic
443
- */
444
- async uploadWithRetry(provider, providerType, options, needsChunking) {
445
- let lastError;
446
- for (let attempt = 0; attempt < this.options.maxRetries; attempt++) {
447
- try {
448
- if (needsChunking) {
449
- return await this.uploadChunked(provider, options);
450
- } else {
451
- if (options.onProgress) {
452
- const totalSize = options.files.reduce((sum, file) => {
453
- const size = file.content instanceof Buffer || file.content instanceof Uint8Array ? file.content.length : Buffer.from(file.content).length;
454
- return sum + size;
455
- }, 0);
456
- let uploadedBytes = 0;
457
- for (const file of options.files) {
458
- const size = file.content instanceof Buffer || file.content instanceof Uint8Array ? file.content.length : Buffer.from(file.content).length;
459
- uploadedBytes += size;
460
- options.onProgress({
461
- uploadedBytes,
462
- totalBytes: totalSize,
463
- percentage: uploadedBytes / totalSize * 100,
464
- currentFile: file.path
465
- });
466
- }
467
- }
468
- return await provider.upload(options.files, options);
469
- }
470
- } catch (error) {
471
- lastError = error;
472
- if (attempt < this.options.maxRetries - 1) {
473
- const delay = this.options.retryDelay * Math.pow(2, attempt);
474
- await this.delay(delay);
475
- }
476
- }
477
- }
478
- throw new IPFSUploadError(
479
- `Upload failed after ${this.options.maxRetries} attempts`,
480
- providerType,
481
- lastError
482
- );
483
- }
484
- /**
485
- * Upload large files in chunks
486
- *
487
- * Breaks large files into smaller chunks, uploads them separately,
488
- * and combines them into a single IPFS directory.
489
- */
490
- async uploadChunked(provider, options) {
491
- const chunks = [];
492
- let totalSize = 0;
493
- let uploadedBytes = 0;
494
- for (const file of options.files) {
495
- const content = file.content instanceof Buffer || file.content instanceof Uint8Array ? file.content : Buffer.from(file.content);
496
- const fileSize = content.length;
497
- totalSize += fileSize;
498
- if (fileSize > this.options.chunkSize) {
499
- const numChunks = Math.ceil(fileSize / this.options.chunkSize);
500
- for (let i = 0; i < numChunks; i++) {
501
- const start = i * this.options.chunkSize;
502
- const end = Math.min(start + this.options.chunkSize, fileSize);
503
- const chunk = content.slice(start, end);
504
- chunks.push({
505
- path: `${file.path}.chunk${i}`,
506
- content: chunk
507
- });
508
- uploadedBytes += chunk.length;
509
- if (options.onProgress) {
510
- options.onProgress({
511
- uploadedBytes,
512
- totalBytes: totalSize,
513
- percentage: uploadedBytes / totalSize * 100,
514
- currentFile: file.path
515
- });
516
- }
517
- }
518
- } else {
519
- chunks.push(file);
520
- uploadedBytes += fileSize;
521
- if (options.onProgress) {
522
- options.onProgress({
523
- uploadedBytes,
524
- totalBytes: totalSize,
525
- percentage: uploadedBytes / totalSize * 100,
526
- currentFile: file.path
527
- });
528
- }
529
- }
530
- }
531
- return await provider.upload(chunks, options);
532
- }
533
- /**
534
- * Build upload result
535
- */
536
- buildUploadResult(cid, size, startTime, pinned) {
537
- const gatewayUrl = `${this.options.gatewayUrl}/${cid}`;
538
- const cdnUrl = this.options.enableCDN ? `${this.cdnGateway}/${cid}` : void 0;
539
- return {
540
- cid,
541
- uri: `ipfs://${cid}`,
542
- gatewayUrl,
543
- cdnUrl,
544
- pinned,
545
- size,
546
- duration: Date.now() - startTime
547
- };
548
- }
549
- /**
550
- * Pin existing CID to IPFS
551
- *
552
- * @param cid IPFS CID to pin
553
- * @param name Optional name for the pin
554
- * @throws {IPFSPinError} If pin operation fails
555
- */
556
- async pin(cid, name) {
557
- try {
558
- await this.primaryProvider.pin(cid, name);
559
- } catch (error) {
560
- throw new IPFSPinError(`Failed to pin CID ${cid}`, cid, error);
561
- }
562
- }
563
- /**
564
- * Unpin CID from IPFS
565
- *
566
- * @param cid IPFS CID to unpin
567
- * @throws {IPFSPinError} If unpin operation fails
568
- */
569
- async unpin(cid) {
570
- try {
571
- await this.primaryProvider.unpin(cid);
572
- } catch (error) {
573
- throw new IPFSPinError(`Failed to unpin CID ${cid}`, cid, error);
574
- }
575
- }
576
- /**
577
- * Get pin status for CID
578
- *
579
- * @param cid IPFS CID to check
580
- * @returns Pin status ('pinned', 'pinning', or 'unpinned')
581
- */
582
- async getPinStatus(cid) {
583
- return await this.primaryProvider.getPinStatus(cid);
584
- }
585
- /**
586
- * Verify CID exists and is accessible
587
- *
588
- * @param cid IPFS CID to verify
589
- * @returns True if CID is accessible
590
- */
591
- async verifyCID(cid) {
592
- return await this.primaryProvider.verifyCID(cid);
593
- }
594
- /**
595
- * Get file from IPFS
596
- *
597
- * @param cid IPFS CID
598
- * @param path Optional path within directory
599
- * @returns File content as Uint8Array
600
- */
601
- async get(cid, path) {
602
- const url = path ? `${this.options.gatewayUrl}/${cid}/${path}` : `${this.options.gatewayUrl}/${cid}`;
603
- const response = await fetch(url);
604
- if (!response.ok) {
605
- throw new Error(`Failed to fetch CID ${cid}: ${response.statusText}`);
606
- }
607
- const buffer = await response.arrayBuffer();
608
- return new Uint8Array(buffer);
609
- }
610
- /**
611
- * List all pins for account
612
- *
613
- * @returns Array of pin information
614
- */
615
- async listPins() {
616
- return await this.primaryProvider.listPins();
617
- }
618
- /**
619
- * Delay helper for retry logic
620
- */
621
- delay(ms) {
622
- return new Promise((resolve) => setTimeout(resolve, ms));
623
- }
624
- /**
625
- * Get CDN URL for CID
626
- *
627
- * @param cid IPFS CID
628
- * @returns CDN URL if enabled, otherwise gateway URL
629
- */
630
- getCDNUrl(cid) {
631
- return this.options.enableCDN ? `${this.cdnGateway}/${cid}` : `${this.options.gatewayUrl}/${cid}`;
632
- }
633
- /**
634
- * Get gateway URL for CID
635
- *
636
- * @param cid IPFS CID
637
- * @returns Gateway URL
638
- */
639
- getGatewayUrl(cid) {
640
- return `${this.options.gatewayUrl}/${cid}`;
641
- }
642
- /**
643
- * Get IPFS URI for CID
644
- *
645
- * @param cid IPFS CID
646
- * @returns IPFS URI (ipfs://...)
647
- */
648
- getIPFSUri(cid) {
649
- return `ipfs://${cid}`;
650
- }
651
- };
652
-
653
- export { FileSizeExceededError, IPFSPinError, IPFSService, IPFSUploadError, InfuraProvider, NFTStorageProvider, PinataProvider };
654
- //# sourceMappingURL=chunk-54FHG2MX.js.map
655
- //# sourceMappingURL=chunk-54FHG2MX.js.map
@@ -1,56 +0,0 @@
1
- // src/math/vec3.ts
2
- function vec3NormalizeInPlace(v) {
3
- const len = Math.sqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]);
4
- if (len > 1e-8) {
5
- v[0] /= len;
6
- v[1] /= len;
7
- v[2] /= len;
8
- }
9
- return len;
10
- }
11
- function vec3Normalize(v) {
12
- const len = Math.sqrt(v.x * v.x + v.y * v.y + v.z * v.z);
13
- if (len === 0) return { x: 0, y: 0, z: 0 };
14
- return { x: v.x / len, y: v.y / len, z: v.z / len };
15
- }
16
- function vec3Length(v) {
17
- return Math.sqrt(v.x * v.x + v.y * v.y + v.z * v.z);
18
- }
19
- function vec3Cross(a, b) {
20
- return {
21
- x: a.y * b.z - a.z * b.y,
22
- y: a.z * b.x - a.x * b.z,
23
- z: a.x * b.y - a.y * b.x
24
- };
25
- }
26
- function vec3CrossArray(a, b) {
27
- return [a[1] * b[2] - a[2] * b[1], a[2] * b[0] - a[0] * b[2], a[0] * b[1] - a[1] * b[0]];
28
- }
29
- function vec3Sub(a, b) {
30
- return { x: a.x - b.x, y: a.y - b.y, z: a.z - b.z };
31
- }
32
- function vec3SubArray(a, b) {
33
- return [a[0] - b[0], a[1] - b[1], a[2] - b[2]];
34
- }
35
- function vec3Add(a, b) {
36
- return { x: a.x + b.x, y: a.y + b.y, z: a.z + b.z };
37
- }
38
- function vec3Scale(v, s) {
39
- return { x: v.x * s, y: v.y * s, z: v.z * s };
40
- }
41
- function vec3ScaleArray(v, s) {
42
- return [v[0] * s, v[1] * s, v[2] * s];
43
- }
44
- function vec3Distance(a, b) {
45
- const dx = b.x - a.x;
46
- const dy = b.y - a.y;
47
- const dz = b.z - a.z;
48
- return Math.sqrt(dx * dx + dy * dy + dz * dz);
49
- }
50
- function vec3Dot(a, b) {
51
- return a.x * b.x + a.y * b.y + a.z * b.z;
52
- }
53
-
54
- export { vec3Add, vec3Cross, vec3CrossArray, vec3Distance, vec3Dot, vec3Length, vec3Normalize, vec3NormalizeInPlace, vec3Scale, vec3ScaleArray, vec3Sub, vec3SubArray };
55
- //# sourceMappingURL=chunk-56IF4NTA.js.map
56
- //# sourceMappingURL=chunk-56IF4NTA.js.map