motionary 10.5.0 → 10.7.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 (128) hide show
  1. package/AGENTS.md +2 -0
  2. package/CHANGELOG.md +28 -0
  3. package/README.md +95 -1
  4. package/bin/motionary-mcp.mjs +160 -11
  5. package/dist/chunks/{anim-image-DuxvYhq6.cjs → anim-image-CFGpUX7t.cjs} +2 -2
  6. package/dist/chunks/{anim-image-DuxvYhq6.cjs.map → anim-image-CFGpUX7t.cjs.map} +1 -1
  7. package/dist/chunks/{anim-image-BlNPv4JG.js → anim-image-CXDD19FH.js} +2 -2
  8. package/dist/chunks/{anim-image-BlNPv4JG.js.map → anim-image-CXDD19FH.js.map} +1 -1
  9. package/dist/chunks/{keyframes-Ce1s05n3.cjs → keyframes-DdwGY1gr.cjs} +2 -2
  10. package/dist/chunks/{keyframes-Ce1s05n3.cjs.map → keyframes-DdwGY1gr.cjs.map} +1 -1
  11. package/dist/chunks/{keyframes-B8ITIAVa.js → keyframes-DwR6GPej.js} +2 -2
  12. package/dist/chunks/{keyframes-B8ITIAVa.js.map → keyframes-DwR6GPej.js.map} +1 -1
  13. package/dist/chunks/{registry-DXdFb2fJ.js → registry-D87dP_aR.js} +3 -3
  14. package/dist/chunks/{registry-DXdFb2fJ.js.map → registry-D87dP_aR.js.map} +1 -1
  15. package/dist/chunks/{registry-VhfPSI0v.cjs → registry-DhKZCitb.cjs} +2 -2
  16. package/dist/chunks/{registry-VhfPSI0v.cjs.map → registry-DhKZCitb.cjs.map} +1 -1
  17. package/dist/chunks/{ticker-C5RMHMW7.js → ticker-CJYI5Pxc.js} +2 -2
  18. package/dist/chunks/{ticker-C5RMHMW7.js.map → ticker-CJYI5Pxc.js.map} +1 -1
  19. package/dist/chunks/{ticker-DvmC6WLS.cjs → ticker-jD9_A9Rh.cjs} +2 -2
  20. package/dist/chunks/{ticker-DvmC6WLS.cjs.map → ticker-jD9_A9Rh.cjs.map} +1 -1
  21. package/dist/chunks/{tween-_BGIl6hK.cjs → tween-Dk0QmNe9.cjs} +2 -2
  22. package/dist/chunks/{tween-_BGIl6hK.cjs.map → tween-Dk0QmNe9.cjs.map} +1 -1
  23. package/dist/chunks/{tween-CPtm-EdT.js → tween-_Lld1MsF.js} +2 -2
  24. package/dist/chunks/{tween-CPtm-EdT.js.map → tween-_Lld1MsF.js.map} +1 -1
  25. package/dist/components/ai.cjs +314 -0
  26. package/dist/components/ai.cjs.map +1 -0
  27. package/dist/components/ai.d.cts +58 -0
  28. package/dist/components/ai.d.ts +58 -0
  29. package/dist/components/ai.js +311 -0
  30. package/dist/components/ai.js.map +1 -0
  31. package/dist/components/lite.cjs +179 -0
  32. package/dist/components/lite.cjs.map +1 -1
  33. package/dist/components/lite.js +176 -1
  34. package/dist/components/lite.js.map +1 -1
  35. package/dist/components/tokens.cjs +179 -0
  36. package/dist/components/tokens.cjs.map +1 -1
  37. package/dist/components/tokens.d.cts +36 -1
  38. package/dist/components/tokens.d.ts +36 -1
  39. package/dist/components/tokens.js +176 -1
  40. package/dist/components/tokens.js.map +1 -1
  41. package/dist/components/widgets.cjs +985 -221
  42. package/dist/components/widgets.cjs.map +1 -1
  43. package/dist/components/widgets.d.cts +606 -4
  44. package/dist/components/widgets.d.ts +606 -4
  45. package/dist/components/widgets.js +976 -222
  46. package/dist/components/widgets.js.map +1 -1
  47. package/dist/components.cjs +4 -0
  48. package/dist/components.cjs.map +1 -1
  49. package/dist/components.d.cts +36 -1
  50. package/dist/components.d.ts +36 -1
  51. package/dist/components.js +1 -1
  52. package/dist/components.umd.js +2 -2
  53. package/dist/components.umd.js.map +1 -1
  54. package/dist/index.umd.js.map +1 -1
  55. package/dist/llms-full.txt +221 -1
  56. package/dist/llms.txt +11 -2
  57. package/dist/manifest.json +580 -1
  58. package/dist/runtime/format-apng.cjs +4 -4
  59. package/dist/runtime/format-apng.js +4 -4
  60. package/dist/runtime/format-css.cjs +4 -4
  61. package/dist/runtime/format-css.js +4 -4
  62. package/dist/runtime/format-gif.cjs +4 -4
  63. package/dist/runtime/format-gif.js +4 -4
  64. package/dist/runtime/format-gltf.cjs +1 -1
  65. package/dist/runtime/format-gltf.js +1 -1
  66. package/dist/runtime/format-motion.cjs +4 -4
  67. package/dist/runtime/format-motion.js +4 -4
  68. package/dist/runtime/format-obj.cjs +1 -1
  69. package/dist/runtime/format-obj.js +1 -1
  70. package/dist/runtime/format-scene.cjs +241 -0
  71. package/dist/runtime/format-scene.cjs.map +1 -0
  72. package/dist/runtime/format-scene.d.cts +349 -0
  73. package/dist/runtime/format-scene.d.ts +349 -0
  74. package/dist/runtime/format-scene.iife.js +2 -0
  75. package/dist/runtime/format-scene.iife.js.map +1 -0
  76. package/dist/runtime/format-scene.js +233 -0
  77. package/dist/runtime/format-scene.js.map +1 -0
  78. package/dist/runtime/format-sprite.cjs +3 -3
  79. package/dist/runtime/format-sprite.js +3 -3
  80. package/dist/runtime/format-svg.cjs +3 -3
  81. package/dist/runtime/format-svg.js +3 -3
  82. package/dist/runtime/format-webp.cjs +4 -4
  83. package/dist/runtime/format-webp.js +4 -4
  84. package/dist/runtime/gl.cjs +1 -1
  85. package/dist/runtime/gl.js +1 -1
  86. package/dist/runtime/physics.cjs +739 -0
  87. package/dist/runtime/physics.cjs.map +1 -0
  88. package/dist/runtime/physics.d.cts +250 -0
  89. package/dist/runtime/physics.d.ts +250 -0
  90. package/dist/runtime/physics.iife.js +2 -0
  91. package/dist/runtime/physics.iife.js.map +1 -0
  92. package/dist/runtime/physics.js +731 -0
  93. package/dist/runtime/physics.js.map +1 -0
  94. package/dist/runtime/scroll.cjs +2 -2
  95. package/dist/runtime/scroll.js +2 -2
  96. package/dist/runtime/smooth.cjs +1 -1
  97. package/dist/runtime/smooth.js +1 -1
  98. package/dist/runtime/text.cjs +1 -1
  99. package/dist/runtime/text.js +1 -1
  100. package/dist/runtime/vector.cjs +704 -0
  101. package/dist/runtime/vector.cjs.map +1 -0
  102. package/dist/runtime/vector.d.cts +306 -0
  103. package/dist/runtime/vector.d.ts +306 -0
  104. package/dist/runtime/vector.iife.js +2 -0
  105. package/dist/runtime/vector.iife.js.map +1 -0
  106. package/dist/runtime/vector.js +692 -0
  107. package/dist/runtime/vector.js.map +1 -0
  108. package/dist/runtime.cjs +3 -3
  109. package/dist/runtime.d.cts +1 -1
  110. package/dist/runtime.d.ts +1 -1
  111. package/dist/runtime.iife.js +1 -1
  112. package/dist/runtime.iife.js.map +1 -1
  113. package/dist/runtime.js +5 -5
  114. package/dist/widgets.umd.js +1 -1
  115. package/dist/widgets.umd.js.map +1 -1
  116. package/docs/ROADMAP.md +2 -2
  117. package/docs/components/README.md +6 -1
  118. package/docs/components/usa-lottie-player.md +60 -0
  119. package/docs/components/usa-motion-prompt.md +32 -0
  120. package/docs/components/usa-physics-playground.md +63 -0
  121. package/docs/components/usa-rive.md +57 -0
  122. package/docs/components/usa-token-editor.md +32 -0
  123. package/docs/components.md +116 -0
  124. package/docs/runtime/format-scene.md +59 -0
  125. package/docs/runtime/physics.md +61 -0
  126. package/docs/runtime/rive.md +55 -0
  127. package/docs/runtime/vector.md +67 -0
  128. package/package.json +46 -2
