@2112-lab/central-plant 0.1.4 → 0.1.6

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 (88) hide show
  1. package/dist/bundle/index.js +33146 -1
  2. package/dist/cjs/_virtual/_rollupPluginBabelHelpers.js +432 -1
  3. package/dist/cjs/node_modules/@2112-lab/pathfinder/dist/index.esm.js +1448 -1
  4. package/dist/cjs/node_modules/three/examples/jsm/controls/OrbitControls.js +1853 -1
  5. package/dist/cjs/node_modules/three/examples/jsm/exporters/GLTFExporter.js +3537 -1
  6. package/dist/cjs/node_modules/three/examples/jsm/exporters/OBJExporter.js +305 -1
  7. package/dist/cjs/node_modules/three/examples/jsm/exporters/PLYExporter.js +542 -1
  8. package/dist/cjs/node_modules/three/examples/jsm/exporters/STLExporter.js +218 -1
  9. package/dist/cjs/node_modules/three/examples/jsm/loaders/DRACOLoader.js +683 -1
  10. package/dist/cjs/node_modules/three/examples/jsm/loaders/GLTFLoader.js +4811 -1
  11. package/dist/cjs/node_modules/three/examples/jsm/loaders/RGBELoader.js +480 -1
  12. package/dist/cjs/node_modules/three/examples/jsm/renderers/CSS2DRenderer.js +309 -1
  13. package/dist/cjs/node_modules/three/examples/jsm/utils/BufferGeometryUtils.js +120 -1
  14. package/dist/cjs/src/analysis/analysis.js +560 -1
  15. package/dist/cjs/src/analysis/testing.js +958 -1
  16. package/dist/cjs/src/core/centralPlant.js +1149 -1
  17. package/dist/cjs/src/core/debugLogger.js +175 -1
  18. package/dist/cjs/src/core/mathUtils.js +574 -1
  19. package/dist/cjs/src/core/nameUtils.js +93 -1
  20. package/dist/cjs/src/data/export.js +716 -1
  21. package/dist/cjs/src/data/import.js +380 -1
  22. package/dist/cjs/src/data/numerics.js +522 -1
  23. package/dist/cjs/src/helpers/sceneHelper.js +572 -1
  24. package/dist/cjs/src/index.js +69 -1
  25. package/dist/cjs/src/managers/components/animationManager.js +123 -1
  26. package/dist/cjs/src/managers/components/componentManager.js +332 -1
  27. package/dist/cjs/src/managers/components/pathfindingManager.js +1441 -1
  28. package/dist/cjs/src/managers/controls/TransformControls.js +1063 -1
  29. package/dist/cjs/src/managers/controls/cameraControlsManager.js +79 -1
  30. package/dist/cjs/src/managers/controls/dragDropManager.js +1026 -1
  31. package/dist/cjs/src/managers/controls/keyboardControlsManager.js +395 -1
  32. package/dist/cjs/src/managers/controls/transformControlsManager.js +1807 -1
  33. package/dist/cjs/src/managers/environment/environmentManager.js +714 -1
  34. package/dist/cjs/src/managers/environment/textureConfig.js +229 -1
  35. package/dist/cjs/src/managers/scene/sceneExportManager.js +264 -1
  36. package/dist/cjs/src/managers/scene/sceneInitializationManager.js +346 -1
  37. package/dist/cjs/src/managers/scene/sceneOperationsManager.js +1509 -1
  38. package/dist/cjs/src/managers/scene/sceneTooltipsManager.js +661 -1
  39. package/dist/cjs/src/managers/system/disposalManager.js +444 -1
  40. package/dist/cjs/src/managers/system/hotReloadManager.js +291 -1
  41. package/dist/cjs/src/managers/system/performanceMonitor.js +863 -1
  42. package/dist/cjs/src/rendering/modelPreloader.js +369 -1
  43. package/dist/cjs/src/rendering/rendering2D.js +631 -1
  44. package/dist/cjs/src/rendering/rendering3D.js +685 -1
  45. package/dist/esm/_virtual/_rollupPluginBabelHelpers.js +396 -1
  46. package/dist/esm/node_modules/@2112-lab/pathfinder/dist/index.esm.js +1444 -1
  47. package/dist/esm/node_modules/three/examples/jsm/controls/OrbitControls.js +1849 -1
  48. package/dist/esm/node_modules/three/examples/jsm/exporters/GLTFExporter.js +3533 -1
  49. package/dist/esm/node_modules/three/examples/jsm/exporters/OBJExporter.js +301 -1
  50. package/dist/esm/node_modules/three/examples/jsm/exporters/PLYExporter.js +538 -1
  51. package/dist/esm/node_modules/three/examples/jsm/exporters/STLExporter.js +214 -1
  52. package/dist/esm/node_modules/three/examples/jsm/loaders/DRACOLoader.js +679 -1
  53. package/dist/esm/node_modules/three/examples/jsm/loaders/GLTFLoader.js +4807 -1
  54. package/dist/esm/node_modules/three/examples/jsm/loaders/RGBELoader.js +476 -1
  55. package/dist/esm/node_modules/three/examples/jsm/renderers/CSS2DRenderer.js +304 -1
  56. package/dist/esm/node_modules/three/examples/jsm/utils/BufferGeometryUtils.js +116 -1
  57. package/dist/esm/src/analysis/analysis.js +536 -1
  58. package/dist/esm/src/analysis/testing.js +954 -1
  59. package/dist/esm/src/core/centralPlant.js +1144 -1
  60. package/dist/esm/src/core/debugLogger.js +167 -1
  61. package/dist/esm/src/core/mathUtils.js +570 -1
  62. package/dist/esm/src/core/nameUtils.js +87 -1
  63. package/dist/esm/src/data/export.js +712 -1
  64. package/dist/esm/src/data/import.js +356 -1
  65. package/dist/esm/src/data/numerics.js +518 -1
  66. package/dist/esm/src/helpers/sceneHelper.js +547 -1
  67. package/dist/esm/src/index.js +35 -1
  68. package/dist/esm/src/managers/components/animationManager.js +119 -1
  69. package/dist/esm/src/managers/components/componentManager.js +328 -1
  70. package/dist/esm/src/managers/components/pathfindingManager.js +1417 -1
  71. package/dist/esm/src/managers/controls/TransformControls.js +1057 -1
  72. package/dist/esm/src/managers/controls/cameraControlsManager.js +75 -1
  73. package/dist/esm/src/managers/controls/dragDropManager.js +1002 -1
  74. package/dist/esm/src/managers/controls/keyboardControlsManager.js +371 -1
  75. package/dist/esm/src/managers/controls/transformControlsManager.js +1782 -1
  76. package/dist/esm/src/managers/environment/environmentManager.js +690 -1
  77. package/dist/esm/src/managers/environment/textureConfig.js +202 -1
  78. package/dist/esm/src/managers/scene/sceneExportManager.js +260 -1
  79. package/dist/esm/src/managers/scene/sceneInitializationManager.js +322 -1
  80. package/dist/esm/src/managers/scene/sceneOperationsManager.js +1485 -1
  81. package/dist/esm/src/managers/scene/sceneTooltipsManager.js +637 -1
  82. package/dist/esm/src/managers/system/disposalManager.js +440 -1
  83. package/dist/esm/src/managers/system/hotReloadManager.js +287 -1
  84. package/dist/esm/src/managers/system/performanceMonitor.js +858 -1
  85. package/dist/esm/src/rendering/modelPreloader.js +364 -1
  86. package/dist/esm/src/rendering/rendering2D.js +627 -1
  87. package/dist/esm/src/rendering/rendering3D.js +661 -1
  88. package/package.json +1 -1
