@vib3code/sdk 2.0.1
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.
- package/CHANGELOG.md +118 -0
- package/DOCS/BLUEPRINT_EXECUTION_PLAN_2026-01-07.md +34 -0
- package/DOCS/CI_TESTING.md +38 -0
- package/DOCS/CLI_ONBOARDING.md +75 -0
- package/DOCS/CONTROL_REFERENCE.md +64 -0
- package/DOCS/DEV_TRACK_ANALYSIS.md +77 -0
- package/DOCS/DEV_TRACK_PLAN_2026-01-07.md +42 -0
- package/DOCS/DEV_TRACK_SESSION_2026-01-31.md +220 -0
- package/DOCS/ENV_SETUP.md +189 -0
- package/DOCS/EXPORT_FORMATS.md +417 -0
- package/DOCS/GPU_DISPOSAL_GUIDE.md +21 -0
- package/DOCS/LICENSING_TIERS.md +275 -0
- package/DOCS/MASTER_PLAN_2026-01-31.md +570 -0
- package/DOCS/OBS_SETUP_GUIDE.md +98 -0
- package/DOCS/PROJECT_SETUP.md +66 -0
- package/DOCS/RENDERER_LIFECYCLE.md +40 -0
- package/DOCS/REPO_MANIFEST.md +121 -0
- package/DOCS/SESSION_014_PLAN.md +195 -0
- package/DOCS/SESSION_LOG_2026-01-07.md +56 -0
- package/DOCS/STRATEGIC_BLUEPRINT_2026-01-07.md +72 -0
- package/DOCS/SYSTEM_AUDIT_2026-01-30.md +738 -0
- package/DOCS/SYSTEM_INVENTORY.md +520 -0
- package/DOCS/TELEMETRY_EXPORTS.md +34 -0
- package/DOCS/WEBGPU_STATUS.md +38 -0
- package/DOCS/XR_BENCHMARKS.md +608 -0
- package/LICENSE +21 -0
- package/README.md +426 -0
- package/docs/.nojekyll +0 -0
- package/docs/01-dissolution_of_euclidean_hegemony.html +346 -0
- package/docs/02-hyperspatial_ego_death.html +346 -0
- package/docs/03-post_cartesian_sublime.html +346 -0
- package/docs/04-crystalline_void_meditation.html +346 -0
- package/docs/05-quantum_decoherence_ballet.html +346 -0
- package/docs/06-dissolution_of_euclidean_hegemony.html +346 -0
- package/docs/07-hyperspatial_ego_death.html +346 -0
- package/docs/08-post_cartesian_sublime.html +346 -0
- package/docs/09-crystalline_void_meditation.html +346 -0
- package/docs/10-quantum_decoherence_ballet.html +346 -0
- package/docs/11-dissolution_of_euclidean_hegemony.html +346 -0
- package/docs/12-hyperspatial_ego_death.html +346 -0
- package/docs/13-post_cartesian_sublime.html +346 -0
- package/docs/index.html +794 -0
- package/docs/test-hub.html +441 -0
- package/docs/url-state.js +102 -0
- package/docs/vib3-exports/01-quantum-quantum-tetrahedron-lattice.html +489 -0
- package/docs/vib3-exports/02-quantum-quantum-hypersphere-matrix.html +489 -0
- package/docs/vib3-exports/03-quantum-quantum-hypertetra-fractal.html +489 -0
- package/docs/vib3-exports/04-faceted-faceted-crystal-structure.html +407 -0
- package/docs/vib3-exports/05-faceted-faceted-klein-bottle.html +407 -0
- package/docs/vib3-exports/06-faceted-faceted-hypertetra-torus.html +407 -0
- package/docs/vib3-exports/07-holographic-holographic-wave-field.html +457 -0
- package/docs/vib3-exports/08-holographic-holographic-hypersphere-sphere.html +457 -0
- package/docs/vib3-exports/09-holographic-holographic-hypertetra-crystal.html +457 -0
- package/docs/vib3-exports/index.html +238 -0
- package/docs/webgpu-live.html +702 -0
- package/package.json +367 -0
- package/src/advanced/AIPresetGenerator.js +777 -0
- package/src/advanced/MIDIController.js +703 -0
- package/src/advanced/OffscreenWorker.js +1051 -0
- package/src/advanced/WebGPUCompute.js +1051 -0
- package/src/advanced/WebXRRenderer.js +680 -0
- package/src/agent/cli/AgentCLI.js +615 -0
- package/src/agent/cli/index.js +14 -0
- package/src/agent/index.js +73 -0
- package/src/agent/mcp/MCPServer.js +950 -0
- package/src/agent/mcp/index.js +9 -0
- package/src/agent/mcp/tools.js +548 -0
- package/src/agent/telemetry/EventStream.js +669 -0
- package/src/agent/telemetry/Instrumentation.js +618 -0
- package/src/agent/telemetry/TelemetryExporters.js +427 -0
- package/src/agent/telemetry/TelemetryService.js +464 -0
- package/src/agent/telemetry/index.js +52 -0
- package/src/benchmarks/BenchmarkRunner.js +381 -0
- package/src/benchmarks/MetricsCollector.js +299 -0
- package/src/benchmarks/index.js +9 -0
- package/src/benchmarks/scenes.js +259 -0
- package/src/cli/index.js +675 -0
- package/src/config/ApiConfig.js +88 -0
- package/src/core/CanvasManager.js +217 -0
- package/src/core/ErrorReporter.js +117 -0
- package/src/core/ParameterMapper.js +333 -0
- package/src/core/Parameters.js +396 -0
- package/src/core/RendererContracts.js +200 -0
- package/src/core/UnifiedResourceManager.js +370 -0
- package/src/core/VIB3Engine.js +636 -0
- package/src/core/renderers/FacetedRendererAdapter.js +32 -0
- package/src/core/renderers/HolographicRendererAdapter.js +29 -0
- package/src/core/renderers/QuantumRendererAdapter.js +29 -0
- package/src/core/renderers/RendererLifecycleManager.js +63 -0
- package/src/creative/ColorPresetsSystem.js +980 -0
- package/src/creative/ParameterTimeline.js +1061 -0
- package/src/creative/PostProcessingPipeline.js +1113 -0
- package/src/creative/TransitionAnimator.js +683 -0
- package/src/export/CSSExporter.js +226 -0
- package/src/export/CardGeneratorBase.js +279 -0
- package/src/export/ExportManager.js +580 -0
- package/src/export/FacetedCardGenerator.js +279 -0
- package/src/export/HolographicCardGenerator.js +543 -0
- package/src/export/LottieExporter.js +552 -0
- package/src/export/QuantumCardGenerator.js +315 -0
- package/src/export/SVGExporter.js +519 -0
- package/src/export/ShaderExporter.js +903 -0
- package/src/export/TradingCardGenerator.js +3055 -0
- package/src/export/TradingCardManager.js +181 -0
- package/src/export/VIB3PackageExporter.js +559 -0
- package/src/export/index.js +14 -0
- package/src/export/systems/TradingCardSystemFaceted.js +494 -0
- package/src/export/systems/TradingCardSystemHolographic.js +452 -0
- package/src/export/systems/TradingCardSystemQuantum.js +411 -0
- package/src/faceted/FacetedSystem.js +963 -0
- package/src/features/CollectionManager.js +433 -0
- package/src/gallery/CollectionManager.js +240 -0
- package/src/gallery/GallerySystem.js +485 -0
- package/src/geometry/GeometryFactory.js +314 -0
- package/src/geometry/GeometryLibrary.js +72 -0
- package/src/geometry/buffers/BufferBuilder.js +338 -0
- package/src/geometry/buffers/index.js +18 -0
- package/src/geometry/generators/Crystal.js +420 -0
- package/src/geometry/generators/Fractal.js +298 -0
- package/src/geometry/generators/KleinBottle.js +197 -0
- package/src/geometry/generators/Sphere.js +192 -0
- package/src/geometry/generators/Tesseract.js +160 -0
- package/src/geometry/generators/Tetrahedron.js +225 -0
- package/src/geometry/generators/Torus.js +304 -0
- package/src/geometry/generators/Wave.js +341 -0
- package/src/geometry/index.js +142 -0
- package/src/geometry/warp/HypersphereCore.js +211 -0
- package/src/geometry/warp/HypertetraCore.js +386 -0
- package/src/geometry/warp/index.js +57 -0
- package/src/holograms/HolographicVisualizer.js +1073 -0
- package/src/holograms/RealHolographicSystem.js +966 -0
- package/src/holograms/variantRegistry.js +69 -0
- package/src/integrations/FigmaPlugin.js +854 -0
- package/src/integrations/OBSMode.js +754 -0
- package/src/integrations/ThreeJsPackage.js +660 -0
- package/src/integrations/TouchDesignerExport.js +552 -0
- package/src/integrations/frameworks/Vib3React.js +591 -0
- package/src/integrations/frameworks/Vib3Svelte.js +654 -0
- package/src/integrations/frameworks/Vib3Vue.js +628 -0
- package/src/llm/LLMParameterInterface.js +240 -0
- package/src/llm/LLMParameterUI.js +577 -0
- package/src/math/Mat4x4.js +708 -0
- package/src/math/Projection.js +341 -0
- package/src/math/Rotor4D.js +637 -0
- package/src/math/Vec4.js +476 -0
- package/src/math/constants.js +164 -0
- package/src/math/index.js +68 -0
- package/src/math/projections.js +54 -0
- package/src/math/rotations.js +196 -0
- package/src/quantum/QuantumEngine.js +906 -0
- package/src/quantum/QuantumVisualizer.js +1103 -0
- package/src/reactivity/ReactivityConfig.js +499 -0
- package/src/reactivity/ReactivityManager.js +586 -0
- package/src/reactivity/SpatialInputSystem.js +1783 -0
- package/src/reactivity/index.js +93 -0
- package/src/render/CommandBuffer.js +465 -0
- package/src/render/MultiCanvasBridge.js +340 -0
- package/src/render/RenderCommand.js +514 -0
- package/src/render/RenderResourceRegistry.js +523 -0
- package/src/render/RenderState.js +552 -0
- package/src/render/RenderTarget.js +512 -0
- package/src/render/ShaderLoader.js +253 -0
- package/src/render/ShaderProgram.js +599 -0
- package/src/render/UnifiedRenderBridge.js +496 -0
- package/src/render/backends/WebGLBackend.js +1108 -0
- package/src/render/backends/WebGPUBackend.js +1409 -0
- package/src/render/commands/CommandBufferExecutor.js +607 -0
- package/src/render/commands/RenderCommandBuffer.js +661 -0
- package/src/render/commands/index.js +17 -0
- package/src/render/index.js +367 -0
- package/src/scene/Disposable.js +498 -0
- package/src/scene/MemoryPool.js +618 -0
- package/src/scene/Node4D.js +697 -0
- package/src/scene/ResourceManager.js +599 -0
- package/src/scene/Scene4D.js +540 -0
- package/src/scene/index.js +98 -0
- package/src/schemas/error.schema.json +84 -0
- package/src/schemas/extension.schema.json +88 -0
- package/src/schemas/index.js +214 -0
- package/src/schemas/parameters.schema.json +142 -0
- package/src/schemas/tool-pack.schema.json +44 -0
- package/src/schemas/tool-response.schema.json +127 -0
- package/src/shaders/common/fullscreen.vert.glsl +5 -0
- package/src/shaders/common/fullscreen.vert.wgsl +17 -0
- package/src/shaders/common/geometry24.glsl +65 -0
- package/src/shaders/common/geometry24.wgsl +54 -0
- package/src/shaders/common/rotation4d.glsl +85 -0
- package/src/shaders/common/rotation4d.wgsl +86 -0
- package/src/shaders/common/uniforms.glsl +44 -0
- package/src/shaders/common/uniforms.wgsl +48 -0
- package/src/shaders/faceted/faceted.frag.glsl +129 -0
- package/src/shaders/faceted/faceted.frag.wgsl +164 -0
- package/src/shaders/holographic/holographic.frag.glsl +406 -0
- package/src/shaders/holographic/holographic.frag.wgsl +185 -0
- package/src/shaders/quantum/quantum.frag.glsl +513 -0
- package/src/shaders/quantum/quantum.frag.wgsl +361 -0
- package/src/testing/ParallelTestFramework.js +519 -0
- package/src/testing/__snapshots__/exportFormats.test.js.snap +24 -0
- package/src/testing/exportFormats.test.js +8 -0
- package/src/testing/projections.test.js +14 -0
- package/src/testing/rotations.test.js +37 -0
- package/src/ui/InteractivityMenu.js +516 -0
- package/src/ui/StatusManager.js +96 -0
- package/src/ui/adaptive/renderers/webgpu/BufferLayout.ts +252 -0
- package/src/ui/adaptive/renderers/webgpu/PolytopeInstanceBuffer.ts +144 -0
- package/src/ui/adaptive/renderers/webgpu/TripleBufferedUniform.ts +170 -0
- package/src/ui/adaptive/renderers/webgpu/WebGPURenderer.ts +735 -0
- package/src/ui/adaptive/renderers/webgpu/index.ts +112 -0
- package/src/variations/VariationManager.js +431 -0
- package/src/viewer/AudioReactivity.js +505 -0
- package/src/viewer/CardBending.js +481 -0
- package/src/viewer/GalleryUI.js +832 -0
- package/src/viewer/ReactivityManager.js +590 -0
- package/src/viewer/TradingCardExporter.js +600 -0
- package/src/viewer/ViewerPortal.js +374 -0
- package/src/viewer/index.js +12 -0
- package/src/wasm/WasmLoader.js +296 -0
- package/src/wasm/index.js +132 -0
- package/tools/agentic/mcpTools.js +88 -0
- package/tools/cli/agent-cli.js +92 -0
- package/tools/export/formats.js +24 -0
- package/tools/math/rotation-baseline.mjs +64 -0
- package/tools/shader-sync-verify.js +937 -0
- package/tools/telemetry/manifestPipeline.js +141 -0
- package/tools/telemetry/telemetryEvents.js +35 -0
- package/types/adaptive-sdk.d.ts +185 -0
- package/types/advanced/AIPresetGenerator.d.ts +81 -0
- package/types/advanced/MIDIController.d.ts +100 -0
- package/types/advanced/OffscreenWorker.d.ts +82 -0
- package/types/advanced/WebGPUCompute.d.ts +52 -0
- package/types/advanced/WebXRRenderer.d.ts +77 -0
- package/types/advanced/index.d.ts +46 -0
- package/types/core/ErrorReporter.d.ts +50 -0
- package/types/core/VIB3Engine.d.ts +204 -0
- package/types/creative/ColorPresetsSystem.d.ts +91 -0
- package/types/creative/ParameterTimeline.d.ts +74 -0
- package/types/creative/PostProcessingPipeline.d.ts +109 -0
- package/types/creative/TransitionAnimator.d.ts +71 -0
- package/types/creative/index.d.ts +35 -0
- package/types/integrations/FigmaPlugin.d.ts +46 -0
- package/types/integrations/OBSMode.d.ts +74 -0
- package/types/integrations/ThreeJsPackage.d.ts +62 -0
- package/types/integrations/TouchDesignerExport.d.ts +36 -0
- package/types/integrations/Vib3React.d.ts +74 -0
- package/types/integrations/Vib3Svelte.d.ts +63 -0
- package/types/integrations/Vib3Vue.d.ts +55 -0
- package/types/integrations/index.d.ts +52 -0
- package/types/reactivity/SpatialInputSystem.d.ts +173 -0
- package/types/reactivity/index.d.ts +394 -0
- package/types/render/CommandBuffer.d.ts +169 -0
- package/types/render/RenderCommand.d.ts +312 -0
- package/types/render/RenderState.d.ts +279 -0
- package/types/render/RenderTarget.d.ts +254 -0
- package/types/render/ShaderProgram.d.ts +277 -0
- package/types/render/UnifiedRenderBridge.d.ts +143 -0
- package/types/render/WebGLBackend.d.ts +168 -0
- package/types/render/WebGPUBackend.d.ts +186 -0
- package/types/render/index.d.ts +141 -0
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* API Configuration for VIB34D
|
|
3
|
+
* Manages API keys and service configurations
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export class ApiConfig {
|
|
7
|
+
constructor() {
|
|
8
|
+
this.keys = {
|
|
9
|
+
gemini: null
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
this.endpoints = {
|
|
13
|
+
gemini: 'https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash:generateContent'
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
this.loadFromStorage();
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Load API keys from localStorage
|
|
21
|
+
*/
|
|
22
|
+
loadFromStorage() {
|
|
23
|
+
const storedKeys = localStorage.getItem('vib34d-api-keys');
|
|
24
|
+
if (storedKeys) {
|
|
25
|
+
try {
|
|
26
|
+
const parsed = JSON.parse(storedKeys);
|
|
27
|
+
Object.assign(this.keys, parsed);
|
|
28
|
+
console.log('🔑 API keys loaded from storage');
|
|
29
|
+
} catch (error) {
|
|
30
|
+
console.error('Error loading API keys:', error);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Save API keys to localStorage
|
|
37
|
+
*/
|
|
38
|
+
saveToStorage() {
|
|
39
|
+
localStorage.setItem('vib34d-api-keys', JSON.stringify(this.keys));
|
|
40
|
+
console.log('💾 API keys saved to storage');
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Set Gemini API key
|
|
45
|
+
*/
|
|
46
|
+
setGeminiKey(apiKey) {
|
|
47
|
+
this.keys.gemini = apiKey;
|
|
48
|
+
this.saveToStorage();
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Get Gemini API key
|
|
53
|
+
*/
|
|
54
|
+
getGeminiKey() {
|
|
55
|
+
return this.keys.gemini;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Check if Gemini is configured
|
|
60
|
+
*/
|
|
61
|
+
isGeminiConfigured() {
|
|
62
|
+
return !!this.keys.gemini;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Clear all API keys
|
|
67
|
+
*/
|
|
68
|
+
clearKeys() {
|
|
69
|
+
this.keys = {
|
|
70
|
+
gemini: null
|
|
71
|
+
};
|
|
72
|
+
localStorage.removeItem('vib34d-api-keys');
|
|
73
|
+
console.log('🗑️ API keys cleared');
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Get API endpoint URL with key
|
|
78
|
+
*/
|
|
79
|
+
getGeminiEndpoint() {
|
|
80
|
+
if (!this.keys.gemini) {
|
|
81
|
+
throw new Error('Gemini API key not configured');
|
|
82
|
+
}
|
|
83
|
+
return `${this.endpoints.gemini}?key=${this.keys.gemini}`;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// Export singleton instance
|
|
88
|
+
export const apiConfig = new ApiConfig();
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dead Simple Canvas Manager - Just hide/show containers + fresh engines
|
|
3
|
+
* No canvas destruction - HTML canvases stay put, just switch visibility
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export class CanvasManager {
|
|
7
|
+
constructor() {
|
|
8
|
+
this.currentSystem = null;
|
|
9
|
+
this.currentEngine = null;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
async switchToSystem(systemName, engineClasses) {
|
|
13
|
+
console.log(`🔄 DESTROY OLD → CREATE NEW: ${systemName}`);
|
|
14
|
+
|
|
15
|
+
// STEP 1: DESTROY current engine completely
|
|
16
|
+
if (this.currentEngine) {
|
|
17
|
+
if (this.currentEngine.setActive) {
|
|
18
|
+
this.currentEngine.setActive(false);
|
|
19
|
+
}
|
|
20
|
+
if (this.currentEngine.destroy) {
|
|
21
|
+
this.currentEngine.destroy();
|
|
22
|
+
}
|
|
23
|
+
console.log('💥 Old engine destroyed');
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// STEP 2: DESTROY old WebGL contexts
|
|
27
|
+
this.destroyOldWebGLContexts();
|
|
28
|
+
|
|
29
|
+
// STEP 3: DESTROY all canvases + CREATE 5 fresh ones
|
|
30
|
+
this.destroyAllCanvasesAndCreateFresh(systemName);
|
|
31
|
+
|
|
32
|
+
// STEP 4: CREATE fresh engine
|
|
33
|
+
const engine = await this.createFreshEngine(systemName, engineClasses);
|
|
34
|
+
|
|
35
|
+
// STEP 5: Start new engine
|
|
36
|
+
if (engine && engine.setActive) {
|
|
37
|
+
engine.setActive(true);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
this.currentSystem = systemName;
|
|
41
|
+
this.currentEngine = engine;
|
|
42
|
+
console.log(`✅ DESTROY → CREATE complete: ${systemName} ready`);
|
|
43
|
+
return engine;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
destroyOldWebGLContexts() {
|
|
47
|
+
console.log('💥 COMPLETE DESTRUCTION: WebGL contexts + old system cleanup...');
|
|
48
|
+
|
|
49
|
+
// STEP 1: Kill all WebGL contexts first
|
|
50
|
+
const allCanvases = document.querySelectorAll('canvas');
|
|
51
|
+
let destroyedCount = 0;
|
|
52
|
+
|
|
53
|
+
allCanvases.forEach(canvas => {
|
|
54
|
+
// Get any existing WebGL context
|
|
55
|
+
const gl = canvas.getContext('webgl2') || canvas.getContext('webgl');
|
|
56
|
+
if (gl) {
|
|
57
|
+
// Force context loss
|
|
58
|
+
const loseContextExt = gl.getExtension('WEBGL_lose_context');
|
|
59
|
+
if (loseContextExt) {
|
|
60
|
+
loseContextExt.loseContext();
|
|
61
|
+
destroyedCount++;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
// STEP 2: Clear all global engine references (old system cleanup)
|
|
67
|
+
if (window.engine) {
|
|
68
|
+
console.log('💥 Clearing window.engine');
|
|
69
|
+
window.engine = null;
|
|
70
|
+
}
|
|
71
|
+
if (window.quantumEngine) {
|
|
72
|
+
console.log('💥 Clearing window.quantumEngine');
|
|
73
|
+
window.quantumEngine = null;
|
|
74
|
+
}
|
|
75
|
+
if (window.holographicSystem) {
|
|
76
|
+
console.log('💥 Clearing window.holographicSystem');
|
|
77
|
+
window.holographicSystem = null;
|
|
78
|
+
}
|
|
79
|
+
if (window.polychoraSystem) {
|
|
80
|
+
console.log('💥 Clearing window.polychoraSystem');
|
|
81
|
+
window.polychoraSystem = null;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
console.log(`💥 DESTRUCTION COMPLETE: ${destroyedCount} WebGL contexts destroyed, all engine refs cleared`);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
destroyAllCanvasesAndCreateFresh(systemName) {
|
|
88
|
+
console.log('💥 DESTROYING ALL CANVASES + CREATING 5 FRESH ONES');
|
|
89
|
+
|
|
90
|
+
// STEP 1: DESTROY all existing canvases completely
|
|
91
|
+
const allCanvases = document.querySelectorAll('canvas');
|
|
92
|
+
allCanvases.forEach(canvas => canvas.remove());
|
|
93
|
+
console.log(`💥 Destroyed ${allCanvases.length} old canvases`);
|
|
94
|
+
|
|
95
|
+
// STEP 2: Clear all containers
|
|
96
|
+
const containers = ['vib34dLayers', 'quantumLayers', 'holographicLayers', 'polychoraLayers'];
|
|
97
|
+
containers.forEach(containerId => {
|
|
98
|
+
const container = document.getElementById(containerId);
|
|
99
|
+
if (container) {
|
|
100
|
+
container.innerHTML = '';
|
|
101
|
+
container.style.display = 'none';
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
// STEP 3: CREATE 5 fresh canvases for the new system
|
|
106
|
+
const targetId = systemName === 'faceted' ? 'vib34dLayers' : `${systemName}Layers`;
|
|
107
|
+
const targetContainer = document.getElementById(targetId);
|
|
108
|
+
|
|
109
|
+
if (!targetContainer) {
|
|
110
|
+
console.error(`❌ Container ${targetId} not found`);
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// Create canvas IDs for this system
|
|
115
|
+
const canvasIds = this.getCanvasIdsForSystem(systemName);
|
|
116
|
+
|
|
117
|
+
// Create 5 fresh canvases
|
|
118
|
+
canvasIds.forEach((canvasId, index) => {
|
|
119
|
+
const canvas = document.createElement('canvas');
|
|
120
|
+
canvas.id = canvasId;
|
|
121
|
+
canvas.className = 'visualization-canvas';
|
|
122
|
+
canvas.style.position = 'absolute';
|
|
123
|
+
canvas.style.top = '0';
|
|
124
|
+
canvas.style.left = '0';
|
|
125
|
+
canvas.style.width = '100%';
|
|
126
|
+
canvas.style.height = '100%';
|
|
127
|
+
canvas.style.zIndex = index + 1;
|
|
128
|
+
|
|
129
|
+
// Set canvas dimensions
|
|
130
|
+
const viewWidth = window.innerWidth;
|
|
131
|
+
const viewHeight = window.innerHeight;
|
|
132
|
+
const dpr = Math.min(window.devicePixelRatio || 1, 2);
|
|
133
|
+
canvas.width = viewWidth * dpr;
|
|
134
|
+
canvas.height = viewHeight * dpr;
|
|
135
|
+
|
|
136
|
+
targetContainer.appendChild(canvas);
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
// Show the target container
|
|
140
|
+
targetContainer.style.display = 'block';
|
|
141
|
+
targetContainer.style.visibility = 'visible';
|
|
142
|
+
targetContainer.style.opacity = '1';
|
|
143
|
+
|
|
144
|
+
console.log(`✅ Created 5 fresh canvases for ${systemName}: ${canvasIds.join(', ')}`);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
getCanvasIdsForSystem(systemName) {
|
|
148
|
+
const baseIds = ['background-canvas', 'shadow-canvas', 'content-canvas', 'highlight-canvas', 'accent-canvas'];
|
|
149
|
+
|
|
150
|
+
switch (systemName) {
|
|
151
|
+
case 'faceted':
|
|
152
|
+
return baseIds;
|
|
153
|
+
case 'quantum':
|
|
154
|
+
return baseIds.map(id => `quantum-${id}`);
|
|
155
|
+
case 'holographic':
|
|
156
|
+
return baseIds.map(id => `holo-${id}`);
|
|
157
|
+
case 'polychora':
|
|
158
|
+
return baseIds.map(id => `polychora-${id}`);
|
|
159
|
+
default:
|
|
160
|
+
return baseIds;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
async createFreshEngine(systemName, engineClasses) {
|
|
165
|
+
console.log(`🚀 Creating fresh ${systemName} engine`);
|
|
166
|
+
|
|
167
|
+
let engine = null;
|
|
168
|
+
|
|
169
|
+
try {
|
|
170
|
+
switch(systemName) {
|
|
171
|
+
case 'faceted':
|
|
172
|
+
if (engineClasses.VIB34DIntegratedEngine) {
|
|
173
|
+
engine = new engineClasses.VIB34DIntegratedEngine();
|
|
174
|
+
window.engine = engine;
|
|
175
|
+
console.log('✅ Fresh Faceted engine');
|
|
176
|
+
}
|
|
177
|
+
break;
|
|
178
|
+
|
|
179
|
+
case 'quantum':
|
|
180
|
+
if (engineClasses.QuantumEngine) {
|
|
181
|
+
engine = new engineClasses.QuantumEngine();
|
|
182
|
+
window.quantumEngine = engine;
|
|
183
|
+
console.log('✅ Fresh Quantum engine');
|
|
184
|
+
}
|
|
185
|
+
break;
|
|
186
|
+
|
|
187
|
+
case 'holographic':
|
|
188
|
+
if (engineClasses.RealHolographicSystem) {
|
|
189
|
+
engine = new engineClasses.RealHolographicSystem();
|
|
190
|
+
window.holographicSystem = engine;
|
|
191
|
+
console.log('✅ Fresh Holographic engine');
|
|
192
|
+
}
|
|
193
|
+
break;
|
|
194
|
+
|
|
195
|
+
case 'polychora':
|
|
196
|
+
// POLYCHORA: TBD placeholder - not production ready
|
|
197
|
+
// Engine disabled until system is complete
|
|
198
|
+
console.warn('⚠️ Polychora system is TBD placeholder - not available');
|
|
199
|
+
if (false && engineClasses.NewPolychoraEngine) {
|
|
200
|
+
engine = new engineClasses.NewPolychoraEngine();
|
|
201
|
+
window.newPolychoraEngine = engine;
|
|
202
|
+
console.log('✅ Fresh TRUE 4D Polychora Engine with VIB34D DNA');
|
|
203
|
+
}
|
|
204
|
+
break;
|
|
205
|
+
|
|
206
|
+
default:
|
|
207
|
+
console.error(`❌ Unknown system: ${systemName}`);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
} catch (error) {
|
|
211
|
+
console.error(`💥 Engine creation failed for ${systemName}:`, error);
|
|
212
|
+
engine = null;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
return engine;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* VIB3+ Opt-in Error Reporter
|
|
3
|
+
*
|
|
4
|
+
* Captures unhandled errors and rejections for crash telemetry.
|
|
5
|
+
* OFF by default. Must be explicitly enabled by the host application.
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* import { ErrorReporter } from '@vib3code/sdk/core/error-reporter';
|
|
9
|
+
* const reporter = new ErrorReporter({ endpoint: '/api/errors' });
|
|
10
|
+
* reporter.enable();
|
|
11
|
+
*
|
|
12
|
+
* No data is sent unless enable() is called. All reports are anonymized
|
|
13
|
+
* (no user IDs, no cookies, no PII).
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
export class ErrorReporter {
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @param {Object} [options]
|
|
20
|
+
* @param {string} [options.endpoint] - URL to POST error reports to
|
|
21
|
+
* @param {Function} [options.onError] - Custom callback instead of HTTP POST
|
|
22
|
+
* @param {number} [options.maxReports=50] - Max reports per session (rate limiting)
|
|
23
|
+
* @param {boolean} [options.includeStack=true] - Include stack traces
|
|
24
|
+
*/
|
|
25
|
+
constructor(options = {}) {
|
|
26
|
+
this._endpoint = options.endpoint || null;
|
|
27
|
+
this._onError = typeof options.onError === 'function' ? options.onError : null;
|
|
28
|
+
this._maxReports = options.maxReports ?? 50;
|
|
29
|
+
this._includeStack = options.includeStack !== false;
|
|
30
|
+
this._reportCount = 0;
|
|
31
|
+
this._enabled = false;
|
|
32
|
+
this._boundOnError = this._handleError.bind(this);
|
|
33
|
+
this._boundOnRejection = this._handleRejection.bind(this);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** Enable error capture. Must be called explicitly. */
|
|
37
|
+
enable() {
|
|
38
|
+
if (this._enabled || typeof window === 'undefined') return;
|
|
39
|
+
this._enabled = true;
|
|
40
|
+
window.addEventListener('error', this._boundOnError);
|
|
41
|
+
window.addEventListener('unhandledrejection', this._boundOnRejection);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** Disable error capture and remove listeners. */
|
|
45
|
+
disable() {
|
|
46
|
+
if (!this._enabled || typeof window === 'undefined') return;
|
|
47
|
+
this._enabled = false;
|
|
48
|
+
window.removeEventListener('error', this._boundOnError);
|
|
49
|
+
window.removeEventListener('unhandledrejection', this._boundOnRejection);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** @returns {boolean} Whether the reporter is active */
|
|
53
|
+
get isEnabled() {
|
|
54
|
+
return this._enabled;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** @private */
|
|
58
|
+
_handleError(event) {
|
|
59
|
+
this._report({
|
|
60
|
+
type: 'error',
|
|
61
|
+
message: event.message || 'Unknown error',
|
|
62
|
+
filename: event.filename || '',
|
|
63
|
+
lineno: event.lineno || 0,
|
|
64
|
+
colno: event.colno || 0,
|
|
65
|
+
stack: this._includeStack && event.error ? event.error.stack : undefined,
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** @private */
|
|
70
|
+
_handleRejection(event) {
|
|
71
|
+
const reason = event.reason;
|
|
72
|
+
this._report({
|
|
73
|
+
type: 'unhandledrejection',
|
|
74
|
+
message: reason instanceof Error ? reason.message : String(reason),
|
|
75
|
+
stack: this._includeStack && reason instanceof Error ? reason.stack : undefined,
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** @private */
|
|
80
|
+
_report(data) {
|
|
81
|
+
if (this._reportCount >= this._maxReports) return;
|
|
82
|
+
this._reportCount++;
|
|
83
|
+
|
|
84
|
+
const report = {
|
|
85
|
+
...data,
|
|
86
|
+
timestamp: Date.now(),
|
|
87
|
+
url: typeof location !== 'undefined' ? location.pathname : '',
|
|
88
|
+
userAgent: typeof navigator !== 'undefined' ? navigator.userAgent : '',
|
|
89
|
+
sdkVersion: '2.0.0',
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
// Custom callback takes priority
|
|
93
|
+
if (this._onError) {
|
|
94
|
+
try { this._onError(report); } catch (_) { /* swallow */ }
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// HTTP POST if endpoint configured
|
|
99
|
+
if (this._endpoint && typeof fetch === 'function') {
|
|
100
|
+
fetch(this._endpoint, {
|
|
101
|
+
method: 'POST',
|
|
102
|
+
headers: { 'Content-Type': 'application/json' },
|
|
103
|
+
body: JSON.stringify(report),
|
|
104
|
+
keepalive: true,
|
|
105
|
+
}).catch(() => { /* swallow network errors */ });
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/** Destroy reporter and clean up. */
|
|
110
|
+
dispose() {
|
|
111
|
+
this.disable();
|
|
112
|
+
this._onError = null;
|
|
113
|
+
this._endpoint = null;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export default ErrorReporter;
|