samcan 0.0.2 → 0.1.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 (327) hide show
  1. package/{license → LICENSE} +3 -1
  2. package/README.md +3 -0
  3. package/dist/camera/index.cjs +370 -0
  4. package/dist/camera/index.d.cts +54 -0
  5. package/dist/camera/index.d.ts +54 -0
  6. package/dist/camera/index.js +70 -0
  7. package/dist/document/index.cjs +735 -0
  8. package/dist/document/index.d.cts +174 -0
  9. package/dist/document/index.d.ts +174 -0
  10. package/dist/document/index.js +161 -0
  11. package/dist/editor/index.cjs +5007 -0
  12. package/dist/editor/index.d.cts +374 -0
  13. package/dist/editor/index.d.ts +374 -0
  14. package/dist/editor/index.js +2401 -0
  15. package/dist/engine/index.cjs +3752 -0
  16. package/dist/engine/index.d.cts +183 -0
  17. package/dist/engine/index.d.ts +183 -0
  18. package/dist/engine/index.js +111 -0
  19. package/dist/index.cjs +8899 -0
  20. package/dist/index.d.cts +962 -0
  21. package/dist/index.d.ts +962 -46
  22. package/dist/index.js +1008 -49
  23. package/dist/math/index.cjs +2230 -0
  24. package/dist/math/index.d.cts +302 -0
  25. package/dist/math/index.d.ts +302 -0
  26. package/dist/math/index.js +1109 -0
  27. package/dist/renderer/index.cjs +1865 -0
  28. package/dist/renderer/index.d.cts +91 -0
  29. package/dist/renderer/index.d.ts +91 -0
  30. package/dist/renderer/index.js +89 -0
  31. package/dist/shared/chunk-35pkr0zs.js +110 -0
  32. package/dist/shared/chunk-7sr7q84y.js +80 -0
  33. package/dist/shared/chunk-87399bz7.js +89 -0
  34. package/dist/shared/chunk-8ynnz57m.js +129 -0
  35. package/dist/shared/chunk-d6gxvapt.js +500 -0
  36. package/dist/shared/chunk-hewznwbd.js +305 -0
  37. package/dist/shared/chunk-jdvrd5tv.js +623 -0
  38. package/dist/shared/chunk-rvag1j46.js +461 -0
  39. package/dist/shared/chunk-rzxyjwk8.js +397 -0
  40. package/dist/shared/chunk-s3qdcmcq.js +1392 -0
  41. package/dist/shared/chunk-v53jprrn.js +68 -0
  42. package/dist/shared/chunk-wa3772hp.js +117 -0
  43. package/dist/spatial/index.cjs +954 -0
  44. package/dist/spatial/index.d.cts +136 -0
  45. package/dist/spatial/index.d.ts +136 -0
  46. package/dist/spatial/index.js +301 -0
  47. package/dist/stroke/index.cjs +1010 -0
  48. package/dist/stroke/index.d.cts +143 -0
  49. package/dist/stroke/index.d.ts +143 -0
  50. package/dist/stroke/index.js +343 -0
  51. package/package.json +122 -58
  52. package/dist/bundle.js +0 -5888
  53. package/dist/core/animation/animationruntime.d.ts +0 -238
  54. package/dist/core/animation/animationruntime.d.ts.map +0 -1
  55. package/dist/core/animation/animationruntime.js +0 -530
  56. package/dist/core/animation/animationruntime.js.map +0 -1
  57. package/dist/core/animation/animationstate.d.ts +0 -85
  58. package/dist/core/animation/animationstate.d.ts.map +0 -1
  59. package/dist/core/animation/animationstate.js +0 -119
  60. package/dist/core/animation/animationstate.js.map +0 -1
  61. package/dist/core/animation/animationtrack.d.ts +0 -55
  62. package/dist/core/animation/animationtrack.d.ts.map +0 -1
  63. package/dist/core/animation/animationtrack.js +0 -185
  64. package/dist/core/animation/animationtrack.js.map +0 -1
  65. package/dist/core/animation/easing.d.ts +0 -80
  66. package/dist/core/animation/easing.d.ts.map +0 -1
  67. package/dist/core/animation/easing.js +0 -126
  68. package/dist/core/animation/easing.js.map +0 -1
  69. package/dist/core/animation/index.d.ts +0 -11
  70. package/dist/core/animation/index.d.ts.map +0 -1
  71. package/dist/core/animation/index.js +0 -10
  72. package/dist/core/animation/index.js.map +0 -1
  73. package/dist/core/animation/interpolator.d.ts +0 -82
  74. package/dist/core/animation/interpolator.d.ts.map +0 -1
  75. package/dist/core/animation/interpolator.js +0 -108
  76. package/dist/core/animation/interpolator.js.map +0 -1
  77. package/dist/core/animation/keyframe.d.ts +0 -52
  78. package/dist/core/animation/keyframe.d.ts.map +0 -1
  79. package/dist/core/animation/keyframe.js +0 -65
  80. package/dist/core/animation/keyframe.js.map +0 -1
  81. package/dist/core/animation/logger.d.ts +0 -8
  82. package/dist/core/animation/logger.d.ts.map +0 -1
  83. package/dist/core/animation/logger.js +0 -20
  84. package/dist/core/animation/logger.js.map +0 -1
  85. package/dist/core/animation/statemachine.d.ts +0 -178
  86. package/dist/core/animation/statemachine.d.ts.map +0 -1
  87. package/dist/core/animation/statemachine.js +0 -378
  88. package/dist/core/animation/statemachine.js.map +0 -1
  89. package/dist/core/animation/statetransition.d.ts +0 -142
  90. package/dist/core/animation/statetransition.d.ts.map +0 -1
  91. package/dist/core/animation/statetransition.js +0 -189
  92. package/dist/core/animation/statetransition.js.map +0 -1
  93. package/dist/core/animation/timeline.d.ts +0 -62
  94. package/dist/core/animation/timeline.d.ts.map +0 -1
  95. package/dist/core/animation/timeline.js +0 -102
  96. package/dist/core/animation/timeline.js.map +0 -1
  97. package/dist/core/api.d.ts +0 -245
  98. package/dist/core/api.d.ts.map +0 -1
  99. package/dist/core/api.js +0 -369
  100. package/dist/core/api.js.map +0 -1
  101. package/dist/core/asset/assetmanager.d.ts +0 -196
  102. package/dist/core/asset/assetmanager.d.ts.map +0 -1
  103. package/dist/core/asset/assetmanager.js +0 -502
  104. package/dist/core/asset/assetmanager.js.map +0 -1
  105. package/dist/core/asset/index.d.ts +0 -3
  106. package/dist/core/asset/index.d.ts.map +0 -1
  107. package/dist/core/asset/index.js +0 -3
  108. package/dist/core/asset/index.js.map +0 -1
  109. package/dist/core/asset/types.d.ts +0 -36
  110. package/dist/core/asset/types.d.ts.map +0 -1
  111. package/dist/core/asset/types.js +0 -1
  112. package/dist/core/asset/types.js.map +0 -1
  113. package/dist/core/command/basecommand.d.ts +0 -29
  114. package/dist/core/command/basecommand.d.ts.map +0 -1
  115. package/dist/core/command/basecommand.js +0 -36
  116. package/dist/core/command/basecommand.js.map +0 -1
  117. package/dist/core/command/command.d.ts +0 -55
  118. package/dist/core/command/command.d.ts.map +0 -1
  119. package/dist/core/command/command.js +0 -1
  120. package/dist/core/command/command.js.map +0 -1
  121. package/dist/core/command/commandhistory.d.ts +0 -76
  122. package/dist/core/command/commandhistory.d.ts.map +0 -1
  123. package/dist/core/command/commandhistory.js +0 -122
  124. package/dist/core/command/commandhistory.js.map +0 -1
  125. package/dist/core/command/editorcommands.d.ts +0 -108
  126. package/dist/core/command/editorcommands.d.ts.map +0 -1
  127. package/dist/core/command/editorcommands.js +0 -274
  128. package/dist/core/command/editorcommands.js.map +0 -1
  129. package/dist/core/command/index.d.ts +0 -5
  130. package/dist/core/command/index.d.ts.map +0 -1
  131. package/dist/core/command/index.js +0 -5
  132. package/dist/core/command/index.js.map +0 -1
  133. package/dist/core/editor/events/emitter.d.ts +0 -45
  134. package/dist/core/editor/events/emitter.d.ts.map +0 -1
  135. package/dist/core/editor/events/emitter.js +0 -88
  136. package/dist/core/editor/events/emitter.js.map +0 -1
  137. package/dist/core/error/animationerror.d.ts +0 -27
  138. package/dist/core/error/animationerror.d.ts.map +0 -1
  139. package/dist/core/error/animationerror.js +0 -41
  140. package/dist/core/error/animationerror.js.map +0 -1
  141. package/dist/core/error/asseterror.d.ts +0 -32
  142. package/dist/core/error/asseterror.d.ts.map +0 -1
  143. package/dist/core/error/asseterror.js +0 -48
  144. package/dist/core/error/asseterror.js.map +0 -1
  145. package/dist/core/error/index.d.ts +0 -7
  146. package/dist/core/error/index.d.ts.map +0 -1
  147. package/dist/core/error/index.js +0 -7
  148. package/dist/core/error/index.js.map +0 -1
  149. package/dist/core/error/pluginerror.d.ts +0 -22
  150. package/dist/core/error/pluginerror.d.ts.map +0 -1
  151. package/dist/core/error/pluginerror.js +0 -33
  152. package/dist/core/error/pluginerror.js.map +0 -1
  153. package/dist/core/error/renderererror.d.ts +0 -26
  154. package/dist/core/error/renderererror.d.ts.map +0 -1
  155. package/dist/core/error/renderererror.js +0 -40
  156. package/dist/core/error/renderererror.js.map +0 -1
  157. package/dist/core/error/samcanerror.d.ts +0 -72
  158. package/dist/core/error/samcanerror.d.ts.map +0 -1
  159. package/dist/core/error/samcanerror.js +0 -108
  160. package/dist/core/error/samcanerror.js.map +0 -1
  161. package/dist/core/error/serializationerror.d.ts +0 -31
  162. package/dist/core/error/serializationerror.d.ts.map +0 -1
  163. package/dist/core/error/serializationerror.js +0 -46
  164. package/dist/core/error/serializationerror.js.map +0 -1
  165. package/dist/core/index.d.ts +0 -12
  166. package/dist/core/index.d.ts.map +0 -1
  167. package/dist/core/index.js +0 -12
  168. package/dist/core/index.js.map +0 -1
  169. package/dist/core/math/color.d.ts +0 -56
  170. package/dist/core/math/color.d.ts.map +0 -1
  171. package/dist/core/math/color.js +0 -125
  172. package/dist/core/math/color.js.map +0 -1
  173. package/dist/core/math/index.d.ts +0 -14
  174. package/dist/core/math/index.d.ts.map +0 -1
  175. package/dist/core/math/index.js +0 -14
  176. package/dist/core/math/index.js.map +0 -1
  177. package/dist/core/math/matrix.d.ts +0 -101
  178. package/dist/core/math/matrix.d.ts.map +0 -1
  179. package/dist/core/math/matrix.js +0 -177
  180. package/dist/core/math/matrix.js.map +0 -1
  181. package/dist/core/math/paint.d.ts +0 -104
  182. package/dist/core/math/paint.d.ts.map +0 -1
  183. package/dist/core/math/paint.js +0 -204
  184. package/dist/core/math/paint.js.map +0 -1
  185. package/dist/core/math/path/index.d.ts +0 -94
  186. package/dist/core/math/path/index.d.ts.map +0 -1
  187. package/dist/core/math/path/index.js +0 -180
  188. package/dist/core/math/path/index.js.map +0 -1
  189. package/dist/core/math/path/operations.d.ts +0 -38
  190. package/dist/core/math/path/operations.d.ts.map +0 -1
  191. package/dist/core/math/path/operations.js +0 -149
  192. package/dist/core/math/path/operations.js.map +0 -1
  193. package/dist/core/math/pool.d.ts +0 -54
  194. package/dist/core/math/pool.d.ts.map +0 -1
  195. package/dist/core/math/pool.js +0 -97
  196. package/dist/core/math/pool.js.map +0 -1
  197. package/dist/core/math/pools.d.ts +0 -29
  198. package/dist/core/math/pools.d.ts.map +0 -1
  199. package/dist/core/math/pools.js +0 -50
  200. package/dist/core/math/pools.js.map +0 -1
  201. package/dist/core/math/rectangle.d.ts +0 -68
  202. package/dist/core/math/rectangle.d.ts.map +0 -1
  203. package/dist/core/math/rectangle.js +0 -124
  204. package/dist/core/math/rectangle.js.map +0 -1
  205. package/dist/core/math/utils.d.ts +0 -68
  206. package/dist/core/math/utils.d.ts.map +0 -1
  207. package/dist/core/math/utils.js +0 -110
  208. package/dist/core/math/utils.js.map +0 -1
  209. package/dist/core/math/vector2.d.ts +0 -85
  210. package/dist/core/math/vector2.d.ts.map +0 -1
  211. package/dist/core/math/vector2.js +0 -134
  212. package/dist/core/math/vector2.js.map +0 -1
  213. package/dist/core/plugin/animationcontroller.d.ts +0 -43
  214. package/dist/core/plugin/animationcontroller.d.ts.map +0 -1
  215. package/dist/core/plugin/animationcontroller.js +0 -11
  216. package/dist/core/plugin/animationcontroller.js.map +0 -1
  217. package/dist/core/plugin/index.d.ts +0 -6
  218. package/dist/core/plugin/index.d.ts.map +0 -1
  219. package/dist/core/plugin/index.js +0 -4
  220. package/dist/core/plugin/index.js.map +0 -1
  221. package/dist/core/plugin/plugin.d.ts +0 -53
  222. package/dist/core/plugin/plugin.d.ts.map +0 -1
  223. package/dist/core/plugin/plugin.js +0 -29
  224. package/dist/core/plugin/plugin.js.map +0 -1
  225. package/dist/core/plugin/pluginregistry.d.ts +0 -71
  226. package/dist/core/plugin/pluginregistry.d.ts.map +0 -1
  227. package/dist/core/plugin/pluginregistry.js +0 -143
  228. package/dist/core/plugin/pluginregistry.js.map +0 -1
  229. package/dist/core/renderer/batchmanager.d.ts +0 -68
  230. package/dist/core/renderer/batchmanager.d.ts.map +0 -1
  231. package/dist/core/renderer/batchmanager.js +0 -82
  232. package/dist/core/renderer/batchmanager.js.map +0 -1
  233. package/dist/core/renderer/canvas2drenderer.d.ts +0 -139
  234. package/dist/core/renderer/canvas2drenderer.d.ts.map +0 -1
  235. package/dist/core/renderer/canvas2drenderer.js +0 -499
  236. package/dist/core/renderer/canvas2drenderer.js.map +0 -1
  237. package/dist/core/renderer/dirtyregionmanager.d.ts +0 -54
  238. package/dist/core/renderer/dirtyregionmanager.d.ts.map +0 -1
  239. package/dist/core/renderer/dirtyregionmanager.js +0 -129
  240. package/dist/core/renderer/dirtyregionmanager.js.map +0 -1
  241. package/dist/core/renderer/index.d.ts +0 -8
  242. package/dist/core/renderer/index.d.ts.map +0 -1
  243. package/dist/core/renderer/index.js +0 -6
  244. package/dist/core/renderer/index.js.map +0 -1
  245. package/dist/core/renderer/renderer.d.ts +0 -154
  246. package/dist/core/renderer/renderer.d.ts.map +0 -1
  247. package/dist/core/renderer/renderer.js +0 -1
  248. package/dist/core/renderer/renderer.js.map +0 -1
  249. package/dist/core/renderer/rendererfactory.d.ts +0 -66
  250. package/dist/core/renderer/rendererfactory.d.ts.map +0 -1
  251. package/dist/core/renderer/rendererfactory.js +0 -219
  252. package/dist/core/renderer/rendererfactory.js.map +0 -1
  253. package/dist/core/renderer/webglrenderer.d.ts +0 -185
  254. package/dist/core/renderer/webglrenderer.d.ts.map +0 -1
  255. package/dist/core/renderer/webglrenderer.js +0 -1007
  256. package/dist/core/renderer/webglrenderer.js.map +0 -1
  257. package/dist/core/scene/index.d.ts +0 -4
  258. package/dist/core/scene/index.d.ts.map +0 -1
  259. package/dist/core/scene/index.js +0 -4
  260. package/dist/core/scene/index.js.map +0 -1
  261. package/dist/core/scene/node.d.ts +0 -162
  262. package/dist/core/scene/node.d.ts.map +0 -1
  263. package/dist/core/scene/node.js +0 -402
  264. package/dist/core/scene/node.js.map +0 -1
  265. package/dist/core/scene/nodes/artboard.d.ts +0 -42
  266. package/dist/core/scene/nodes/artboard.d.ts.map +0 -1
  267. package/dist/core/scene/nodes/artboard.js +0 -64
  268. package/dist/core/scene/nodes/artboard.js.map +0 -1
  269. package/dist/core/scene/nodes/groupnode.d.ts +0 -10
  270. package/dist/core/scene/nodes/groupnode.d.ts.map +0 -1
  271. package/dist/core/scene/nodes/groupnode.js +0 -12
  272. package/dist/core/scene/nodes/groupnode.js.map +0 -1
  273. package/dist/core/scene/nodes/imagenode.d.ts +0 -38
  274. package/dist/core/scene/nodes/imagenode.d.ts.map +0 -1
  275. package/dist/core/scene/nodes/imagenode.js +0 -77
  276. package/dist/core/scene/nodes/imagenode.js.map +0 -1
  277. package/dist/core/scene/nodes/index.d.ts +0 -5
  278. package/dist/core/scene/nodes/index.d.ts.map +0 -1
  279. package/dist/core/scene/nodes/index.js +0 -5
  280. package/dist/core/scene/nodes/index.js.map +0 -1
  281. package/dist/core/scene/nodes/shapenode.d.ts +0 -76
  282. package/dist/core/scene/nodes/shapenode.d.ts.map +0 -1
  283. package/dist/core/scene/nodes/shapenode.js +0 -212
  284. package/dist/core/scene/nodes/shapenode.js.map +0 -1
  285. package/dist/core/scene/transform.d.ts +0 -27
  286. package/dist/core/scene/transform.d.ts.map +0 -1
  287. package/dist/core/scene/transform.js +0 -52
  288. package/dist/core/scene/transform.js.map +0 -1
  289. package/dist/core/serialization/index.d.ts +0 -3
  290. package/dist/core/serialization/index.d.ts.map +0 -1
  291. package/dist/core/serialization/index.js +0 -2
  292. package/dist/core/serialization/index.js.map +0 -1
  293. package/dist/core/serialization/serializer.d.ts +0 -323
  294. package/dist/core/serialization/serializer.d.ts.map +0 -1
  295. package/dist/core/serialization/serializer.js +0 -1173
  296. package/dist/core/serialization/serializer.js.map +0 -1
  297. package/dist/core/serialization/types.d.ts +0 -242
  298. package/dist/core/serialization/types.d.ts.map +0 -1
  299. package/dist/core/serialization/types.js +0 -1
  300. package/dist/core/serialization/types.js.map +0 -1
  301. package/dist/core/timing/clock.d.ts +0 -43
  302. package/dist/core/timing/clock.d.ts.map +0 -1
  303. package/dist/core/timing/clock.js +0 -78
  304. package/dist/core/timing/clock.js.map +0 -1
  305. package/dist/core/timing/index.d.ts +0 -3
  306. package/dist/core/timing/index.d.ts.map +0 -1
  307. package/dist/core/timing/index.js +0 -3
  308. package/dist/core/timing/index.js.map +0 -1
  309. package/dist/core/timing/scheduler.d.ts +0 -72
  310. package/dist/core/timing/scheduler.d.ts.map +0 -1
  311. package/dist/core/timing/scheduler.js +0 -163
  312. package/dist/core/timing/scheduler.js.map +0 -1
  313. package/dist/index.d.ts.map +0 -1
  314. package/dist/index.js.map +0 -1
  315. package/dist/wrapper/react/index.d.ts +0 -5
  316. package/dist/wrapper/react/index.d.ts.map +0 -1
  317. package/dist/wrapper/react/index.js +0 -3
  318. package/dist/wrapper/react/index.js.map +0 -1
  319. package/dist/wrapper/react/samcan-player.d.ts +0 -26
  320. package/dist/wrapper/react/samcan-player.d.ts.map +0 -1
  321. package/dist/wrapper/react/samcan-player.js +0 -19
  322. package/dist/wrapper/react/samcan-player.js.map +0 -1
  323. package/dist/wrapper/react/use-samcan-player.d.ts +0 -33
  324. package/dist/wrapper/react/use-samcan-player.d.ts.map +0 -1
  325. package/dist/wrapper/react/use-samcan-player.js +0 -65
  326. package/dist/wrapper/react/use-samcan-player.js.map +0 -1
  327. package/readme.md +0 -96
