sygnal 6.5.0 → 7.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +156 -0
- package/README.md +2 -0
- package/dist/astro/index.cjs.js +423 -27
- package/dist/astro/index.cjs.js.map +1 -1
- package/dist/astro/index.mjs +423 -27
- package/dist/astro/index.mjs.map +1 -1
- package/dist/astro/server.cjs.js.map +1 -1
- package/dist/astro/server.mjs.map +1 -1
- package/dist/devtools.cjs.js +141 -3
- package/dist/devtools.cjs.js.map +1 -1
- package/dist/devtools.esm.js +141 -4
- package/dist/devtools.esm.js.map +1 -1
- package/dist/diagnostics.cjs.js +169 -14
- package/dist/diagnostics.cjs.js.map +1 -1
- package/dist/diagnostics.esm.js +168 -15
- package/dist/diagnostics.esm.js.map +1 -1
- package/dist/guide/accessibility.md +2 -0
- package/dist/guide/ai-chat.md +6 -6
- package/dist/guide/behaviors.md +1 -1
- package/dist/guide/element-commands.md +4 -2
- package/dist/guide/forms-reference.md +89 -3
- package/dist/guide/forms.md +8 -8
- package/dist/guide/http.md +77 -7
- package/dist/guide/migrating-to-7.md +314 -0
- package/dist/guide/recipes/ai-summarize.md +2 -1
- package/dist/guide/recipes/i18n.md +1 -1
- package/dist/guide/ui/tabs.md +5 -4
- package/dist/guide/ui/tooltip.md +24 -0
- package/dist/index.cjs.js +781 -320
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +319 -43
- package/dist/index.esm.js +781 -320
- package/dist/index.esm.js.map +1 -1
- package/dist/sygnal.min.js +1 -1
- package/dist/sygnal.min.js.map +1 -1
- package/dist/ui.cjs.js +96 -11
- package/dist/ui.cjs.js.map +1 -1
- package/dist/ui.esm.js +96 -12
- package/dist/ui.esm.js.map +1 -1
- package/dist/vike/config/package.json +1 -1
- package/dist/vike/onRenderClient.cjs.js +63 -43
- package/dist/vike/onRenderClient.cjs.js.map +1 -1
- package/dist/vike/onRenderClient.mjs +63 -43
- package/dist/vike/onRenderClient.mjs.map +1 -1
- package/dist/vike/onRenderHtml.cjs.js +21 -25
- package/dist/vike/onRenderHtml.cjs.js.map +1 -1
- package/dist/vike/onRenderHtml.mjs +21 -25
- package/dist/vike/onRenderHtml.mjs.map +1 -1
- package/dist/vite/plugin.cjs.js +410 -27
- package/dist/vite/plugin.cjs.js.map +1 -1
- package/dist/vite/plugin.mjs +410 -27
- package/dist/vite/plugin.mjs.map +1 -1
- package/llms.txt +17 -16
- package/package.json +1 -1
- package/src/astro/index.d.ts +8 -0
- package/src/astro/index.ts +18 -0
- package/src/core/actions.ts +28 -21
- package/src/core/define.ts +2 -0
- package/src/core/hooks.ts +8 -2
- package/src/core/hosts/collection.ts +4 -3
- package/src/core/instance.ts +60 -16
- package/src/core/runtime.ts +5 -1
- package/src/core/view.ts +2 -0
- package/src/cycle/dom/utils.ts +4 -2
- package/src/devtools.d.ts +13 -0
- package/src/devtools.ts +3 -0
- package/src/extra/ai/chat/behavior.ts +3 -3
- package/src/extra/ai/commandBar.ts +3 -3
- package/src/extra/ai/compose/behavior.ts +3 -3
- package/src/extra/ai/transports/shared.ts +8 -2
- package/src/extra/behaviors.ts +21 -0
- package/src/extra/devGraph.ts +111 -0
- package/src/extra/devMcp.ts +1 -1
- package/src/extra/devtools.ts +18 -0
- package/src/extra/diagnostics/checks/fetch.ts +21 -1
- package/src/extra/diagnostics/checks/forms.ts +4 -3
- package/src/extra/diagnostics/checks/index.ts +2 -1
- package/src/extra/diagnostics/checks/inspect.ts +68 -6
- package/src/extra/diagnostics/checks/next.ts +3 -0
- package/src/extra/diagnostics/checks/public.d.ts +133 -12
- package/src/extra/diagnostics/checks/timingAudit.ts +47 -0
- package/src/extra/diagnostics/codes.ts +19 -0
- package/src/extra/fetchDriver.ts +112 -7
- package/src/extra/fetchEventSource.ts +113 -0
- package/src/extra/form.ts +68 -26
- package/src/extra/formHelpers.ts +3 -1
- package/src/extra/lens.ts +3 -2
- package/src/extra/queryCache.ts +4 -3
- package/src/extra/socketDriver.ts +10 -4
- package/src/extra/testing.ts +68 -11
- package/src/index.d.ts +199 -30
- package/src/index.ts +1 -0
- package/src/shared.ts +3 -0
- package/src/ui/dialog.ts +3 -2
- package/src/ui/tooltips.ts +92 -0
- package/src/ui.d.ts +35 -0
- package/src/ui.ts +1 -0
- package/src/vike/onRenderClient.ts +44 -46
- package/src/vike/onRenderHtml.ts +5 -26
- package/src/vike/shell.ts +33 -0
- package/src/vite/graph.ts +255 -0
- package/src/vite/mcp.ts +3 -3
- package/src/vite/plugin.d.ts +19 -0
- package/src/vite/plugin.ts +144 -25
package/dist/devtools.esm.js
CHANGED
|
@@ -871,6 +871,25 @@ class SygnalDevTools {
|
|
|
871
871
|
case 'GET_STATE':
|
|
872
872
|
this._sendComponentState(msg.payload.componentId);
|
|
873
873
|
break;
|
|
874
|
+
case 'GET_GRAPH':
|
|
875
|
+
this._post('GRAPH', this._graph(msg.payload));
|
|
876
|
+
break;
|
|
877
|
+
}
|
|
878
|
+
}
|
|
879
|
+
/**
|
|
880
|
+
* PLAN-10 P-1: the runtime app graph for the panel's App graph view: inspect() with the recent
|
|
881
|
+
* actions, JSON-safe. inspect() is on this object only when 'sygnal/diagnostics' is loaded
|
|
882
|
+
* (sygnal/vite loads it in dev); without it the panel shows why.
|
|
883
|
+
*/
|
|
884
|
+
_graph(opts) {
|
|
885
|
+
const inspect = this.inspect;
|
|
886
|
+
if (typeof inspect !== 'function')
|
|
887
|
+
return { graph: null, reason: 'no-diagnostics' };
|
|
888
|
+
try {
|
|
889
|
+
return { graph: JSON.parse(JSON.stringify(inspect({ actions: opts?.actions ?? 200 }))) };
|
|
890
|
+
}
|
|
891
|
+
catch (e) {
|
|
892
|
+
return { graph: null, reason: 'error', message: String(e?.message ?? e) };
|
|
874
893
|
}
|
|
875
894
|
}
|
|
876
895
|
onComponentCreated(componentNumber, name, instance) {
|
|
@@ -1746,15 +1765,15 @@ function pageTools(o, notifyWaiting = () => { }) {
|
|
|
1746
1765
|
};
|
|
1747
1766
|
return tools;
|
|
1748
1767
|
}
|
|
1749
|
-
let installed = null;
|
|
1768
|
+
let installed$1 = null;
|
|
1750
1769
|
/**
|
|
1751
1770
|
* Connect this page to the dev server's MCP endpoint (sygnal/vite with `mcp: true` calls it from
|
|
1752
1771
|
* 'virtual:sygnal/mcp'). Once per page; no-op without a hot channel.
|
|
1753
1772
|
*/
|
|
1754
1773
|
function installMcpBridge(hot, options = {}) {
|
|
1755
|
-
if (!hot || installed === hot)
|
|
1774
|
+
if (!hot || installed$1 === hot)
|
|
1756
1775
|
return;
|
|
1757
|
-
installed = hot;
|
|
1776
|
+
installed$1 = hot;
|
|
1758
1777
|
if (!options.app)
|
|
1759
1778
|
trackApps();
|
|
1760
1779
|
const tools = pageTools(options, (id) => hot.send(MCP_RESPONSE, { id, waiting: true }));
|
|
@@ -1800,6 +1819,124 @@ function installMcpBridge(hot, options = {}) {
|
|
|
1800
1819
|
}
|
|
1801
1820
|
}
|
|
1802
1821
|
|
|
1822
|
+
/**
|
|
1823
|
+
* PLAN-10 P-2 (D544): the app side of the graph page's "Live data" (sygnal/vite serves the page at
|
|
1824
|
+
* `/__sygnal/graph` in dev, W-2 / D543). Dev only: it is part of the 'sygnal/devtools' entry, and
|
|
1825
|
+
* sygnal/vite's 'virtual:sygnal/graph' module (served by the dev server, never in a build) calls
|
|
1826
|
+
* installGraphBridge().
|
|
1827
|
+
*
|
|
1828
|
+
* The page is served by the dev server on the app's own origin, so the two talk over a
|
|
1829
|
+
* BroadcastChannel ('sygnal:graph'): no server round trip, no HMR traffic, nothing a page on
|
|
1830
|
+
* another origin can join. Every message carries `v: 1`.
|
|
1831
|
+
*
|
|
1832
|
+
* page → apps { type: 'who', watch? } every 2 s while the page is open; `watch` names
|
|
1833
|
+
* the tab the page follows (it keeps that tab
|
|
1834
|
+
* sending for 6 s)
|
|
1835
|
+
* app → page { type: 'here', tab, url, title, at, ok } the answer, and on load / focus
|
|
1836
|
+
* (`at`: when the tab was last loaded or focused;
|
|
1837
|
+
* `ok`: inspect() is there, i.e. diagnostics on)
|
|
1838
|
+
* app → page { type: 'graph', tab, graph } inspect({ actions: 200 }) of the page's apps, JSON
|
|
1839
|
+
* safe: when it starts being watched, then 150 ms
|
|
1840
|
+
* after the last action or component change
|
|
1841
|
+
* app → page { type: 'action', tab, record } { type, instance, component } at once (a flash)
|
|
1842
|
+
* page → app { type: 'get-state', tab, req, id } an instance's state
|
|
1843
|
+
* app → page { type: 'state', tab, req, id, value?, error? }
|
|
1844
|
+
* app → page { type: 'bye', tab } the tab is going away (pagehide)
|
|
1845
|
+
*
|
|
1846
|
+
* State values go through the DevTools preview (JSON safe, as the MCP tools send them). The static
|
|
1847
|
+
* keys the page joins on are on the component functions (sygnal/vite's dev transform) and come out
|
|
1848
|
+
* of inspect() as `key`.
|
|
1849
|
+
*/
|
|
1850
|
+
const GRAPH_CHANNEL = 'sygnal:graph';
|
|
1851
|
+
const WATCH_MS = 6000;
|
|
1852
|
+
const SETTLE_MS = 150;
|
|
1853
|
+
let installed = false;
|
|
1854
|
+
/** Connect this page to the graph page's "Live data" (sygnal/vite calls it in dev). Once per page. */
|
|
1855
|
+
function installGraphBridge(options = {}) {
|
|
1856
|
+
const g = globalThis;
|
|
1857
|
+
if (installed || typeof g.BroadcastChannel != 'function' || !g.window)
|
|
1858
|
+
return;
|
|
1859
|
+
installed = true;
|
|
1860
|
+
trackApps();
|
|
1861
|
+
const bc = new g.BroadcastChannel(options.channel || GRAPH_CHANNEL);
|
|
1862
|
+
const tab = Math.random().toString(36).slice(2, 10) + Date.now().toString(36);
|
|
1863
|
+
const tools = pageTools({});
|
|
1864
|
+
let at = Date.now();
|
|
1865
|
+
let watchedUntil = 0;
|
|
1866
|
+
let timer = 0;
|
|
1867
|
+
const inspect = () => {
|
|
1868
|
+
const f = g.__SYGNAL_DIAGNOSTICS__?.inspect || getDevTools()?.inspect;
|
|
1869
|
+
return typeof f == 'function' ? f : null;
|
|
1870
|
+
};
|
|
1871
|
+
const post = (m) => { try {
|
|
1872
|
+
bc.postMessage({ v: 1, tab, ...m });
|
|
1873
|
+
}
|
|
1874
|
+
catch (_) { /* closed */ } };
|
|
1875
|
+
const here = () => post({ type: 'here', url: String(g.location?.href || ''), title: String(g.document?.title || ''), at, ok: !!inspect() });
|
|
1876
|
+
const watched = () => Date.now() < watchedUntil;
|
|
1877
|
+
const sendGraph = () => {
|
|
1878
|
+
clearTimeout(timer);
|
|
1879
|
+
timer = 0;
|
|
1880
|
+
const f = inspect();
|
|
1881
|
+
if (!watched() || !f)
|
|
1882
|
+
return;
|
|
1883
|
+
let graph;
|
|
1884
|
+
try {
|
|
1885
|
+
graph = JSON.parse(JSON.stringify(f({ actions: 200 })));
|
|
1886
|
+
}
|
|
1887
|
+
catch (_) {
|
|
1888
|
+
return;
|
|
1889
|
+
}
|
|
1890
|
+
post({ type: 'graph', graph });
|
|
1891
|
+
};
|
|
1892
|
+
const settle = () => {
|
|
1893
|
+
if (!watched())
|
|
1894
|
+
return;
|
|
1895
|
+
clearTimeout(timer);
|
|
1896
|
+
timer = setTimeout(sendGraph, SETTLE_MS);
|
|
1897
|
+
};
|
|
1898
|
+
const watch = () => {
|
|
1899
|
+
const was = watched();
|
|
1900
|
+
watchedUntil = Date.now() + WATCH_MS;
|
|
1901
|
+
if (!was)
|
|
1902
|
+
sendGraph();
|
|
1903
|
+
};
|
|
1904
|
+
bc.onmessage = (e) => {
|
|
1905
|
+
const m = e && e.data;
|
|
1906
|
+
if (!m || m.v !== 1 || typeof m.type != 'string')
|
|
1907
|
+
return;
|
|
1908
|
+
if (m.type == 'who') {
|
|
1909
|
+
if (m.watch === tab)
|
|
1910
|
+
watch();
|
|
1911
|
+
here();
|
|
1912
|
+
}
|
|
1913
|
+
else if (m.type == 'get-state' && m.tab === tab) {
|
|
1914
|
+
let value, error;
|
|
1915
|
+
try {
|
|
1916
|
+
value = tools.get_state({ component: String(m.id) }, m.req).state;
|
|
1917
|
+
}
|
|
1918
|
+
catch (err) {
|
|
1919
|
+
error = String(err?.message || err);
|
|
1920
|
+
}
|
|
1921
|
+
post({ type: 'state', req: m.req, id: m.id, ...(error ? { error } : { value }) });
|
|
1922
|
+
}
|
|
1923
|
+
};
|
|
1924
|
+
onAction((a, kind) => {
|
|
1925
|
+
if (!watched())
|
|
1926
|
+
return;
|
|
1927
|
+
if (kind == 'add' && a)
|
|
1928
|
+
post({ type: 'action', record: { type: a.type, instance: String(a.instance), component: a.component } });
|
|
1929
|
+
settle();
|
|
1930
|
+
});
|
|
1931
|
+
addLayer(() => ({ onCreate: settle, onDispose: settle }));
|
|
1932
|
+
const seen = () => { at = Date.now(); here(); };
|
|
1933
|
+
g.addEventListener?.('focus', seen);
|
|
1934
|
+
g.document?.addEventListener?.('visibilitychange', () => { if (g.document.visibilityState == 'visible')
|
|
1935
|
+
seen(); });
|
|
1936
|
+
g.addEventListener?.('pagehide', () => post({ type: 'bye' }));
|
|
1937
|
+
here();
|
|
1938
|
+
}
|
|
1939
|
+
|
|
1803
1940
|
// 'sygnal/devtools' (D77): the DevTools bridge for the browser extension, a dev-only
|
|
1804
1941
|
// entry. Importing it installs window.__SYGNAL_DEVTOOLS__ (run() did this before 6.0),
|
|
1805
1942
|
// so import it before run(): components created earlier are not in the tree.
|
|
@@ -1823,5 +1960,5 @@ function copyAsTest(target, options) {
|
|
|
1823
1960
|
return copyAsTestResult(target, options).code;
|
|
1824
1961
|
}
|
|
1825
1962
|
|
|
1826
|
-
export { clearActions, connectReduxDevtools, copyAsTest, copyAsTestResult, getActions, getDevTools, getSession, installDevTools, installMcpBridge, isRecording, onAction, recordActions };
|
|
1963
|
+
export { clearActions, connectReduxDevtools, copyAsTest, copyAsTestResult, getActions, getDevTools, getSession, installDevTools, installGraphBridge, installMcpBridge, isRecording, onAction, recordActions };
|
|
1827
1964
|
//# sourceMappingURL=devtools.esm.js.map
|