viberadar 0.3.215 → 0.3.216

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7845,11 +7845,12 @@ function applyLoadImport(raw, sourceName) {
7845
7845
  }
7846
7846
 
7847
7847
  function loadImportConfigClick() {
7848
- const input = document.getElementById('loadConfigImportFile');
7849
- if (input) {
7850
- input.value = '';
7851
- input.click();
7852
- }
7848
+ openLoadImportConfigModal();
7849
+ }
7850
+
7851
+ function readLoadImportConfigText(text, sourceName) {
7852
+ const raw = JSON.parse(String(text || '{}'));
7853
+ applyLoadImport(raw, sourceName);
7853
7854
  }
7854
7855
 
7855
7856
  function loadImportConfigFile(input) {
@@ -7858,8 +7859,9 @@ function loadImportConfigFile(input) {
7858
7859
  const reader = new FileReader();
7859
7860
  reader.onload = () => {
7860
7861
  try {
7861
- const raw = JSON.parse(String(reader.result || '{}'));
7862
- applyLoadImport(raw, file.name);
7862
+ readLoadImportConfigText(reader.result || '{}', file.name);
7863
+ const overlay = document.getElementById('loadImportConfigOverlay');
7864
+ if (overlay) overlay.remove();
7863
7865
  } catch (e) {
7864
7866
  alert('Конфиг не импортирован: ' + e.message);
7865
7867
  }
@@ -7868,6 +7870,88 @@ function loadImportConfigFile(input) {
7868
7870
  reader.readAsText(file);
7869
7871
  }
7870
7872
 
7873
+ function openLoadImportConfigModal() {
7874
+ let overlay = document.getElementById('loadImportConfigOverlay');
7875
+ if (overlay) overlay.remove();
7876
+ overlay = document.createElement('div');
7877
+ overlay.id = 'loadImportConfigOverlay';
7878
+ overlay.style.cssText = 'position:fixed;inset:0;background:rgba(0,0,0,0.62);display:flex;align-items:center;justify-content:center;z-index:9999;padding:18px';
7879
+ overlay.innerHTML = `
7880
+ <div style="background:var(--bg-card);border:1px solid var(--border);border-radius:8px;padding:18px;width:720px;max-width:96vw;max-height:92vh;overflow:auto">
7881
+ <div style="display:flex;align-items:center;justify-content:space-between;gap:12px;margin-bottom:10px">
7882
+ <div>
7883
+ <div style="font-size:15px;font-weight:600;color:var(--text)">Импорт k6 конфига</div>
7884
+ <div style="font-size:12px;color:var(--muted);margin-top:3px">Вставь JSON из буфера или выбери файл. После импорта поля можно править вручную.</div>
7885
+ </div>
7886
+ <button id="loadImportClose" class="load-btn" style="padding:4px 9px">Закрыть</button>
7887
+ </div>
7888
+ <textarea id="loadImportConfigText" spellcheck="false" placeholder='{"name":"auth-browse","baseUrl":"https://demo.unica.hopper-it.ru","vus":10,"duration":"2m","accounts":[{"email":"user@example.com","password":"pass"}],"script":"import http from ..."}' style="width:100%;min-height:260px;resize:vertical;background:var(--bg);border:1px solid var(--border);border-radius:6px;color:var(--text);font-family:ui-monospace,SFMono-Regular,Consolas,monospace;font-size:12px;line-height:1.45;padding:10px;outline:none"></textarea>
7889
+ <div id="loadImportStatus" style="min-height:18px;margin-top:8px;font-size:12px;color:var(--muted)">JSON пока не вставлен</div>
7890
+ <div style="display:flex;gap:8px;justify-content:space-between;align-items:center;margin-top:14px;flex-wrap:wrap">
7891
+ <div>
7892
+ <input id="loadConfigImportFile" type="file" accept=".json,application/json" style="display:none" onchange="loadImportConfigFile(this)" />
7893
+ <button class="load-btn" id="loadImportFileBtn">Выбрать JSON-файл</button>
7894
+ </div>
7895
+ <div style="display:flex;gap:8px">
7896
+ <button class="load-btn" id="loadImportCancel">Отмена</button>
7897
+ <button class="load-btn load-btn-run" id="loadImportApply" disabled>Импорт</button>
7898
+ </div>
7899
+ </div>
7900
+ </div>`;
7901
+ document.body.appendChild(overlay);
7902
+
7903
+ const textEl = overlay.querySelector('#loadImportConfigText');
7904
+ const statusEl = overlay.querySelector('#loadImportStatus');
7905
+ const applyBtn = overlay.querySelector('#loadImportApply');
7906
+ const close = () => overlay.remove();
7907
+ const validate = () => {
7908
+ const text = textEl.value.trim();
7909
+ if (!text) {
7910
+ statusEl.textContent = 'JSON пока не вставлен';
7911
+ statusEl.style.color = 'var(--muted)';
7912
+ applyBtn.disabled = true;
7913
+ return;
7914
+ }
7915
+ try {
7916
+ const raw = JSON.parse(text);
7917
+ const imported = normalizeLoadImport(raw, 'clipboard');
7918
+ const parts = [];
7919
+ if (imported.scriptName) parts.push(imported.scriptName);
7920
+ if (imported.baseUrl) parts.push(imported.baseUrl);
7921
+ if (imported.vus) parts.push(`${imported.vus} VUs`);
7922
+ if (imported.duration) parts.push(imported.duration);
7923
+ statusEl.textContent = `JSON валидный${parts.length ? ': ' + parts.join(' · ') : ''}`;
7924
+ statusEl.style.color = 'var(--green)';
7925
+ applyBtn.disabled = false;
7926
+ } catch (e) {
7927
+ statusEl.textContent = 'JSON невалидный: ' + e.message;
7928
+ statusEl.style.color = 'var(--red)';
7929
+ applyBtn.disabled = true;
7930
+ }
7931
+ };
7932
+
7933
+ overlay.addEventListener('click', e => { if (e.target === overlay) close(); });
7934
+ overlay.querySelector('#loadImportClose').addEventListener('click', close);
7935
+ overlay.querySelector('#loadImportCancel').addEventListener('click', close);
7936
+ overlay.querySelector('#loadImportFileBtn').addEventListener('click', () => {
7937
+ const input = overlay.querySelector('#loadConfigImportFile');
7938
+ input.value = '';
7939
+ input.click();
7940
+ });
7941
+ textEl.addEventListener('input', validate);
7942
+ applyBtn.addEventListener('click', () => {
7943
+ try {
7944
+ readLoadImportConfigText(textEl.value, 'clipboard');
7945
+ close();
7946
+ } catch (e) {
7947
+ statusEl.textContent = 'Конфиг не импортирован: ' + e.message;
7948
+ statusEl.style.color = 'var(--red)';
7949
+ applyBtn.disabled = true;
7950
+ }
7951
+ });
7952
+ setTimeout(() => textEl.focus(), 0);
7953
+ }
7954
+
7871
7955
  function renderLoad(c) {
7872
7956
  const isRunning = loadState && loadState.status === 'running';
7873
7957
  const isDone = loadState && (loadState.status === 'done' || loadState.status === 'stopped');
@@ -7928,9 +8012,8 @@ function renderLoad(c) {
7928
8012
  <button class="load-btn load-btn-run" style="font-size:13px;padding:8px 20px" onclick="loadNewTest()">+ Новый тест</button>
7929
8013
  </div>
7930
8014
  </div>
7931
- <input id="loadConfigImportFile" type="file" accept=".json,application/json" style="display:none" onchange="loadImportConfigFile(this)" />
7932
-
7933
- ${loadSavedScripts.length === 0
8015
+
8016
+ ${loadSavedScripts.length === 0
7934
8017
  ? `<div class="load-library-empty">
7935
8018
  <div style="font-size:32px;margin-bottom:12px">📋</div>
7936
8019
  <div style="font-size:14px;font-weight:500;margin-bottom:6px">Нет сохранённых тестов</div>
@@ -7980,7 +8063,6 @@ function renderLoad(c) {
7980
8063
  <div class="load-editor-topbar">
7981
8064
  ${!isRunning ? `<button class="load-back-btn" onclick="loadView='library';renderContent()">← Все тесты</button>` : ''}
7982
8065
  ${!isRunning ? `<button class="load-btn" style="font-size:12px;padding:5px 10px" onclick="loadImportConfigClick()">Импорт конфига</button>` : ''}
7983
- <input id="loadConfigImportFile" type="file" accept=".json,application/json" style="display:none" onchange="loadImportConfigFile(this)" />
7984
8066
  <span style="font-size:12px;color:var(--muted);margin-left:4px">${statusBadge}</span>
7985
8067
  </div>
7986
8068
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "viberadar",
3
- "version": "0.3.215",
3
+ "version": "0.3.216",
4
4
  "description": "Live module map with test coverage for vibecoding projects",
5
5
  "main": "./dist/cli.js",
6
6
  "bin": {