@@ -0,0 +1,735 @@
1
+ var import_node_module = require("node:module");
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __moduleCache = /* @__PURE__ */ new WeakMap;
7
+ var __toCommonJS = (from) => {
8
+ var entry = __moduleCache.get(from), desc;
9
+ if (entry)
10
+ return entry;
11
+ entry = __defProp({}, "__esModule", { value: true });
12
+ if (from && typeof from === "object" || typeof from === "function")
13
+ __getOwnPropNames(from).map((key) => !__hasOwnProp.call(entry, key) && __defProp(entry, key, {
14
+ get: () => from[key],
15
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
+ }));
17
+ __moduleCache.set(from, entry);
18
+ return entry;
19
+ };
20
+ var __export = (target, all) => {
21
+ for (var name in all)
22
+ __defProp(target, name, {
23
+ get: all[name],
24
+ enumerable: true,
25
+ configurable: true,
26
+ set: (newValue) => all[name] = () => newValue
27
+ });
28
+ };
29
+
30
+ // document/index.ts
31
+ var exports_document = {};
32
+ __export(exports_document, {
33
+ z_index_of_element: () => z_index_of_element,
34
+ update_text_content: () => update_text_content,
35
+ update_stroke_spline: () => update_stroke_spline,
36
+ update_stroke_simplified_points: () => update_stroke_simplified_points,
37
+ update_stroke_points: () => update_stroke_points,
38
+ update_layer_visibility: () => update_layer_visibility,
39
+ update_layer_opacity: () => update_layer_opacity,
40
+ update_layer_name: () => update_layer_name,
41
+ update_layer_locked: () => update_layer_locked,
42
+ update_image_loaded: () => update_image_loaded,
43
+ update_image_asset_id: () => update_image_asset_id,
44
+ update_element_z_index: () => update_element_z_index,
45
+ update_element_layer_id: () => update_element_layer_id,
46
+ update_element_document: () => update_element_document,
47
+ update_element_bounds: () => update_element_bounds,
48
+ type_of_element: () => type_of_element,
49
+ text_align_right: () => text_align_right,
50
+ text_align_left: () => text_align_left,
51
+ text_align_center: () => text_align_center,
52
+ shape_type_rectangle: () => shape_type_rectangle,
53
+ shape_type_line: () => shape_type_line,
54
+ shape_type_frame: () => shape_type_frame,
55
+ shape_type_ellipse: () => shape_type_ellipse,
56
+ shape_type_arrow: () => shape_type_arrow,
57
+ set_active_layer_document: () => set_active_layer_document,
58
+ reorder_layers_document: () => reorder_layers_document,
59
+ reorder_element_ids_in_layer: () => reorder_element_ids_in_layer,
60
+ remove_layer_document: () => remove_layer_document,
61
+ remove_image_asset_document: () => remove_image_asset_document,
62
+ remove_element_id_from_layer: () => remove_element_id_from_layer,
63
+ remove_element_document: () => remove_element_document,
64
+ recalculate_bounds_document: () => recalculate_bounds_document,
65
+ opacity_of_layer: () => opacity_of_layer,
66
+ name_of_layer: () => name_of_layer,
67
+ layers_of_document: () => layers_of_document,
68
+ layer_id_of_element: () => layer_id_of_element,
69
+ is_visible_layer: () => is_visible_layer,
70
+ is_locked_layer: () => is_locked_layer,
71
+ id_of_layer: () => id_of_layer,
72
+ id_of_element: () => id_of_element,
73
+ id_of_document: () => id_of_document,
74
+ has_element_id_in_layer: () => has_element_id_in_layer,
75
+ get_layer_by_id_document: () => get_layer_by_id_document,
76
+ get_image_asset_document: () => get_image_asset_document,
77
+ get_elements_in_layer_document: () => get_elements_in_layer_document,
78
+ get_element_by_id_document: () => get_element_by_id_document,
79
+ get_all_elements_document: () => get_all_elements_document,
80
+ equals_layer: () => equals_layer,
81
+ equals_element_identity: () => equals_element_identity,
82
+ elements_map_of_document: () => elements_map_of_document,
83
+ element_type_text: () => element_type_text,
84
+ element_type_stroke: () => element_type_stroke,
85
+ element_type_shape: () => element_type_shape,
86
+ element_type_image: () => element_type_image,
87
+ element_ids_of_layer: () => element_ids_of_layer,
88
+ element_count_of_layer: () => element_count_of_layer,
89
+ element_count_of_document: () => element_count_of_document,
90
+ create_text_element: () => create_text_element,
91
+ create_stroke_element: () => create_stroke_element,
92
+ create_shape_element: () => create_shape_element,
93
+ create_layer: () => create_layer,
94
+ create_image_element: () => create_image_element,
95
+ create_image_asset: () => create_image_asset,
96
+ create_document: () => create_document,
97
+ clone_layer: () => clone_layer,
98
+ clone_element: () => clone_element,
99
+ clone_document: () => clone_document,
100
+ clear_document: () => clear_document,
101
+ bounds_of_element: () => bounds_of_element,
102
+ bounds_of_document: () => bounds_of_document,
103
+ assets_of_document: () => assets_of_document,
104
+ add_layer_document: () => add_layer_document,
105
+ add_image_asset_document: () => add_image_asset_document,
106
+ add_element_id_to_layer: () => add_element_id_to_layer,
107
+ add_element_document: () => add_element_document,
108
+ active_layer_id_of_document: () => active_layer_id_of_document
109
+ });
110
+ module.exports = __toCommonJS(exports_document);
111
+
112
+ // document/asset.ts
113
+ function create_image_asset(id, src, width = 0, height = 0) {
114
+ return { id, src, width, height };
115
+ }
116
+ // document/layer.ts
117
+ function create_layer(id, name, visible = true, locked = false, opacity = 1) {
118
+ return {
119
+ id,
120
+ name,
121
+ visible,
122
+ locked,
123
+ opacity: Math.max(0, Math.min(1, opacity)),
124
+ element_ids: []
125
+ };
126
+ }
127
+ function clone_layer(l) {
128
+ return {
129
+ id: l.id,
130
+ name: l.name,
131
+ visible: l.visible,
132
+ locked: l.locked,
133
+ opacity: l.opacity,
134
+ element_ids: [...l.element_ids]
135
+ };
136
+ }
137
+ function id_of_layer(l) {
138
+ return l.id;
139
+ }
140
+ function name_of_layer(l) {
141
+ return l.name;
142
+ }
143
+ function is_visible_layer(l) {
144
+ return l.visible;
145
+ }
146
+ function is_locked_layer(l) {
147
+ return l.locked;
148
+ }
149
+ function opacity_of_layer(l) {
150
+ return l.opacity;
151
+ }
152
+ function element_ids_of_layer(l) {
153
+ return l.element_ids;
154
+ }
155
+ function element_count_of_layer(l) {
156
+ return l.element_ids.length;
157
+ }
158
+ function update_layer_name(l, name) {
159
+ return {
160
+ ...l,
161
+ name
162
+ };
163
+ }
164
+ function update_layer_visibility(l, visible) {
165
+ return {
166
+ ...l,
167
+ visible
168
+ };
169
+ }
170
+ function update_layer_locked(l, locked) {
171
+ return {
172
+ ...l,
173
+ locked
174
+ };
175
+ }
176
+ function update_layer_opacity(l, opacity) {
177
+ return {
178
+ ...l,
179
+ opacity: Math.max(0, Math.min(1, opacity))
180
+ };
181
+ }
182
+ function add_element_id_to_layer(l, element_id) {
183
+ if (l.element_ids.includes(element_id)) {
184
+ return l;
185
+ }
186
+ return {
187
+ ...l,
188
+ element_ids: [...l.element_ids, element_id]
189
+ };
190
+ }
191
+ function remove_element_id_from_layer(l, element_id) {
192
+ const index = l.element_ids.indexOf(element_id);
193
+ if (index === -1) {
194
+ return l;
195
+ }
196
+ const new_ids = [...l.element_ids];
197
+ new_ids.splice(index, 1);
198
+ return {
199
+ ...l,
200
+ element_ids: new_ids
201
+ };
202
+ }
203
+ function has_element_id_in_layer(l, element_id) {
204
+ return l.element_ids.includes(element_id);
205
+ }
206
+ function reorder_element_ids_in_layer(l, element_ids) {
207
+ const existing_set = new Set(l.element_ids);
208
+ const filtered_ids = element_ids.filter((id) => existing_set.has(id));
209
+ const new_ids_set = new Set(filtered_ids);
210
+ const remaining_ids = l.element_ids.filter((id) => !new_ids_set.has(id));
211
+ return {
212
+ ...l,
213
+ element_ids: [...remaining_ids, ...filtered_ids]
214
+ };
215
+ }
216
+ function equals_layer(a, b) {
217
+ if (a.id !== b.id || a.name !== b.name) {
218
+ return false;
219
+ }
220
+ if (a.visible !== b.visible || a.locked !== b.locked) {
221
+ return false;
222
+ }
223
+ if (a.opacity !== b.opacity) {
224
+ return false;
225
+ }
226
+ if (a.element_ids.length !== b.element_ids.length) {
227
+ return false;
228
+ }
229
+ for (let i = 0;i < a.element_ids.length; i = i + 1) {
230
+ if (a.element_ids[i] !== b.element_ids[i]) {
231
+ return false;
232
+ }
233
+ }
234
+ return true;
235
+ }
236
+
237
+ // document/document.ts
238
+ function create_document(id, active_layer_id) {
239
+ return {
240
+ id,
241
+ elements: new Map,
242
+ layers: [],
243
+ active_layer_id,
244
+ assets: new Map,
245
+ bounds: [0, 0, 0, 0],
246
+ element_count: 0
247
+ };
248
+ }
249
+ function clone_document(doc) {
250
+ const new_elements = new Map;
251
+ for (const [id, el] of doc.elements) {
252
+ new_elements.set(id, el);
253
+ }
254
+ return {
255
+ id: doc.id,
256
+ elements: new_elements,
257
+ layers: doc.layers.map((l) => ({ ...l, element_ids: [...l.element_ids] })),
258
+ active_layer_id: doc.active_layer_id,
259
+ assets: new Map(doc.assets),
260
+ bounds: [doc.bounds[0], doc.bounds[1], doc.bounds[2], doc.bounds[3]],
261
+ element_count: doc.element_count
262
+ };
263
+ }
264
+ function id_of_document(doc) {
265
+ return doc.id;
266
+ }
267
+ function elements_map_of_document(doc) {
268
+ return doc.elements;
269
+ }
270
+ function layers_of_document(doc) {
271
+ return doc.layers;
272
+ }
273
+ function active_layer_id_of_document(doc) {
274
+ return doc.active_layer_id;
275
+ }
276
+ function assets_of_document(doc) {
277
+ return doc.assets;
278
+ }
279
+ function bounds_of_document(doc) {
280
+ return [doc.bounds[0], doc.bounds[1], doc.bounds[2], doc.bounds[3]];
281
+ }
282
+ function element_count_of_document(doc) {
283
+ return doc.element_count;
284
+ }
285
+ function get_element_by_id_document(doc, element_id) {
286
+ return doc.elements.get(element_id) || null;
287
+ }
288
+ function get_layer_by_id_document(doc, layer_id) {
289
+ for (let i = 0;i < doc.layers.length; i = i + 1) {
290
+ const layer = doc.layers[i];
291
+ if (layer && layer.id === layer_id) {
292
+ return layer;
293
+ }
294
+ }
295
+ return null;
296
+ }
297
+ function add_element_document(doc, el) {
298
+ const layer = get_layer_by_id_document(doc, el.layer_id);
299
+ if (layer === null) {
300
+ return doc;
301
+ }
302
+ const new_elements = new Map(doc.elements);
303
+ new_elements.set(el.id, el);
304
+ const new_layers = doc.layers.map((l) => {
305
+ if (l.id === el.layer_id) {
306
+ return add_element_id_to_layer(l, el.id);
307
+ }
308
+ return l;
309
+ });
310
+ const new_bounds = calculate_bounds_document_internal(new_elements);
311
+ return {
312
+ id: doc.id,
313
+ elements: new_elements,
314
+ layers: new_layers,
315
+ active_layer_id: doc.active_layer_id,
316
+ assets: doc.assets,
317
+ bounds: new_bounds,
318
+ element_count: new_elements.size
319
+ };
320
+ }
321
+ function remove_element_document(doc, element_id) {
322
+ const el = doc.elements.get(element_id);
323
+ if (el === undefined) {
324
+ return doc;
325
+ }
326
+ const new_elements = new Map(doc.elements);
327
+ new_elements.delete(element_id);
328
+ const new_layers = doc.layers.map((l) => {
329
+ if (l.id === el.layer_id) {
330
+ return remove_element_id_from_layer(l, element_id);
331
+ }
332
+ return l;
333
+ });
334
+ const new_bounds = calculate_bounds_document_internal(new_elements);
335
+ return {
336
+ id: doc.id,
337
+ elements: new_elements,
338
+ layers: new_layers,
339
+ active_layer_id: doc.active_layer_id,
340
+ assets: doc.assets,
341
+ bounds: new_bounds,
342
+ element_count: new_elements.size
343
+ };
344
+ }
345
+ function update_element_document(doc, element_id, new_element) {
346
+ if (!doc.elements.has(element_id)) {
347
+ return doc;
348
+ }
349
+ const old_element = doc.elements.get(element_id);
350
+ if (old_element === undefined) {
351
+ return doc;
352
+ }
353
+ const new_elements = new Map(doc.elements);
354
+ new_elements.set(element_id, new_element);
355
+ let new_layers = doc.layers;
356
+ if (old_element.layer_id !== new_element.layer_id) {
357
+ new_layers = doc.layers.map((l) => {
358
+ if (l.id === old_element.layer_id) {
359
+ return remove_element_id_from_layer(l, element_id);
360
+ }
361
+ if (l.id === new_element.layer_id) {
362
+ return add_element_id_to_layer(l, element_id);
363
+ }
364
+ return l;
365
+ });
366
+ }
367
+ const new_bounds = calculate_bounds_document_internal(new_elements);
368
+ return {
369
+ id: doc.id,
370
+ elements: new_elements,
371
+ layers: new_layers,
372
+ active_layer_id: doc.active_layer_id,
373
+ assets: doc.assets,
374
+ bounds: new_bounds,
375
+ element_count: new_elements.size
376
+ };
377
+ }
378
+ function add_layer_document(doc, layer) {
379
+ const existing = get_layer_by_id_document(doc, layer.id);
380
+ if (existing !== null) {
381
+ return doc;
382
+ }
383
+ return {
384
+ id: doc.id,
385
+ elements: doc.elements,
386
+ layers: [...doc.layers, layer],
387
+ active_layer_id: doc.active_layer_id,
388
+ assets: doc.assets,
389
+ bounds: doc.bounds,
390
+ element_count: doc.element_count
391
+ };
392
+ }
393
+ function remove_layer_document(doc, layer_id) {
394
+ const layer = get_layer_by_id_document(doc, layer_id);
395
+ if (layer === null) {
396
+ return doc;
397
+ }
398
+ const new_elements = new Map(doc.elements);
399
+ for (const element_id of layer.element_ids) {
400
+ new_elements.delete(element_id);
401
+ }
402
+ const new_layers = doc.layers.filter((l) => l.id !== layer_id);
403
+ let new_active_layer_id = doc.active_layer_id;
404
+ if (doc.active_layer_id === layer_id) {
405
+ if (new_layers.length > 0) {
406
+ const first_layer = new_layers[0];
407
+ if (first_layer !== undefined) {
408
+ new_active_layer_id = first_layer.id;
409
+ } else {
410
+ new_active_layer_id = "";
411
+ }
412
+ } else {
413
+ new_active_layer_id = "";
414
+ }
415
+ }
416
+ const new_bounds = calculate_bounds_document_internal(new_elements);
417
+ return {
418
+ id: doc.id,
419
+ elements: new_elements,
420
+ layers: new_layers,
421
+ active_layer_id: new_active_layer_id,
422
+ assets: doc.assets,
423
+ bounds: new_bounds,
424
+ element_count: new_elements.size
425
+ };
426
+ }
427
+ function reorder_layers_document(doc, layer_ids) {
428
+ const id_set = new Set(layer_ids);
429
+ const existing_ids = doc.layers.map((l) => l.id);
430
+ const missing_ids = existing_ids.filter((id) => !id_set.has(id));
431
+ const ordered_layers = [];
432
+ const layer_map = new Map(doc.layers.map((l) => [l.id, l]));
433
+ for (const id of layer_ids) {
434
+ const layer = layer_map.get(id);
435
+ if (layer) {
436
+ ordered_layers.push(layer);
437
+ }
438
+ }
439
+ for (const id of missing_ids) {
440
+ const layer = layer_map.get(id);
441
+ if (layer) {
442
+ ordered_layers.push(layer);
443
+ }
444
+ }
445
+ return {
446
+ id: doc.id,
447
+ elements: doc.elements,
448
+ layers: ordered_layers,
449
+ active_layer_id: doc.active_layer_id,
450
+ assets: doc.assets,
451
+ bounds: doc.bounds,
452
+ element_count: doc.element_count
453
+ };
454
+ }
455
+ function set_active_layer_document(doc, layer_id) {
456
+ const layer = get_layer_by_id_document(doc, layer_id);
457
+ if (layer === null) {
458
+ return doc;
459
+ }
460
+ return {
461
+ id: doc.id,
462
+ elements: doc.elements,
463
+ layers: doc.layers,
464
+ active_layer_id: layer_id,
465
+ assets: doc.assets,
466
+ bounds: doc.bounds,
467
+ element_count: doc.element_count
468
+ };
469
+ }
470
+ function get_elements_in_layer_document(doc, layer_id) {
471
+ const layer = get_layer_by_id_document(doc, layer_id);
472
+ if (layer === null) {
473
+ return [];
474
+ }
475
+ const elements = [];
476
+ for (const element_id of layer.element_ids) {
477
+ const el = doc.elements.get(element_id);
478
+ if (el !== undefined) {
479
+ elements.push(el);
480
+ }
481
+ }
482
+ return elements;
483
+ }
484
+ function get_all_elements_document(doc) {
485
+ return Array.from(doc.elements.values());
486
+ }
487
+ function calculate_bounds_document_internal(elements) {
488
+ if (elements.size === 0) {
489
+ return [0, 0, 0, 0];
490
+ }
491
+ let min_x = Infinity;
492
+ let min_y = Infinity;
493
+ let max_x = -Infinity;
494
+ let max_y = -Infinity;
495
+ for (const el of elements.values()) {
496
+ const bounds = el.bounds;
497
+ min_x = Math.min(min_x, bounds[0]);
498
+ min_y = Math.min(min_y, bounds[1]);
499
+ max_x = Math.max(max_x, bounds[0] + bounds[2]);
500
+ max_y = Math.max(max_y, bounds[1] + bounds[3]);
501
+ }
502
+ if (min_x === Infinity) {
503
+ return [0, 0, 0, 0];
504
+ }
505
+ return [min_x, min_y, max_x - min_x, max_y - min_y];
506
+ }
507
+ function recalculate_bounds_document(doc) {
508
+ const new_bounds = calculate_bounds_document_internal(doc.elements);
509
+ return {
510
+ id: doc.id,
511
+ elements: doc.elements,
512
+ layers: doc.layers,
513
+ active_layer_id: doc.active_layer_id,
514
+ assets: doc.assets,
515
+ bounds: new_bounds,
516
+ element_count: doc.element_count
517
+ };
518
+ }
519
+ function clear_document(doc) {
520
+ return {
521
+ id: doc.id,
522
+ elements: new Map,
523
+ layers: doc.layers.map((l) => ({ ...l, element_ids: [] })),
524
+ active_layer_id: doc.active_layer_id,
525
+ assets: doc.assets,
526
+ bounds: [0, 0, 0, 0],
527
+ element_count: 0
528
+ };
529
+ }
530
+ function add_image_asset_document(doc, asset) {
531
+ const assets = new Map(doc.assets);
532
+ assets.set(asset.id, { ...asset });
533
+ return {
534
+ ...doc,
535
+ assets
536
+ };
537
+ }
538
+ function get_image_asset_document(doc, asset_id) {
539
+ return doc.assets.get(asset_id) ?? null;
540
+ }
541
+ function remove_image_asset_document(doc, asset_id) {
542
+ if (!doc.assets.has(asset_id))
543
+ return doc;
544
+ const assets = new Map(doc.assets);
545
+ assets.delete(asset_id);
546
+ return {
547
+ ...doc,
548
+ assets
549
+ };
550
+ }
551
+ // document/element.ts
552
+ var element_type_stroke = 0;
553
+ var element_type_shape = 1;
554
+ var element_type_image = 2;
555
+ var element_type_text = 3;
556
+ var shape_type_rectangle = 0;
557
+ var shape_type_ellipse = 1;
558
+ var shape_type_line = 2;
559
+ var shape_type_arrow = 3;
560
+ var shape_type_frame = 4;
561
+ var text_align_left = 0;
562
+ var text_align_center = 1;
563
+ var text_align_right = 2;
564
+ function create_stroke_element(id, bounds, z_index, layer_id, points, pressure, color, width, group_id = null) {
565
+ return {
566
+ type: element_type_stroke,
567
+ id,
568
+ bounds: [bounds[0], bounds[1], bounds[2], bounds[3]],
569
+ z_index,
570
+ layer_id,
571
+ group_id,
572
+ points: points.map((p) => [p[0], p[1]]),
573
+ pressure: pressure === null ? null : [...pressure],
574
+ color: [color[0], color[1], color[2], color[3]],
575
+ width,
576
+ simplified_points: null,
577
+ spline: null
578
+ };
579
+ }
580
+ function create_shape_element(id, bounds, z_index, layer_id, shape_type, fill_color, stroke_color, stroke_width, start_point, end_point, group_id = null) {
581
+ return {
582
+ type: element_type_shape,
583
+ id,
584
+ bounds: [bounds[0], bounds[1], bounds[2], bounds[3]],
585
+ z_index,
586
+ layer_id,
587
+ group_id,
588
+ shape_type,
589
+ fill_color: fill_color === null ? null : [fill_color[0], fill_color[1], fill_color[2], fill_color[3]],
590
+ stroke_color: stroke_color === null ? null : [stroke_color[0], stroke_color[1], stroke_color[2], stroke_color[3]],
591
+ stroke_width,
592
+ start_point: start_point === null ? null : [start_point[0], start_point[1]],
593
+ end_point: end_point === null ? null : [end_point[0], end_point[1]]
594
+ };
595
+ }
596
+ function create_image_element(id, bounds, z_index, layer_id, src, original_width, original_height, opacity, group_id = null, asset_id = null) {
597
+ return {
598
+ type: element_type_image,
599
+ id,
600
+ bounds: [bounds[0], bounds[1], bounds[2], bounds[3]],
601
+ z_index,
602
+ layer_id,
603
+ group_id,
604
+ asset_id,
605
+ src,
606
+ original_width,
607
+ original_height,
608
+ opacity,
609
+ loaded: false,
610
+ load_error: false,
611
+ bitmap: null
612
+ };
613
+ }
614
+ function create_text_element(id, bounds, z_index, layer_id, content, font_family, font_size, color, align, group_id = null) {
615
+ return {
616
+ type: element_type_text,
617
+ id,
618
+ bounds: [bounds[0], bounds[1], bounds[2], bounds[3]],
619
+ z_index,
620
+ layer_id,
621
+ group_id,
622
+ content,
623
+ font_family,
624
+ font_size,
625
+ color: [color[0], color[1], color[2], color[3]],
626
+ align
627
+ };
628
+ }
629
+ function clone_element(el) {
630
+ if (el.type === element_type_stroke) {
631
+ const stroke = el;
632
+ return create_stroke_element(stroke.id, stroke.bounds, stroke.z_index, stroke.layer_id, stroke.points, stroke.pressure, stroke.color, stroke.width, stroke.group_id);
633
+ } else if (el.type === element_type_shape) {
634
+ const shape = el;
635
+ return create_shape_element(shape.id, shape.bounds, shape.z_index, shape.layer_id, shape.shape_type, shape.fill_color, shape.stroke_color, shape.stroke_width, shape.start_point, shape.end_point, shape.group_id);
636
+ } else if (el.type === element_type_image) {
637
+ const image = el;
638
+ const cloned = create_image_element(image.id, image.bounds, image.z_index, image.layer_id, image.src, image.original_width, image.original_height, image.opacity, image.group_id, image.asset_id);
639
+ cloned.loaded = image.loaded;
640
+ cloned.load_error = image.load_error;
641
+ cloned.bitmap = image.bitmap;
642
+ return cloned;
643
+ } else {
644
+ const text = el;
645
+ return create_text_element(text.id, text.bounds, text.z_index, text.layer_id, text.content, text.font_family, text.font_size, text.color, text.align, text.group_id);
646
+ }
647
+ }
648
+ function id_of_element(el) {
649
+ return el.id;
650
+ }
651
+ function bounds_of_element(el) {
652
+ return [el.bounds[0], el.bounds[1], el.bounds[2], el.bounds[3]];
653
+ }
654
+ function z_index_of_element(el) {
655
+ return el.z_index;
656
+ }
657
+ function layer_id_of_element(el) {
658
+ return el.layer_id;
659
+ }
660
+ function type_of_element(el) {
661
+ return el.type;
662
+ }
663
+ function update_element_bounds(el, bounds) {
664
+ const cloned = clone_element(el);
665
+ const mutable = cloned;
666
+ mutable.bounds = [bounds[0], bounds[1], bounds[2], bounds[3]];
667
+ return cloned;
668
+ }
669
+ function update_element_z_index(el, z_index) {
670
+ const cloned = clone_element(el);
671
+ const mutable = cloned;
672
+ mutable.z_index = z_index;
673
+ return cloned;
674
+ }
675
+ function update_element_layer_id(el, layer_id) {
676
+ const cloned = clone_element(el);
677
+ const mutable = cloned;
678
+ mutable.layer_id = layer_id;
679
+ return cloned;
680
+ }
681
+ function update_stroke_points(el, points) {
682
+ return {
683
+ ...el,
684
+ points: points.map((p) => [p[0], p[1]]),
685
+ simplified_points: null,
686
+ spline: null
687
+ };
688
+ }
689
+ function update_stroke_simplified_points(el, simplified) {
690
+ return {
691
+ ...el,
692
+ simplified_points: simplified === null ? null : simplified.map((p) => [p[0], p[1]])
693
+ };
694
+ }
695
+ function update_stroke_spline(el, spline_data) {
696
+ return {
697
+ ...el,
698
+ spline: spline_data
699
+ };
700
+ }
701
+ function update_image_loaded(el, loaded, bitmap, load_error = false) {
702
+ return {
703
+ ...el,
704
+ loaded,
705
+ load_error,
706
+ bitmap
707
+ };
708
+ }
709
+ function update_image_asset_id(el, asset_id) {
710
+ return {
711
+ ...el,
712
+ asset_id
713
+ };
714
+ }
715
+ function update_text_content(el, content) {
716
+ return {
717
+ ...el,
718
+ content
719
+ };
720
+ }
721
+ function equals_element_identity(a, b) {
722
+ if (a.type !== b.type || a.id !== b.id) {
723
+ return false;
724
+ }
725
+ if (a.z_index !== b.z_index || a.layer_id !== b.layer_id) {
726
+ return false;
727
+ }
728
+ if (a.group_id !== b.group_id) {
729
+ return false;
730
+ }
731
+ if (a.bounds[0] !== b.bounds[0] || a.bounds[1] !== b.bounds[1] || a.bounds[2] !== b.bounds[2] || a.bounds[3] !== b.bounds[3]) {
732
+ return false;
733
+ }
734
+ return true;
735
+ }