@@ -1 +1,954 @@
1
- import{createClass as e,typeof as t,createForOfIteratorHelper as r,slicedToArray as n,classCallCheck as o,defineProperty as s,objectSpread2 as i,asyncToGenerator as a,regenerator as u}from"../../_virtual/_rollupPluginBabelHelpers.js";import{logger as c}from"../core/debugLogger.js";var f=function(){return e(function e(){var t,r=this;o(this,e),s(this,"mock",{create:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=i({calls:[],callCount:0},e);return Object.keys(e).forEach(function(r){var n=e[r];t[r]=function(){for(var e=arguments.length,o=new Array(e),s=0;s<e;s++)o[s]=arguments[s];return t.calls.push({method:r,args:o,timestamp:Date.now()}),t.callCount++,n.apply(void 0,o)}}),t},spy:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:function(){},t=function(){for(var r=arguments.length,n=new Array(r),o=0;o<r;o++)n[o]=arguments[o];return t.calls.push({args:n,timestamp:Date.now()}),t.callCount++,void 0!==t.returnValue?t.returnValue:e.apply(void 0,n)};return t.calls=[],t.callCount=0,t.returnValue=void 0,t.returns=function(e){return t.returnValue=e,t},t.throws=function(e){return t.throwError=e,t},t},three:{vector3:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return{x:e,y:t,z:r,set:function(n,o,s){e=n,t=o,r=s},clone:function(){return{x:e,y:t,z:r}},add:function(n){return{x:e+n.x,y:t+n.y,z:r+n.z}},sub:function(n){return{x:e-n.x,y:t-n.y,z:r-n.z}},length:function(){return Math.sqrt(e*e+t*t+r*r)},normalize:function(){var n=Math.sqrt(e*e+t*t+r*r);return{x:e/n,y:t/n,z:r/n}}}},object3D:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{position:{x:0,y:0,z:0},rotation:{x:0,y:0,z:0},scale:{x:1,y:1,z:1},children:[],parent:null,name:e.name||"",uuid:e.uuid||Math.random().toString(36),add:function(e){this.children.push(e),e.parent=this},remove:function(e){var t=this.children.indexOf(e);t>-1&&this.children.splice(t,1)},traverse:function(e){e(this),this.children.forEach(function(t){return t.traverse(e)})}}},scene:function(){return i(i({},r.mock.three.object3D()),{},{background:null,environment:null,fog:null,type:"Scene"})}}}),s(this,"benchmark",{run:(t=a(u().m(function e(t,n){var o,s,i,a,f,h,d,l,p,m,w,v,E,g,y,b,k,x,T,M=arguments;return u().w(function(e){for(;;)switch(e.n){case 0:s=(o=M.length>2&&void 0!==M[2]?M[2]:{}).iterations,i=void 0===s?1e3:s,a=o.warmupIterations,f=void 0===a?10:a,h=o.timeout,d=void 0===h?5e3:h,c.info("⏱️ Running benchmark: ".concat(t)),l=0;case 1:if(!(l<f)){e.n=3;break}return e.n=2,n();case 2:l++,e.n=1;break;case 3:p=[],m=performance.now(),w=0;case 4:if(!(w<i)){e.n=7;break}return v=performance.now(),e.n=5,n();case 5:if(E=performance.now(),p.push(E-v),!(performance.now()-m>d)){e.n=6;break}return c.warn('⚠️ Benchmark "'.concat(t,'" timed out after ').concat(w+1," iterations")),e.a(3,7);case 6:w++,e.n=4;break;case 7:return g=performance.now()-m,y=p.reduce(function(e,t){return e+t},0)/p.length,b=Math.min.apply(Math,p),k=Math.max.apply(Math,p),x=p.sort()[Math.floor(p.length/2)],T={name:t,iterations:p.length,totalTime:g,avgTime:y,minTime:b,maxTime:k,medianTime:x,opsPerSecond:1e3/y},r.benchmarks.set(t,T),c.info('✅ Benchmark "'.concat(t,'" completed: ').concat(T.opsPerSecond.toFixed(2)," ops/sec")),e.a(2,T)}},e)})),function(e,r){return t.apply(this,arguments)}),compare:function(e){var t=e.map(function(e){return r.benchmarks.get(e)}).filter(Boolean);if(t.length<2)throw new Error("Need at least 2 benchmarks to compare");var n=t.reduce(function(e,t){return e.opsPerSecond>t.opsPerSecond?e:t}),o=t.map(function(e){return{name:e.name,opsPerSecond:e.opsPerSecond,relativeSpeed:e.opsPerSecond/n.opsPerSecond,slower:n.opsPerSecond/e.opsPerSecond}});return{fastest:n.name,comparison:o}}}),this.testSuites=new Map,this.testResults=[],this.mockData=new Map,this.assertions=new Map,this.benchmarks=new Map,this.setupDefaultAssertions()},[{key:"setupDefaultAssertions",value:function(){this.addAssertion("equals",function(e,t,r){if(e!==t)throw new Error(r||"Expected ".concat(t,", got ").concat(e))}),this.addAssertion("notEquals",function(e,t,r){if(e===t)throw new Error(r||"Expected not ".concat(t,", got ").concat(e))}),this.addAssertion("deepEquals",function(e,t,r){if(JSON.stringify(e)!==JSON.stringify(t))throw new Error(r||"Deep equality failed")}),this.addAssertion("true",function(e,t){if(!0!==e)throw new Error(t||"Expected true, got ".concat(e))}),this.addAssertion("false",function(e,t){if(!1!==e)throw new Error(t||"Expected false, got ".concat(e))}),this.addAssertion("truthy",function(e,t){if(!e)throw new Error(t||"Expected truthy value, got ".concat(e))}),this.addAssertion("falsy",function(e,t){if(e)throw new Error(t||"Expected falsy value, got ".concat(e))}),this.addAssertion("null",function(e,t){if(null!==e)throw new Error(t||"Expected null, got ".concat(e))}),this.addAssertion("undefined",function(e,t){if(void 0!==e)throw new Error(t||"Expected undefined, got ".concat(e))}),this.addAssertion("defined",function(e,t){if(void 0===e)throw new Error(t||"Expected defined value, got undefined")}),this.addAssertion("instanceOf",function(e,r,n){if(!(e instanceof r))throw new Error(n||"Expected instance of ".concat(r.name,", got ").concat(t(e)))}),this.addAssertion("typeof",function(e,r,n){if(t(e)!==r)throw new Error(n||"Expected type ".concat(r,", got ").concat(t(e)))}),this.addAssertion("greaterThan",function(e,t,r){if(e<=t)throw new Error(r||"Expected ".concat(e," > ").concat(t))}),this.addAssertion("lessThan",function(e,t,r){if(e>=t)throw new Error(r||"Expected ".concat(e," < ").concat(t))}),this.addAssertion("greaterThanOrEqual",function(e,t,r){if(e<t)throw new Error(r||"Expected ".concat(e," >= ").concat(t))}),this.addAssertion("lessThanOrEqual",function(e,t,r){if(e>t)throw new Error(r||"Expected ".concat(e," <= ").concat(t))}),this.addAssertion("approximately",function(e,t,r,n){if(Math.abs(e-t)>r)throw new Error(n||"Expected ".concat(e," ≈ ").concat(t," (±").concat(r,")"))}),this.addAssertion("includes",function(e,t,r){if(!e.includes(t))throw new Error(r||'Expected "'.concat(e,'" to include "').concat(t,'"'))}),this.addAssertion("startsWith",function(e,t,r){if(!e.startsWith(t))throw new Error(r||'Expected "'.concat(e,'" to start with "').concat(t,'"'))}),this.addAssertion("endsWith",function(e,t,r){if(!e.endsWith(t))throw new Error(r||'Expected "'.concat(e,'" to end with "').concat(t,'"'))}),this.addAssertion("matches",function(e,t,r){if(!t.test(e))throw new Error(r||'Expected "'.concat(e,'" to match pattern ').concat(t))}),this.addAssertion("hasLength",function(e,t,r){if(e.length!==t)throw new Error(r||"Expected length ".concat(t,", got ").concat(e.length))}),this.addAssertion("isEmpty",function(e,t){if(0!==e.length)throw new Error(t||"Expected empty array/string, got length ".concat(e.length))}),this.addAssertion("isNotEmpty",function(e,t){if(0===e.length)throw new Error(t||"Expected non-empty array/string")}),this.addAssertion("hasProperty",function(e,t,r){if(!e.hasOwnProperty(t))throw new Error(r||'Expected object to have property "'.concat(t,'"'))}),this.addAssertion("hasMethod",function(e,t,r){if("function"!=typeof e[t])throw new Error(r||'Expected object to have method "'.concat(t,'"'))}),this.addAssertion("resolves",function(){var e=a(u().m(function e(t,r){var n;return u().w(function(e){for(;;)switch(e.n){case 0:return e.p=0,e.n=1,t;case 1:e.n=3;break;case 2:throw e.p=2,n=e.v,new Error(r||"Expected promise to resolve, but it rejected: ".concat(n.message));case 3:return e.a(2)}},e,null,[[0,2]])}));return function(t,r){return e.apply(this,arguments)}}()),this.addAssertion("rejects",function(){var e=a(u().m(function e(t,r){return u().w(function(e){for(;;)switch(e.n){case 0:return e.p=0,e.n=1,t;case 1:throw new Error(r||"Expected promise to reject, but it resolved");case 2:e.p=2,e.v;case 3:return e.a(2)}},e,null,[[0,2]])}));return function(t,r){return e.apply(this,arguments)}}()),this.addAssertion("throws",function(e,t){try{throw e(),new Error(t||"Expected function to throw, but it didn't")}catch(e){}})}},{key:"addAssertion",value:function(e,t){this.assertions.set(e,t)}},{key:"createTestSuite",value:function(e){var t=this,r={name:e,tests:[],beforeEach:null,afterEach:null,beforeAll:null,afterAll:null,setup:arguments.length>1&&void 0!==arguments[1]?arguments[1]:null};return this.testSuites.set(e,r),{test:function(r,n){return t.addTest(e,r,n)},beforeEach:function(e){r.beforeEach=e},afterEach:function(e){r.afterEach=e},beforeAll:function(e){r.beforeAll=e},afterAll:function(e){r.afterAll=e}}}},{key:"addTest",value:function(e,t,r){var n=this.testSuites.get(e);if(!n)throw new Error('Test suite "'.concat(e,'" not found'));n.tests.push({name:t,fn:r,skip:!1,only:!1})}},{key:"runAllTests",value:(d=a(u().m(function e(){var t,o,s,i,a,f,h,d;return u().w(function(e){for(;;)switch(e.n){case 0:c.info("🧪 Running all test suites..."),t=performance.now(),o={suites:[],totalTests:0,passedTests:0,failedTests:0,skippedTests:0,duration:0},s=r(this.testSuites),e.p=1,s.s();case 2:if((i=s.n()).done){e.n=5;break}return a=n(i.value,2),f=a[0],a[1],e.n=3,this.runTestSuite(f);case 3:h=e.v,o.suites.push(h),o.totalTests+=h.totalTests,o.passedTests+=h.passedTests,o.failedTests+=h.failedTests,o.skippedTests+=h.skippedTests;case 4:e.n=2;break;case 5:e.n=7;break;case 6:e.p=6,d=e.v,s.e(d);case 7:return e.p=7,s.f(),e.f(7);case 8:return o.duration=performance.now()-t,c.info("✅ All tests completed: ".concat(o.passedTests,"/").concat(o.totalTests," passed in ").concat(o.duration.toFixed(2),"ms")),this.testResults.push(o),e.a(2,o)}},e,this,[[1,6,7,8]])})),function(){return d.apply(this,arguments)})},{key:"runTestSuite",value:(h=a(u().m(function e(t){var n,o,s,i,a,f,h,d,l;return u().w(function(e){for(;;)switch(e.n){case 0:if(n=this.testSuites.get(t)){e.n=1;break}throw new Error('Test suite "'.concat(t,'" not found'));case 1:if(c.info("🧪 Running test suite: ".concat(t)),o=performance.now(),s={name:t,tests:[],totalTests:n.tests.length,passedTests:0,failedTests:0,skippedTests:0,duration:0},e.p=2,!n.setup){e.n=3;break}return e.n=3,n.setup();case 3:if(!n.beforeAll){e.n=4;break}return e.n=4,n.beforeAll();case 4:i=r(n.tests),e.p=5,i.s();case 6:if((a=i.n()).done){e.n=9;break}return f=a.value,e.n=7,this.runTest(n,f);case 7:h=e.v,s.tests.push(h),"passed"===h.status?s.passedTests++:"failed"===h.status?s.failedTests++:"skipped"===h.status&&s.skippedTests++;case 8:e.n=6;break;case 9:e.n=11;break;case 10:e.p=10,d=e.v,i.e(d);case 11:return e.p=11,i.f(),e.f(11);case 12:if(!n.afterAll){e.n=13;break}return e.n=13,n.afterAll();case 13:e.n=15;break;case 14:e.p=14,l=e.v,c.error('❌ Test suite "'.concat(t,'" setup failed:'),l);case 15:return s.duration=performance.now()-o,c.info('✅ Suite "'.concat(t,'" completed: ').concat(s.passedTests,"/").concat(s.totalTests," passed")),e.a(2,s)}},e,this,[[5,10,11,12],[2,14]])})),function(e){return h.apply(this,arguments)})},{key:"runTest",value:(f=a(u().m(function e(t,r){var n,o,s,i;return u().w(function(e){for(;;)switch(e.n){case 0:if(!r.skip){e.n=1;break}return e.a(2,{name:r.name,status:"skipped",duration:0,error:null});case 1:if(n=performance.now(),o={name:r.name,status:"passed",duration:0,error:null},e.p=2,!t.beforeEach){e.n=3;break}return e.n=3,t.beforeEach();case 3:return s=this.createAssertionContext(),e.n=4,r.fn(s);case 4:if(!t.afterEach){e.n=5;break}return e.n=5,t.afterEach();case 5:e.n=7;break;case 6:e.p=6,i=e.v,o.status="failed",o.error={message:i.message,stack:i.stack},c.error('❌ Test "'.concat(r.name,'" failed:'),i.message);case 7:return o.duration=performance.now()-n,e.a(2,o)}},e,this,[[2,6]])})),function(e,t){return f.apply(this,arguments)})},{key:"createAssertionContext",value:function(){var e,t={},o=r(this.assertions);try{for(o.s();!(e=o.n()).done;){var s=n(e.value,2),i=s[0],a=s[1];t[i]=a}}catch(e){o.e(e)}finally{o.f()}return t}},{key:"generateReport",value:function(e){var t=(e.passedTests/e.totalTests*100).toFixed(1),r='\n<!DOCTYPE html>\n<html>\n<head>\n <title>Test Report</title>\n <style>\n body { font-family: Arial, sans-serif; margin: 20px; }\n .summary { background: #f5f5f5; padding: 15px; border-radius: 5px; margin-bottom: 20px; }\n .suite { margin-bottom: 20px; border: 1px solid #ddd; border-radius: 5px; }\n .suite-header { background: #e9e9e9; padding: 10px; font-weight: bold; }\n .test { padding: 10px; border-bottom: 1px solid #eee; }\n .test:last-child { border-bottom: none; }\n .passed { color: green; }\n .failed { color: red; }\n .skipped { color: orange; }\n .error { background: #ffe6e6; padding: 10px; margin-top: 5px; border-radius: 3px; }\n </style>\n</head>\n<body>\n <h1>Test Report</h1>\n \n <div class="summary">\n <h2>Summary</h2>\n <p><strong>Total Tests:</strong> '.concat(e.totalTests,'</p>\n <p><strong>Passed:</strong> <span class="passed">').concat(e.passedTests,'</span></p>\n <p><strong>Failed:</strong> <span class="failed">').concat(e.failedTests,'</span></p>\n <p><strong>Skipped:</strong> <span class="skipped">').concat(e.skippedTests,"</span></p>\n <p><strong>Pass Rate:</strong> ").concat(t,"%</p>\n <p><strong>Duration:</strong> ").concat(e.duration.toFixed(2),"ms</p>\n </div>\n \n <h2>Test Suites</h2>\n");return e.suites.forEach(function(e){r+='\n <div class="suite">\n <div class="suite-header">\n '.concat(e.name," (").concat(e.passedTests,"/").concat(e.totalTests," passed)\n </div>\n"),e.tests.forEach(function(e){r+='\n <div class="test">\n <span class="'.concat(e.status,'">').concat(e.status.toUpperCase(),"</span>\n <strong>").concat(e.name,"</strong>\n <small>(").concat(e.duration.toFixed(2),"ms)</small>\n"),e.error&&(r+='\n <div class="error">\n <strong>Error:</strong> '.concat(e.error.message,"\n </div>\n")),r+=" </div>"}),r+=" </div>"}),r+="\n</body>\n</html>\n"}},{key:"clearResults",value:function(){this.testResults=[]}},{key:"getResults",value:function(){return this.testResults}},{key:"getBenchmarks",value:function(){return this.benchmarks}},{key:"dispose",value:function(){this.testSuites.clear(),this.clearResults(),this.mockData.clear(),this.benchmarks.clear(),c.info("Testing disposed")}}]);var f,h,d}();export{f as Testing};
1
+ import { createClass as _createClass, typeof as _typeof, createForOfIteratorHelper as _createForOfIteratorHelper, slicedToArray as _slicedToArray, classCallCheck as _classCallCheck, defineProperty as _defineProperty, objectSpread2 as _objectSpread2, asyncToGenerator as _asyncToGenerator, regenerator as _regenerator } from '../../_virtual/_rollupPluginBabelHelpers.js';
2
+ import { logger } from '../core/debugLogger.js';
3
+
4
+ var Testing = /*#__PURE__*/function () {
5
+ function Testing() {
6
+ var _this = this;
7
+ _classCallCheck(this, Testing);
8
+ /**
9
+ * Mock data utilities
10
+ */
11
+ _defineProperty(this, "mock", {
12
+ /**
13
+ * Create mock object
14
+ * @param {Object} methods - Mock methods
15
+ * @returns {Object} Mock object
16
+ */
17
+ create: function create() {
18
+ var methods = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
19
+ var mock = _objectSpread2({
20
+ calls: [],
21
+ callCount: 0
22
+ }, methods);
23
+
24
+ // Wrap methods to track calls
25
+ Object.keys(methods).forEach(function (methodName) {
26
+ var originalMethod = methods[methodName];
27
+ mock[methodName] = function () {
28
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
29
+ args[_key] = arguments[_key];
30
+ }
31
+ mock.calls.push({
32
+ method: methodName,
33
+ args: args,
34
+ timestamp: Date.now()
35
+ });
36
+ mock.callCount++;
37
+ return originalMethod.apply(void 0, args);
38
+ };
39
+ });
40
+ return mock;
41
+ },
42
+ /**
43
+ * Create spy function
44
+ * @param {Function} originalFn - Original function to spy on
45
+ * @returns {Function} Spy function
46
+ */
47
+ spy: function _spy() {
48
+ var originalFn = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : function () {};
49
+ var _spy = function spy() {
50
+ for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
51
+ args[_key2] = arguments[_key2];
52
+ }
53
+ _spy.calls.push({
54
+ args: args,
55
+ timestamp: Date.now()
56
+ });
57
+ _spy.callCount++;
58
+ return _spy.returnValue !== undefined ? _spy.returnValue : originalFn.apply(void 0, args);
59
+ };
60
+ _spy.calls = [];
61
+ _spy.callCount = 0;
62
+ _spy.returnValue = undefined;
63
+ _spy.returns = function (value) {
64
+ _spy.returnValue = value;
65
+ return _spy;
66
+ };
67
+ _spy.throws = function (error) {
68
+ _spy.throwError = error;
69
+ return _spy;
70
+ };
71
+ return _spy;
72
+ },
73
+ /**
74
+ * Mock Three.js objects
75
+ */
76
+ three: {
77
+ /**
78
+ * Create mock Vector3
79
+ * @param {number} x - X component
80
+ * @param {number} y - Y component
81
+ * @param {number} z - Z component
82
+ * @returns {Object} Mock Vector3
83
+ */
84
+ vector3: function vector3() {
85
+ var x = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
86
+ var y = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
87
+ var z = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
88
+ return {
89
+ x: x,
90
+ y: y,
91
+ z: z,
92
+ set: function set(newX, newY, newZ) {
93
+ x = newX;
94
+ y = newY;
95
+ z = newZ;
96
+ },
97
+ clone: function clone() {
98
+ return {
99
+ x: x,
100
+ y: y,
101
+ z: z
102
+ };
103
+ },
104
+ add: function add(v) {
105
+ return {
106
+ x: x + v.x,
107
+ y: y + v.y,
108
+ z: z + v.z
109
+ };
110
+ },
111
+ sub: function sub(v) {
112
+ return {
113
+ x: x - v.x,
114
+ y: y - v.y,
115
+ z: z - v.z
116
+ };
117
+ },
118
+ length: function length() {
119
+ return Math.sqrt(x * x + y * y + z * z);
120
+ },
121
+ normalize: function normalize() {
122
+ var len = Math.sqrt(x * x + y * y + z * z);
123
+ return {
124
+ x: x / len,
125
+ y: y / len,
126
+ z: z / len
127
+ };
128
+ }
129
+ };
130
+ },
131
+ /**
132
+ * Create mock Object3D
133
+ * @param {Object} options - Object options
134
+ * @returns {Object} Mock Object3D
135
+ */
136
+ object3D: function object3D() {
137
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
138
+ return {
139
+ position: {
140
+ x: 0,
141
+ y: 0,
142
+ z: 0
143
+ },
144
+ rotation: {
145
+ x: 0,
146
+ y: 0,
147
+ z: 0
148
+ },
149
+ scale: {
150
+ x: 1,
151
+ y: 1,
152
+ z: 1
153
+ },
154
+ children: [],
155
+ parent: null,
156
+ name: options.name || '',
157
+ uuid: options.uuid || Math.random().toString(36),
158
+ add: function add(child) {
159
+ this.children.push(child);
160
+ child.parent = this;
161
+ },
162
+ remove: function remove(child) {
163
+ var index = this.children.indexOf(child);
164
+ if (index > -1) this.children.splice(index, 1);
165
+ },
166
+ traverse: function traverse(callback) {
167
+ callback(this);
168
+ this.children.forEach(function (child) {
169
+ return child.traverse(callback);
170
+ });
171
+ }
172
+ };
173
+ },
174
+ /**
175
+ * Create mock Scene
176
+ * @returns {Object} Mock Scene
177
+ */
178
+ scene: function scene() {
179
+ return _objectSpread2(_objectSpread2({}, _this.mock.three.object3D()), {}, {
180
+ background: null,
181
+ environment: null,
182
+ fog: null,
183
+ type: 'Scene'
184
+ });
185
+ }
186
+ }
187
+ });
188
+ /**
189
+ * Performance testing utilities
190
+ */
191
+ _defineProperty(this, "benchmark", {
192
+ /**
193
+ * Run performance benchmark
194
+ * @param {string} name - Benchmark name
195
+ * @param {Function} fn - Function to benchmark
196
+ * @param {Object} options - Benchmark options
197
+ * @returns {Promise<Object>} Benchmark results
198
+ */
199
+ run: function () {
200
+ var _run = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(name, fn) {
201
+ var options,
202
+ _options$iterations,
203
+ iterations,
204
+ _options$warmupIterat,
205
+ warmupIterations,
206
+ _options$timeout,
207
+ timeout,
208
+ i,
209
+ times,
210
+ startTime,
211
+ _i,
212
+ iterationStart,
213
+ iterationEnd,
214
+ totalTime,
215
+ avgTime,
216
+ minTime,
217
+ maxTime,
218
+ medianTime,
219
+ result,
220
+ _args = arguments;
221
+ return _regenerator().w(function (_context) {
222
+ while (1) switch (_context.n) {
223
+ case 0:
224
+ options = _args.length > 2 && _args[2] !== undefined ? _args[2] : {};
225
+ _options$iterations = options.iterations, iterations = _options$iterations === void 0 ? 1000 : _options$iterations, _options$warmupIterat = options.warmupIterations, warmupIterations = _options$warmupIterat === void 0 ? 10 : _options$warmupIterat, _options$timeout = options.timeout, timeout = _options$timeout === void 0 ? 5000 : _options$timeout;
226
+ logger.info("\u23F1\uFE0F Running benchmark: ".concat(name));
227
+
228
+ // Warmup
229
+ i = 0;
230
+ case 1:
231
+ if (!(i < warmupIterations)) {
232
+ _context.n = 3;
233
+ break;
234
+ }
235
+ _context.n = 2;
236
+ return fn();
237
+ case 2:
238
+ i++;
239
+ _context.n = 1;
240
+ break;
241
+ case 3:
242
+ // Benchmark
243
+ times = [];
244
+ startTime = performance.now();
245
+ _i = 0;
246
+ case 4:
247
+ if (!(_i < iterations)) {
248
+ _context.n = 7;
249
+ break;
250
+ }
251
+ iterationStart = performance.now();
252
+ _context.n = 5;
253
+ return fn();
254
+ case 5:
255
+ iterationEnd = performance.now();
256
+ times.push(iterationEnd - iterationStart);
257
+
258
+ // Check timeout
259
+ if (!(performance.now() - startTime > timeout)) {
260
+ _context.n = 6;
261
+ break;
262
+ }
263
+ logger.warn("\u26A0\uFE0F Benchmark \"".concat(name, "\" timed out after ").concat(_i + 1, " iterations"));
264
+ return _context.a(3, 7);
265
+ case 6:
266
+ _i++;
267
+ _context.n = 4;
268
+ break;
269
+ case 7:
270
+ // Calculate statistics
271
+ totalTime = performance.now() - startTime;
272
+ avgTime = times.reduce(function (sum, time) {
273
+ return sum + time;
274
+ }, 0) / times.length;
275
+ minTime = Math.min.apply(Math, times);
276
+ maxTime = Math.max.apply(Math, times);
277
+ medianTime = times.sort()[Math.floor(times.length / 2)];
278
+ result = {
279
+ name: name,
280
+ iterations: times.length,
281
+ totalTime: totalTime,
282
+ avgTime: avgTime,
283
+ minTime: minTime,
284
+ maxTime: maxTime,
285
+ medianTime: medianTime,
286
+ opsPerSecond: 1000 / avgTime
287
+ };
288
+ _this.benchmarks.set(name, result);
289
+ logger.info("\u2705 Benchmark \"".concat(name, "\" completed: ").concat(result.opsPerSecond.toFixed(2), " ops/sec"));
290
+ return _context.a(2, result);
291
+ }
292
+ }, _callee);
293
+ }));
294
+ function run(_x, _x2) {
295
+ return _run.apply(this, arguments);
296
+ }
297
+ return run;
298
+ }(),
299
+ /**
300
+ * Compare benchmarks
301
+ * @param {Array} benchmarkNames - Names of benchmarks to compare
302
+ * @returns {Object} Comparison results
303
+ */
304
+ compare: function compare(benchmarkNames) {
305
+ var results = benchmarkNames.map(function (name) {
306
+ return _this.benchmarks.get(name);
307
+ }).filter(Boolean);
308
+ if (results.length < 2) {
309
+ throw new Error('Need at least 2 benchmarks to compare');
310
+ }
311
+ var fastest = results.reduce(function (prev, current) {
312
+ return prev.opsPerSecond > current.opsPerSecond ? prev : current;
313
+ });
314
+ var comparison = results.map(function (result) {
315
+ return {
316
+ name: result.name,
317
+ opsPerSecond: result.opsPerSecond,
318
+ relativeSpeed: result.opsPerSecond / fastest.opsPerSecond,
319
+ slower: fastest.opsPerSecond / result.opsPerSecond
320
+ };
321
+ });
322
+ return {
323
+ fastest: fastest.name,
324
+ comparison: comparison
325
+ };
326
+ }
327
+ });
328
+ this.testSuites = new Map();
329
+ this.testResults = [];
330
+ this.mockData = new Map();
331
+ this.assertions = new Map();
332
+ this.benchmarks = new Map();
333
+ this.setupDefaultAssertions();
334
+ }
335
+
336
+ /**
337
+ * Setup default assertion methods
338
+ */
339
+ return _createClass(Testing, [{
340
+ key: "setupDefaultAssertions",
341
+ value: function setupDefaultAssertions() {
342
+ // Basic assertions
343
+ this.addAssertion('equals', function (actual, expected, message) {
344
+ if (actual !== expected) {
345
+ throw new Error(message || "Expected ".concat(expected, ", got ").concat(actual));
346
+ }
347
+ });
348
+ this.addAssertion('notEquals', function (actual, expected, message) {
349
+ if (actual === expected) {
350
+ throw new Error(message || "Expected not ".concat(expected, ", got ").concat(actual));
351
+ }
352
+ });
353
+ this.addAssertion('deepEquals', function (actual, expected, message) {
354
+ if (JSON.stringify(actual) !== JSON.stringify(expected)) {
355
+ throw new Error(message || "Deep equality failed");
356
+ }
357
+ });
358
+ this.addAssertion('true', function (actual, message) {
359
+ if (actual !== true) {
360
+ throw new Error(message || "Expected true, got ".concat(actual));
361
+ }
362
+ });
363
+ this.addAssertion('false', function (actual, message) {
364
+ if (actual !== false) {
365
+ throw new Error(message || "Expected false, got ".concat(actual));
366
+ }
367
+ });
368
+ this.addAssertion('truthy', function (actual, message) {
369
+ if (!actual) {
370
+ throw new Error(message || "Expected truthy value, got ".concat(actual));
371
+ }
372
+ });
373
+ this.addAssertion('falsy', function (actual, message) {
374
+ if (actual) {
375
+ throw new Error(message || "Expected falsy value, got ".concat(actual));
376
+ }
377
+ });
378
+ this.addAssertion('null', function (actual, message) {
379
+ if (actual !== null) {
380
+ throw new Error(message || "Expected null, got ".concat(actual));
381
+ }
382
+ });
383
+ this.addAssertion('undefined', function (actual, message) {
384
+ if (actual !== undefined) {
385
+ throw new Error(message || "Expected undefined, got ".concat(actual));
386
+ }
387
+ });
388
+ this.addAssertion('defined', function (actual, message) {
389
+ if (actual === undefined) {
390
+ throw new Error(message || "Expected defined value, got undefined");
391
+ }
392
+ });
393
+
394
+ // Type assertions
395
+ this.addAssertion('instanceOf', function (actual, expected, message) {
396
+ if (!(actual instanceof expected)) {
397
+ throw new Error(message || "Expected instance of ".concat(expected.name, ", got ").concat(_typeof(actual)));
398
+ }
399
+ });
400
+ this.addAssertion('typeof', function (actual, expected, message) {
401
+ if (_typeof(actual) !== expected) {
402
+ throw new Error(message || "Expected type ".concat(expected, ", got ").concat(_typeof(actual)));
403
+ }
404
+ });
405
+
406
+ // Numeric assertions
407
+ this.addAssertion('greaterThan', function (actual, expected, message) {
408
+ if (actual <= expected) {
409
+ throw new Error(message || "Expected ".concat(actual, " > ").concat(expected));
410
+ }
411
+ });
412
+ this.addAssertion('lessThan', function (actual, expected, message) {
413
+ if (actual >= expected) {
414
+ throw new Error(message || "Expected ".concat(actual, " < ").concat(expected));
415
+ }
416
+ });
417
+ this.addAssertion('greaterThanOrEqual', function (actual, expected, message) {
418
+ if (actual < expected) {
419
+ throw new Error(message || "Expected ".concat(actual, " >= ").concat(expected));
420
+ }
421
+ });
422
+ this.addAssertion('lessThanOrEqual', function (actual, expected, message) {
423
+ if (actual > expected) {
424
+ throw new Error(message || "Expected ".concat(actual, " <= ").concat(expected));
425
+ }
426
+ });
427
+ this.addAssertion('approximately', function (actual, expected, delta, message) {
428
+ if (Math.abs(actual - expected) > delta) {
429
+ throw new Error(message || "Expected ".concat(actual, " \u2248 ").concat(expected, " (\xB1").concat(delta, ")"));
430
+ }
431
+ });
432
+
433
+ // String assertions
434
+ this.addAssertion('includes', function (actual, expected, message) {
435
+ if (!actual.includes(expected)) {
436
+ throw new Error(message || "Expected \"".concat(actual, "\" to include \"").concat(expected, "\""));
437
+ }
438
+ });
439
+ this.addAssertion('startsWith', function (actual, expected, message) {
440
+ if (!actual.startsWith(expected)) {
441
+ throw new Error(message || "Expected \"".concat(actual, "\" to start with \"").concat(expected, "\""));
442
+ }
443
+ });
444
+ this.addAssertion('endsWith', function (actual, expected, message) {
445
+ if (!actual.endsWith(expected)) {
446
+ throw new Error(message || "Expected \"".concat(actual, "\" to end with \"").concat(expected, "\""));
447
+ }
448
+ });
449
+ this.addAssertion('matches', function (actual, pattern, message) {
450
+ if (!pattern.test(actual)) {
451
+ throw new Error(message || "Expected \"".concat(actual, "\" to match pattern ").concat(pattern));
452
+ }
453
+ });
454
+
455
+ // Array assertions
456
+ this.addAssertion('hasLength', function (actual, expected, message) {
457
+ if (actual.length !== expected) {
458
+ throw new Error(message || "Expected length ".concat(expected, ", got ").concat(actual.length));
459
+ }
460
+ });
461
+ this.addAssertion('isEmpty', function (actual, message) {
462
+ if (actual.length !== 0) {
463
+ throw new Error(message || "Expected empty array/string, got length ".concat(actual.length));
464
+ }
465
+ });
466
+ this.addAssertion('isNotEmpty', function (actual, message) {
467
+ if (actual.length === 0) {
468
+ throw new Error(message || "Expected non-empty array/string");
469
+ }
470
+ });
471
+
472
+ // Object assertions
473
+ this.addAssertion('hasProperty', function (actual, property, message) {
474
+ if (!actual.hasOwnProperty(property)) {
475
+ throw new Error(message || "Expected object to have property \"".concat(property, "\""));
476
+ }
477
+ });
478
+ this.addAssertion('hasMethod', function (actual, method, message) {
479
+ if (typeof actual[method] !== 'function') {
480
+ throw new Error(message || "Expected object to have method \"".concat(method, "\""));
481
+ }
482
+ });
483
+
484
+ // Async assertions
485
+ this.addAssertion('resolves', /*#__PURE__*/function () {
486
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(promise, message) {
487
+ var _t;
488
+ return _regenerator().w(function (_context2) {
489
+ while (1) switch (_context2.n) {
490
+ case 0:
491
+ _context2.p = 0;
492
+ _context2.n = 1;
493
+ return promise;
494
+ case 1:
495
+ _context2.n = 3;
496
+ break;
497
+ case 2:
498
+ _context2.p = 2;
499
+ _t = _context2.v;
500
+ throw new Error(message || "Expected promise to resolve, but it rejected: ".concat(_t.message));
501
+ case 3:
502
+ return _context2.a(2);
503
+ }
504
+ }, _callee2, null, [[0, 2]]);
505
+ }));
506
+ return function (_x3, _x4) {
507
+ return _ref.apply(this, arguments);
508
+ };
509
+ }());
510
+ this.addAssertion('rejects', /*#__PURE__*/function () {
511
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(promise, message) {
512
+ return _regenerator().w(function (_context3) {
513
+ while (1) switch (_context3.n) {
514
+ case 0:
515
+ _context3.p = 0;
516
+ _context3.n = 1;
517
+ return promise;
518
+ case 1:
519
+ throw new Error(message || "Expected promise to reject, but it resolved");
520
+ case 2:
521
+ _context3.p = 2;
522
+ _context3.v;
523
+ case 3:
524
+ return _context3.a(2);
525
+ }
526
+ }, _callee3, null, [[0, 2]]);
527
+ }));
528
+ return function (_x5, _x6) {
529
+ return _ref2.apply(this, arguments);
530
+ };
531
+ }());
532
+ this.addAssertion('throws', function (fn, message) {
533
+ try {
534
+ fn();
535
+ throw new Error(message || "Expected function to throw, but it didn't");
536
+ } catch (error) {
537
+ // Expected behavior
538
+ }
539
+ });
540
+ }
541
+
542
+ /**
543
+ * Add custom assertion
544
+ * @param {string} name - Assertion name
545
+ * @param {Function} assertionFn - Assertion function
546
+ */
547
+ }, {
548
+ key: "addAssertion",
549
+ value: function addAssertion(name, assertionFn) {
550
+ this.assertions.set(name, assertionFn);
551
+ }
552
+
553
+ /**
554
+ * Create test suite
555
+ * @param {string} name - Suite name
556
+ * @param {Function} setupFn - Setup function
557
+ * @returns {Object} Test suite object
558
+ */
559
+ }, {
560
+ key: "createTestSuite",
561
+ value: function createTestSuite(name) {
562
+ var _this2 = this;
563
+ var setupFn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
564
+ var suite = {
565
+ name: name,
566
+ tests: [],
567
+ beforeEach: null,
568
+ afterEach: null,
569
+ beforeAll: null,
570
+ afterAll: null,
571
+ setup: setupFn
572
+ };
573
+ this.testSuites.set(name, suite);
574
+ return {
575
+ test: function test(testName, testFn) {
576
+ return _this2.addTest(name, testName, testFn);
577
+ },
578
+ beforeEach: function beforeEach(fn) {
579
+ suite.beforeEach = fn;
580
+ },
581
+ afterEach: function afterEach(fn) {
582
+ suite.afterEach = fn;
583
+ },
584
+ beforeAll: function beforeAll(fn) {
585
+ suite.beforeAll = fn;
586
+ },
587
+ afterAll: function afterAll(fn) {
588
+ suite.afterAll = fn;
589
+ }
590
+ };
591
+ }
592
+
593
+ /**
594
+ * Add test to suite
595
+ * @param {string} suiteName - Suite name
596
+ * @param {string} testName - Test name
597
+ * @param {Function} testFn - Test function
598
+ */
599
+ }, {
600
+ key: "addTest",
601
+ value: function addTest(suiteName, testName, testFn) {
602
+ var suite = this.testSuites.get(suiteName);
603
+ if (!suite) {
604
+ throw new Error("Test suite \"".concat(suiteName, "\" not found"));
605
+ }
606
+ suite.tests.push({
607
+ name: testName,
608
+ fn: testFn,
609
+ skip: false,
610
+ only: false
611
+ });
612
+ }
613
+
614
+ /**
615
+ * Run all test suites
616
+ * @returns {Promise<Object>} Test results
617
+ */
618
+ }, {
619
+ key: "runAllTests",
620
+ value: (function () {
621
+ var _runAllTests = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4() {
622
+ var startTime, results, _iterator, _step, _step$value, suiteName, suiteResult, _t3;
623
+ return _regenerator().w(function (_context4) {
624
+ while (1) switch (_context4.n) {
625
+ case 0:
626
+ logger.info('🧪 Running all test suites...');
627
+ startTime = performance.now();
628
+ results = {
629
+ suites: [],
630
+ totalTests: 0,
631
+ passedTests: 0,
632
+ failedTests: 0,
633
+ skippedTests: 0,
634
+ duration: 0
635
+ };
636
+ _iterator = _createForOfIteratorHelper(this.testSuites);
637
+ _context4.p = 1;
638
+ _iterator.s();
639
+ case 2:
640
+ if ((_step = _iterator.n()).done) {
641
+ _context4.n = 5;
642
+ break;
643
+ }
644
+ _step$value = _slicedToArray(_step.value, 2), suiteName = _step$value[0], _step$value[1];
645
+ _context4.n = 3;
646
+ return this.runTestSuite(suiteName);
647
+ case 3:
648
+ suiteResult = _context4.v;
649
+ results.suites.push(suiteResult);
650
+ results.totalTests += suiteResult.totalTests;
651
+ results.passedTests += suiteResult.passedTests;
652
+ results.failedTests += suiteResult.failedTests;
653
+ results.skippedTests += suiteResult.skippedTests;
654
+ case 4:
655
+ _context4.n = 2;
656
+ break;
657
+ case 5:
658
+ _context4.n = 7;
659
+ break;
660
+ case 6:
661
+ _context4.p = 6;
662
+ _t3 = _context4.v;
663
+ _iterator.e(_t3);
664
+ case 7:
665
+ _context4.p = 7;
666
+ _iterator.f();
667
+ return _context4.f(7);
668
+ case 8:
669
+ results.duration = performance.now() - startTime;
670
+ logger.info("\u2705 All tests completed: ".concat(results.passedTests, "/").concat(results.totalTests, " passed in ").concat(results.duration.toFixed(2), "ms"));
671
+ this.testResults.push(results);
672
+ return _context4.a(2, results);
673
+ }
674
+ }, _callee4, this, [[1, 6, 7, 8]]);
675
+ }));
676
+ function runAllTests() {
677
+ return _runAllTests.apply(this, arguments);
678
+ }
679
+ return runAllTests;
680
+ }()
681
+ /**
682
+ * Run specific test suite
683
+ * @param {string} suiteName - Suite name
684
+ * @returns {Promise<Object>} Suite results
685
+ */
686
+ )
687
+ }, {
688
+ key: "runTestSuite",
689
+ value: (function () {
690
+ var _runTestSuite = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(suiteName) {
691
+ var suite, startTime, result, _iterator2, _step2, test, testResult, _t4, _t5;
692
+ return _regenerator().w(function (_context5) {
693
+ while (1) switch (_context5.n) {
694
+ case 0:
695
+ suite = this.testSuites.get(suiteName);
696
+ if (suite) {
697
+ _context5.n = 1;
698
+ break;
699
+ }
700
+ throw new Error("Test suite \"".concat(suiteName, "\" not found"));
701
+ case 1:
702
+ logger.info("\uD83E\uDDEA Running test suite: ".concat(suiteName));
703
+ startTime = performance.now();
704
+ result = {
705
+ name: suiteName,
706
+ tests: [],
707
+ totalTests: suite.tests.length,
708
+ passedTests: 0,
709
+ failedTests: 0,
710
+ skippedTests: 0,
711
+ duration: 0
712
+ };
713
+ _context5.p = 2;
714
+ if (!suite.setup) {
715
+ _context5.n = 3;
716
+ break;
717
+ }
718
+ _context5.n = 3;
719
+ return suite.setup();
720
+ case 3:
721
+ if (!suite.beforeAll) {
722
+ _context5.n = 4;
723
+ break;
724
+ }
725
+ _context5.n = 4;
726
+ return suite.beforeAll();
727
+ case 4:
728
+ // Run tests
729
+ _iterator2 = _createForOfIteratorHelper(suite.tests);
730
+ _context5.p = 5;
731
+ _iterator2.s();
732
+ case 6:
733
+ if ((_step2 = _iterator2.n()).done) {
734
+ _context5.n = 9;
735
+ break;
736
+ }
737
+ test = _step2.value;
738
+ _context5.n = 7;
739
+ return this.runTest(suite, test);
740
+ case 7:
741
+ testResult = _context5.v;
742
+ result.tests.push(testResult);
743
+ if (testResult.status === 'passed') result.passedTests++;else if (testResult.status === 'failed') result.failedTests++;else if (testResult.status === 'skipped') result.skippedTests++;
744
+ case 8:
745
+ _context5.n = 6;
746
+ break;
747
+ case 9:
748
+ _context5.n = 11;
749
+ break;
750
+ case 10:
751
+ _context5.p = 10;
752
+ _t4 = _context5.v;
753
+ _iterator2.e(_t4);
754
+ case 11:
755
+ _context5.p = 11;
756
+ _iterator2.f();
757
+ return _context5.f(11);
758
+ case 12:
759
+ if (!suite.afterAll) {
760
+ _context5.n = 13;
761
+ break;
762
+ }
763
+ _context5.n = 13;
764
+ return suite.afterAll();
765
+ case 13:
766
+ _context5.n = 15;
767
+ break;
768
+ case 14:
769
+ _context5.p = 14;
770
+ _t5 = _context5.v;
771
+ logger.error("\u274C Test suite \"".concat(suiteName, "\" setup failed:"), _t5);
772
+ case 15:
773
+ result.duration = performance.now() - startTime;
774
+ logger.info("\u2705 Suite \"".concat(suiteName, "\" completed: ").concat(result.passedTests, "/").concat(result.totalTests, " passed"));
775
+ return _context5.a(2, result);
776
+ }
777
+ }, _callee5, this, [[5, 10, 11, 12], [2, 14]]);
778
+ }));
779
+ function runTestSuite(_x7) {
780
+ return _runTestSuite.apply(this, arguments);
781
+ }
782
+ return runTestSuite;
783
+ }()
784
+ /**
785
+ * Run individual test
786
+ * @param {Object} suite - Test suite
787
+ * @param {Object} test - Test object
788
+ * @returns {Promise<Object>} Test result
789
+ */
790
+ )
791
+ }, {
792
+ key: "runTest",
793
+ value: (function () {
794
+ var _runTest = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6(suite, test) {
795
+ var startTime, result, assert, _t6;
796
+ return _regenerator().w(function (_context6) {
797
+ while (1) switch (_context6.n) {
798
+ case 0:
799
+ if (!test.skip) {
800
+ _context6.n = 1;
801
+ break;
802
+ }
803
+ return _context6.a(2, {
804
+ name: test.name,
805
+ status: 'skipped',
806
+ duration: 0,
807
+ error: null
808
+ });
809
+ case 1:
810
+ startTime = performance.now();
811
+ result = {
812
+ name: test.name,
813
+ status: 'passed',
814
+ duration: 0,
815
+ error: null
816
+ };
817
+ _context6.p = 2;
818
+ if (!suite.beforeEach) {
819
+ _context6.n = 3;
820
+ break;
821
+ }
822
+ _context6.n = 3;
823
+ return suite.beforeEach();
824
+ case 3:
825
+ // Create assertion context
826
+ assert = this.createAssertionContext(); // Run test
827
+ _context6.n = 4;
828
+ return test.fn(assert);
829
+ case 4:
830
+ if (!suite.afterEach) {
831
+ _context6.n = 5;
832
+ break;
833
+ }
834
+ _context6.n = 5;
835
+ return suite.afterEach();
836
+ case 5:
837
+ _context6.n = 7;
838
+ break;
839
+ case 6:
840
+ _context6.p = 6;
841
+ _t6 = _context6.v;
842
+ result.status = 'failed';
843
+ result.error = {
844
+ message: _t6.message,
845
+ stack: _t6.stack
846
+ };
847
+ logger.error("\u274C Test \"".concat(test.name, "\" failed:"), _t6.message);
848
+ case 7:
849
+ result.duration = performance.now() - startTime;
850
+ return _context6.a(2, result);
851
+ }
852
+ }, _callee6, this, [[2, 6]]);
853
+ }));
854
+ function runTest(_x8, _x9) {
855
+ return _runTest.apply(this, arguments);
856
+ }
857
+ return runTest;
858
+ }()
859
+ /**
860
+ * Create assertion context for tests
861
+ * @returns {Object} Assertion methods
862
+ */
863
+ )
864
+ }, {
865
+ key: "createAssertionContext",
866
+ value: function createAssertionContext() {
867
+ var context = {};
868
+ var _iterator3 = _createForOfIteratorHelper(this.assertions),
869
+ _step3;
870
+ try {
871
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
872
+ var _step3$value = _slicedToArray(_step3.value, 2),
873
+ name = _step3$value[0],
874
+ assertionFn = _step3$value[1];
875
+ context[name] = assertionFn;
876
+ }
877
+ } catch (err) {
878
+ _iterator3.e(err);
879
+ } finally {
880
+ _iterator3.f();
881
+ }
882
+ return context;
883
+ }
884
+ }, {
885
+ key: "generateReport",
886
+ value:
887
+ /**
888
+ * Generate test report
889
+ * @param {Object} results - Test results
890
+ * @returns {string} HTML report
891
+ */
892
+ function generateReport(results) {
893
+ var passRate = (results.passedTests / results.totalTests * 100).toFixed(1);
894
+ var html = "\n<!DOCTYPE html>\n<html>\n<head>\n <title>Test Report</title>\n <style>\n body { font-family: Arial, sans-serif; margin: 20px; }\n .summary { background: #f5f5f5; padding: 15px; border-radius: 5px; margin-bottom: 20px; }\n .suite { margin-bottom: 20px; border: 1px solid #ddd; border-radius: 5px; }\n .suite-header { background: #e9e9e9; padding: 10px; font-weight: bold; }\n .test { padding: 10px; border-bottom: 1px solid #eee; }\n .test:last-child { border-bottom: none; }\n .passed { color: green; }\n .failed { color: red; }\n .skipped { color: orange; }\n .error { background: #ffe6e6; padding: 10px; margin-top: 5px; border-radius: 3px; }\n </style>\n</head>\n<body>\n <h1>Test Report</h1>\n \n <div class=\"summary\">\n <h2>Summary</h2>\n <p><strong>Total Tests:</strong> ".concat(results.totalTests, "</p>\n <p><strong>Passed:</strong> <span class=\"passed\">").concat(results.passedTests, "</span></p>\n <p><strong>Failed:</strong> <span class=\"failed\">").concat(results.failedTests, "</span></p>\n <p><strong>Skipped:</strong> <span class=\"skipped\">").concat(results.skippedTests, "</span></p>\n <p><strong>Pass Rate:</strong> ").concat(passRate, "%</p>\n <p><strong>Duration:</strong> ").concat(results.duration.toFixed(2), "ms</p>\n </div>\n \n <h2>Test Suites</h2>\n");
895
+ results.suites.forEach(function (suite) {
896
+ html += "\n <div class=\"suite\">\n <div class=\"suite-header\">\n ".concat(suite.name, " (").concat(suite.passedTests, "/").concat(suite.totalTests, " passed)\n </div>\n");
897
+ suite.tests.forEach(function (test) {
898
+ html += "\n <div class=\"test\">\n <span class=\"".concat(test.status, "\">").concat(test.status.toUpperCase(), "</span>\n <strong>").concat(test.name, "</strong>\n <small>(").concat(test.duration.toFixed(2), "ms)</small>\n");
899
+ if (test.error) {
900
+ html += "\n <div class=\"error\">\n <strong>Error:</strong> ".concat(test.error.message, "\n </div>\n");
901
+ }
902
+ html += ' </div>';
903
+ });
904
+ html += ' </div>';
905
+ });
906
+ html += "\n</body>\n</html>\n";
907
+ return html;
908
+ }
909
+
910
+ /**
911
+ * Clear test results
912
+ */
913
+ }, {
914
+ key: "clearResults",
915
+ value: function clearResults() {
916
+ this.testResults = [];
917
+ }
918
+
919
+ /**
920
+ * Get test results
921
+ * @returns {Array} Test results
922
+ */
923
+ }, {
924
+ key: "getResults",
925
+ value: function getResults() {
926
+ return this.testResults;
927
+ }
928
+
929
+ /**
930
+ * Get benchmark results
931
+ * @returns {Map} Benchmark results
932
+ */
933
+ }, {
934
+ key: "getBenchmarks",
935
+ value: function getBenchmarks() {
936
+ return this.benchmarks;
937
+ }
938
+
939
+ /**
940
+ * Dispose of testing manager
941
+ */
942
+ }, {
943
+ key: "dispose",
944
+ value: function dispose() {
945
+ this.testSuites.clear();
946
+ this.clearResults();
947
+ this.mockData.clear();
948
+ this.benchmarks.clear();
949
+ logger.info('Testing disposed');
950
+ }
951
+ }]);
952
+ }();
953
+
954
+ export { Testing };