@@ -0,0 +1,2 @@
1
+ !function(e,t){"use strict";const i="motionary-scene@1",s=e=>"number"==typeof e&&isFinite(e),n=e=>Array.isArray(e)&&2===e.length&&e.every(s);function o(e){const t=[],n="string"==typeof e?JSON.parse(e):JSON.parse(JSON.stringify(e??{}));if(n.format===i)return{scene:n,changes:t};if(n.format&&"motionary-scene@0"!==n.format)throw new Error(`[motionary] scene: unknown format "${n.format}" (this build reads ${i} and migrates motionary-scene@0 / unversioned scenes)`);return t.push(`${n.format||"unversioned"} → ${i}`),n.format=i,n.world||(n.world={width:n.width??600,height:n.height??400},null!=n.gravity&&(n.world.gravity=s(n.gravity)?[0,n.gravity]:n.gravity),null!=n.walls&&(n.world.walls=n.walls),delete n.width,delete n.height,delete n.gravity,delete n.walls,t.push('top-level width / height / gravity moved into "world"')),s(n.world.gravity)&&(n.world.gravity=[0,n.world.gravity],t.push("world.gravity number → [0, g]")),n.bodies=(n.bodies||[]).map((e,i)=>{const n={...e};return n.id||(n.id=`body-${i+1}`,t.push(`bodies[${i}]: id "${n.id}" added`)),null==n.position&&(s(n.x)||s(n.y))&&(n.position=[n.x??0,n.y??0],delete n.x,delete n.y,t.push(`bodies[${i}]: x / y → position`)),null==n.size&&(s(n.w)||s(n.h))&&(n.size=[n.w??40,n.h??40],delete n.w,delete n.h,t.push(`bodies[${i}]: w / h → size`)),"static"===n.type||"kinematic"===n.type?(n[n.type]=!0,delete n.type,t.push(`bodies[${i}]: type → ${n.static?"static":"kinematic"}: true`)):"dynamic"===n.type&&delete n.type,n.shape||(n.shape=null!=n.radius?"circle":n.vertices?"polygon":"box"),n}),{scene:n,changes:t}}function a(e){const t=[];let i;try{i=o(e).scene}catch(e){return[String(e.message).replace("[motionary] scene: ","")]}(!i.world||!s(i.world.width)||!s(i.world.height)||i.world.width<=0||i.world.height<=0)&&t.push("world: width and height must be positive numbers"),null==i.world?.gravity||n(i.world.gravity)||t.push("world.gravity must be [x, y]");const a=i.materials||{};for(const[e,i]of Object.entries(a))for(const n of["restitution","friction","density"])null!=i[n]&&(!s(i[n])||i[n]<0)&&t.push(`materials.${e}.${n} must be a number ≥ 0`);Array.isArray(i.bodies)||t.push("bodies must be an array");const r=new Set;return(i.bodies||[]).forEach((e,i)=>{const o=`bodies[${i}]${e.id?` ("${e.id}")`:""}`;r.has(e.id)&&t.push(`${o}: duplicate id`),r.add(e.id),["circle","box","polygon"].includes(e.shape)||t.push(`${o}: shape must be circle, box or polygon`),n(e.position)||t.push(`${o}: position must be [x, y]`),"circle"!==e.shape||s(e.radius)&&e.radius>0||t.push(`${o}: circle needs radius > 0`),"box"!==e.shape||n(e.size)&&e.size[0]>0&&e.size[1]>0||t.push(`${o}: box needs size [w, h] > 0`),"polygon"!==e.shape||Array.isArray(e.vertices)&&e.vertices.length>=3&&e.vertices.every(n)||t.push(`${o}: polygon needs ≥ 3 vertices [x, y]`),e.material&&!a[e.material]&&t.push(`${o}: unknown material "${e.material}"`),e.static&&e.kinematic&&t.push(`${o}: static and kinematic are exclusive`)}),(i.constraints||[]).forEach((e,i)=>{const o=`constraints[${i}]`;["distance","pin"].includes(e.type)||t.push(`${o}: type must be distance or pin`),r.has(e.a)||t.push(`${o}: unknown body "${e.a}"`),"distance"!==e.type||r.has(e.b)||t.push(`${o}: distance needs body b (unknown "${e.b}")`),"pin"!==e.type||null==e.point||n(e.point)||t.push(`${o}: point must be [x, y]`),null==e.stiffness||s(e.stiffness)&&e.stiffness>0&&e.stiffness<=1||t.push(`${o}: stiffness must be in (0, 1]`)}),t}function r(e){const{scene:t}=o(e),i=a(t);if(i.length)throw new Error(`[motionary] scene: ${i.length} problem(s): ${i.join("; ")}`);return t}function l(e){const i=r(e),s=t.requireModule("physics","motionary/runtime/format-scene"),n=i.world,o=s.createWorld({gravity:n.gravity||[0,980],iterations:n.iterations});n.walls&&o.bounds(n.width,n.height,50,"object"==typeof n.walls?n.walls:{});const a={};for(const e of i.bodies){const t=e.material&&i.materials?.[e.material]||{},s={shape:e.shape,x:e.position[0],y:e.position[1],angle:e.angle,radius:e.radius,width:e.size?.[0],height:e.size?.[1],vertices:e.vertices,type:e.static?"static":e.kinematic?"kinematic":"dynamic",restitution:e.restitution??t.restitution,friction:e.friction??t.friction,density:e.density??t.density,vx:e.velocity?.[0],vy:e.velocity?.[1],angularVelocity:e.angularVelocity,sensor:e.sensor,label:e.id,data:{id:e.id,style:e.style||{},material:e.material}};a[e.id]=o.body(s)}for(const e of i.constraints||[])o.constraint({type:e.type,a:a[e.a],b:e.b?a[e.b]:void 0,point:e.point,anchorA:e.anchorA,anchorB:e.anchorB,length:e.length,stiffness:e.stiffness,damping:e.damping});return{world:o,bodies:a,scene:i}}function c(e,t={width:600,height:400}){const s=e=>Math.round(1e3*e)/1e3,n=new Set(["floor","wall-left","wall-right","ceiling"]),o=e.bodies.filter(e=>!(e.isStatic&&n.has(e.label))),a=e=>e.data?.id||e.label+"-"+e.id,r=o.map(e=>{const t={id:a(e),shape:e.shape,position:[s(e.position.x),s(e.position.y)]};if(e.angle&&(t.angle=s(e.angle)),"circle"===e.shape)t.radius=s(e.radius);else{const i=e.verts.map(e=>e.x),n=e.verts.map(e=>e.y);"box"===e.shape?t.size=[s(Math.max(...i)-Math.min(...i)),s(Math.max(...n)-Math.min(...n))]:t.vertices=e.verts.map(e=>[s(e.x),s(e.y)])}"static"===e.type&&(t.static=!0),"kinematic"===e.type&&(t.kinematic=!0),t.restitution=e.restitution,t.friction=e.friction,"dynamic"===e.type&&(e.velocity.x||e.velocity.y)&&(t.velocity=[s(e.velocity.x),s(e.velocity.y)]),e.angularVelocity&&(t.angularVelocity=s(e.angularVelocity)),e.sensor&&(t.sensor=!0);const i=e.data?.style;return i&&Object.keys(i).length&&(t.style=i),t}),l=e.constraints.filter(e=>"drag"!==e.label&&o.includes(e.a)&&(!e.b||o.includes(e.b))).map(e=>({type:e.type,a:a(e.a),...e.b?{b:a(e.b)}:{point:[s(e.point.x),s(e.point.y)]},anchorA:[s(e.anchorA.x),s(e.anchorA.y)],...e.b?{anchorB:[s(e.anchorB.x),s(e.anchorB.y)]}:{},length:s(e.length),stiffness:e.stiffness,damping:e.damping}));return{format:i,...t.name?{name:t.name}:{},world:{width:t.width,height:t.height,gravity:[e.gravity.x,e.gravity.y],walls:t.walls??e.bodies.some(e=>n.has(e.label))},bodies:r,constraints:l}}const d={id:"format-scene",version:t.RUNTIME_VERSION,requires:["core","physics"],api:{SCENE_FORMAT:i,migrateScene:o,validateScene:a,parseScene:r,sceneToWorld:l,worldToScene:c}};t.register(d),e.SCENE_FORMAT=i,e.formatScene=d,e.migrateScene=o,e.parseScene=r,e.sceneToWorld=l,e.validateScene=a,e.worldToScene=c}(this.MotionaryRuntime=this.MotionaryRuntime||{},MotionaryRuntime);
2
+ //# sourceMappingURL=format-scene.iife.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format-scene.iife.js","sources":["../../src/runtime/format-scene.ts","../../src/runtime/iife/format-scene.ts"],"sourcesContent":["/**\n * `motionary/runtime/format-scene` (10.7) — the versioned scene format\n * `motionary-scene@1`: a JSON description of a 2D physics scene (world,\n * named materials, bodies, constraints, per-body style) that\n * `<usa-physics-playground>` and your own code can load, validate,\n * migrate and save.\n *\n * ```json\n * { \"format\": \"motionary-scene@1\",\n * \"world\": { \"width\": 600, \"height\": 360, \"gravity\": [0, 980], \"walls\": true },\n * \"materials\": { \"rubber\": { \"restitution\": 0.8, \"friction\": 0.6, \"density\": 0.001 } },\n * \"bodies\": [\n * { \"id\": \"ball\", \"shape\": \"circle\", \"radius\": 20, \"position\": [120, 40], \"material\": \"rubber\", \"style\": { \"fill\": \"#f472b6\" } },\n * { \"id\": \"floor-plank\", \"shape\": \"box\", \"size\": [300, 16], \"position\": [300, 300], \"angle\": 0.1, \"static\": true }\n * ],\n * \"constraints\": [ { \"type\": \"distance\", \"a\": \"ball\", \"b\": \"floor-plank\", \"length\": 120, \"stiffness\": 0.3 } ] }\n * ```\n *\n * - `validateScene(json)` lists problems (never throws);\n * - `migrateScene(json)` upgrades older shapes (an unversioned scene, the\n * `motionary-scene@0` draft) to `@1` and reports what it changed;\n * - `parseScene(json)` = migrate + validate, throws on errors;\n * - `sceneToWorld(scene)` builds a `motionary/runtime/physics` world\n * (bodies by id); `worldToScene(world)` saves one back.\n *\n * Needs `motionary/runtime/physics` registered for `sceneToWorld` /\n * `worldToScene`; validation and migration are pure.\n */\nimport { RUNTIME_VERSION, requireModule, type RuntimeModule } from './registry';\nimport type { PhysicsApi, World, Body, BodyOptions } from './physics';\n\ntype Num = number;\nexport const SCENE_FORMAT = 'motionary-scene@1';\n\nexport interface SceneMaterial { restitution?: Num; friction?: Num; density?: Num }\nexport interface SceneBody {\n id: string;\n shape: 'circle' | 'box' | 'polygon';\n position: [Num, Num];\n angle?: Num;\n radius?: Num;\n size?: [Num, Num];\n vertices?: [Num, Num][];\n static?: boolean;\n kinematic?: boolean;\n material?: string;\n restitution?: Num;\n friction?: Num;\n density?: Num;\n velocity?: [Num, Num];\n angularVelocity?: Num;\n sensor?: boolean;\n style?: { fill?: string; stroke?: string; label?: string };\n}\nexport interface SceneConstraint {\n type: 'distance' | 'pin';\n a: string;\n b?: string;\n point?: [Num, Num];\n anchorA?: [Num, Num];\n anchorB?: [Num, Num];\n length?: Num;\n stiffness?: Num;\n damping?: Num;\n}\nexport interface Scene {\n format: typeof SCENE_FORMAT;\n name?: string;\n world: { width: Num; height: Num; gravity?: [Num, Num]; walls?: boolean | { top?: boolean }; iterations?: Num };\n materials?: Record<string, SceneMaterial>;\n bodies: SceneBody[];\n constraints?: SceneConstraint[];\n}\n\nconst isNum = (x: unknown): x is Num => typeof x === 'number' && isFinite(x);\nconst isVec = (x: unknown): x is [Num, Num] => Array.isArray(x) && x.length === 2 && x.every(isNum);\n\n/** Upgrade older scene shapes to `motionary-scene@1`. Returns the scene and what changed. */\nexport function migrateScene(input: unknown): { scene: any; changes: string[] } {\n const changes: string[] = [];\n const s: any = typeof input === 'string' ? JSON.parse(input) : JSON.parse(JSON.stringify(input ?? {}));\n if (s.format === SCENE_FORMAT) return { scene: s, changes };\n if (s.format && s.format !== 'motionary-scene@0') throw new Error(`[motionary] scene: unknown format \"${s.format}\" (this build reads ${SCENE_FORMAT} and migrates motionary-scene@0 / unversioned scenes)`);\n changes.push(`${s.format || 'unversioned'} → ${SCENE_FORMAT}`);\n s.format = SCENE_FORMAT;\n // @0 / unversioned: { width, height, gravity: number } at the top level, bodies with x / y / w / h / type\n if (!s.world) {\n s.world = { width: s.width ?? 600, height: s.height ?? 400 };\n if (s.gravity != null) s.world.gravity = isNum(s.gravity) ? [0, s.gravity] : s.gravity;\n if (s.walls != null) s.world.walls = s.walls;\n delete s.width, delete s.height, delete s.gravity, delete s.walls;\n changes.push('top-level width / height / gravity moved into \"world\"');\n }\n if (isNum(s.world.gravity)) {\n s.world.gravity = [0, s.world.gravity];\n changes.push('world.gravity number → [0, g]');\n }\n s.bodies = (s.bodies || []).map((b: any, i: number) => {\n const o: any = { ...b };\n if (!o.id) (o.id = `body-${i + 1}`), changes.push(`bodies[${i}]: id \"${o.id}\" added`);\n if (o.position == null && (isNum(o.x) || isNum(o.y))) {\n o.position = [o.x ?? 0, o.y ?? 0];\n delete o.x, delete o.y;\n changes.push(`bodies[${i}]: x / y → position`);\n }\n if (o.size == null && (isNum(o.w) || isNum(o.h))) {\n o.size = [o.w ?? 40, o.h ?? 40];\n delete o.w, delete o.h;\n changes.push(`bodies[${i}]: w / h → size`);\n }\n if (o.type === 'static' || o.type === 'kinematic') {\n o[o.type] = true;\n delete o.type;\n changes.push(`bodies[${i}]: type → ${o.static ? 'static' : 'kinematic'}: true`);\n } else if (o.type === 'dynamic') delete o.type;\n if (!o.shape) o.shape = o.radius != null ? 'circle' : o.vertices ? 'polygon' : 'box';\n return o;\n });\n return { scene: s, changes };\n}\n\n/** Problems in a `motionary-scene@1` document (after migration). Never throws. */\nexport function validateScene(input: unknown): string[] {\n const out: string[] = [];\n let s: any;\n try {\n s = migrateScene(input).scene;\n } catch (e) {\n return [String((e as Error).message).replace('[motionary] scene: ', '')];\n }\n if (!s.world || !isNum(s.world.width) || !isNum(s.world.height) || s.world.width <= 0 || s.world.height <= 0) out.push('world: width and height must be positive numbers');\n if (s.world?.gravity != null && !isVec(s.world.gravity)) out.push('world.gravity must be [x, y]');\n const mats = s.materials || {};\n for (const [k, m] of Object.entries<any>(mats)) for (const p of ['restitution', 'friction', 'density']) if (m[p] != null && (!isNum(m[p]) || m[p] < 0)) out.push(`materials.${k}.${p} must be a number ≥ 0`);\n if (!Array.isArray(s.bodies)) out.push('bodies must be an array');\n const ids = new Set<string>();\n (s.bodies || []).forEach((b: any, i: number) => {\n const w = `bodies[${i}]${b.id ? ` (\"${b.id}\")` : ''}`;\n if (ids.has(b.id)) out.push(`${w}: duplicate id`);\n ids.add(b.id);\n if (!['circle', 'box', 'polygon'].includes(b.shape)) out.push(`${w}: shape must be circle, box or polygon`);\n if (!isVec(b.position)) out.push(`${w}: position must be [x, y]`);\n if (b.shape === 'circle' && !(isNum(b.radius) && b.radius > 0)) out.push(`${w}: circle needs radius > 0`);\n if (b.shape === 'box' && !(isVec(b.size) && b.size[0] > 0 && b.size[1] > 0)) out.push(`${w}: box needs size [w, h] > 0`);\n if (b.shape === 'polygon' && !(Array.isArray(b.vertices) && b.vertices.length >= 3 && b.vertices.every(isVec))) out.push(`${w}: polygon needs ≥ 3 vertices [x, y]`);\n if (b.material && !mats[b.material]) out.push(`${w}: unknown material \"${b.material}\"`);\n if (b.static && b.kinematic) out.push(`${w}: static and kinematic are exclusive`);\n });\n (s.constraints || []).forEach((c: any, i: number) => {\n const w = `constraints[${i}]`;\n if (!['distance', 'pin'].includes(c.type)) out.push(`${w}: type must be distance or pin`);\n if (!ids.has(c.a)) out.push(`${w}: unknown body \"${c.a}\"`);\n if (c.type === 'distance' && !ids.has(c.b)) out.push(`${w}: distance needs body b (unknown \"${c.b}\")`);\n if (c.type === 'pin' && c.point != null && !isVec(c.point)) out.push(`${w}: point must be [x, y]`);\n if (c.stiffness != null && !(isNum(c.stiffness) && c.stiffness > 0 && c.stiffness <= 1)) out.push(`${w}: stiffness must be in (0, 1]`);\n });\n return out;\n}\n\n/** Migrate + validate; throws one error listing every problem. */\nexport function parseScene(input: unknown): Scene {\n const { scene } = migrateScene(input);\n const problems = validateScene(scene);\n if (problems.length) throw new Error(`[motionary] scene: ${problems.length} problem(s): ${problems.join('; ')}`);\n return scene as Scene;\n}\n\n/** Build a physics world from a scene (needs `use(physics)`). */\nexport function sceneToWorld(input: Scene | unknown): { world: World; bodies: Record<string, Body>; scene: Scene } {\n const scene = parseScene(input);\n const P = requireModule<PhysicsApi>('physics', 'motionary/runtime/format-scene');\n const w = scene.world;\n const world = P.createWorld({ gravity: w.gravity || [0, 980], iterations: w.iterations });\n if (w.walls) world.bounds(w.width, w.height, 50, typeof w.walls === 'object' ? w.walls : {});\n const bodies: Record<string, Body> = {};\n for (const b of scene.bodies) {\n const m = (b.material && scene.materials?.[b.material]) || {};\n const o: BodyOptions = {\n shape: b.shape,\n x: b.position[0],\n y: b.position[1],\n angle: b.angle,\n radius: b.radius,\n width: b.size?.[0],\n height: b.size?.[1],\n vertices: b.vertices,\n type: b.static ? 'static' : b.kinematic ? 'kinematic' : 'dynamic',\n restitution: b.restitution ?? m.restitution,\n friction: b.friction ?? m.friction,\n density: b.density ?? m.density,\n vx: b.velocity?.[0],\n vy: b.velocity?.[1],\n angularVelocity: b.angularVelocity,\n sensor: b.sensor,\n label: b.id,\n data: { id: b.id, style: b.style || {}, material: b.material },\n };\n bodies[b.id] = world.body(o);\n }\n for (const c of scene.constraints || []) world.constraint({ type: c.type, a: bodies[c.a], b: c.b ? bodies[c.b] : undefined, point: c.point, anchorA: c.anchorA, anchorB: c.anchorB, length: c.length, stiffness: c.stiffness, damping: c.damping });\n return { world, bodies, scene };\n}\n\n/** Save the current state of a world as a scene (walls made by `bounds()` are left out; `w` / `h` give the world size). */\nexport function worldToScene(world: World, o: { width: Num; height: Num; name?: string; walls?: boolean } = { width: 600, height: 400 }): Scene {\n const r = (x: Num) => Math.round(x * 1000) / 1000;\n const wallLabels = new Set(['floor', 'wall-left', 'wall-right', 'ceiling']);\n const kept = world.bodies.filter((b) => !(b.isStatic && wallLabels.has(b.label)));\n const id = (b: Body) => (b.data as any)?.id || b.label + '-' + b.id;\n const bodies: SceneBody[] = kept.map((b) => {\n const sb: SceneBody = { id: id(b), shape: b.shape, position: [r(b.position.x), r(b.position.y)] };\n if (b.angle) sb.angle = r(b.angle);\n if (b.shape === 'circle') sb.radius = r(b.radius);\n else {\n const xs = b.verts.map((p) => p.x), ys = b.verts.map((p) => p.y);\n const isBox = b.shape === 'box';\n if (isBox) sb.size = [r(Math.max(...xs) - Math.min(...xs)), r(Math.max(...ys) - Math.min(...ys))];\n else sb.vertices = b.verts.map((p) => [r(p.x), r(p.y)]);\n }\n if (b.type === 'static') sb.static = true;\n if (b.type === 'kinematic') sb.kinematic = true;\n sb.restitution = b.restitution;\n sb.friction = b.friction;\n if (b.type === 'dynamic' && (b.velocity.x || b.velocity.y)) sb.velocity = [r(b.velocity.x), r(b.velocity.y)];\n if (b.angularVelocity) sb.angularVelocity = r(b.angularVelocity);\n if (b.sensor) sb.sensor = true;\n const st = (b.data as any)?.style;\n if (st && Object.keys(st).length) sb.style = st;\n return sb;\n });\n const constraints: SceneConstraint[] = world.constraints\n .filter((c) => c.label !== 'drag' && kept.includes(c.a) && (!c.b || kept.includes(c.b)))\n .map((c) => ({ type: c.type, a: id(c.a), ...(c.b ? { b: id(c.b) } : { point: [r(c.point.x), r(c.point.y)] as [Num, Num] }), anchorA: [r(c.anchorA.x), r(c.anchorA.y)] as [Num, Num], ...(c.b ? { anchorB: [r(c.anchorB.x), r(c.anchorB.y)] as [Num, Num] } : {}), length: r(c.length), stiffness: c.stiffness, damping: c.damping }));\n return { format: SCENE_FORMAT, ...(o.name ? { name: o.name } : {}), world: { width: o.width, height: o.height, gravity: [world.gravity.x, world.gravity.y], walls: o.walls ?? world.bodies.some((b) => wallLabels.has(b.label)) }, bodies, constraints };\n}\n\nexport interface FormatSceneApi {\n SCENE_FORMAT: typeof SCENE_FORMAT;\n migrateScene: typeof migrateScene;\n validateScene: typeof validateScene;\n parseScene: typeof parseScene;\n sceneToWorld: typeof sceneToWorld;\n worldToScene: typeof worldToScene;\n}\n\n/** The module object for `use(formatScene)` (needs `physics`). */\nexport const formatScene: RuntimeModule<FormatSceneApi> = { id: 'format-scene', version: RUNTIME_VERSION, requires: ['core', 'physics'], api: { SCENE_FORMAT, migrateScene, validateScene, parseScene, sceneToWorld, worldToScene } };\n","// CDN build: load runtime.iife.js first, then this file → registers motionary/runtime/format-scene and adds its API to window.MotionaryRuntime.\nimport { register } from '../registry';\nimport { formatScene } from '../format-scene';\nexport * from '../format-scene';\nregister(formatScene);\n"],"names":["SCENE_FORMAT","isNum","x","isFinite","isVec","Array","isArray","length","every","migrateScene","input","changes","s","JSON","parse","stringify","format","scene","Error","push","world","width","height","gravity","walls","bodies","map","b","i","o","id","position","y","size","w","h","type","static","shape","radius","vertices","validateScene","out","e","String","message","replace","mats","materials","k","m","Object","entries","p","ids","Set","forEach","has","add","includes","material","kinematic","constraints","c","a","point","stiffness","parseScene","problems","join","sceneToWorld","P","requireModule","createWorld","iterations","bounds","angle","restitution","friction","density","vx","velocity","vy","angularVelocity","sensor","label","data","style","body","constraint","undefined","anchorA","anchorB","damping","worldToScene","r","Math","round","wallLabels","kept","filter","isStatic","sb","xs","verts","ys","max","min","st","keys","name","some","formatScene","version","RUNTIME_VERSION","requires","api","register"],"mappings":"4BAgCO,MAAMA,EAAe,oBA0CtBC,EAASC,GAAsC,iBAANA,GAAkBC,SAASD,GACpEE,EAASF,GAAgCG,MAAMC,QAAQJ,IAAmB,IAAbA,EAAEK,QAAgBL,EAAEM,MAAMP,GAGvF,SAAUQ,EAAaC,GAC3B,MAAMC,EAAoB,GACpBC,EAA0B,iBAAVF,EAAqBG,KAAKC,MAAMJ,GAASG,KAAKC,MAAMD,KAAKE,UAAUL,GAAS,CAAA,IAClG,GAAIE,EAAEI,SAAWhB,EAAc,MAAO,CAAEiB,MAAOL,EAAGD,WAClD,GAAIC,EAAEI,QAAuB,sBAAbJ,EAAEI,OAAgC,MAAM,IAAIE,MAAM,sCAAsCN,EAAEI,6BAA6BhB,0DAoCvI,OAnCAW,EAAQQ,KAAK,GAAGP,EAAEI,QAAU,mBAAmBhB,KAC/CY,EAAEI,OAAShB,EAENY,EAAEQ,QACLR,EAAEQ,MAAQ,CAAEC,MAAOT,EAAES,OAAS,IAAKC,OAAQV,EAAEU,QAAU,KACtC,MAAbV,EAAEW,UAAiBX,EAAEQ,MAAMG,QAAUtB,EAAMW,EAAEW,SAAW,CAAC,EAAGX,EAAEW,SAAWX,EAAEW,SAChE,MAAXX,EAAEY,QAAeZ,EAAEQ,MAAMI,MAAQZ,EAAEY,cAChCZ,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J,EAAMK,OAAOsF,KAAMpF,GAAMuE,EAAWzC,IAAI9B,EAAE0D,SAAW5D,SAAQqC,cAC7O,CAYO,MAAMkD,EAA6C,CAAElF,GAAI,eAAgBmF,QAASC,EAAAA,gBAAiBC,SAAU,CAAC,OAAQ,WAAYC,IAAK,CAAEpH,eAAcS,eAAcgC,gBAAe0B,aAAYG,eAAcwB,iBClPrNuB,EAAAA,SAASL"}
@@ -0,0 +1,233 @@
1
+ import { R as RUNTIME_VERSION, a as requireModule } from '../chunks/registry-D87dP_aR.js';
2
+
3
+ /**
4
+ * `motionary/runtime/format-scene` (10.7) — the versioned scene format
5
+ * `motionary-scene@1`: a JSON description of a 2D physics scene (world,
6
+ * named materials, bodies, constraints, per-body style) that
7
+ * `<usa-physics-playground>` and your own code can load, validate,
8
+ * migrate and save.
9
+ *
10
+ * ```json
11
+ * { "format": "motionary-scene@1",
12
+ * "world": { "width": 600, "height": 360, "gravity": [0, 980], "walls": true },
13
+ * "materials": { "rubber": { "restitution": 0.8, "friction": 0.6, "density": 0.001 } },
14
+ * "bodies": [
15
+ * { "id": "ball", "shape": "circle", "radius": 20, "position": [120, 40], "material": "rubber", "style": { "fill": "#f472b6" } },
16
+ * { "id": "floor-plank", "shape": "box", "size": [300, 16], "position": [300, 300], "angle": 0.1, "static": true }
17
+ * ],
18
+ * "constraints": [ { "type": "distance", "a": "ball", "b": "floor-plank", "length": 120, "stiffness": 0.3 } ] }
19
+ * ```
20
+ *
21
+ * - `validateScene(json)` lists problems (never throws);
22
+ * - `migrateScene(json)` upgrades older shapes (an unversioned scene, the
23
+ * `motionary-scene@0` draft) to `@1` and reports what it changed;
24
+ * - `parseScene(json)` = migrate + validate, throws on errors;
25
+ * - `sceneToWorld(scene)` builds a `motionary/runtime/physics` world
26
+ * (bodies by id); `worldToScene(world)` saves one back.
27
+ *
28
+ * Needs `motionary/runtime/physics` registered for `sceneToWorld` /
29
+ * `worldToScene`; validation and migration are pure.
30
+ */
31
+ const SCENE_FORMAT = 'motionary-scene@1';
32
+ const isNum = (x) => typeof x === 'number' && isFinite(x);
33
+ const isVec = (x) => Array.isArray(x) && x.length === 2 && x.every(isNum);
34
+ /** Upgrade older scene shapes to `motionary-scene@1`. Returns the scene and what changed. */
35
+ function migrateScene(input) {
36
+ const changes = [];
37
+ const s = typeof input === 'string' ? JSON.parse(input) : JSON.parse(JSON.stringify(input ?? {}));
38
+ if (s.format === SCENE_FORMAT)
39
+ return { scene: s, changes };
40
+ if (s.format && s.format !== 'motionary-scene@0')
41
+ throw new Error(`[motionary] scene: unknown format "${s.format}" (this build reads ${SCENE_FORMAT} and migrates motionary-scene@0 / unversioned scenes)`);
42
+ changes.push(`${s.format || 'unversioned'} → ${SCENE_FORMAT}`);
43
+ s.format = SCENE_FORMAT;
44
+ // @0 / unversioned: { width, height, gravity: number } at the top level, bodies with x / y / w / h / type
45
+ if (!s.world) {
46
+ s.world = { width: s.width ?? 600, height: s.height ?? 400 };
47
+ if (s.gravity != null)
48
+ s.world.gravity = isNum(s.gravity) ? [0, s.gravity] : s.gravity;
49
+ if (s.walls != null)
50
+ s.world.walls = s.walls;
51
+ delete s.width, delete s.height, delete s.gravity, delete s.walls;
52
+ changes.push('top-level width / height / gravity moved into "world"');
53
+ }
54
+ if (isNum(s.world.gravity)) {
55
+ s.world.gravity = [0, s.world.gravity];
56
+ changes.push('world.gravity number → [0, g]');
57
+ }
58
+ s.bodies = (s.bodies || []).map((b, i) => {
59
+ const o = { ...b };
60
+ if (!o.id)
61
+ (o.id = `body-${i + 1}`), changes.push(`bodies[${i}]: id "${o.id}" added`);
62
+ if (o.position == null && (isNum(o.x) || isNum(o.y))) {
63
+ o.position = [o.x ?? 0, o.y ?? 0];
64
+ delete o.x, delete o.y;
65
+ changes.push(`bodies[${i}]: x / y → position`);
66
+ }
67
+ if (o.size == null && (isNum(o.w) || isNum(o.h))) {
68
+ o.size = [o.w ?? 40, o.h ?? 40];
69
+ delete o.w, delete o.h;
70
+ changes.push(`bodies[${i}]: w / h → size`);
71
+ }
72
+ if (o.type === 'static' || o.type === 'kinematic') {
73
+ o[o.type] = true;
74
+ delete o.type;
75
+ changes.push(`bodies[${i}]: type → ${o.static ? 'static' : 'kinematic'}: true`);
76
+ }
77
+ else if (o.type === 'dynamic')
78
+ delete o.type;
79
+ if (!o.shape)
80
+ o.shape = o.radius != null ? 'circle' : o.vertices ? 'polygon' : 'box';
81
+ return o;
82
+ });
83
+ return { scene: s, changes };
84
+ }
85
+ /** Problems in a `motionary-scene@1` document (after migration). Never throws. */
86
+ function validateScene(input) {
87
+ const out = [];
88
+ let s;
89
+ try {
90
+ s = migrateScene(input).scene;
91
+ }
92
+ catch (e) {
93
+ return [String(e.message).replace('[motionary] scene: ', '')];
94
+ }
95
+ if (!s.world || !isNum(s.world.width) || !isNum(s.world.height) || s.world.width <= 0 || s.world.height <= 0)
96
+ out.push('world: width and height must be positive numbers');
97
+ if (s.world?.gravity != null && !isVec(s.world.gravity))
98
+ out.push('world.gravity must be [x, y]');
99
+ const mats = s.materials || {};
100
+ for (const [k, m] of Object.entries(mats))
101
+ for (const p of ['restitution', 'friction', 'density'])
102
+ if (m[p] != null && (!isNum(m[p]) || m[p] < 0))
103
+ out.push(`materials.${k}.${p} must be a number ≥ 0`);
104
+ if (!Array.isArray(s.bodies))
105
+ out.push('bodies must be an array');
106
+ const ids = new Set();
107
+ (s.bodies || []).forEach((b, i) => {
108
+ const w = `bodies[${i}]${b.id ? ` ("${b.id}")` : ''}`;
109
+ if (ids.has(b.id))
110
+ out.push(`${w}: duplicate id`);
111
+ ids.add(b.id);
112
+ if (!['circle', 'box', 'polygon'].includes(b.shape))
113
+ out.push(`${w}: shape must be circle, box or polygon`);
114
+ if (!isVec(b.position))
115
+ out.push(`${w}: position must be [x, y]`);
116
+ if (b.shape === 'circle' && !(isNum(b.radius) && b.radius > 0))
117
+ out.push(`${w}: circle needs radius > 0`);
118
+ if (b.shape === 'box' && !(isVec(b.size) && b.size[0] > 0 && b.size[1] > 0))
119
+ out.push(`${w}: box needs size [w, h] > 0`);
120
+ if (b.shape === 'polygon' && !(Array.isArray(b.vertices) && b.vertices.length >= 3 && b.vertices.every(isVec)))
121
+ out.push(`${w}: polygon needs ≥ 3 vertices [x, y]`);
122
+ if (b.material && !mats[b.material])
123
+ out.push(`${w}: unknown material "${b.material}"`);
124
+ if (b.static && b.kinematic)
125
+ out.push(`${w}: static and kinematic are exclusive`);
126
+ });
127
+ (s.constraints || []).forEach((c, i) => {
128
+ const w = `constraints[${i}]`;
129
+ if (!['distance', 'pin'].includes(c.type))
130
+ out.push(`${w}: type must be distance or pin`);
131
+ if (!ids.has(c.a))
132
+ out.push(`${w}: unknown body "${c.a}"`);
133
+ if (c.type === 'distance' && !ids.has(c.b))
134
+ out.push(`${w}: distance needs body b (unknown "${c.b}")`);
135
+ if (c.type === 'pin' && c.point != null && !isVec(c.point))
136
+ out.push(`${w}: point must be [x, y]`);
137
+ if (c.stiffness != null && !(isNum(c.stiffness) && c.stiffness > 0 && c.stiffness <= 1))
138
+ out.push(`${w}: stiffness must be in (0, 1]`);
139
+ });
140
+ return out;
141
+ }
142
+ /** Migrate + validate; throws one error listing every problem. */
143
+ function parseScene(input) {
144
+ const { scene } = migrateScene(input);
145
+ const problems = validateScene(scene);
146
+ if (problems.length)
147
+ throw new Error(`[motionary] scene: ${problems.length} problem(s): ${problems.join('; ')}`);
148
+ return scene;
149
+ }
150
+ /** Build a physics world from a scene (needs `use(physics)`). */
151
+ function sceneToWorld(input) {
152
+ const scene = parseScene(input);
153
+ const P = requireModule('physics', 'motionary/runtime/format-scene');
154
+ const w = scene.world;
155
+ const world = P.createWorld({ gravity: w.gravity || [0, 980], iterations: w.iterations });
156
+ if (w.walls)
157
+ world.bounds(w.width, w.height, 50, typeof w.walls === 'object' ? w.walls : {});
158
+ const bodies = {};
159
+ for (const b of scene.bodies) {
160
+ const m = (b.material && scene.materials?.[b.material]) || {};
161
+ const o = {
162
+ shape: b.shape,
163
+ x: b.position[0],
164
+ y: b.position[1],
165
+ angle: b.angle,
166
+ radius: b.radius,
167
+ width: b.size?.[0],
168
+ height: b.size?.[1],
169
+ vertices: b.vertices,
170
+ type: b.static ? 'static' : b.kinematic ? 'kinematic' : 'dynamic',
171
+ restitution: b.restitution ?? m.restitution,
172
+ friction: b.friction ?? m.friction,
173
+ density: b.density ?? m.density,
174
+ vx: b.velocity?.[0],
175
+ vy: b.velocity?.[1],
176
+ angularVelocity: b.angularVelocity,
177
+ sensor: b.sensor,
178
+ label: b.id,
179
+ data: { id: b.id, style: b.style || {}, material: b.material },
180
+ };
181
+ bodies[b.id] = world.body(o);
182
+ }
183
+ for (const c of scene.constraints || [])
184
+ world.constraint({ type: c.type, a: bodies[c.a], b: c.b ? bodies[c.b] : undefined, point: c.point, anchorA: c.anchorA, anchorB: c.anchorB, length: c.length, stiffness: c.stiffness, damping: c.damping });
185
+ return { world, bodies, scene };
186
+ }
187
+ /** Save the current state of a world as a scene (walls made by `bounds()` are left out; `w` / `h` give the world size). */
188
+ function worldToScene(world, o = { width: 600, height: 400 }) {
189
+ const r = (x) => Math.round(x * 1000) / 1000;
190
+ const wallLabels = new Set(['floor', 'wall-left', 'wall-right', 'ceiling']);
191
+ const kept = world.bodies.filter((b) => !(b.isStatic && wallLabels.has(b.label)));
192
+ const id = (b) => b.data?.id || b.label + '-' + b.id;
193
+ const bodies = kept.map((b) => {
194
+ const sb = { id: id(b), shape: b.shape, position: [r(b.position.x), r(b.position.y)] };
195
+ if (b.angle)
196
+ sb.angle = r(b.angle);
197
+ if (b.shape === 'circle')
198
+ sb.radius = r(b.radius);
199
+ else {
200
+ const xs = b.verts.map((p) => p.x), ys = b.verts.map((p) => p.y);
201
+ const isBox = b.shape === 'box';
202
+ if (isBox)
203
+ sb.size = [r(Math.max(...xs) - Math.min(...xs)), r(Math.max(...ys) - Math.min(...ys))];
204
+ else
205
+ sb.vertices = b.verts.map((p) => [r(p.x), r(p.y)]);
206
+ }
207
+ if (b.type === 'static')
208
+ sb.static = true;
209
+ if (b.type === 'kinematic')
210
+ sb.kinematic = true;
211
+ sb.restitution = b.restitution;
212
+ sb.friction = b.friction;
213
+ if (b.type === 'dynamic' && (b.velocity.x || b.velocity.y))
214
+ sb.velocity = [r(b.velocity.x), r(b.velocity.y)];
215
+ if (b.angularVelocity)
216
+ sb.angularVelocity = r(b.angularVelocity);
217
+ if (b.sensor)
218
+ sb.sensor = true;
219
+ const st = b.data?.style;
220
+ if (st && Object.keys(st).length)
221
+ sb.style = st;
222
+ return sb;
223
+ });
224
+ const constraints = world.constraints
225
+ .filter((c) => c.label !== 'drag' && kept.includes(c.a) && (!c.b || kept.includes(c.b)))
226
+ .map((c) => ({ type: c.type, a: id(c.a), ...(c.b ? { b: id(c.b) } : { point: [r(c.point.x), r(c.point.y)] }), anchorA: [r(c.anchorA.x), r(c.anchorA.y)], ...(c.b ? { anchorB: [r(c.anchorB.x), r(c.anchorB.y)] } : {}), length: r(c.length), stiffness: c.stiffness, damping: c.damping }));
227
+ return { format: SCENE_FORMAT, ...(o.name ? { name: o.name } : {}), world: { width: o.width, height: o.height, gravity: [world.gravity.x, world.gravity.y], walls: o.walls ?? world.bodies.some((b) => wallLabels.has(b.label)) }, bodies, constraints };
228
+ }
229
+ /** The module object for `use(formatScene)` (needs `physics`). */
230
+ const formatScene = { id: 'format-scene', version: RUNTIME_VERSION, requires: ['core', 'physics'], api: { SCENE_FORMAT, migrateScene, validateScene, parseScene, sceneToWorld, worldToScene } };
231
+
232
+ export { SCENE_FORMAT, formatScene, migrateScene, parseScene, sceneToWorld, validateScene, worldToScene };
233
+ //# sourceMappingURL=format-scene.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format-scene.js","sources":["../../src/runtime/format-scene.ts"],"sourcesContent":["/**\n * `motionary/runtime/format-scene` (10.7) — the versioned scene format\n * `motionary-scene@1`: a JSON description of a 2D physics scene (world,\n * named materials, bodies, constraints, per-body style) that\n * `<usa-physics-playground>` and your own code can load, validate,\n * migrate and save.\n *\n * ```json\n * { \"format\": \"motionary-scene@1\",\n * \"world\": { \"width\": 600, \"height\": 360, \"gravity\": [0, 980], \"walls\": true },\n * \"materials\": { \"rubber\": { \"restitution\": 0.8, \"friction\": 0.6, \"density\": 0.001 } },\n * \"bodies\": [\n * { \"id\": \"ball\", \"shape\": \"circle\", \"radius\": 20, \"position\": [120, 40], \"material\": \"rubber\", \"style\": { \"fill\": \"#f472b6\" } },\n * { \"id\": \"floor-plank\", \"shape\": \"box\", \"size\": [300, 16], \"position\": [300, 300], \"angle\": 0.1, \"static\": true }\n * ],\n * \"constraints\": [ { \"type\": \"distance\", \"a\": \"ball\", \"b\": \"floor-plank\", \"length\": 120, \"stiffness\": 0.3 } ] }\n * ```\n *\n * - `validateScene(json)` lists problems (never throws);\n * - `migrateScene(json)` upgrades older shapes (an unversioned scene, the\n * `motionary-scene@0` draft) to `@1` and reports what it changed;\n * - `parseScene(json)` = migrate + validate, throws on errors;\n * - `sceneToWorld(scene)` builds a `motionary/runtime/physics` world\n * (bodies by id); `worldToScene(world)` saves one back.\n *\n * Needs `motionary/runtime/physics` registered for `sceneToWorld` /\n * `worldToScene`; validation and migration are pure.\n */\nimport { RUNTIME_VERSION, requireModule, type RuntimeModule } from './registry';\nimport type { PhysicsApi, World, Body, BodyOptions } from './physics';\n\ntype Num = number;\nexport const SCENE_FORMAT = 'motionary-scene@1';\n\nexport interface SceneMaterial { restitution?: Num; friction?: Num; density?: Num }\nexport interface SceneBody {\n id: string;\n shape: 'circle' | 'box' | 'polygon';\n position: [Num, Num];\n angle?: Num;\n radius?: Num;\n size?: [Num, Num];\n vertices?: [Num, Num][];\n static?: boolean;\n kinematic?: boolean;\n material?: string;\n restitution?: Num;\n friction?: Num;\n density?: Num;\n velocity?: [Num, Num];\n angularVelocity?: Num;\n sensor?: boolean;\n style?: { fill?: string; stroke?: string; label?: string };\n}\nexport interface SceneConstraint {\n type: 'distance' | 'pin';\n a: string;\n b?: string;\n point?: [Num, Num];\n anchorA?: [Num, Num];\n anchorB?: [Num, Num];\n length?: Num;\n stiffness?: Num;\n damping?: Num;\n}\nexport interface Scene {\n format: typeof SCENE_FORMAT;\n name?: string;\n world: { width: Num; height: Num; gravity?: [Num, Num]; walls?: boolean | { top?: boolean }; iterations?: Num };\n materials?: Record<string, SceneMaterial>;\n bodies: SceneBody[];\n constraints?: SceneConstraint[];\n}\n\nconst isNum = (x: unknown): x is Num => typeof x === 'number' && isFinite(x);\nconst isVec = (x: unknown): x is [Num, Num] => Array.isArray(x) && x.length === 2 && x.every(isNum);\n\n/** Upgrade older scene shapes to `motionary-scene@1`. Returns the scene and what changed. */\nexport function migrateScene(input: unknown): { scene: any; changes: string[] } {\n const changes: string[] = [];\n const s: any = typeof input === 'string' ? JSON.parse(input) : JSON.parse(JSON.stringify(input ?? {}));\n if (s.format === SCENE_FORMAT) return { scene: s, changes };\n if (s.format && s.format !== 'motionary-scene@0') throw new Error(`[motionary] scene: unknown format \"${s.format}\" (this build reads ${SCENE_FORMAT} and migrates motionary-scene@0 / unversioned scenes)`);\n changes.push(`${s.format || 'unversioned'} → ${SCENE_FORMAT}`);\n s.format = SCENE_FORMAT;\n // @0 / unversioned: { width, height, gravity: number } at the top level, bodies with x / y / w / h / type\n if (!s.world) {\n s.world = { width: s.width ?? 600, height: s.height ?? 400 };\n if (s.gravity != null) s.world.gravity = isNum(s.gravity) ? [0, s.gravity] : s.gravity;\n if (s.walls != null) s.world.walls = s.walls;\n delete s.width, delete s.height, delete s.gravity, delete s.walls;\n changes.push('top-level width / height / gravity moved into \"world\"');\n }\n if (isNum(s.world.gravity)) {\n s.world.gravity = [0, s.world.gravity];\n changes.push('world.gravity number → [0, g]');\n }\n s.bodies = (s.bodies || []).map((b: any, i: number) => {\n const o: any = { ...b };\n if (!o.id) (o.id = `body-${i + 1}`), changes.push(`bodies[${i}]: id \"${o.id}\" added`);\n if (o.position == null && (isNum(o.x) || isNum(o.y))) {\n o.position = [o.x ?? 0, o.y ?? 0];\n delete o.x, delete o.y;\n changes.push(`bodies[${i}]: x / y → position`);\n }\n if (o.size == null && (isNum(o.w) || isNum(o.h))) {\n o.size = [o.w ?? 40, o.h ?? 40];\n delete o.w, delete o.h;\n changes.push(`bodies[${i}]: w / h → size`);\n }\n if (o.type === 'static' || o.type === 'kinematic') {\n o[o.type] = true;\n delete o.type;\n changes.push(`bodies[${i}]: type → ${o.static ? 'static' : 'kinematic'}: true`);\n } else if (o.type === 'dynamic') delete o.type;\n if (!o.shape) o.shape = o.radius != null ? 'circle' : o.vertices ? 'polygon' : 'box';\n return o;\n });\n return { scene: s, changes };\n}\n\n/** Problems in a `motionary-scene@1` document (after migration). Never throws. */\nexport function validateScene(input: unknown): string[] {\n const out: string[] = [];\n let s: any;\n try {\n s = migrateScene(input).scene;\n } catch (e) {\n return [String((e as Error).message).replace('[motionary] scene: ', '')];\n }\n if (!s.world || !isNum(s.world.width) || !isNum(s.world.height) || s.world.width <= 0 || s.world.height <= 0) out.push('world: width and height must be positive numbers');\n if (s.world?.gravity != null && !isVec(s.world.gravity)) out.push('world.gravity must be [x, y]');\n const mats = s.materials || {};\n for (const [k, m] of Object.entries<any>(mats)) for (const p of ['restitution', 'friction', 'density']) if (m[p] != null && (!isNum(m[p]) || m[p] < 0)) out.push(`materials.${k}.${p} must be a number ≥ 0`);\n if (!Array.isArray(s.bodies)) out.push('bodies must be an array');\n const ids = new Set<string>();\n (s.bodies || []).forEach((b: any, i: number) => {\n const w = `bodies[${i}]${b.id ? ` (\"${b.id}\")` : ''}`;\n if (ids.has(b.id)) out.push(`${w}: duplicate id`);\n ids.add(b.id);\n if (!['circle', 'box', 'polygon'].includes(b.shape)) out.push(`${w}: shape must be circle, box or polygon`);\n if (!isVec(b.position)) out.push(`${w}: position must be [x, y]`);\n if (b.shape === 'circle' && !(isNum(b.radius) && b.radius > 0)) out.push(`${w}: circle needs radius > 0`);\n if (b.shape === 'box' && !(isVec(b.size) && b.size[0] > 0 && b.size[1] > 0)) out.push(`${w}: box needs size [w, h] > 0`);\n if (b.shape === 'polygon' && !(Array.isArray(b.vertices) && b.vertices.length >= 3 && b.vertices.every(isVec))) out.push(`${w}: polygon needs ≥ 3 vertices [x, y]`);\n if (b.material && !mats[b.material]) out.push(`${w}: unknown material \"${b.material}\"`);\n if (b.static && b.kinematic) out.push(`${w}: static and kinematic are exclusive`);\n });\n (s.constraints || []).forEach((c: any, i: number) => {\n const w = `constraints[${i}]`;\n if (!['distance', 'pin'].includes(c.type)) out.push(`${w}: type must be distance or pin`);\n if (!ids.has(c.a)) out.push(`${w}: unknown body \"${c.a}\"`);\n if (c.type === 'distance' && !ids.has(c.b)) out.push(`${w}: distance needs body b (unknown \"${c.b}\")`);\n if (c.type === 'pin' && c.point != null && !isVec(c.point)) out.push(`${w}: point must be [x, y]`);\n if (c.stiffness != null && !(isNum(c.stiffness) && c.stiffness > 0 && c.stiffness <= 1)) out.push(`${w}: stiffness must be in (0, 1]`);\n });\n return out;\n}\n\n/** Migrate + validate; throws one error listing every problem. */\nexport function parseScene(input: unknown): Scene {\n const { scene } = migrateScene(input);\n const problems = validateScene(scene);\n if (problems.length) throw new Error(`[motionary] scene: ${problems.length} problem(s): ${problems.join('; ')}`);\n return scene as Scene;\n}\n\n/** Build a physics world from a scene (needs `use(physics)`). */\nexport function sceneToWorld(input: Scene | unknown): { world: World; bodies: Record<string, Body>; scene: Scene } {\n const scene = parseScene(input);\n const P = requireModule<PhysicsApi>('physics', 'motionary/runtime/format-scene');\n const w = scene.world;\n const world = P.createWorld({ gravity: w.gravity || [0, 980], iterations: w.iterations });\n if (w.walls) world.bounds(w.width, w.height, 50, typeof w.walls === 'object' ? w.walls : {});\n const bodies: Record<string, Body> = {};\n for (const b of scene.bodies) {\n const m = (b.material && scene.materials?.[b.material]) || {};\n const o: BodyOptions = {\n shape: b.shape,\n x: b.position[0],\n y: b.position[1],\n angle: b.angle,\n radius: b.radius,\n width: b.size?.[0],\n height: b.size?.[1],\n vertices: b.vertices,\n type: b.static ? 'static' : b.kinematic ? 'kinematic' : 'dynamic',\n restitution: b.restitution ?? m.restitution,\n friction: b.friction ?? m.friction,\n density: b.density ?? m.density,\n vx: b.velocity?.[0],\n vy: b.velocity?.[1],\n angularVelocity: b.angularVelocity,\n sensor: b.sensor,\n label: b.id,\n data: { id: b.id, style: b.style || {}, material: b.material },\n };\n bodies[b.id] = world.body(o);\n }\n for (const c of scene.constraints || []) world.constraint({ type: c.type, a: bodies[c.a], b: c.b ? bodies[c.b] : undefined, point: c.point, anchorA: c.anchorA, anchorB: c.anchorB, length: c.length, stiffness: c.stiffness, damping: c.damping });\n return { world, bodies, scene };\n}\n\n/** Save the current state of a world as a scene (walls made by `bounds()` are left out; `w` / `h` give the world size). */\nexport function worldToScene(world: World, o: { width: Num; height: Num; name?: string; walls?: boolean } = { width: 600, height: 400 }): Scene {\n const r = (x: Num) => Math.round(x * 1000) / 1000;\n const wallLabels = new Set(['floor', 'wall-left', 'wall-right', 'ceiling']);\n const kept = world.bodies.filter((b) => !(b.isStatic && wallLabels.has(b.label)));\n const id = (b: Body) => (b.data as any)?.id || b.label + '-' + b.id;\n const bodies: SceneBody[] = kept.map((b) => {\n const sb: SceneBody = { id: id(b), shape: b.shape, position: [r(b.position.x), r(b.position.y)] };\n if (b.angle) sb.angle = r(b.angle);\n if (b.shape === 'circle') sb.radius = r(b.radius);\n else {\n const xs = b.verts.map((p) => p.x), ys = b.verts.map((p) => p.y);\n const isBox = b.shape === 'box';\n if (isBox) sb.size = [r(Math.max(...xs) - Math.min(...xs)), r(Math.max(...ys) - Math.min(...ys))];\n else sb.vertices = b.verts.map((p) => [r(p.x), r(p.y)]);\n }\n if (b.type === 'static') sb.static = true;\n if (b.type === 'kinematic') sb.kinematic = true;\n sb.restitution = b.restitution;\n sb.friction = b.friction;\n if (b.type === 'dynamic' && (b.velocity.x || b.velocity.y)) sb.velocity = [r(b.velocity.x), r(b.velocity.y)];\n if (b.angularVelocity) sb.angularVelocity = r(b.angularVelocity);\n if (b.sensor) sb.sensor = true;\n const st = (b.data as any)?.style;\n if (st && Object.keys(st).length) sb.style = st;\n return sb;\n });\n const constraints: SceneConstraint[] = world.constraints\n .filter((c) => c.label !== 'drag' && kept.includes(c.a) && (!c.b || kept.includes(c.b)))\n .map((c) => ({ type: c.type, a: id(c.a), ...(c.b ? { b: id(c.b) } : { point: [r(c.point.x), r(c.point.y)] as [Num, Num] }), anchorA: [r(c.anchorA.x), r(c.anchorA.y)] as [Num, Num], ...(c.b ? { anchorB: [r(c.anchorB.x), r(c.anchorB.y)] as [Num, Num] } : {}), length: r(c.length), stiffness: c.stiffness, damping: c.damping }));\n return { format: SCENE_FORMAT, ...(o.name ? { name: o.name } : {}), world: { width: o.width, height: o.height, gravity: [world.gravity.x, world.gravity.y], walls: o.walls ?? world.bodies.some((b) => wallLabels.has(b.label)) }, bodies, constraints };\n}\n\nexport interface FormatSceneApi {\n SCENE_FORMAT: typeof SCENE_FORMAT;\n migrateScene: typeof migrateScene;\n validateScene: typeof validateScene;\n parseScene: typeof parseScene;\n sceneToWorld: typeof sceneToWorld;\n worldToScene: typeof worldToScene;\n}\n\n/** The module object for `use(formatScene)` (needs `physics`). */\nexport const formatScene: RuntimeModule<FormatSceneApi> = { id: 'format-scene', version: RUNTIME_VERSION, requires: ['core', 'physics'], api: { SCENE_FORMAT, migrateScene, validateScene, parseScene, sceneToWorld, worldToScene } };\n"],"names":[],"mappings":";;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BG;AAKI,MAAM,YAAY,GAAG;AA0C5B,MAAM,KAAK,GAAG,CAAC,CAAU,KAAe,OAAO,CAAC,KAAK,QAAQ,IAAI,QAAQ,CAAC,CAAC,CAAC;AAC5E,MAAM,KAAK,GAAG,CAAC,CAAU,KAAsB,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC;AAEnG;AACM,SAAU,YAAY,CAAC,KAAc,EAAA;IACzC,M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AAO,CAAC,CAAC,CAAC,CAAe,EAAE,GAAG,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,SAAS,EAAE,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;AACvU,IAAA,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,IAAI,CAAC,CAAC,IAAI,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,OAAO,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,KAAK,IAAI,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,MAAM,EAAE,WAAW,EAAE;AAC1P;AAWA;AACO,MAAM,WAAW,GAAkC,EAAE,EAAE,EAAE,cAAc,EAAE,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,CAAC,MAAM,EAAE,SAAS,CAAC,EAAE,GAAG,EAAE,EAAE,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,YAAY,EAAE,YAAY,EAAE;;"}
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
- var registry = require('../chunks/registry-VhfPSI0v.cjs');
4
- var tween = require('../chunks/tween-_BGIl6hK.cjs');
5
- require('../chunks/ticker-DvmC6WLS.cjs');
3
+ var registry = require('../chunks/registry-DhKZCitb.cjs');
4
+ var tween = require('../chunks/tween-Dk0QmNe9.cjs');
5
+ require('../chunks/ticker-jD9_A9Rh.cjs');
6
6
  require('../chunks/ease-HwYZnZat.cjs');
