diff --git a/prototypes/CMakeLists.txt b/prototypes/CMakeLists.txt new file mode 100644 index 0000000..1f63a0f --- /dev/null +++ b/prototypes/CMakeLists.txt @@ -0,0 +1,10 @@ +# SPDX-License-Identifier: MPL-2.0 +# +# Prototypes jetables (non produit). Voir docs/SEQUA_Engine_resume_complet_v2.md §5.6. +# Seuls les prototypes supportes par la plateforme courante sont ajoutes. + +if(WIN32) + add_subdirectory(gpu_interop) +else() + message(STATUS "prototypes : gpu_interop ignore (Windows uniquement pour l'instant)") +endif() diff --git a/prototypes/gpu_interop/CMakeLists.txt b/prototypes/gpu_interop/CMakeLists.txt new file mode 100644 index 0000000..e7ff709 --- /dev/null +++ b/prototypes/gpu_interop/CMakeLists.txt @@ -0,0 +1,18 @@ +# SPDX-License-Identifier: MPL-2.0 +# +# Prototype jetable : export/import d'une texture Vulkan via un HANDLE Win32. +# Aucune dependance hors Vulkan SDK. + +find_package(Vulkan REQUIRED) + +add_executable(gpu_interop_vk_export + main.cpp) + +target_link_libraries(gpu_interop_vk_export PRIVATE Vulkan::Vulkan) + +sequa_target_defaults(gpu_interop_vk_export) + +if(SEQUA_BUILD_TESTS) + add_test(NAME gpu_interop_vk_export COMMAND gpu_interop_vk_export) + set_tests_properties(gpu_interop_vk_export PROPERTIES LABELS "gpu;prototype") +endif() diff --git a/prototypes/gpu_interop/README.md b/prototypes/gpu_interop/README.md new file mode 100644 index 0000000..f85c6fd --- /dev/null +++ b/prototypes/gpu_interop/README.md @@ -0,0 +1,154 @@ +> **PROTOTYPE JETABLE — pas du code produit.** +> Ce dossier sert uniquement à valider une hypothèse technique. Il n'a ni les garanties, ni l'API, +> ni la qualité d'ingénierie attendues du reste du dépôt, et il sera supprimé ou réécrit. + +# gpu_interop — export/import d'une texture Vulkan (étape 1) + +## SEQUA Engine en bref + +**SEQUA** signifie **Simulate Environments, Quantify Uncertainty, Adapt** : l'engine simule des +environnements, quantifie l'incertitude de leur représentation et adapte les méthodes de calcul et de +rendu au contexte. Le produit s'articule en quatre couches : **SEQUA Studio** (l'outil de création), +**SEQUA Core** (format de projet, simulation déterministe, orchestration), **SEQUA 3D** (le contrat de +données et les adaptateurs) et des **moteurs 3D interchangeables** (Godot, Unreal, puis un moteur +maison) qui exécutent le rendu sans contenir la logique du produit. Le rendu neuronal et génératif +est un mode optionnel, piloté par des budgets et des cartes de confiance. + +## Rôle de ce prototype dans l'engine + +Le risque n°1 identifié au §5.6 de `docs/SEQUA_Engine_resume_complet_v2.md` est la **fuite des +abstractions au passage GPU rendu → inférence** : + +> « Les données restent résidentes sur le GPU autant que possible. Le passage de textures entre l'API +> graphique (Vulkan, DirectX) et le moteur d'inférence (CUDA, TensorRT) sans copie CPU est le point où +> les abstractions fuient le plus ; il est testé en tout premier. » + +Ce prototype vérifie donc la brique la plus basse et la plus décisive : une texture produite par un +contexte Vulkan peut-elle être **exportée puis réutilisée par un autre contexte GPU** sans jamais +transiter par la mémoire système ? Si l'étape 1 échoue, le contrat `NeuralFrameContext` (§5.6) doit +prévoir des copies CPU, ce qui change l'architecture et les budgets. L'étape 1 ne dépend que du +Vulkan SDK et ne touche ni à CUDA ni à ONNX Runtime. + +## Étapes prévues + +| Étape | Contenu | État | +|---|---|---| +| 1 | Export d'une `VkImage` en `HANDLE` Win32 (`OPAQUE_WIN32`), import dans un second `VkDevice`, comparaison octet à octet, mesures | **fait (ce programme)** | +| 2 | Import de la même allocation dans CUDA via `cudaImportExternalMemory` / `cudaExternalMemoryGetMappedMipmappedArray` | à faire — **nécessite le CUDA Toolkit, non installé sur la machine de référence** | +| 3 | Inférence ONNX Runtime (ou TensorRT) directement sur le tampon importé, sans copie CPU | à faire | +| 4 | Synchronisation fine par sémaphores externes (`VK_KHR_external_semaphore_win32` / `cudaExternalSemaphore`), suppression des `vkQueueWaitIdle` | à faire — l'extension est **disponible** sur le GPU de test, vérifiée et affichée par l'étape 1 | + +## Ce que fait le programme + +1. Crée une instance Vulkan headless (aucune fenêtre, aucune surface) sur API 1.2. +2. Sélectionne un GPU avec file graphique et `VK_KHR_external_memory_win32`, puis crée **deux + `VkDevice` distincts sur le même `VkPhysicalDevice`**, et vérifie que leurs `deviceUUID` concordent. +3. Alloue une `VkImage` **1920×1080 `VK_FORMAT_R8G8B8A8_UNORM`** en mémoire `DEVICE_LOCAL`, avec + `VkExternalMemoryImageCreateInfo` + `VkExportMemoryAllocateInfo` + (`VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_BIT`) et une allocation dédiée. +4. La remplit avec un motif déterministe (R = x & 0xFF, G = y & 0xFF, B = (x ^ y) & 0xFF, A = 0xFF) + par staging buffer + `vkCmdCopyBufferToImage` — **aucun shader**, donc aucune dépendance glslang. +5. Exporte la mémoire avec `vkGetMemoryWin32HandleKHR`, importe le `HANDLE` dans le second device + (`VkImportMemoryWin32HandleInfoKHR`), lie une `VkImage` identique à la mémoire importée. +6. Relit l'image du second device via un staging buffer et compare **octet à octet** au motif. +7. Mesure l'export, l'import et, à titre de référence, un aller-retour **GPU → CPU → GPU** complet + de la même image (5 essais, minimum et médiane). +8. Ferme le `HANDLE` avec `CloseHandle` et libère toutes les ressources (RAII). + +Code de retour : `0` si les 8 294 400 octets sont identiques, `2` si le contenu diffère, `1` sur +erreur Vulkan ou d'initialisation. + +## Construire et lancer + +Prérequis : Windows 10/11, Visual Studio 2022 avec les outils C++ x64, Vulkan SDK (testé avec +1.4.341.1), un GPU exposant `VK_KHR_external_memory_win32`. + +Depuis la racine du dépôt : + +```powershell +powershell.exe -NoProfile -ExecutionPolicy Bypass -File scripts\build.ps1 -Preset windows-msvc-prototypes +``` + +Le script configure, compile et lance `ctest`. Pour exécuter seulement l'essai du prototype : + +```powershell +ctest --preset windows-msvc-prototypes -L prototype --output-on-failure +``` + +Ou directement : + +```powershell +.\build\windows-msvc-prototypes\prototypes\gpu_interop\gpu_interop_vk_export.exe +``` + +Sous Linux/macOS, `prototypes/CMakeLists.txt` n'ajoute pas la cible et affiche un message `STATUS` : +le code de cette étape est Windows uniquement. + +## Résultats mesurés + +Machine de référence : Windows 11, NVIDIA GeForce RTX 4090 Laptop GPU (16 Go), pilote Vulkan +1.4.357, MSVC 14.44, build `RelWithDebInfo`, 6 novembre 2026. + +Image : 1920×1080 `R8G8B8A8_UNORM`, 8 294 400 octets utiles, allocation de 8 847 360 octets. + +| Mesure | Valeur | +|---|---| +| Export `vkGetMemoryWin32HandleKHR` | **0,001 ms** | +| Import dans le second `VkDevice` (création image + `vkAllocateMemory` + `vkBindImageMemory`) | **0,066 – 0,135 ms** (selon l'exécution) | +| Aller-retour GPU → CPU → GPU de référence (médiane de 5 essais) | **30,7 – 37,0 ms** | +| Comparaison octet à octet après import | **identique** (8 294 400 / 8 294 400 octets) | + +Extrait d'exécution : + +```text +[5] Export : HANDLE Win32 0x00000000000005F4 en 0.001 ms +[6] Import dans le device B : type 1, 0.075 ms (creation image + alloc + bind) +[7] Comparaison octet a octet apres import : IDENTIQUE +[8] CloseHandle du HANDLE exporte : OK +[9] Aller-retour GPU->CPU->GPU de reference (5 essais) + min 30.612 ms, mediane 30.725 ms, contenu identique + +=== RESULTATS === + Export HANDLE Win32 : 0.001 ms + Import dans un 2e device : 0.075 ms + Aller-retour GPU->CPU->GPU : 30.725 ms (mediane de 5 essais) + Verification octet a octet : OK +``` + +Lecture : l'export et l'import sont des opérations de métadonnées (aucune donnée déplacée), d'où des +temps négligeables devant le round-trip CPU, qui déplace réellement 2 × 8,3 Mo sur le bus et subit +deux synchronisations `vkQueueWaitIdle` (latence WDDM). C'est exactement l'écart que l'étape 2 doit +rendre inutile. + +## Limites et points non vérifiés + +- Import d'un handle `OPAQUE_WIN32` : `vkGetMemoryWin32HandlePropertiesKHR` ne doit **pas** être + appelé pour ce type de handle (VUID-vkGetMemoryWin32HandlePropertiesKHR-handleType-00666 ; la + première version l'appelait et obtenait `VK_ERROR_INITIALIZATION_FAILED`). La spec impose + d'importer avec le même `memoryTypeIndex` et la même taille qu'à l'export ; le programme vérifie + seulement que l'image importée accepte ce type. Non retesté avec les validation layers. +- La synchronisation inter-devices repose sur un `vkQueueWaitIdle` avant l'export : suffisant pour un + prototype mono-thread, **pas** un mécanisme de production. L'étape 4 doit le remplacer par des + sémaphores externes. +- Les deux `VkDevice` vivent dans le **même processus**. Un partage inter-processus demanderait + `DuplicateHandle`. +- La vérification `deviceUUID` compare deux requêtes sur le même `VkPhysicalDevice` : elle est donc + structurellement vraie ici. Elle deviendra significative quand le device d'inférence sera créé par + un autre runtime (CUDA) ou un autre processus. +- L'aller-retour de référence inclut deux soumissions, deux attentes de file et les copies hôte ; + il mesure donc surtout la latence de synchronisation Windows, pas la bande passante PCIe. +- Les temps export/import sont des mesures uniques par exécution (ils ne peuvent pas être répétés sans + réexporter) ; seule la variabilité de l'aller-retour est établie sur 5 essais. +- Aucune couche de validation Vulkan n'est activée : le prototype n'a pas été passé sous + `VK_LAYER_KHRONOS_validation`. +- Étape 2 non commencée : aucun CUDA Toolkit n'est installé, aucune mesure CUDA n'est donc disponible. + +## Licences + +- Ce prototype est publié sous **MPL 2.0**, comme le reste de SEQUA (voir `LICENSE` à la racine). + Chaque fichier source porte l'en-tête `SPDX-License-Identifier: MPL-2.0`. +- Dépendances de l'étape 1 : **Vulkan SDK / Vulkan-Loader** (Apache 2.0) uniquement. Aucune autre + bibliothèque n'est liée : pas de glslang, pas de validation layer, pas de framework de test dédié. +- **CUDA et TensorRT sont propriétaires (NVIDIA)**. Ils n'entreront jamais dans le cœur : ce seront + des plugins facultatifs derrière `IComputeBackend`, conformément au §10.2 du document d'architecture, + et ils ne seront pas requis pour compiler ou exécuter l'engine. diff --git a/prototypes/gpu_interop/main.cpp b/prototypes/gpu_interop/main.cpp new file mode 100644 index 0000000..07663dc --- /dev/null +++ b/prototypes/gpu_interop/main.cpp @@ -0,0 +1,1019 @@ +// SPDX-License-Identifier: MPL-2.0 +// +// PROTOTYPE JETABLE - pas du code produit. +// +// Etape 1 du risque n°1 de SEQUA (docs/SEQUA_Engine_resume_complet_v2.md §5.6) : +// verifier qu'une texture produite par le rendu Vulkan peut etre partagee avec un +// autre contexte Vulkan (puis, a terme, CUDA / ONNX Runtime) sans copie CPU. +// +// Ce programme : +// 1. cree une instance et deux VkDevice headless sur le meme GPU physique ; +// 2. remplit une VkImage 1920x1080 R8G8B8A8_UNORM DEVICE_LOCAL avec un motif +// deterministe (staging buffer + vkCmdCopyBufferToImage, aucun shader) ; +// 3. exporte sa memoire en HANDLE Win32 (VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_BIT), +// l'importe dans le second device, relie une VkImage identique et compare +// octet a octet apres relecture ; +// 4. mesure l'export, l'import et un aller-retour GPU->CPU->GPU de reference. +// +// Windows uniquement (VK_KHR_external_memory_win32). Code non produit. + +#ifndef NOMINMAX +#define NOMINMAX +#endif +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN +#endif + +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace { + +using Clock = std::chrono::steady_clock; + +constexpr uint32_t kWidth = 1920; +constexpr uint32_t kHeight = 1080; +constexpr VkDeviceSize kBytesPerPixel = 4; +constexpr VkDeviceSize kImageBytes = static_cast(kWidth) * kHeight * kBytesPerPixel; +constexpr VkFormat kFormat = VK_FORMAT_R8G8B8A8_UNORM; +constexpr int kRoundtripIterations = 5; + +// --------------------------------------------------------------------------- +// Erreurs et formatage +// --------------------------------------------------------------------------- + +const char* result_name(VkResult result) +{ + switch (result) { + case VK_SUCCESS: + return "VK_SUCCESS"; + case VK_NOT_READY: + return "VK_NOT_READY"; + case VK_TIMEOUT: + return "VK_TIMEOUT"; + case VK_EVENT_SET: + return "VK_EVENT_SET"; + case VK_EVENT_RESET: + return "VK_EVENT_RESET"; + case VK_INCOMPLETE: + return "VK_INCOMPLETE"; + case VK_ERROR_OUT_OF_HOST_MEMORY: + return "VK_ERROR_OUT_OF_HOST_MEMORY"; + case VK_ERROR_OUT_OF_DEVICE_MEMORY: + return "VK_ERROR_OUT_OF_DEVICE_MEMORY"; + case VK_ERROR_INITIALIZATION_FAILED: + return "VK_ERROR_INITIALIZATION_FAILED"; + case VK_ERROR_DEVICE_LOST: + return "VK_ERROR_DEVICE_LOST"; + case VK_ERROR_MEMORY_MAP_FAILED: + return "VK_ERROR_MEMORY_MAP_FAILED"; + case VK_ERROR_LAYER_NOT_PRESENT: + return "VK_ERROR_LAYER_NOT_PRESENT"; + case VK_ERROR_EXTENSION_NOT_PRESENT: + return "VK_ERROR_EXTENSION_NOT_PRESENT"; + case VK_ERROR_FEATURE_NOT_PRESENT: + return "VK_ERROR_FEATURE_NOT_PRESENT"; + case VK_ERROR_INCOMPATIBLE_DRIVER: + return "VK_ERROR_INCOMPATIBLE_DRIVER"; + case VK_ERROR_TOO_MANY_OBJECTS: + return "VK_ERROR_TOO_MANY_OBJECTS"; + case VK_ERROR_FORMAT_NOT_SUPPORTED: + return "VK_ERROR_FORMAT_NOT_SUPPORTED"; + case VK_ERROR_INVALID_EXTERNAL_HANDLE: + return "VK_ERROR_INVALID_EXTERNAL_HANDLE"; + case VK_ERROR_OUT_OF_DATE_KHR: + return "VK_ERROR_OUT_OF_DATE_KHR"; + default: + return "VkResult inconnu"; + } +} + +[[noreturn]] void throw_vk(const char* what, VkResult result) +{ + char buffer[256]; + std::snprintf(buffer, sizeof(buffer), "%s : %s (%d)", what, result_name(result), static_cast(result)); + throw std::runtime_error(buffer); +} + +void check(VkResult result, const char* what) +{ + if (result != VK_SUCCESS) { + throw_vk(what, result); + } +} + +double elapsed_ms(Clock::time_point start) +{ + return std::chrono::duration(Clock::now() - start).count(); +} + +void print_external_format_support(VkPhysicalDevice physicalDevice) +{ + VkPhysicalDeviceExternalImageFormatInfo externalInfo{}; + externalInfo.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_IMAGE_FORMAT_INFO; + externalInfo.handleType = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_BIT; + + VkPhysicalDeviceImageFormatInfo2 formatInfo{}; + formatInfo.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_FORMAT_INFO_2; + formatInfo.pNext = &externalInfo; + formatInfo.format = kFormat; + formatInfo.type = VK_IMAGE_TYPE_2D; + formatInfo.tiling = VK_IMAGE_TILING_OPTIMAL; + formatInfo.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT; + + VkExternalImageFormatProperties externalProperties{}; + externalProperties.sType = VK_STRUCTURE_TYPE_EXTERNAL_IMAGE_FORMAT_PROPERTIES; + VkImageFormatProperties2 properties{}; + properties.sType = VK_STRUCTURE_TYPE_IMAGE_FORMAT_PROPERTIES_2; + properties.pNext = &externalProperties; + + const VkResult result = vkGetPhysicalDeviceImageFormatProperties2(physicalDevice, &formatInfo, &properties); + if (result != VK_SUCCESS) { + std::printf(" VkExternalImageFormatProperties 2D/R8G8B8A8_UNORM/OPAQUE_WIN32 : %s\n", result_name(result)); + return; + } + + const VkExternalMemoryFeatureFlags features = externalProperties.externalMemoryProperties.externalMemoryFeatures; + std::printf(" VkExternalImageFormatProperties 2D/R8G8B8A8_UNORM/OPAQUE_WIN32 : exportable=%s importable=%s " + "dedicated_only=%s\n", + (features & VK_EXTERNAL_MEMORY_FEATURE_EXPORTABLE_BIT) != 0u ? "oui" : "non", + (features & VK_EXTERNAL_MEMORY_FEATURE_IMPORTABLE_BIT) != 0u ? "oui" : "non", + (features & VK_EXTERNAL_MEMORY_FEATURE_DEDICATED_ONLY_BIT) != 0u ? "oui" : "non"); +} + +const char* device_type_name(VkPhysicalDeviceType type) +{ + switch (type) { + case VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU: + return "discrete"; + case VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU: + return "integrated"; + case VK_PHYSICAL_DEVICE_TYPE_VIRTUAL_GPU: + return "virtual"; + case VK_PHYSICAL_DEVICE_TYPE_CPU: + return "cpu"; + default: + return "other"; + } +} + +std::string uuid_to_string(const std::array& uuid) +{ + std::string text; + text.reserve(uuid.size() * 2); + char byte[4]; + for (uint8_t value : uuid) { + std::snprintf(byte, sizeof(byte), "%02x", static_cast(value)); + text += byte; + } + return text; +} + +// --------------------------------------------------------------------------- +// RAII minimal +// --------------------------------------------------------------------------- + +struct Win32Handle { + HANDLE value = nullptr; + + Win32Handle() = default; + Win32Handle(const Win32Handle&) = delete; + Win32Handle& operator=(const Win32Handle&) = delete; + ~Win32Handle() + { + if (value != nullptr) { + (void)CloseHandle(value); + } + } +}; + +struct InstanceContext { + VkInstance instance = VK_NULL_HANDLE; + + InstanceContext() = default; + InstanceContext(const InstanceContext&) = delete; + InstanceContext& operator=(const InstanceContext&) = delete; + ~InstanceContext() + { + if (instance != VK_NULL_HANDLE) { + vkDestroyInstance(instance, nullptr); + } + } +}; + +struct DeviceContext { + VkPhysicalDevice physicalDevice = VK_NULL_HANDLE; + VkDevice device = VK_NULL_HANDLE; + VkQueue queue = VK_NULL_HANDLE; + uint32_t queueFamily = 0; + VkCommandPool commandPool = VK_NULL_HANDLE; + VkCommandBuffer commandBuffer = VK_NULL_HANDLE; + + DeviceContext() = default; + DeviceContext(const DeviceContext&) = delete; + DeviceContext& operator=(const DeviceContext&) = delete; + ~DeviceContext() + { + if (device != VK_NULL_HANDLE) { + (void)vkDeviceWaitIdle(device); + if (commandPool != VK_NULL_HANDLE) { + vkDestroyCommandPool(device, commandPool, nullptr); + } + vkDestroyDevice(device, nullptr); + } + } +}; + +struct ImageResource { + VkDevice device = VK_NULL_HANDLE; + VkImage image = VK_NULL_HANDLE; + VkDeviceMemory memory = VK_NULL_HANDLE; + + ImageResource() = default; + ImageResource(const ImageResource&) = delete; + ImageResource& operator=(const ImageResource&) = delete; + ~ImageResource() + { + if (device != VK_NULL_HANDLE) { + if (image != VK_NULL_HANDLE) { + vkDestroyImage(device, image, nullptr); + } + if (memory != VK_NULL_HANDLE) { + vkFreeMemory(device, memory, nullptr); + } + } + } +}; + +struct BufferResource { + VkDevice device = VK_NULL_HANDLE; + VkBuffer buffer = VK_NULL_HANDLE; + VkDeviceMemory memory = VK_NULL_HANDLE; + VkDeviceSize size = 0; + + BufferResource() = default; + BufferResource(const BufferResource&) = delete; + BufferResource& operator=(const BufferResource&) = delete; + ~BufferResource() + { + if (device != VK_NULL_HANDLE) { + if (buffer != VK_NULL_HANDLE) { + vkDestroyBuffer(device, buffer, nullptr); + } + if (memory != VK_NULL_HANDLE) { + vkFreeMemory(device, memory, nullptr); + } + } + } +}; + +// --------------------------------------------------------------------------- +// Enumeration / selection +// --------------------------------------------------------------------------- + +std::vector enumerate_instance_extensions() +{ + uint32_t count = 0; + check(vkEnumerateInstanceExtensionProperties(nullptr, &count, nullptr), "vkEnumerateInstanceExtensionProperties"); + std::vector extensions(count); + if (count != 0) { + check(vkEnumerateInstanceExtensionProperties(nullptr, &count, extensions.data()), + "vkEnumerateInstanceExtensionProperties"); + } + return extensions; +} + +std::vector enumerate_device_extensions(VkPhysicalDevice physicalDevice) +{ + uint32_t count = 0; + check(vkEnumerateDeviceExtensionProperties(physicalDevice, nullptr, &count, nullptr), + "vkEnumerateDeviceExtensionProperties"); + std::vector extensions(count); + if (count != 0) { + check(vkEnumerateDeviceExtensionProperties(physicalDevice, nullptr, &count, extensions.data()), + "vkEnumerateDeviceExtensionProperties"); + } + return extensions; +} + +bool has_extension(const std::vector& extensions, const char* name) +{ + for (const VkExtensionProperties& extension : extensions) { + if (std::strcmp(extension.extensionName, name) == 0) { + return true; + } + } + return false; +} + +void create_instance(InstanceContext& out) +{ + uint32_t loaderVersion = 0; + check(vkEnumerateInstanceVersion(&loaderVersion), "vkEnumerateInstanceVersion"); + if (loaderVersion < VK_API_VERSION_1_2) { + char buffer[160]; + std::snprintf(buffer, sizeof(buffer), "Vulkan loader trop ancien : %u.%u.%u (1.2 minimum requis)", + static_cast(VK_API_VERSION_MAJOR(loaderVersion)), + static_cast(VK_API_VERSION_MINOR(loaderVersion)), + static_cast(VK_API_VERSION_PATCH(loaderVersion))); + throw std::runtime_error(buffer); + } + + const std::vector available = enumerate_instance_extensions(); + std::vector enabled; + if (has_extension(available, VK_KHR_EXTERNAL_MEMORY_CAPABILITIES_EXTENSION_NAME)) { + enabled.push_back(VK_KHR_EXTERNAL_MEMORY_CAPABILITIES_EXTENSION_NAME); + } + if (has_extension(available, VK_KHR_EXTERNAL_SEMAPHORE_CAPABILITIES_EXTENSION_NAME)) { + enabled.push_back(VK_KHR_EXTERNAL_SEMAPHORE_CAPABILITIES_EXTENSION_NAME); + } + + VkApplicationInfo application{}; + application.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO; + application.pApplicationName = "gpu_interop_vk_export"; + application.applicationVersion = VK_MAKE_API_VERSION(0, 0, 1, 0); + application.pEngineName = "SEQUA (prototype)"; + application.engineVersion = VK_MAKE_API_VERSION(0, 0, 1, 0); + application.apiVersion = VK_API_VERSION_1_2; + + VkInstanceCreateInfo info{}; + info.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO; + info.pApplicationInfo = &application; + info.enabledExtensionCount = static_cast(enabled.size()); + info.ppEnabledExtensionNames = enabled.data(); + + check(vkCreateInstance(&info, nullptr, &out.instance), "vkCreateInstance"); +} + +std::array query_device_uuid(VkPhysicalDevice physicalDevice) +{ + VkPhysicalDeviceIDProperties idProperties{}; + idProperties.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ID_PROPERTIES; + VkPhysicalDeviceProperties2 properties2{}; + properties2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2; + properties2.pNext = &idProperties; + vkGetPhysicalDeviceProperties2(physicalDevice, &properties2); + + std::array uuid{}; + std::copy(std::begin(idProperties.deviceUUID), std::end(idProperties.deviceUUID), uuid.begin()); + return uuid; +} + +struct DeviceInfo { + VkPhysicalDevice physicalDevice = VK_NULL_HANDLE; + uint32_t queueFamily = 0; + VkPhysicalDeviceProperties properties{}; + std::array uuid{}; + bool externalMemory = false; + bool externalMemoryWin32 = false; + bool externalSemaphore = false; + bool externalSemaphoreWin32 = false; +}; + +DeviceInfo pick_physical_device(VkInstance instance) +{ + uint32_t count = 0; + check(vkEnumeratePhysicalDevices(instance, &count, nullptr), "vkEnumeratePhysicalDevices"); + if (count == 0) { + throw std::runtime_error("Aucun GPU Vulkan detecte."); + } + std::vector devices(count); + check(vkEnumeratePhysicalDevices(instance, &count, devices.data()), "vkEnumeratePhysicalDevices"); + + std::string rejected; + for (VkPhysicalDevice physicalDevice : devices) { + DeviceInfo info{}; + info.physicalDevice = physicalDevice; + + VkPhysicalDeviceProperties2 properties2{}; + properties2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2; + vkGetPhysicalDeviceProperties2(physicalDevice, &properties2); + info.properties = properties2.properties; + info.uuid = query_device_uuid(physicalDevice); + + const std::vector extensions = enumerate_device_extensions(physicalDevice); + info.externalMemory = has_extension(extensions, VK_KHR_EXTERNAL_MEMORY_EXTENSION_NAME); + info.externalMemoryWin32 = has_extension(extensions, VK_KHR_EXTERNAL_MEMORY_WIN32_EXTENSION_NAME); + info.externalSemaphore = has_extension(extensions, VK_KHR_EXTERNAL_SEMAPHORE_EXTENSION_NAME); + info.externalSemaphoreWin32 = has_extension(extensions, VK_KHR_EXTERNAL_SEMAPHORE_WIN32_EXTENSION_NAME); + + uint32_t familyCount = 0; + vkGetPhysicalDeviceQueueFamilyProperties(physicalDevice, &familyCount, nullptr); + std::vector families(familyCount); + if (familyCount != 0) { + vkGetPhysicalDeviceQueueFamilyProperties(physicalDevice, &familyCount, families.data()); + } + bool hasGraphicsQueue = false; + for (uint32_t index = 0; index < familyCount; ++index) { + if ((families[index].queueFlags & VK_QUEUE_GRAPHICS_BIT) != 0u) { + info.queueFamily = index; + hasGraphicsQueue = true; + break; + } + } + + std::printf(" GPU : %s (%s, API %u.%u.%u) - external_memory_win32=%s\n", info.properties.deviceName, + device_type_name(info.properties.deviceType), + static_cast(VK_API_VERSION_MAJOR(info.properties.apiVersion)), + static_cast(VK_API_VERSION_MINOR(info.properties.apiVersion)), + static_cast(VK_API_VERSION_PATCH(info.properties.apiVersion)), + info.externalMemoryWin32 ? "oui" : "non"); + + if (hasGraphicsQueue && info.externalMemory && info.externalMemoryWin32) { + return info; + } + rejected += " - ignore : "; + rejected += info.properties.deviceName; + rejected += hasGraphicsQueue ? "" : " (pas de file graphique)"; + rejected += info.externalMemoryWin32 ? "" : " (VK_KHR_external_memory_win32 absent)"; + rejected += '\n'; + } + + throw std::runtime_error("Aucun GPU ne remplit les conditions (file graphique + VK_KHR_external_memory_win32).\n" + + rejected); +} + +void create_device(const DeviceInfo& info, bool enableExternalSemaphore, DeviceContext& out, const char* label) +{ + const std::vector available = enumerate_device_extensions(info.physicalDevice); + std::vector enabled; + if (has_extension(available, VK_KHR_EXTERNAL_MEMORY_EXTENSION_NAME)) { + enabled.push_back(VK_KHR_EXTERNAL_MEMORY_EXTENSION_NAME); + } + enabled.push_back(VK_KHR_EXTERNAL_MEMORY_WIN32_EXTENSION_NAME); + if (enableExternalSemaphore) { + if (has_extension(available, VK_KHR_EXTERNAL_SEMAPHORE_EXTENSION_NAME)) { + enabled.push_back(VK_KHR_EXTERNAL_SEMAPHORE_EXTENSION_NAME); + } + if (info.externalSemaphoreWin32) { + enabled.push_back(VK_KHR_EXTERNAL_SEMAPHORE_WIN32_EXTENSION_NAME); + } + } + + const float priority = 1.0f; + VkDeviceQueueCreateInfo queueInfo{}; + queueInfo.sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO; + queueInfo.queueFamilyIndex = info.queueFamily; + queueInfo.queueCount = 1; + queueInfo.pQueuePriorities = &priority; + + VkDeviceCreateInfo createInfo{}; + createInfo.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO; + createInfo.queueCreateInfoCount = 1; + createInfo.pQueueCreateInfos = &queueInfo; + createInfo.enabledExtensionCount = static_cast(enabled.size()); + createInfo.ppEnabledExtensionNames = enabled.data(); + + check(vkCreateDevice(info.physicalDevice, &createInfo, nullptr, &out.device), label); + out.physicalDevice = info.physicalDevice; + out.queueFamily = info.queueFamily; + vkGetDeviceQueue(out.device, info.queueFamily, 0, &out.queue); + + VkCommandPoolCreateInfo poolInfo{}; + poolInfo.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; + poolInfo.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; + poolInfo.queueFamilyIndex = info.queueFamily; + check(vkCreateCommandPool(out.device, &poolInfo, nullptr, &out.commandPool), "vkCreateCommandPool"); + + VkCommandBufferAllocateInfo bufferInfo{}; + bufferInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; + bufferInfo.commandPool = out.commandPool; + bufferInfo.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; + bufferInfo.commandBufferCount = 1; + check(vkAllocateCommandBuffers(out.device, &bufferInfo, &out.commandBuffer), "vkAllocateCommandBuffers"); +} + +uint32_t find_memory_type(VkPhysicalDevice physicalDevice, uint32_t typeBits, VkMemoryPropertyFlags required, + const char* what) +{ + VkPhysicalDeviceMemoryProperties properties{}; + vkGetPhysicalDeviceMemoryProperties(physicalDevice, &properties); + for (uint32_t index = 0; index < properties.memoryTypeCount; ++index) { + const bool allowed = (typeBits & (1u << index)) != 0u; + const bool suitable = (properties.memoryTypes[index].propertyFlags & required) == required; + if (allowed && suitable) { + return index; + } + } + throw std::runtime_error(std::string("Aucun type de memoire compatible pour : ") + what); +} + +// --------------------------------------------------------------------------- +// Objets GPU +// --------------------------------------------------------------------------- + +void create_external_image(ImageResource& out, VkDevice device, const char* label) +{ + out.device = device; + + VkExternalMemoryImageCreateInfo externalInfo{}; + externalInfo.sType = VK_STRUCTURE_TYPE_EXTERNAL_MEMORY_IMAGE_CREATE_INFO; + externalInfo.handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_BIT; + + VkImageCreateInfo info{}; + info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; + info.pNext = &externalInfo; + info.imageType = VK_IMAGE_TYPE_2D; + info.format = kFormat; + info.extent.width = kWidth; + info.extent.height = kHeight; + info.extent.depth = 1; + info.mipLevels = 1; + info.arrayLayers = 1; + info.samples = VK_SAMPLE_COUNT_1_BIT; + info.tiling = VK_IMAGE_TILING_OPTIMAL; + info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT; + info.sharingMode = VK_SHARING_MODE_EXCLUSIVE; + info.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; + + check(vkCreateImage(device, &info, nullptr, &out.image), label); +} + +void create_host_buffer(BufferResource& out, DeviceContext& context, VkDeviceSize size, const char* label) +{ + out.device = context.device; + out.size = size; + + VkBufferCreateInfo info{}; + info.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; + info.size = size; + info.usage = VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT; + info.sharingMode = VK_SHARING_MODE_EXCLUSIVE; + check(vkCreateBuffer(context.device, &info, nullptr, &out.buffer), label); + + VkMemoryRequirements requirements{}; + vkGetBufferMemoryRequirements(context.device, out.buffer, &requirements); + const uint32_t memoryType = find_memory_type(context.physicalDevice, requirements.memoryTypeBits, + VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | + VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, + label); + + VkMemoryAllocateInfo allocateInfo{}; + allocateInfo.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; + allocateInfo.allocationSize = requirements.size; + allocateInfo.memoryTypeIndex = memoryType; + check(vkAllocateMemory(context.device, &allocateInfo, nullptr, &out.memory), label); + check(vkBindBufferMemory(context.device, out.buffer, out.memory, 0), label); +} + +void* map_memory(VkDevice device, VkDeviceMemory memory, VkDeviceSize size, const char* label) +{ + void* pointer = nullptr; + check(vkMapMemory(device, memory, 0, size, 0, &pointer), label); + return pointer; +} + +void flush_mapped_memory(VkDevice device, VkDeviceMemory memory) +{ + VkMappedMemoryRange range{}; + range.sType = VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE; + range.memory = memory; + range.offset = 0; + range.size = VK_WHOLE_SIZE; + check(vkFlushMappedMemoryRanges(device, 1, &range), "vkFlushMappedMemoryRanges"); +} + +void invalidate_mapped_memory(VkDevice device, VkDeviceMemory memory) +{ + VkMappedMemoryRange range{}; + range.sType = VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE; + range.memory = memory; + range.offset = 0; + range.size = VK_WHOLE_SIZE; + check(vkInvalidateMappedMemoryRanges(device, 1, &range), "vkInvalidateMappedMemoryRanges"); +} + +// --------------------------------------------------------------------------- +// Commandes +// --------------------------------------------------------------------------- + +void begin_commands(DeviceContext& context) +{ + check(vkResetCommandPool(context.device, context.commandPool, 0), "vkResetCommandPool"); + VkCommandBufferBeginInfo info{}; + info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; + info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; + check(vkBeginCommandBuffer(context.commandBuffer, &info), "vkBeginCommandBuffer"); +} + +void submit_and_wait(DeviceContext& context) +{ + check(vkEndCommandBuffer(context.commandBuffer), "vkEndCommandBuffer"); + + VkSubmitInfo submit{}; + submit.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; + submit.commandBufferCount = 1; + submit.pCommandBuffers = &context.commandBuffer; + check(vkQueueSubmit(context.queue, 1, &submit, VK_NULL_HANDLE), "vkQueueSubmit"); + check(vkQueueWaitIdle(context.queue), "vkQueueWaitIdle"); +} + +void cmd_image_barrier(VkCommandBuffer commandBuffer, VkImage image, VkImageLayout oldLayout, VkImageLayout newLayout, + VkPipelineStageFlags sourceStage, VkAccessFlags sourceAccess, VkPipelineStageFlags dstStage, + VkAccessFlags dstAccess) +{ + VkImageMemoryBarrier barrier{}; + barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; + barrier.srcAccessMask = sourceAccess; + barrier.dstAccessMask = dstAccess; + barrier.oldLayout = oldLayout; + barrier.newLayout = newLayout; + barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; + barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; + barrier.image = image; + barrier.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; + barrier.subresourceRange.baseMipLevel = 0; + barrier.subresourceRange.levelCount = 1; + barrier.subresourceRange.baseArrayLayer = 0; + barrier.subresourceRange.layerCount = 1; + + vkCmdPipelineBarrier(commandBuffer, sourceStage, dstStage, 0, 0, nullptr, 0, nullptr, 1, &barrier); +} + +void cmd_buffer_barrier(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize size, + VkPipelineStageFlags sourceStage, VkAccessFlags sourceAccess, VkPipelineStageFlags dstStage, + VkAccessFlags dstAccess) +{ + VkBufferMemoryBarrier barrier{}; + barrier.sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER; + barrier.srcAccessMask = sourceAccess; + barrier.dstAccessMask = dstAccess; + barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; + barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; + barrier.buffer = buffer; + barrier.offset = 0; + barrier.size = size; + + vkCmdPipelineBarrier(commandBuffer, sourceStage, dstStage, 0, 0, nullptr, 1, &barrier, 0, nullptr); +} + +VkBufferImageCopy full_image_copy() +{ + VkBufferImageCopy region{}; + region.bufferOffset = 0; + region.bufferRowLength = 0; // 0 = largeur de l'image, donnees serrees + region.bufferImageHeight = 0; // 0 = hauteur de l'image + region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; + region.imageSubresource.mipLevel = 0; + region.imageSubresource.baseArrayLayer = 0; + region.imageSubresource.layerCount = 1; + region.imageOffset.x = 0; + region.imageOffset.y = 0; + region.imageOffset.z = 0; + region.imageExtent.width = kWidth; + region.imageExtent.height = kHeight; + region.imageExtent.depth = 1; + return region; +} + +// --------------------------------------------------------------------------- +// Motif deterministe +// --------------------------------------------------------------------------- + +std::vector make_pattern() +{ + std::vector pixels(static_cast(kImageBytes)); + for (uint32_t y = 0; y < kHeight; ++y) { + for (uint32_t x = 0; x < kWidth; ++x) { + const size_t offset = (static_cast(y) * kWidth + x) * 4; + pixels[offset + 0] = static_cast(x & 0xFFu); // R + pixels[offset + 1] = static_cast(y & 0xFFu); // G + pixels[offset + 2] = static_cast((x ^ y) & 0xFFu); // B + pixels[offset + 3] = 0xFFu; // A + } + } + return pixels; +} + +size_t first_mismatch(const std::vector& expected, const uint8_t* actual, size_t size) +{ + for (size_t index = 0; index < size; ++index) { + if (expected[index] != actual[index]) { + return index; + } + } + return size; +} + +void print_pattern_mismatch(size_t offset, size_t total) +{ + std::printf(" PREMIERE DIFFERENCE a l'octet %llu sur %llu\n", static_cast(offset), + static_cast(total)); + std::printf(" pixel (%llu, %llu), composante %llu\n", + static_cast(offset / (4 * kWidth)), + static_cast((offset % (4 * kWidth)) / 4), + static_cast(offset % 4)); +} + +// --------------------------------------------------------------------------- +// Programme +// --------------------------------------------------------------------------- + +int run() +{ + std::printf("=== SEQUA - prototype gpu_interop_vk_export (etape 1) ===\n"); + std::printf("Image %ux%u R8G8B8A8_UNORM, %llu octets, DEVICE_LOCAL exportable\n\n", kWidth, kHeight, + static_cast(kImageBytes)); + + // --- Instance ----------------------------------------------------------- + InstanceContext instanceContext; + create_instance(instanceContext); + + // --- GPU ---------------------------------------------------------------- + std::printf("[1] Selection du GPU\n"); + const DeviceInfo deviceInfo = pick_physical_device(instanceContext.instance); + std::printf(" retenu : %s, UUID %s, file %u\n", deviceInfo.properties.deviceName, + uuid_to_string(deviceInfo.uuid).c_str(), deviceInfo.queueFamily); + std::printf(" VK_KHR_external_semaphore_win32 : %s (verifie, non utilise a l'etape 1)\n", + deviceInfo.externalSemaphoreWin32 ? "disponible" : "indisponible"); + print_external_format_support(deviceInfo.physicalDevice); + + // --- Deux devices ------------------------------------------------------- + DeviceContext deviceA; + DeviceContext deviceB; + create_device(deviceInfo, true, deviceA, "vkCreateDevice (A, export)"); + create_device(deviceInfo, true, deviceB, "vkCreateDevice (B, import)"); + std::printf("[2] Deux VkDevice crees sur le meme GPU\n"); + + const std::array uuidA = query_device_uuid(deviceA.physicalDevice); + const std::array uuidB = query_device_uuid(deviceB.physicalDevice); + std::printf(" deviceUUID A : %s\n", uuid_to_string(uuidA).c_str()); + std::printf(" deviceUUID B : %s\n", uuid_to_string(uuidB).c_str()); + if (uuidA != uuidB) { + throw std::runtime_error("deviceUUID differents entre les deux devices."); + } + std::printf(" correspondance deviceUUID : OK\n"); + + // --- Motif + staging ---------------------------------------------------- + const std::vector pattern = make_pattern(); + + BufferResource stagingA; + create_host_buffer(stagingA, deviceA, kImageBytes, "staging A"); + { + void* pointer = map_memory(deviceA.device, stagingA.memory, kImageBytes, "vkMapMemory (staging A)"); + std::memcpy(pointer, pattern.data(), pattern.size()); + flush_mapped_memory(deviceA.device, stagingA.memory); + vkUnmapMemory(deviceA.device, stagingA.memory); + } + + // --- Image A exportable ------------------------------------------------- + ImageResource imageA; + create_external_image(imageA, deviceA.device, "vkCreateImage (A, export)"); + + VkMemoryRequirements requirementsA{}; + vkGetImageMemoryRequirements(deviceA.device, imageA.image, &requirementsA); + const uint32_t memoryTypeIndex = + find_memory_type(deviceA.physicalDevice, requirementsA.memoryTypeBits, + VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, "image A DEVICE_LOCAL exportable"); + + VkMemoryDedicatedAllocateInfo dedicatedA{}; + dedicatedA.sType = VK_STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO; + dedicatedA.image = imageA.image; + + VkExportMemoryAllocateInfo exportAllocateInfo{}; + exportAllocateInfo.sType = VK_STRUCTURE_TYPE_EXPORT_MEMORY_ALLOCATE_INFO; + exportAllocateInfo.pNext = &dedicatedA; + exportAllocateInfo.handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_BIT; + + VkMemoryAllocateInfo allocateA{}; + allocateA.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; + allocateA.pNext = &exportAllocateInfo; + allocateA.allocationSize = requirementsA.size; + allocateA.memoryTypeIndex = memoryTypeIndex; + check(vkAllocateMemory(deviceA.device, &allocateA, nullptr, &imageA.memory), "vkAllocateMemory (A, export)"); + check(vkBindImageMemory(deviceA.device, imageA.image, imageA.memory, 0), "vkBindImageMemory (A)"); + + std::printf("[3] Image A : memoire DEVICE_LOCAL exportable (type %u, %llu octets)\n", memoryTypeIndex, + static_cast(requirementsA.size)); + + // --- Remplissage CPU -> GPU -------------------------------------------- + { + const VkBufferImageCopy region = full_image_copy(); + begin_commands(deviceA); + cmd_image_barrier(deviceA.commandBuffer, imageA.image, VK_IMAGE_LAYOUT_UNDEFINED, + VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, 0, + VK_PIPELINE_STAGE_TRANSFER_BIT, VK_ACCESS_TRANSFER_WRITE_BIT); + vkCmdCopyBufferToImage(deviceA.commandBuffer, stagingA.buffer, imageA.image, + VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1, ®ion); + cmd_image_barrier(deviceA.commandBuffer, imageA.image, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, + VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, VK_PIPELINE_STAGE_TRANSFER_BIT, + VK_ACCESS_TRANSFER_WRITE_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_ACCESS_TRANSFER_READ_BIT); + submit_and_wait(deviceA); + } + check(vkDeviceWaitIdle(deviceA.device), "vkDeviceWaitIdle (A)"); + std::printf("[4] Motif deterministe uploade (staging buffer + vkCmdCopyBufferToImage)\n"); + + // --- Export ------------------------------------------------------------- + const auto getWin32Handle = reinterpret_cast( + vkGetDeviceProcAddr(deviceA.device, "vkGetMemoryWin32HandleKHR")); + if (getWin32Handle == nullptr) { + throw std::runtime_error("vkGetMemoryWin32HandleKHR introuvable (extension non exposee)."); + } + + VkMemoryGetWin32HandleInfoKHR handleInfo{}; + handleInfo.sType = VK_STRUCTURE_TYPE_MEMORY_GET_WIN32_HANDLE_INFO_KHR; + handleInfo.memory = imageA.memory; + handleInfo.handleType = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_BIT; + + Win32Handle exported; + const Clock::time_point exportStart = Clock::now(); + check(getWin32Handle(deviceA.device, &handleInfo, &exported.value), "vkGetMemoryWin32HandleKHR"); + const double exportMs = elapsed_ms(exportStart); + + if (exported.value == nullptr) { + throw std::runtime_error("vkGetMemoryWin32HandleKHR a retourne un HANDLE nul."); + } + std::printf("[5] Export : HANDLE Win32 0x%p en %.3f ms\n", static_cast(exported.value), exportMs); + + // --- Import dans le device B ------------------------------------------- + ImageResource imageB; + const Clock::time_point importStart = Clock::now(); + create_external_image(imageB, deviceB.device, "vkCreateImage (B, import)"); + + // Handles OPAQUE_WIN32 : vkGetMemoryWin32HandlePropertiesKHR est interdit + // (VUID-vkGetMemoryWin32HandlePropertiesKHR-handleType-00666). La spec impose + // d'importer avec le meme memoryTypeIndex et la meme taille qu'a l'export ; + // on verifie seulement que l'image B accepte ce type. + VkMemoryRequirements requirementsB{}; + vkGetImageMemoryRequirements(deviceB.device, imageB.image, &requirementsB); + if ((requirementsB.memoryTypeBits & (1u << memoryTypeIndex)) == 0) { + char message[192]; + std::snprintf(message, sizeof(message), + "L'image B n'accepte pas le type de memoire exporte (%u).", memoryTypeIndex); + throw std::runtime_error(message); + } + const uint32_t importMemoryType = memoryTypeIndex; + + VkMemoryDedicatedAllocateInfo dedicatedB{}; + dedicatedB.sType = VK_STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO; + dedicatedB.image = imageB.image; + + VkImportMemoryWin32HandleInfoKHR importInfo{}; + importInfo.sType = VK_STRUCTURE_TYPE_IMPORT_MEMORY_WIN32_HANDLE_INFO_KHR; + importInfo.pNext = &dedicatedB; + importInfo.handleType = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_BIT; + importInfo.handle = exported.value; + importInfo.name = nullptr; + + VkMemoryAllocateInfo allocateB{}; + allocateB.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; + allocateB.pNext = &importInfo; + allocateB.allocationSize = requirementsA.size; + allocateB.memoryTypeIndex = importMemoryType; + check(vkAllocateMemory(deviceB.device, &allocateB, nullptr, &imageB.memory), "vkAllocateMemory (B, import)"); + check(vkBindImageMemory(deviceB.device, imageB.image, imageB.memory, 0), "vkBindImageMemory (B)"); + const double importMs = elapsed_ms(importStart); + + std::printf("[6] Import dans le device B : type %u, %.3f ms (creation image + alloc + bind)\n", importMemoryType, + importMs); + + // --- Relecture sur B et comparaison ------------------------------------ + BufferResource stagingB; + create_host_buffer(stagingB, deviceB, kImageBytes, "staging B"); + { + const VkBufferImageCopy region = full_image_copy(); + begin_commands(deviceB); + // L'image a ete laissee en TRANSFER_SRC_OPTIMAL par le device A. On reutilise + // ce layout comme layout d'origine pour ne pas risquer un contenu "undefined" + // (une transition depuis UNDEFINED autorise l'implementation a jeter le contenu). + cmd_image_barrier(deviceB.commandBuffer, imageB.image, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, + VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, 0, + VK_PIPELINE_STAGE_TRANSFER_BIT, VK_ACCESS_TRANSFER_READ_BIT); + vkCmdCopyImageToBuffer(deviceB.commandBuffer, imageB.image, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, + stagingB.buffer, 1, ®ion); + cmd_buffer_barrier(deviceB.commandBuffer, stagingB.buffer, kImageBytes, VK_PIPELINE_STAGE_TRANSFER_BIT, + VK_ACCESS_TRANSFER_WRITE_BIT, VK_PIPELINE_STAGE_HOST_BIT, VK_ACCESS_HOST_READ_BIT); + submit_and_wait(deviceB); + } + + size_t mismatch = kImageBytes; + { + void* pointer = map_memory(deviceB.device, stagingB.memory, kImageBytes, "vkMapMemory (staging B)"); + invalidate_mapped_memory(deviceB.device, stagingB.memory); + mismatch = first_mismatch(pattern, static_cast(pointer), static_cast(kImageBytes)); + vkUnmapMemory(deviceB.device, stagingB.memory); + } + + const bool identical = mismatch == static_cast(kImageBytes); + std::printf("[7] Comparaison octet a octet apres import : %s\n", + identical ? "IDENTIQUE" : "DIFFERENT"); + if (!identical) { + print_pattern_mismatch(mismatch, static_cast(kImageBytes)); + } + + // Le HANDLE NT a ete duplique par le driver lors de vkAllocateMemory : on peut le fermer. + const bool handleClosed = CloseHandle(exported.value) != FALSE; + exported.value = nullptr; + std::printf("[8] CloseHandle du HANDLE exporte : %s\n", handleClosed ? "OK" : "ECHEC"); + + // --- Reference : aller-retour GPU -> CPU -> GPU ------------------------ + std::vector hostPixels(static_cast(kImageBytes)); + std::vector roundtripSamples; + bool roundtripOk = true; + + for (int iteration = 0; iteration < kRoundtripIterations; ++iteration) { + const Clock::time_point roundtripStart = Clock::now(); + + // GPU -> CPU + { + const VkBufferImageCopy region = full_image_copy(); + begin_commands(deviceA); + cmd_image_barrier(deviceA.commandBuffer, imageA.image, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, + VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, 0, + VK_PIPELINE_STAGE_TRANSFER_BIT, VK_ACCESS_TRANSFER_READ_BIT); + vkCmdCopyImageToBuffer(deviceA.commandBuffer, imageA.image, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, + stagingA.buffer, 1, ®ion); + cmd_buffer_barrier(deviceA.commandBuffer, stagingA.buffer, kImageBytes, VK_PIPELINE_STAGE_TRANSFER_BIT, + VK_ACCESS_TRANSFER_WRITE_BIT, VK_PIPELINE_STAGE_HOST_BIT, VK_ACCESS_HOST_READ_BIT); + submit_and_wait(deviceA); + } + + { + void* pointer = map_memory(deviceA.device, stagingA.memory, kImageBytes, "vkMapMemory (relecture A)"); + invalidate_mapped_memory(deviceA.device, stagingA.memory); + std::memcpy(hostPixels.data(), pointer, hostPixels.size()); + vkUnmapMemory(deviceA.device, stagingA.memory); + } + + if (iteration == 0) { + roundtripOk = first_mismatch(pattern, hostPixels.data(), hostPixels.size()) == hostPixels.size(); + } + + // CPU -> GPU + { + void* pointer = map_memory(deviceA.device, stagingA.memory, kImageBytes, "vkMapMemory (renvoi A)"); + std::memcpy(pointer, hostPixels.data(), hostPixels.size()); + flush_mapped_memory(deviceA.device, stagingA.memory); + vkUnmapMemory(deviceA.device, stagingA.memory); + + const VkBufferImageCopy region = full_image_copy(); + begin_commands(deviceA); + cmd_buffer_barrier(deviceA.commandBuffer, stagingA.buffer, kImageBytes, VK_PIPELINE_STAGE_HOST_BIT, + VK_ACCESS_HOST_WRITE_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_ACCESS_TRANSFER_READ_BIT); + cmd_image_barrier(deviceA.commandBuffer, imageA.image, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, + VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, + VK_PIPELINE_STAGE_TRANSFER_BIT, VK_ACCESS_TRANSFER_WRITE_BIT); + vkCmdCopyBufferToImage(deviceA.commandBuffer, stagingA.buffer, imageA.image, + VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1, ®ion); + cmd_image_barrier(deviceA.commandBuffer, imageA.image, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, + VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, VK_PIPELINE_STAGE_TRANSFER_BIT, + VK_ACCESS_TRANSFER_WRITE_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, + VK_ACCESS_TRANSFER_READ_BIT); + submit_and_wait(deviceA); + } + + roundtripSamples.push_back(elapsed_ms(roundtripStart)); + } + + std::sort(roundtripSamples.begin(), roundtripSamples.end()); + const double roundtripMin = roundtripSamples.front(); + const double roundtripMedian = roundtripSamples[roundtripSamples.size() / 2]; + + std::printf("[9] Aller-retour GPU->CPU->GPU de reference (%d essais)\n", kRoundtripIterations); + for (size_t index = 0; index < roundtripSamples.size(); ++index) { + std::printf(" echantillon %llu (trie) : %.3f ms\n", static_cast(index + 1), + roundtripSamples[index]); + } + std::printf(" min %.3f ms, mediane %.3f ms, contenu %s\n", roundtripMin, roundtripMedian, + roundtripOk ? "identique" : "DIFFERENT"); + + // --- Resume ------------------------------------------------------------- + std::printf("\n=== RESULTATS ===\n"); + std::printf(" Export HANDLE Win32 : %8.3f ms\n", exportMs); + std::printf(" Import dans un 2e device : %8.3f ms\n", importMs); + std::printf(" Aller-retour GPU->CPU->GPU : %8.3f ms (mediane de %d essais)\n", roundtripMedian, + kRoundtripIterations); + std::printf(" Verification octet a octet : %s\n", identical ? "OK" : "ECHEC"); + + if (!identical) { + std::printf("\nECHEC : le contenu importe differe du motif.\n"); + return 2; + } + std::printf("\nOK : texture Vulkan partagee entre deux devices sans copie CPU.\n"); + return 0; +} + +} // namespace + +int main() +{ + try { + return run(); + } catch (const std::exception& error) { + std::printf("\nERREUR : %s\n", error.what()); + return 1; + } +} diff --git a/studio/README.md b/studio/README.md new file mode 100644 index 0000000..0df80d9 --- /dev/null +++ b/studio/README.md @@ -0,0 +1,63 @@ +# SEQUA Studio + +**SEQUA** signifie *Simulate Environments, Quantify Uncertainty, Adapt* : simuler des environnements, quantifier l'incertitude liée à leur représentation et aux traitements, puis adapter les méthodes de calcul et de rendu au contexte. SEQUA Engine réunit quatre couches : **Studio** (la création), **Core** (la source de vérité : projet, simulation déterministe, rejeu, intentions, orchestrateur de rendu, confiance), **SEQUA 3D** (le contrat de données et la synchronisation vers les moteurs) et des **moteurs 3D interchangeables** (Godot, puis Unreal, à terme un moteur maison). SEQUA possède le projet et pilote les moteurs ; il n'est pas un plugin d'un autre moteur. + +## Rôle de Studio + +Studio est le **cœur et le visage du produit** : c'est là que l'auteur exprime son intention, règle le ressenti, compose les modes de jeu et compare des variantes. Studio est une application web TypeScript indépendante de tout moteur ; il ne parle au Core que par un **protocole** (WebSocket et schéma partagé, Protobuf ou FlatBuffers — format non encore choisi). Son conteneur (navigateur, webview système, CEF) est un détail remplaçable. + +L'interface est une **vue d'un modèle d'état sérialisable** : elle ne porte aucune logique produit. Les interactions produisent des événements, l'état évolue uniquement par une fonction pure de réduction, puis la vue est réaffichée. + +## État actuel + +Squelette uniquement, sans framework UI ni bibliothèque de composants : + +- projet Vite + TypeScript strict, tests Vitest ; +- état minimal (`connection`, `protocolVersion`, liste d'intentions vide) et réduction pure ; +- interface sobre affichant le titre, le statut de connexion et la mention **« Core simulé »** ; +- connexion **simulée** : `SimulatedCoreConnection` n'ouvre aucune socket et reproduit la séquence `connecting` → `connected`. Tout ce qui est simulé est marqué comme tel dans l'interface ; +- pas encore de protocole WebSocket réel ni de schéma partagé. + +## Commandes + +Prérequis : Node.js 24 recommandé (Vitest 5 accepte `^22.12`, `^24` et `>=26` ; Vite 8 accepte `^20.19` ou `>=22.12`). + +```bash +npm ci # installation reproductible depuis package-lock.json +npm run dev # serveur de développement Vite +npm run check # typecheck, tests, puis build de production +``` + +Autres scripts : `npm run typecheck` (`tsc --noEmit`), `npm run test` (`vitest run`), `npm run build` (`vite build`), `npm run preview`. + +## Structure + +```text +studio/ +├── index.html +├── package.json +├── tsconfig.json +├── src/ +│ ├── main.ts # montage dans #app, câblage connexion ↔ vue +│ ├── style.css # thème sombre minimal +│ ├── model/state.ts # StudioState, événements, état initial, reduce pure +│ ├── protocol/connection.ts # interface CoreConnection + connexion SIMULÉE +│ └── ui/app.ts # rendu de l'état et actions de connexion +└── tests/ + ├── state.test.ts + └── connection.test.ts +``` + +## Licences + +**SEQUA Studio est distribué sous Mozilla Public License 2.0 (MPL-2.0).** Chaque fichier source porte son identifiant SPDX. + +Dépendances directes de développement (versions et licences relevées dans `node_modules//package.json` après installation) : + +| Paquet | Version | Licence | +|---|---|---| +| vite | 8.3.6 | MIT | +| typescript | 7.0.2 | Apache-2.0 | +| vitest | 5.1.0 | MIT | + +Ce sont les seules dépendances directes. Les paquets transitifs nécessaires à Vite, TypeScript et Vitest sont verrouillés par `package-lock.json` et restent des dépendances de développement, absentes du build de production en dehors des fichiers générés par Vite. diff --git a/studio/index.html b/studio/index.html new file mode 100644 index 0000000..f9eb69a --- /dev/null +++ b/studio/index.html @@ -0,0 +1,14 @@ + + + + + + + + SEQUA Studio + + +
+ + + diff --git a/studio/package-lock.json b/studio/package-lock.json new file mode 100644 index 0000000..123ce3c --- /dev/null +++ b/studio/package-lock.json @@ -0,0 +1,1491 @@ +{ + "name": "@sequa/studio", + "version": "0.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "@sequa/studio", + "version": "0.0.0", + "license": "MPL-2.0", + "devDependencies": { + "typescript": "7.0.2", + "vite": "8.3.6", + "vitest": "5.1.0" + } + }, + "node_modules/@jridgewell/resolve-uri": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz", + "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/sourcemap-codec": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.6.0.tgz", + "integrity": "sha512-T7jf+5zgsZHwNJ4lvQ7/aezbyk0nNX+zJVWpmHA7VYsEx7a7qr5Rg5IbtJFqkgze5Y2sruq1RUY8Q837Od7iFw==", + "dev": true, + "license": "MIT" + }, + "node_modules/@jridgewell/trace-mapping": { + "version": "0.3.31", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.31.tgz", + "integrity": "sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/resolve-uri": "^3.1.0", + "@jridgewell/sourcemap-codec": "^1.4.14" + } + }, + "node_modules/@oxc-project/types": { + "version": "0.156.0", + "resolved": "https://registry.npmjs.org/@oxc-project/types/-/types-0.156.0.tgz", + "integrity": "sha512-1Duyg48TdJNdyhEB8Xn1L36bT9Pv6GUtlKjHxOys8xkaF/rQq3XJE+bAurSK/AgIz5mGFsb77cn9Pb20+WCScw==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/oxc-project" + } + }, + "node_modules/@rolldown/binding-android-arm-eabi": { + "version": "1.2.16", + "resolved": "https://registry.npmjs.org/@rolldown/binding-android-arm-eabi/-/binding-android-arm-eabi-1.2.16.tgz", + "integrity": "sha512-ia3DwAs0OsMGS7+IConptSiyk9pEXkOx/AbJ2n/lAGxH3QkWQus1t8d7gnAT38FCU2sQu8lUbeR6AiZFv4JxaA==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-android-arm64": { + "version": "1.2.16", + "resolved": "https://registry.npmjs.org/@rolldown/binding-android-arm64/-/binding-android-arm64-1.2.16.tgz", + "integrity": "sha512-kx5wBiMB6E7TEvpl2B9gjLU004BkvEm2Dr941BFjx/SontPwSzNuQUIoVKxHHoSjpFIfHMmcguyLOtyn0hObRg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-darwin-arm64": { + "version": "1.2.16", + "resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-arm64/-/binding-darwin-arm64-1.2.16.tgz", + "integrity": "sha512-qslZrXnKJU4cUpjoAmtAo/KQM9e2IRMlmpig6Zpwj+8KWxW8v+nkAf9216Bsek9lOC1jvg2yCjygCFo2f83msQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-darwin-x64": { + "version": "1.2.16", + "resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-x64/-/binding-darwin-x64-1.2.16.tgz", + "integrity": "sha512-FdF+y48ND13eAyM2mQn+85kvAqNlvRWROy2rhgA463X/0Gv4vGtazZtfaF1mRBLscYvtOlh4QnLjOWiFzX69OQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-freebsd-x64": { + "version": "1.2.16", + "resolved": "https://registry.npmjs.org/@rolldown/binding-freebsd-x64/-/binding-freebsd-x64-1.2.16.tgz", + "integrity": "sha512-ddjqFM5e95AgLbUPtKIS7V1KTVlA0RUgCVr5mn+/IEhsdy3pr+Vuj/HZ7nlMN2FyxIwUktOH1LEPIQXO1v9y1Q==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-arm-gnueabihf": { + "version": "1.2.16", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm-gnueabihf/-/binding-linux-arm-gnueabihf-1.2.16.tgz", + "integrity": "sha512-tHdKWbFkFBI687iim3LIyIvyL7j66VvQYkDPss5Stn/qyE2tWkR1YD0dXmXPFKKqT/o5ZEJVsaRsWS2meQwGOA==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-arm64-gnu": { + "version": "1.2.16", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-gnu/-/binding-linux-arm64-gnu-1.2.16.tgz", + "integrity": "sha512-FJiLGAblPBMlBEdbOqw6kW6QcXDWAf/oJu7gYs9ZJZwmg+K+/zjFLxPTIY9izJUzxzc24FHvmseyA0IvJSl17w==", + "cpu": [ + "arm64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-arm64-musl": { + "version": "1.2.16", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-musl/-/binding-linux-arm64-musl-1.2.16.tgz", + "integrity": "sha512-hrJpblMsrQ58U9veWpbXzkhV5zStunds6HWLprqq1qauvgBr1E6P+24kLj6lSLI9vjRn/RYpjprhkHQPKGWpNg==", + "cpu": [ + "arm64" + ], + "dev": true, + "libc": [ + "musl" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-ppc64-gnu": { + "version": "1.2.16", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-ppc64-gnu/-/binding-linux-ppc64-gnu-1.2.16.tgz", + "integrity": "sha512-qJd/dC6j6CwLG9/s/RP2nb1RZ0GIgj7Ioj7x/SYa3RzjVrlzrmH0fhIOpfvqQDeIsdP0loi+kHaMhJzY1PBIaA==", + "cpu": [ + "ppc64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-s390x-gnu": { + "version": "1.2.16", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-s390x-gnu/-/binding-linux-s390x-gnu-1.2.16.tgz", + "integrity": "sha512-Vx7Xg5uUJuNcujJjI70OICaH0EYj80BtOLZTSN7uOYg8QOLlyKnaG0IW7Fn/J0IpJsaKzmDKMhOQv1JBM9m9vg==", + "cpu": [ + "s390x" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-x64-gnu": { + "version": "1.2.16", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-gnu/-/binding-linux-x64-gnu-1.2.16.tgz", + "integrity": "sha512-TNKhgE3uJTsTzatUSSYt0Kgo+Oa2uSlSjz4r1aEIea7HX6ULBym4fAlYUhG1i6pjNf2njfCUAfKwr6C3E9Xg1w==", + "cpu": [ + "x64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-x64-musl": { + "version": "1.2.16", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-musl/-/binding-linux-x64-musl-1.2.16.tgz", + "integrity": "sha512-7chXdpjXZ8qG0+mIxECN3cT9kvhZ3/oZhMX6Pp876P7CDrIy8nJswva6Mq357JR7eYXfuskwZxMeV1SzoZdHrA==", + "cpu": [ + "x64" + ], + "dev": true, + "libc": [ + "musl" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-openharmony-arm64": { + "version": "1.2.16", + "resolved": "https://registry.npmjs.org/@rolldown/binding-openharmony-arm64/-/binding-openharmony-arm64-1.2.16.tgz", + "integrity": "sha512-Kwjt+7uNTJK5/MDkGWGVO2KQPnj8yAV75dMpfwyHZrJSXWHrniOB0aUEWlVYf3H1hOqFLIStLdM5QXq6bnKmOQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-win32-arm64-msvc": { + "version": "1.2.16", + "resolved": "https://registry.npmjs.org/@rolldown/binding-win32-arm64-msvc/-/binding-win32-arm64-msvc-1.2.16.tgz", + "integrity": "sha512-/LH6WfjDRXXJz/p5xl4TmU+jpcnwcxbKEQBW/GZE0JHfN0lGIyTtsUEGaQ/q/GikkGJ2yLKe6pwm7AnEWO8pdw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-win32-x64-msvc": { + "version": "1.2.16", + "resolved": "https://registry.npmjs.org/@rolldown/binding-win32-x64-msvc/-/binding-win32-x64-msvc-1.2.16.tgz", + "integrity": "sha512-1lv1KvX0Z871zfk7vw+dnXMMnHNyDwMzWG8Kv3HxDXMOhzCX4SHc7HK319fInP0i+0p9D8brkfzL7pJOaGl+tw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/pluginutils": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@rolldown/pluginutils/-/pluginutils-1.0.1.tgz", + "integrity": "sha512-2j9bGt5Jh8hj+vPtgzPtl72j0yRxHAyumoo6TNfAjsLB04UtpSvPbPcDcBMxz7n+9CYB0c1GxQFxYRg2jimqGw==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/chai": { + "version": "5.2.3", + "resolved": "https://registry.npmjs.org/@types/chai/-/chai-5.2.3.tgz", + "integrity": "sha512-Mw558oeA9fFbv65/y4mHtXDs9bPnFMZAL/jxdPFUpOHHIXX91mcgEHbS5Lahr+pwZFR8A7GQleRWeI6cGFC2UA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/deep-eql": "*", + "assertion-error": "^2.0.1" + } + }, + "node_modules/@types/deep-eql": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/@types/deep-eql/-/deep-eql-4.0.2.tgz", + "integrity": "sha512-c9h9dVVMigMPc4bwTvC5dxqtqJZwQPePsWjPlpSOnojbor6pGqdk541lfA7AqFQr5pB1BRdq0juY9db81BwyFw==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/estree": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.10.tgz", + "integrity": "sha512-lTyOMnOcmRBzdCv6/4zUZCrEhV0xrqQiUZBZtVcbmLHBXKLnN8q89v/wKRF/Q0HbwVsqbIG3o5HDoFl9sduM+g==", + "dev": true, + "license": "MIT" + }, + "node_modules/@typescript/typescript-aix-ppc64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-aix-ppc64/-/typescript-aix-ppc64-7.0.2.tgz", + "integrity": "sha512-MTKKkWB7p/0E9xi1d1tHtZ5PiLkGEMIq88pK2CubZjOsLtYTLqhgIgi6zepFa+9GHZ6h05NMCkQxGKiPXMxXtQ==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "aix" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-darwin-arm64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-darwin-arm64/-/typescript-darwin-arm64-7.0.2.tgz", + "integrity": "sha512-gowzar9MwS/aRWp6f3a4KUqzRjAZjOsmGNCM6LcTgXum+dBfgsBVMN+AgvOCCbguXyick6LJhpBszxMebJ8syA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-darwin-x64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-darwin-x64/-/typescript-darwin-x64-7.0.2.tgz", + "integrity": "sha512-SZ9xZInqApNlNGc9s0W1VSsktYSOe9cFqNOIqmN1Gs8SmkjKZYFt017G4VwPxASInODuAdbTW7sXiFUf893RgA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-freebsd-arm64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-freebsd-arm64/-/typescript-freebsd-arm64-7.0.2.tgz", + "integrity": "sha512-W5NH4y/J0plIIS5b2xvTEkU7JFxyqdMAOgf+Ilhl0vHQXKO5dZoxd+C/jEtq56c4F3wk71RB4BMRQ2XdI+bwYQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-freebsd-x64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-freebsd-x64/-/typescript-freebsd-x64-7.0.2.tgz", + "integrity": "sha512-UMGDx5sTpzNw3WiPebH7l90IWfJggEd+egHt/q6p7/Cm3zqoV7VxkGXt+3DxPIw8CcmvAB0j3sVVfbhX+M4Tpw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-linux-arm": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-linux-arm/-/typescript-linux-arm-7.0.2.tgz", + "integrity": "sha512-gffT3xPz9sR7j/YJExkyPntrI0P2EP9XbOyWzth2/Gs0RstK+90RBcO0ncXoXy/beYll1SXw846Nf2zdnEz0QQ==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-linux-arm64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-linux-arm64/-/typescript-linux-arm64-7.0.2.tgz", + "integrity": "sha512-Qh4eU4/y3yDjnfjjyPYihMj5/ODIlmt+Bzu17OI+fiSRDW57QmU5SiN63exPRNJPKUzcc1INa1NXdrJ+MqHjUQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-linux-loong64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-linux-loong64/-/typescript-linux-loong64-7.0.2.tgz", + "integrity": "sha512-uEHck9i8hoAzXPiYRib1O7miOnz23SxIeVl6F4LXox+qov1K35jHcEW6VHKvZI+pyvl7fZEP4MCU5LYvIq1GuQ==", + "cpu": [ + "loong64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-linux-mips64el": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-linux-mips64el/-/typescript-linux-mips64el-7.0.2.tgz", + "integrity": "sha512-R4KvAMnE43W5Qeqb0Ly56O3mWMWIAgsMyz36DCaycd5nbg/9kzm0liw3JocfRqyJY0KPmzFjbswozXyW0DnIYA==", + "cpu": [ + "mips64el" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-linux-ppc64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-linux-ppc64/-/typescript-linux-ppc64-7.0.2.tgz", + "integrity": "sha512-DORx5b3sd/4S7eayxm4FQv+A7CrkUIGRaHiwI8oiHTAI1fAPWhF4J0vAlkC8biAlHSVVwxMQ3tjZ2/DVbnQiiA==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-linux-riscv64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-linux-riscv64/-/typescript-linux-riscv64-7.0.2.tgz", + "integrity": "sha512-wf0jqEDOjrPRnKwYRyyJDRo11KMbvMFrU+q4zqKyChODBzvlkbhNQfKvLxQCcwTpdDaXSHZTVuh0JoCrKCUMHQ==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-linux-s390x": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-linux-s390x/-/typescript-linux-s390x-7.0.2.tgz", + "integrity": "sha512-IkwJc3L7yhytWd/ewjyxNDfOmswCm9GWMJT/ue/dU4aZNbwZeYAetq42VyLmsmSjvoX7z74X6ZaYCtzAr0EuGw==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-linux-x64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-linux-x64/-/typescript-linux-x64-7.0.2.tgz", + "integrity": "sha512-EYdf2cNg7rgCWJnxCdJ+F3V39O8ihb37eHAu1LK8oAFizgTQbPOK7zHHXbPt8rX24COqODXeI3sIf0fCXG7H/A==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-netbsd-arm64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-netbsd-arm64/-/typescript-netbsd-arm64-7.0.2.tgz", + "integrity": "sha512-+polYF4MF04aPpO5FTkHran9yUQDSXqy5GiSDKpsll5jy3l3+g9QLhpf39T+ePtefhXLOGrLl0QIjkQP6VnelA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-netbsd-x64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-netbsd-x64/-/typescript-netbsd-x64-7.0.2.tgz", + "integrity": "sha512-8YIT0EHM/3dq10ZOVF/A7pc/YSMtbcecct4rWtexrnSCHOPcpC2KTLXfTCR6vDpnSiY12heNb1GiN/wu+T/FyA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-openbsd-arm64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-openbsd-arm64/-/typescript-openbsd-arm64-7.0.2.tgz", + "integrity": "sha512-APT8+ClYnuYm1u9+kgGXoMj2VzWzcymwh2gNSQVySHfkRDGOTVkoWLjCmOQSaO+PoqQ57B0flRp9SA+7GnnkzQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-openbsd-x64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-openbsd-x64/-/typescript-openbsd-x64-7.0.2.tgz", + "integrity": "sha512-yX7s+Q0Dln0Dt9tEzZsAjXXR/+ytBM7AlglaqyeMPxQszJ1JhlJdZ6jLA+IzldHtflX81em7lDao1xXu+aRRkg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-sunos-x64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-sunos-x64/-/typescript-sunos-x64-7.0.2.tgz", + "integrity": "sha512-dLJDGaLZ1D4HPQn62u1n8mBDkJREwMsAkCdkwd4Ieqw+x3TUyTsqY0YiBCtE6H6OzzgGk3iuZ3vFWRS+E8/d1g==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "sunos" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-win32-arm64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-win32-arm64/-/typescript-win32-arm64-7.0.2.tgz", + "integrity": "sha512-Gyl1Vy6OsWesLzmq+EP0Fb7b4Nid5232AvcA2SFcdYreldpNtYFFofPjnt62y9hQy7VTaZp65ICJjuAQRaVcIQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-win32-x64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-win32-x64/-/typescript-win32-x64-7.0.2.tgz", + "integrity": "sha512-0BQ3HkAHHlKLSp1qRvf3SUhGpGsDuhB/jgFw75guyqbxJqEaS0Cw/VFO8i2nHglJUzQCRtMMR/IBAKE3ETMC4g==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@vitest/mocker": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/@vitest/mocker/-/mocker-5.1.0.tgz", + "integrity": "sha512-5umB9/jlWcqVS6fsrFmv5Gdnpu6wAUio/lEOwAmvB7v+lFo/IW2B9FhAD0p19GCULTgMzLCdUmuCDCnAzWgppQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/trace-mapping": "0.3.31", + "@vitest/spy": "5.1.0", + "estree-walker": "^3.0.3", + "magic-string": "^1.4.3" + }, + "funding": { + "url": "https://opencollective.com/vitest" + }, + "peerDependencies": { + "msw": "^2.4.9 || ^3.0.0", + "vite": "^6.0.0 || ^7.0.0 || ^8.0.0" + }, + "peerDependenciesMeta": { + "msw": { + "optional": true + }, + "vite": { + "optional": true + } + } + }, + "node_modules/@vitest/spy": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/@vitest/spy/-/spy-5.1.0.tgz", + "integrity": "sha512-2DPO5OMHWKrBngC+fCmTQqemNF0gidRhp3lxbBmRhW+M1XJrfgPpqNqWVevXtn2f2ufD5ZaR1B6B641aAlcX5A==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/assertion-error": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-2.0.1.tgz", + "integrity": "sha512-Izi8RQcffqCeNVgFigKli1ssklIbpHnCYc6AknXGYoB6grJqyeby7jv12JUQgmTAnIDnbck1uxksT4dzN3PWBA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + } + }, + "node_modules/chai": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/chai/-/chai-6.3.0.tgz", + "integrity": "sha512-XWAtwJ6OHO+tj0EKCs0Y2UamnyOxseZWltU4x2U2wh8g4AigdjwvtUjvLP2tqkA/avxHEtzxNaqGq/YGNwckKg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + } + }, + "node_modules/detect-libc": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.1.2.tgz", + "integrity": "sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=8" + } + }, + "node_modules/es-module-lexer": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-2.3.2.tgz", + "integrity": "sha512-poHGpORABojJJucnV9KbOavETW8lBVnphkW77ER5/BQ5Fz7oXSoCNek7IH3vR5nRjdsEz926ibFYX8KtLQmdyw==", + "dev": true, + "license": "MIT" + }, + "node_modules/estree-walker": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-3.0.3.tgz", + "integrity": "sha512-7RUKfXgSMMkzt6ZuXmqapOurLGPPfgj6l9uRZ7lRGolvk0y2yocc35LdcxKC5PQZdn2DMqioAQ2NoWcrTKmm6g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/estree": "^1.0.0" + } + }, + "node_modules/expect-type": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/expect-type/-/expect-type-1.4.0.tgz", + "integrity": "sha512-KfYbmpRm0VbLjEvVa9yGwCi9GI34xvi7A/HXYWQO65CSD2u3MczUJSuwXKFIxlGsgBQizV9q5J9NHj4VG0n+pA==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=12.0.0" + } + }, + "node_modules/fdir": { + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz", + "integrity": "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12.0.0" + }, + "peerDependencies": { + "picomatch": "^3 || ^4" + }, + "peerDependenciesMeta": { + "picomatch": { + "optional": true + } + } + }, + "node_modules/fsevents": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/lightningcss": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss/-/lightningcss-1.33.0.tgz", + "integrity": "sha512-WkUDrojuJs0xkgGf2udWxa3yGBRxPtxUkB79i6aCZLRgc7PM8fZe9TosfPDcvEpQZbuFASnHYmRLBLUbmLOIIA==", + "dev": true, + "license": "MPL-2.0", + "dependencies": { + "detect-libc": "^2.0.3" + }, + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + }, + "optionalDependencies": { + "lightningcss-android-arm64": "1.33.0", + "lightningcss-darwin-arm64": "1.33.0", + "lightningcss-darwin-x64": "1.33.0", + "lightningcss-freebsd-x64": "1.33.0", + "lightningcss-linux-arm-gnueabihf": "1.33.0", + "lightningcss-linux-arm64-gnu": "1.33.0", + "lightningcss-linux-arm64-musl": "1.33.0", + "lightningcss-linux-x64-gnu": "1.33.0", + "lightningcss-linux-x64-musl": "1.33.0", + "lightningcss-win32-arm64-msvc": "1.33.0", + "lightningcss-win32-x64-msvc": "1.33.0" + } + }, + "node_modules/lightningcss-android-arm64": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-android-arm64/-/lightningcss-android-arm64-1.33.0.tgz", + "integrity": "sha512-gEpRTalKdosp4Bb8qWtc2iOgE5SeIHlpS1up9bFq2wAyYhl1UdTObYiHe98zEM9SQvSoqQZ1IQD0JNpg3Ml5pg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-darwin-arm64": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-darwin-arm64/-/lightningcss-darwin-arm64-1.33.0.tgz", + "integrity": "sha512-Sciaz8eenNTKn9b3t7+xr0ipTp9YxKQY4npwQ3mrRuL0BAVHBLyZxofhaKBAVtzmtRZ/zTyo0/to4B1uWG/Djg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-darwin-x64": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-darwin-x64/-/lightningcss-darwin-x64-1.33.0.tgz", + "integrity": "sha512-Z5UPAxzrjlWNNyGy6i65cJzzvgJ5D3T6wMvs+gWpY9d7qRhANrxqAp6LhxIgZhWEw18RfJTGcRxjuLIBr+m8XQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-freebsd-x64": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-freebsd-x64/-/lightningcss-freebsd-x64-1.33.0.tgz", + "integrity": "sha512-QQM/Ti/hQajJwCY+RiWuCZ9sdtI/XQk7nDK5vC8kkdwixezOlDgvDx7+RT+QjK6FcFT4MpsuoBnHIo/O3StRRg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-linux-arm-gnueabihf": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-arm-gnueabihf/-/lightningcss-linux-arm-gnueabihf-1.33.0.tgz", + "integrity": "sha512-N7FVBe6iS24MlM6R/4RBTxGhQheZGs7tiQ9U32UtF75NzP5Q7xWPRqLBCKxlRQRk3rY1jCIPLzx7WzOhuUIRLQ==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-linux-arm64-gnu": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-arm64-gnu/-/lightningcss-linux-arm64-gnu-1.33.0.tgz", + "integrity": "sha512-j2v/itmy4HlNxlc6voKXYgBqNi0Ng2LShg4z7GufpEgs05P+2suBVyi9I6YHq5uoVFx9ETin3eCEhLVyXGQnKg==", + "cpu": [ + "arm64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MPL-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-linux-arm64-musl": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-arm64-musl/-/lightningcss-linux-arm64-musl-1.33.0.tgz", + "integrity": "sha512-yiO5ROMuYQgXbC60yjZU5CYSFZGKXL0HFATXt9mHJn1+zW55oCtMI9NfcVhYLMFDL7gV7oBPon/EmMMGg2OvtQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "libc": [ + "musl" + ], + "license": "MPL-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-linux-x64-gnu": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-x64-gnu/-/lightningcss-linux-x64-gnu-1.33.0.tgz", + "integrity": "sha512-ar+Ju7LmcN0Jo4FpL4hpFybwNG9/3A/Br5KW2n2jyODg3MEZXaDYADdemoNS+BDNfMgKvylJLj4S5tyRActuAg==", + "cpu": [ + "x64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MPL-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-linux-x64-musl": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-x64-musl/-/lightningcss-linux-x64-musl-1.33.0.tgz", + "integrity": "sha512-RYiYbkokw0trfKqqzfF55lginwEPrD3OJDfTuJzFs1MK6iFnDenaz1fqLLtX4ITG3OktJQXOeTaw1awrBAlZPw==", + "cpu": [ + "x64" + ], + "dev": true, + "libc": [ + "musl" + ], + "license": "MPL-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-win32-arm64-msvc": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-win32-arm64-msvc/-/lightningcss-win32-arm64-msvc-1.33.0.tgz", + "integrity": "sha512-1K+MPfLSFVpphzpdbfkhlWk6wBrTObBzS2T6db10PNOZgR9GoVsAWzwNyuhUYYbTp23j+4RrncfujZ4uAzXvwA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-win32-x64-msvc": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-win32-x64-msvc/-/lightningcss-win32-x64-msvc-1.33.0.tgz", + "integrity": "sha512-OlEICDx/Xl0FqSp4bry8zFnCvGpig3Gl4gCquvYwHuqJKEC1+n9NgDniFvqHGmMv1ZkqDJrDqKKSykTDX+ehuA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/magic-string": { + "version": "1.4.5", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-1.4.5.tgz", + "integrity": "sha512-oLLC2+YvQUfAa+vxoufE/yc1icb87M9iXIRqAoR/2EhE/8cb3SF/+Gi0c2By1B+5Vz2e2vQtUvHiu1+63Znh+w==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.6.0" + } + }, + "node_modules/nanoid": { + "version": "3.3.20", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.20.tgz", + "integrity": "sha512-uKdg2G3GNCKQn9byYOpxbGqrT2fGO5KRt5J/8b3pok8rT6qxGWF6hxMyJiEYtAf+FVyYuD9hRaDqX5uPFYJ4ZQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "bin": { + "nanoid": "bin/nanoid.cjs" + }, + "engines": { + "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" + } + }, + "node_modules/obug": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/obug/-/obug-3.0.0.tgz", + "integrity": "sha512-5vvB5+W7ePv+p3uqxi+RcW1XAzLW0/hxt3/4X4Lc4qHudzOhmBiBwOY6DRob4WnanAEGvNcLjF+KNOufrUoEQw==", + "dev": true, + "funding": [ + "https://github.com/sponsors/sxzz", + "https://opencollective.com/debug" + ], + "license": "MIT", + "engines": { + "node": ">=12.20.0" + } + }, + "node_modules/picocolors": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", + "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==", + "dev": true, + "license": "ISC" + }, + "node_modules/picomatch": { + "version": "4.0.7", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.7.tgz", + "integrity": "sha512-qcJu88Q2IWqJsDD529JKMdwGm/dvInW4HvQnRwiH9JtihJvzGOscDtHE3x1pBKeUOTysQ8kVmLnJ2kJu7yhcGA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/postcss": { + "version": "8.5.32", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.32.tgz", + "integrity": "sha512-LJlKCCAUFKOuZxipUdYw1NzIITEsPcgyOG9LkvRJvuKj/bRzbuRY0ARXvL0pWGpsZvn8jku+LMep2eU0seHp8g==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/postcss" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "nanoid": "^3.3.20", + "picocolors": "^1.1.1", + "source-map-js": "^1.2.2" + }, + "engines": { + "node": "^10 || ^12 || >=14" + } + }, + "node_modules/rolldown": { + "version": "1.2.16", + "resolved": "https://registry.npmjs.org/rolldown/-/rolldown-1.2.16.tgz", + "integrity": "sha512-bWvlMpFKiTfDKfnK7FC2MPgPeWCf/Kpwsq49ApdW+FQaBZb6O6dZ4MAPbPUjp7hYQrw/RobqCzn64BRrQecGHw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@oxc-project/types": "=0.156.0", + "@rolldown/pluginutils": "^1.0.0" + }, + "bin": { + "rolldown": "bin/cli.mjs" + }, + "engines": { + "node": "^20.19.0 || >=22.12.0" + }, + "optionalDependencies": { + "@rolldown/binding-android-arm-eabi": "1.2.16", + "@rolldown/binding-android-arm64": "1.2.16", + "@rolldown/binding-darwin-arm64": "1.2.16", + "@rolldown/binding-darwin-x64": "1.2.16", + "@rolldown/binding-freebsd-x64": "1.2.16", + "@rolldown/binding-linux-arm-gnueabihf": "1.2.16", + "@rolldown/binding-linux-arm64-gnu": "1.2.16", + "@rolldown/binding-linux-arm64-musl": "1.2.16", + "@rolldown/binding-linux-ppc64-gnu": "1.2.16", + "@rolldown/binding-linux-s390x-gnu": "1.2.16", + "@rolldown/binding-linux-x64-gnu": "1.2.16", + "@rolldown/binding-linux-x64-musl": "1.2.16", + "@rolldown/binding-openharmony-arm64": "1.2.16", + "@rolldown/binding-win32-arm64-msvc": "1.2.16", + "@rolldown/binding-win32-x64-msvc": "1.2.16" + } + }, + "node_modules/source-map-js": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.2.tgz", + "integrity": "sha512-KGj/8Y43x35aZVDtt+J4mK1hoLGHULMYfSkODJNQjNDC3oW1PqPoxMwo0pLUsWM/UEGzON/NxeHywEfNXNP3Vw==", + "dev": true, + "license": "BSD-3-Clause", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/std-env": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/std-env/-/std-env-4.3.0.tgz", + "integrity": "sha512-OtU/EgQ1kIm5KwqQpBC6ZEMXrZRui11w8zgfTWp8cdO9B8OaPsbA8bTHO2P+HNo1VlUTGMVBwPhydu6poeXiag==", + "dev": true, + "license": "MIT" + }, + "node_modules/tinybench": { + "version": "6.2.3", + "resolved": "https://registry.npmjs.org/tinybench/-/tinybench-6.2.3.tgz", + "integrity": "sha512-Al01C2JIBnO2CXCAPbpAl6sUiOZHeThGtHYNTa51JRw9PyWOCdr+9Ong05R4qg/Sk3+H645E8ov1h2c58ityNw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/tinyexec": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/tinyexec/-/tinyexec-1.3.1.tgz", + "integrity": "sha512-GCvB3aoys96IuDFBMcTB46JOR6mdMtAToqwiW8JlWhsoh1mhHi/xn9ss/Dg7N555GiJyEt2qzoG/NHCwM6h1EA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + } + }, + "node_modules/tinyglobby": { + "version": "0.2.17", + "resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.17.tgz", + "integrity": "sha512-wXR/dYpcqKmfWpEdZjiKJOwCNFndD0DMnrW/cYjVGttEkBfVgcLFHoNrlj47mjOVic9yyNu65alsgF4NQyTa2g==", + "dev": true, + "license": "MIT", + "dependencies": { + "fdir": "^6.5.0", + "picomatch": "^4.0.4" + }, + "engines": { + "node": ">=12.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/SuperchupuDev" + } + }, + "node_modules/typescript": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-7.0.2.tgz", + "integrity": "sha512-8FYau96o3NKOhbjKi/qNvG/W5jhzxkbdm5sj9AbZ/5T5sWqn3hJgLfGx27sRKZWTvyzCP8dLRBTf5tBTSRVUNA==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc" + }, + "engines": { + "node": ">=16.20.0" + }, + "optionalDependencies": { + "@typescript/typescript-aix-ppc64": "7.0.2", + "@typescript/typescript-darwin-arm64": "7.0.2", + "@typescript/typescript-darwin-x64": "7.0.2", + "@typescript/typescript-freebsd-arm64": "7.0.2", + "@typescript/typescript-freebsd-x64": "7.0.2", + "@typescript/typescript-linux-arm": "7.0.2", + "@typescript/typescript-linux-arm64": "7.0.2", + "@typescript/typescript-linux-loong64": "7.0.2", + "@typescript/typescript-linux-mips64el": "7.0.2", + "@typescript/typescript-linux-ppc64": "7.0.2", + "@typescript/typescript-linux-riscv64": "7.0.2", + "@typescript/typescript-linux-s390x": "7.0.2", + "@typescript/typescript-linux-x64": "7.0.2", + "@typescript/typescript-netbsd-arm64": "7.0.2", + "@typescript/typescript-netbsd-x64": "7.0.2", + "@typescript/typescript-openbsd-arm64": "7.0.2", + "@typescript/typescript-openbsd-x64": "7.0.2", + "@typescript/typescript-sunos-x64": "7.0.2", + "@typescript/typescript-win32-arm64": "7.0.2", + "@typescript/typescript-win32-x64": "7.0.2" + } + }, + "node_modules/vite": { + "version": "8.3.6", + "resolved": "https://registry.npmjs.org/vite/-/vite-8.3.6.tgz", + "integrity": "sha512-UI7dK29NnS54Fk+mmo7o+jI6U8Fp7hDl+X5Q1k45WH+d4dSlbLVUETGQ+hfkNgvLQGyoElPj837nZyv4MBc0VA==", + "dev": true, + "license": "MIT", + "dependencies": { + "lightningcss": "^1.33.0", + "picomatch": "^4.0.7", + "postcss": "^8.5.32", + "rolldown": "~1.2.16", + "tinyglobby": "^0.2.17" + }, + "bin": { + "vite": "bin/vite.js" + }, + "engines": { + "node": "^20.19.0 || >=22.12.0" + }, + "funding": { + "url": "https://github.com/vitejs/vite?sponsor=1" + }, + "optionalDependencies": { + "fsevents": "~2.3.3" + }, + "peerDependencies": { + "@types/node": "^20.19.0 || >=22.12.0", + "@vitejs/devtools": "^0.7.1 || ^0.8.0", + "esbuild": "^0.27.0 || ^0.28.0", + "jiti": ">=1.21.0", + "less": "^4.0.0", + "sass": "^1.70.0", + "sass-embedded": "^1.70.0", + "stylus": ">=0.54.8", + "sugarss": "^5.0.0", + "terser": "^5.16.0", + "tsx": "^4.8.1", + "yaml": "^2.4.2" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + }, + "@vitejs/devtools": { + "optional": true + }, + "esbuild": { + "optional": true + }, + "jiti": { + "optional": true + }, + "less": { + "optional": true + }, + "sass": { + "optional": true + }, + "sass-embedded": { + "optional": true + }, + "stylus": { + "optional": true + }, + "sugarss": { + "optional": true + }, + "terser": { + "optional": true + }, + "tsx": { + "optional": true + }, + "yaml": { + "optional": true + } + } + }, + "node_modules/vitest": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/vitest/-/vitest-5.1.0.tgz", + "integrity": "sha512-MzmNFnrwa8v8lF1bLxw3UJ4EREwVOVb75VqJZmUDRjJ6EluK/x9th7qTbaeDk41WxE1GxWqmTXcdsfobfH5sOA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/chai": "^5.2.2", + "@vitest/mocker": "5.1.0", + "chai": "^6.3.0", + "es-module-lexer": "^2.3.2", + "expect-type": "^1.4.0", + "magic-string": "^1.4.3", + "obug": "^3.0.0", + "picomatch": "^4.0.7", + "std-env": "^4.3.0", + "tinybench": "^6.2.2", + "tinyexec": "^1.3.1", + "tinyglobby": "^0.2.17", + "why-is-node-running": "3.2.1" + }, + "bin": { + "vitest": "vitest.mjs" + }, + "engines": { + "node": "^22.12.0 || ^24.0.0 || >=26.0.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + }, + "peerDependencies": { + "@edge-runtime/vm": "*", + "@opentelemetry/api": "^1.9.0", + "@types/node": "^22.0.0 || >=24.0.0", + "@vitest/browser-playwright": "5.1.0", + "@vitest/browser-preview": "5.1.0", + "@vitest/browser-webdriverio": "^5.0.0-beta.5 || >=5.0.0", + "@vitest/coverage-istanbul": "5.1.0", + "@vitest/coverage-v8": "5.1.0", + "@vitest/ui": "5.1.0", + "happy-dom": "*", + "jsdom": "*", + "vite": "^6.4.0 || ^7.0.0 || ^8.0.0" + }, + "peerDependenciesMeta": { + "@edge-runtime/vm": { + "optional": true + }, + "@opentelemetry/api": { + "optional": true + }, + "@types/node": { + "optional": true + }, + "@vitest/browser-playwright": { + "optional": true + }, + "@vitest/browser-preview": { + "optional": true + }, + "@vitest/browser-webdriverio": { + "optional": true + }, + "@vitest/coverage-istanbul": { + "optional": true + }, + "@vitest/coverage-v8": { + "optional": true + }, + "@vitest/ui": { + "optional": true + }, + "happy-dom": { + "optional": true + }, + "jsdom": { + "optional": true + }, + "vite": { + "optional": false + } + } + }, + "node_modules/why-is-node-running": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/why-is-node-running/-/why-is-node-running-3.2.1.tgz", + "integrity": "sha512-Tb2FUhB4vUsGQlfSquQLYkApkuPAFQXGFzxWKHHumVz2dK+X1RUm/HnID4+TfIGYJ1kTcwOaCk/buYCEJr6YjQ==", + "dev": true, + "license": "MIT", + "bin": { + "why-is-node-running": "cli.js" + }, + "engines": { + "node": ">=20.11" + } + } + } +} diff --git a/studio/package.json b/studio/package.json new file mode 100644 index 0000000..e2fc36f --- /dev/null +++ b/studio/package.json @@ -0,0 +1,20 @@ +{ + "name": "@sequa/studio", + "version": "0.0.0", + "private": true, + "license": "MPL-2.0", + "type": "module", + "scripts": { + "dev": "vite", + "build": "vite build", + "preview": "vite preview", + "typecheck": "tsc --noEmit", + "test": "vitest run", + "check": "npm run typecheck && npm run test && npm run build" + }, + "devDependencies": { + "typescript": "7.0.2", + "vite": "8.3.6", + "vitest": "5.1.0" + } +} diff --git a/studio/src/.gitkeep b/studio/src/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/studio/src/main.ts b/studio/src/main.ts new file mode 100644 index 0000000..e9cc48c --- /dev/null +++ b/studio/src/main.ts @@ -0,0 +1,33 @@ +// SPDX-License-Identifier: MPL-2.0 + +import './style.css'; +import { createInitialState } from './model/state'; +import { SimulatedCoreConnection } from './protocol/connection'; +import { mountApp } from './ui/app'; + +const root = document.querySelector('#app'); + +if (root === null) { + throw new Error('Élément #app introuvable dans index.html'); +} + +// SIMULÉ : aucune connexion réseau n'est établie à ce stade. +const connection = new SimulatedCoreConnection(); + +const app = mountApp({ + root, + initialState: createInitialState(), + coreLabel: connection.label, + actions: { + connect: () => { + connection.connect(); + }, + disconnect: () => { + connection.disconnect(); + }, + }, +}); + +connection.onEvent((event) => { + app.dispatch(event); +}); diff --git a/studio/src/model/state.ts b/studio/src/model/state.ts new file mode 100644 index 0000000..e0a0efa --- /dev/null +++ b/studio/src/model/state.ts @@ -0,0 +1,57 @@ +// SPDX-License-Identifier: MPL-2.0 + +/** Version du protocole Studio — Core. Aucun protocole réel n'est encore implémenté. */ +export const PROTOCOL_VERSION = '0.1.0'; + +export type ConnectionStatus = 'disconnected' | 'connecting' | 'connected'; + +/** Intention de création. La liste est volontairement vide dans le squelette. */ +export interface Intention { + readonly id: string; + readonly label: string; +} + +/** + * Modèle d'état de Studio. + * + * Il est sérialisable (JSON) et ne contient aucune logique produit : l'interface + * n'en est qu'une vue. + */ +export interface StudioState { + readonly connection: ConnectionStatus; + readonly protocolVersion: string; + readonly intentions: readonly Intention[]; +} + +/** Événements de connexion au Core, seuls événements du squelette. */ +export type StudioEvent = + | { readonly type: 'core/connecting' } + | { readonly type: 'core/connected' } + | { readonly type: 'core/disconnected' }; + +/** État initial : rien n'est connecté, aucune intention n'existe encore. */ +export function createInitialState(): StudioState { + return { + connection: 'disconnected', + protocolVersion: PROTOCOL_VERSION, + intentions: [], + }; +} + +/** + * Réduction pure : produit un nouvel état sans jamais modifier l'état reçu. + * L'interface ne change d'état que par cette fonction. + */ +export function reduce(state: StudioState, event: StudioEvent): StudioState { + switch (event.type) { + case 'core/connecting': + return { ...state, connection: 'connecting' }; + case 'core/connected': + return { ...state, connection: 'connected' }; + case 'core/disconnected': + return { ...state, connection: 'disconnected' }; + } + + const unreachable: never = event; + return unreachable; +} diff --git a/studio/src/protocol/connection.ts b/studio/src/protocol/connection.ts new file mode 100644 index 0000000..f5a61e7 --- /dev/null +++ b/studio/src/protocol/connection.ts @@ -0,0 +1,78 @@ +// SPDX-License-Identifier: MPL-2.0 + +import type { ConnectionStatus, StudioEvent } from '../model/state'; + +export type CoreEventListener = (event: StudioEvent) => void; + +/** + * Contrat de connexion au Core. + * + * Studio ne parle au Core que par protocole (WebSocket plus schéma partagé). + * Toute implémentation réelle devra respecter cette interface. + */ +export interface CoreConnection { + /** Libellé affiché par l'interface. */ + readonly label: string; + /** Vrai lorsque l'implémentation ne contacte aucun Core réel. */ + readonly simulated: boolean; + connect(): void; + disconnect(): void; + /** S'abonne aux événements ; retourne la fonction de désabonnement. */ + onEvent(listener: CoreEventListener): () => void; +} + +const STATUS_EVENTS: Record = { + disconnected: { type: 'core/disconnected' }, + connecting: { type: 'core/connecting' }, + connected: { type: 'core/connected' }, +}; + +/** + * SIMULÉ — cette implémentation ne contacte aucun Core. + * + * Elle reproduit de façon synchrone la séquence d'événements d'une vraie + * connexion (connecting, puis connected) afin de développer l'interface avant + * l'arrivée du protocole. Elle doit rester clairement identifiée comme + * simulée dans l'interface et ne doit jamais être présentée comme un Core réel. + */ +export class SimulatedCoreConnection implements CoreConnection { + public readonly label = 'Core simulé'; + public readonly simulated = true; + + private readonly listeners = new Set(); + private status: ConnectionStatus = 'disconnected'; + + public connect(): void { + if (this.status !== 'disconnected') { + return; + } + + this.transition('connecting'); + this.transition('connected'); + } + + public disconnect(): void { + if (this.status === 'disconnected') { + return; + } + + this.transition('disconnected'); + } + + public onEvent(listener: CoreEventListener): () => void { + this.listeners.add(listener); + + return () => { + this.listeners.delete(listener); + }; + } + + private transition(next: ConnectionStatus): void { + this.status = next; + const event = STATUS_EVENTS[next]; + + for (const listener of this.listeners) { + listener(event); + } + } +} diff --git a/studio/src/style.css b/studio/src/style.css new file mode 100644 index 0000000..58dd880 --- /dev/null +++ b/studio/src/style.css @@ -0,0 +1,172 @@ +/* SPDX-License-Identifier: MPL-2.0 */ + +:root { + color-scheme: dark; + --bg: #0c0f13; + --panel: #141a21; + --panel-raised: #1a222b; + --border: #27313c; + --text: #e7edf4; + --muted: #94a3b3; + --accent: #62b6ff; + --ok: #57d38c; + --warn: #e8b45c; + --off: #778592; + font-family: "Segoe UI", system-ui, -apple-system, sans-serif; + line-height: 1.5; + font-synthesis: none; + text-rendering: optimizeLegibility; +} + +*, +*::before, +*::after { + box-sizing: border-box; +} + +body { + margin: 0; + min-height: 100vh; + background: + radial-gradient(circle at 50% 0%, rgb(98 182 255 / 8%), transparent 55%), + var(--bg); + color: var(--text); +} + +#app { + min-height: 100vh; + display: grid; + place-items: center; + padding: 2rem 1rem; +} + +.studio { + width: min(42rem, 100%); + padding: 2rem; + background: var(--panel); + border: 1px solid var(--border); + border-radius: 0.75rem; + box-shadow: 0 1.5rem 4rem rgb(0 0 0 / 35%); +} + +.studio__header { + display: flex; + flex-wrap: wrap; + align-items: center; + gap: 0.75rem; + padding-bottom: 1rem; + border-bottom: 1px solid var(--border); +} + +.studio__title { + margin: 0; + font-size: 1.5rem; + font-weight: 600; + letter-spacing: 0.01em; +} + +.badge { + padding: 0.15rem 0.55rem; + border-radius: 999px; + font-size: 0.75rem; + font-weight: 600; + text-transform: uppercase; + letter-spacing: 0.06em; +} + +.badge--simulated { + color: var(--warn); + background: rgb(232 180 92 / 12%); + border: 1px solid rgb(232 180 92 / 35%); +} + +.status { + display: flex; + align-items: center; + gap: 0.6rem; + margin: 1.25rem 0 0.5rem; + font-size: 1rem; +} + +.status__dot { + width: 0.6rem; + height: 0.6rem; + border-radius: 50%; + background: var(--off); + flex: none; +} + +.status[data-status="connecting"] .status__dot { + background: var(--warn); +} + +.status[data-status="connected"] .status__dot { + background: var(--ok); +} + +.note { + margin: 0 0 1.5rem; + color: var(--muted); + font-size: 0.85rem; +} + +.facts { + display: grid; + grid-template-columns: auto 1fr; + gap: 0.5rem 1.5rem; + margin: 0 0 1.75rem; + padding: 1rem 1.25rem; + background: var(--panel-raised); + border: 1px solid var(--border); + border-radius: 0.5rem; +} + +.facts dt { + color: var(--muted); + font-size: 0.85rem; +} + +.facts dd { + margin: 0; + font-variant-numeric: tabular-nums; +} + +.controls { + display: flex; + gap: 0.75rem; +} + +.button { + padding: 0.5rem 1.1rem; + border: 1px solid transparent; + border-radius: 0.4rem; + background: var(--accent); + color: #06121f; + font: inherit; + font-weight: 600; + cursor: pointer; +} + +.button:hover:not(:disabled) { + filter: brightness(1.1); +} + +.button--ghost { + background: transparent; + color: var(--text); + border-color: var(--border); +} + +.button--ghost:hover:not(:disabled) { + border-color: var(--muted); +} + +.button:disabled { + opacity: 0.4; + cursor: not-allowed; +} + +.button:focus-visible { + outline: 2px solid var(--accent); + outline-offset: 2px; +} diff --git a/studio/src/ui/app.ts b/studio/src/ui/app.ts new file mode 100644 index 0000000..69b52ba --- /dev/null +++ b/studio/src/ui/app.ts @@ -0,0 +1,124 @@ +// SPDX-License-Identifier: MPL-2.0 + +import type { ConnectionStatus, StudioEvent, StudioState } from '../model/state'; +import { reduce } from '../model/state'; + +export interface AppActions { + readonly connect: () => void; + readonly disconnect: () => void; +} + +export interface AppOptions { + readonly root: HTMLElement; + readonly initialState: StudioState; + /** Libellé de la connexion ; « Core simulé » pour l'implémentation factice. */ + readonly coreLabel: string; + readonly actions: AppActions; +} + +export interface App { + getState(): StudioState; + /** Seul chemin de modification de l'état : délègue à `reduce`. */ + dispatch(event: StudioEvent): void; +} + +const STATUS_LABELS: Record = { + disconnected: 'Déconnecté', + connecting: 'Connexion…', + connected: 'Connecté', +}; + +function element( + tag: K, + className?: string, + text?: string, +): HTMLElementTagNameMap[K] { + const node = document.createElement(tag); + + if (className !== undefined) { + node.className = className; + } + + if (text !== undefined) { + node.textContent = text; + } + + return node; +} + +/** + * Monte la vue de Studio dans `root`. + * + * La vue lit l'état et ne le modifie jamais directement : les interactions + * passent par les actions (connexion) puis par `dispatch`, donc par `reduce`. + */ +export function mountApp(options: AppOptions): App { + const { root, initialState, coreLabel, actions } = options; + let state = initialState; + + root.replaceChildren(); + + const shell = element('main', 'studio'); + + const header = element('header', 'studio__header'); + const title = element('h1', 'studio__title', 'SEQUA Studio'); + const simulationBadge = element('span', 'badge badge--simulated', coreLabel); + simulationBadge.title = 'SIMULÉ — aucun Core réel n’est contacté.'; + header.append(title, simulationBadge); + + const statusLine = element('p', 'status'); + statusLine.setAttribute('role', 'status'); + statusLine.setAttribute('aria-live', 'polite'); + const statusDot = element('span', 'status__dot'); + statusDot.setAttribute('aria-hidden', 'true'); + const statusText = element('span', 'status__text'); + statusLine.append(statusDot, statusText); + + const simulationNote = element( + 'p', + 'note', + 'Connexion simulée : l’interface est développée sans Core réel, en attendant le protocole WebSocket.', + ); + + const details = element('dl', 'facts'); + const versionTerm = element('dt', undefined, 'Version du protocole'); + const versionValue = element('dd', 'facts__value'); + const intentionsTerm = element('dt', undefined, 'Intentions'); + const intentionsValue = element('dd', 'facts__value'); + details.append(versionTerm, versionValue, intentionsTerm, intentionsValue); + + const controls = element('div', 'controls'); + const connectButton = element('button', 'button', 'Connecter'); + connectButton.type = 'button'; + connectButton.addEventListener('click', () => { + actions.connect(); + }); + const disconnectButton = element('button', 'button button--ghost', 'Déconnecter'); + disconnectButton.type = 'button'; + disconnectButton.addEventListener('click', () => { + actions.disconnect(); + }); + controls.append(connectButton, disconnectButton); + + shell.append(header, statusLine, simulationNote, details, controls); + root.append(shell); + + const render = (): void => { + statusLine.dataset['status'] = state.connection; + statusText.textContent = STATUS_LABELS[state.connection]; + versionValue.textContent = state.protocolVersion; + intentionsValue.textContent = String(state.intentions.length); + connectButton.disabled = state.connection !== 'disconnected'; + disconnectButton.disabled = state.connection === 'disconnected'; + }; + + render(); + + return { + getState: () => state, + dispatch: (event) => { + state = reduce(state, event); + render(); + }, + }; +} diff --git a/studio/src/vite-env.d.ts b/studio/src/vite-env.d.ts new file mode 100644 index 0000000..1dfb4a6 --- /dev/null +++ b/studio/src/vite-env.d.ts @@ -0,0 +1,3 @@ +// SPDX-License-Identifier: MPL-2.0 + +/// diff --git a/studio/tests/connection.test.ts b/studio/tests/connection.test.ts new file mode 100644 index 0000000..7167562 --- /dev/null +++ b/studio/tests/connection.test.ts @@ -0,0 +1,63 @@ +// SPDX-License-Identifier: MPL-2.0 + +import { describe, expect, it, vi } from 'vitest'; +import { SimulatedCoreConnection } from '../src/protocol/connection'; + +describe('SimulatedCoreConnection', () => { + it('se déclare clairement comme simulée', () => { + const connection = new SimulatedCoreConnection(); + + expect(connection.simulated).toBe(true); + expect(connection.label).toBe('Core simulé'); + }); + + it('émet connecting puis connected à la connexion', () => { + const connection = new SimulatedCoreConnection(); + const listener = vi.fn(); + connection.onEvent(listener); + + connection.connect(); + + expect(listener).toHaveBeenCalledTimes(2); + expect(listener).toHaveBeenNthCalledWith(1, { type: 'core/connecting' }); + expect(listener).toHaveBeenNthCalledWith(2, { type: 'core/connected' }); + }); + + it('émet disconnected à la déconnexion', () => { + const connection = new SimulatedCoreConnection(); + const listener = vi.fn(); + connection.onEvent(listener); + connection.connect(); + listener.mockClear(); + + connection.disconnect(); + + expect(listener).toHaveBeenCalledTimes(1); + expect(listener).toHaveBeenCalledWith({ type: 'core/disconnected' }); + }); + + it('ignore les transitions redondantes', () => { + const connection = new SimulatedCoreConnection(); + const listener = vi.fn(); + connection.onEvent(listener); + + connection.disconnect(); + expect(listener).not.toHaveBeenCalled(); + + connection.connect(); + listener.mockClear(); + connection.connect(); + expect(listener).not.toHaveBeenCalled(); + }); + + it('cesse d’émettre après désabonnement', () => { + const connection = new SimulatedCoreConnection(); + const listener = vi.fn(); + const unsubscribe = connection.onEvent(listener); + + unsubscribe(); + connection.connect(); + + expect(listener).not.toHaveBeenCalled(); + }); +}); diff --git a/studio/tests/state.test.ts b/studio/tests/state.test.ts new file mode 100644 index 0000000..d370178 --- /dev/null +++ b/studio/tests/state.test.ts @@ -0,0 +1,48 @@ +// SPDX-License-Identifier: MPL-2.0 + +import { describe, expect, it } from 'vitest'; +import { PROTOCOL_VERSION, createInitialState, reduce } from '../src/model/state'; + +describe('état initial', () => { + it('est déconnecté, versionné et sans intention', () => { + const state = createInitialState(); + + expect(state.connection).toBe('disconnected'); + expect(state.protocolVersion).toBe(PROTOCOL_VERSION); + expect(state.intentions).toEqual([]); + }); + + it('est sérialisable en JSON', () => { + const state = createInitialState(); + + expect(JSON.parse(JSON.stringify(state))).toEqual(state); + }); +}); + +describe('reduce', () => { + it('passe par connecting puis connected', () => { + const initial = createInitialState(); + const connecting = reduce(initial, { type: 'core/connecting' }); + const connected = reduce(connecting, { type: 'core/connected' }); + + expect(connecting.connection).toBe('connecting'); + expect(connected.connection).toBe('connected'); + }); + + it('revient à disconnected', () => { + const connected = reduce(createInitialState(), { type: 'core/connected' }); + const disconnected = reduce(connected, { type: 'core/disconnected' }); + + expect(disconnected.connection).toBe('disconnected'); + }); + + it('est pure : l’état reçu reste inchangé', () => { + const initial = createInitialState(); + const next = reduce(initial, { type: 'core/connected' }); + + expect(next).not.toBe(initial); + expect(initial.connection).toBe('disconnected'); + expect(next.protocolVersion).toBe(initial.protocolVersion); + expect(next.intentions).toBe(initial.intentions); + }); +}); diff --git a/studio/tsconfig.json b/studio/tsconfig.json new file mode 100644 index 0000000..27bd45a --- /dev/null +++ b/studio/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "target": "ES2022", + "useDefineForClassFields": true, + "lib": ["ES2023", "DOM", "DOM.Iterable"], + "module": "ESNext", + "moduleResolution": "Bundler", + "moduleDetection": "force", + "verbatimModuleSyntax": true, + "isolatedModules": true, + "noEmit": true, + "strict": true, + "noUncheckedIndexedAccess": true, + "exactOptionalPropertyTypes": true, + "noImplicitOverride": true, + "noImplicitReturns": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noFallthroughCasesInSwitch": true, + "forceConsistentCasingInFileNames": true, + "skipLibCheck": true + }, + "include": ["src", "tests"] +}