7
7
 
8
8
  /**
@@ -1,6 +1,6 @@
1
- import { R as RUNTIME_VERSION } from '../chunks/registry-DXdFb2fJ.js';
2
- import { P as Playable } from '../chunks/tween-CPtm-EdT.js';
3
- import '../chunks/ticker-C5RMHMW7.js';
1
+ import { R as RUNTIME_VERSION } from '../chunks/registry-D87dP_aR.js';
2
+ import { P as Playable } from '../chunks/tween-_Lld1MsF.js';
3
+ import '../chunks/ticker-CJYI5Pxc.js';
4
4
  import '../chunks/ease-XN8_0sXu.js';
5
5
 
6
6
  /**
@@ -1,9 +1,9 @@
1
1
  'use strict';
2
2
 
3
- var registry = require('../chunks/registry-VhfPSI0v.cjs');
4
- var tween = require('../chunks/tween-_BGIl6hK.cjs');
3
+ var registry = require('../chunks/registry-DhKZCitb.cjs');
4
+ var tween = require('../chunks/tween-Dk0QmNe9.cjs');
5
5
  var ease = require('../chunks/ease-HwYZnZat.cjs');
6
- require('../chunks/ticker-DvmC6WLS.cjs');
6
+ require('../chunks/ticker-jD9_A9Rh.cjs');
7
7
 
8
8
  /**
9
9
  * `motionary/runtime/format-svg` (10.2) — SVG animation with the runtime
@@ -1,7 +1,7 @@
1
- import { R as RUNTIME_VERSION } from '../chunks/registry-DXdFb2fJ.js';
2
- import { T as Timeline, P as Playable, p as parseValue } from '../chunks/tween-CPtm-EdT.js';
1
+ import { R as RUNTIME_VERSION } from '../chunks/registry-D87dP_aR.js';
2
+ import { T as Timeline, P as Playable, p as parseValue } from '../chunks/tween-_Lld1MsF.js';
3
3
  import { c as cubicBezier } from '../chunks/ease-XN8_0sXu.js';
4
- import '../chunks/ticker-C5RMHMW7.js';
4
+ import '../chunks/ticker-CJYI5Pxc.js';
5
5
 
6
6
  /**
7
7
  * `motionary/runtime/format-svg` (10.2) — SVG animation with the runtime
@@ -1,9 +1,9 @@
1
1
  'use strict';
2
2
 
3
- var registry = require('../chunks/registry-VhfPSI0v.cjs');
4
- var animImage = require('../chunks/anim-image-DuxvYhq6.cjs');
5
- require('../chunks/tween-_BGIl6hK.cjs');
6
- require('../chunks/ticker-DvmC6WLS.cjs');
3
+ var registry = require('../chunks/registry-DhKZCitb.cjs');
4
+ var animImage = require('../chunks/anim-image-CFGpUX7t.cjs');
5
+ require('../chunks/tween-Dk0QmNe9.cjs');
6
+ require('../chunks/ticker-jD9_A9Rh.cjs');
7
7
  require('../chunks/ease-HwYZnZat.cjs');
8
8
 
9
9
  /**
@@ -1,7 +1,7 @@
1
- import { R as RUNTIME_VERSION } from '../chunks/registry-DXdFb2fJ.js';
2
- import { a as animatedImagePlayer, b as browserDecode, c as composeFrames, d as bytesOf, u as u8, f as fixDelay } from '../chunks/anim-image-BlNPv4JG.js';
3
- import '../chunks/tween-CPtm-EdT.js';
4
- import '../chunks/ticker-C5RMHMW7.js';
1
+ import { R as RUNTIME_VERSION } from '../chunks/registry-D87dP_aR.js';
2
+ import { a as animatedImagePlayer, b as browserDecode, c as composeFrames, d as bytesOf, u as u8, f as fixDelay } from '../chunks/anim-image-CXDD19FH.js';
3
+ import '../chunks/tween-_Lld1MsF.js';
4
+ import '../chunks/ticker-CJYI5Pxc.js';
5
5
  import '../chunks/ease-XN8_0sXu.js';
6
6
 
7
7
  /**
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var registry = require('../chunks/registry-VhfPSI0v.cjs');
3
+ var registry = require('../chunks/registry-DhKZCitb.cjs');
4
4
 
5
5
  /**
6
6
  * `motionary/runtime/gl` (10.5) — a small WebGL2 scene renderer written for
@@ -1,4 +1,4 @@
1
- import { R as RUNTIME_VERSION } from '../chunks/registry-DXdFb2fJ.js';
1
+ import { R as RUNTIME_VERSION } from '../chunks/registry-D87dP_aR.js';
2
2
 
3
3
  /**
4
4
  * `motionary/runtime/gl` (10.5) — a small WebGL2 scene renderer written for