sygnal 6.3.0 → 6.4.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 +51 -0
- package/dist/astro/index.cjs.js +69 -3
- package/dist/astro/index.cjs.js.map +1 -1
- package/dist/astro/index.mjs +69 -3
- 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/diagnostics.cjs.js +47 -8
- package/dist/diagnostics.cjs.js.map +1 -1
- package/dist/diagnostics.esm.js +47 -8
- package/dist/diagnostics.esm.js.map +1 -1
- package/dist/guide/mcp-apps.md +59 -4
- package/dist/index.cjs.js +9 -3
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +9 -2
- package/dist/index.esm.js +9 -3
- 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/vike/config/package.json +1 -1
- package/dist/vite/plugin.cjs.js +69 -3
- package/dist/vite/plugin.cjs.js.map +1 -1
- package/dist/vite/plugin.mjs +69 -3
- package/dist/vite/plugin.mjs.map +1 -1
- package/llms.txt +1 -1
- package/package.json +1 -1
- package/src/extra/diagnostics/checks/dom.ts +10 -2
- package/src/extra/diagnostics/checks/next.ts +17 -1
- package/src/extra/diagnostics/checks/persist.ts +4 -2
- package/src/extra/diagnostics/checks/wiring.ts +14 -6
- package/src/extra/diagnostics/codes.ts +5 -0
- package/src/extra/pwa.ts +3 -1
- package/src/extra/reducers.ts +10 -4
- package/src/index.d.ts +9 -2
- package/src/vite/plugin.ts +63 -2
package/dist/astro/index.mjs
CHANGED
|
@@ -739,6 +739,12 @@ if (import.meta.hot) installMcpBridge(import.meta.hot, { agentTools, confirm: ${
|
|
|
739
739
|
* /__sygnal/mcp (./mcp.ts: streamable HTTP, loopback / local Host / local Origin only)
|
|
740
740
|
* and the dev entries also import 'virtual:sygnal/mcp', which connects the page over the
|
|
741
741
|
* HMR channel (installMcpBridge from 'sygnal/devtools'). Never in `vite build` or Vitest.
|
|
742
|
+
* 11. SYG103 view words (dev server with diagnostics on; never `vite build`, SSR or Vitest): a
|
|
743
|
+
* module that sets `X.intent` or `X.uses` gets a tail registering, for each such X, the
|
|
744
|
+
* words of its string literals and of the relative modules it imports, in
|
|
745
|
+
* `globalThis.__SYGNAL_VIEW_TOKENS__`. The runtime SYG103 check then takes a selector drawn
|
|
746
|
+
* by a view helper (`{state.open && panel()}`) as conditionally rendered, as it does for
|
|
747
|
+
* markup in the view function itself (see viewTokensTail).
|
|
742
748
|
*
|
|
743
749
|
* Why not Vite's `define`? Vite's dependency optimizer does not apply user
|
|
744
750
|
* `define` replacements to pre-bundled dependencies (only process.env.NODE_ENV),
|
|
@@ -976,9 +982,20 @@ function sygnal(options = {}) {
|
|
|
976
982
|
transform(code, id, opts) {
|
|
977
983
|
// SYG666 (PLAN-5 W-2): an adapter entry imported without its optional peers; every mode
|
|
978
984
|
const adapters = adapterImports(this, code, id);
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
985
|
+
const result = adapters
|
|
986
|
+
? checkPeers(this, adapters, id).then(() => devTransform.call(this, code, id, opts))
|
|
987
|
+
: devTransform.call(this, code, id, opts);
|
|
988
|
+
// 11. the words SYG103 may take as conditionally rendered markup (dev server, diagnostics on)
|
|
989
|
+
const tokens = isServe && !isVitest && devOn && !opts?.ssr ? viewTokensTail(this, code, id) : null;
|
|
990
|
+
if (!tokens)
|
|
991
|
+
return result;
|
|
992
|
+
return Promise.all([result, tokens]).then(([r, tail]) => {
|
|
993
|
+
if (!tail)
|
|
994
|
+
return r;
|
|
995
|
+
if (r == null)
|
|
996
|
+
return withSourcemap(code, [], tail, id);
|
|
997
|
+
return typeof r == 'string' ? r + tail : { ...r, code: r.code + tail };
|
|
998
|
+
});
|
|
982
999
|
},
|
|
983
1000
|
};
|
|
984
1001
|
function devTransform(code, id, opts) {
|
|
@@ -1061,6 +1078,55 @@ function sygnal(options = {}) {
|
|
|
1061
1078
|
return done();
|
|
1062
1079
|
}
|
|
1063
1080
|
}
|
|
1081
|
+
// 11. SYG103 (the dev runtime check of an intent selector that never matched) lets a selector
|
|
1082
|
+
// through as conditionally rendered when its words appear in the component's view; the runtime
|
|
1083
|
+
// can read only the view function's own source. A component module (one that sets `X.intent` or
|
|
1084
|
+
// `X.uses`) gets, in dev, a tail registering for each such component the words of its string
|
|
1085
|
+
// literals and those of the relative modules it imports, where view helpers live
|
|
1086
|
+
// (globalThis.__SYGNAL_VIEW_TOKENS__, a WeakMap read by checks/dom.ts).
|
|
1087
|
+
const COMPONENT_WITH_SELECTORS_RE = /(?:^|[^\w$.])([A-Z][\w$]*)\.(?:intent|uses)\s*=(?!=)/g;
|
|
1088
|
+
const STRING_RE = /(['"])((?:\\.|(?!\1)[^\\\n])*)\1|`((?:\\[\s\S]|[^\\`])*)`/g;
|
|
1089
|
+
const RELATIVE_IMPORT_RE = /(?:\bfrom|\bimport)\s*\(?\s*(['"])(\.{1,2}\/[^'"]+)\1/g;
|
|
1090
|
+
// A string that is itself a selector ('.save', '#id', 'form.ask', '[data-x]') or a path / URL: its
|
|
1091
|
+
// words aren't markup (the intent's own DOM.click('.svae') would otherwise vouch for its typo)
|
|
1092
|
+
const NOT_MARKUP_RE = /(?:^|[\s>+~,(])[\w-]*[.#[][\w-]|^\s*(?:\/|[\w+-]+:\/\/)/;
|
|
1093
|
+
/** the class / id / tag-like words in a module's string and template literals (comments skipped) */
|
|
1094
|
+
function stringWords(code, into) {
|
|
1095
|
+
for (const m of blankOut(code, false).matchAll(STRING_RE)) {
|
|
1096
|
+
const text = m[2] ?? m[3] ?? '';
|
|
1097
|
+
if (NOT_MARKUP_RE.test(text))
|
|
1098
|
+
continue;
|
|
1099
|
+
for (const w of text.match(/[A-Za-z_][\w-]*/g) || [])
|
|
1100
|
+
into.add(w);
|
|
1101
|
+
}
|
|
1102
|
+
}
|
|
1103
|
+
function viewTokensTail(ctx, code, id) {
|
|
1104
|
+
const file = cleanId(id);
|
|
1105
|
+
if (!/\.[jt]sx?$/.test(file) || id.includes('node_modules') || id.startsWith('\0'))
|
|
1106
|
+
return null;
|
|
1107
|
+
const names = new Set();
|
|
1108
|
+
for (const m of blankOut(code, true).matchAll(COMPONENT_WITH_SELECTORS_RE))
|
|
1109
|
+
names.add(m[1]);
|
|
1110
|
+
if (!names.size)
|
|
1111
|
+
return null;
|
|
1112
|
+
const words = new Set();
|
|
1113
|
+
stringWords(code, words);
|
|
1114
|
+
const specs = new Set(Array.from(blankOut(code, false).matchAll(RELATIVE_IMPORT_RE), m => m[2]));
|
|
1115
|
+
return Promise.all([...specs].map(async (spec) => {
|
|
1116
|
+
try {
|
|
1117
|
+
const r = await ctx.resolve(spec, id);
|
|
1118
|
+
const dep = r && !r.external && cleanId(r.id);
|
|
1119
|
+
if (!dep || !/\.[cm]?[jt]sx?$/.test(dep) || dep.includes('node_modules'))
|
|
1120
|
+
return;
|
|
1121
|
+
ctx.addWatchFile?.(dep);
|
|
1122
|
+
stringWords(await fs.promises.readFile(dep, 'utf8'), words);
|
|
1123
|
+
}
|
|
1124
|
+
catch (_) { /* unreadable: its words are just not added */ }
|
|
1125
|
+
})).then(() => {
|
|
1126
|
+
const comps = [...names].map(n => `typeof ${n} == 'function' && ${n}`).join(', ');
|
|
1127
|
+
return `\n;(() => { try { const m = globalThis.__SYGNAL_VIEW_TOKENS__ ||= new WeakMap(), t = ${JSON.stringify([...words].join(' '))}; for (const c of [${comps}]) if (c) m.set(c, t) } catch (_) {} })();\n`;
|
|
1128
|
+
});
|
|
1129
|
+
}
|
|
1064
1130
|
// PLAN-5 W-2 (D209): the adapter entries and the optional peer dependencies each one imports
|
|
1065
1131
|
// (the Zag packages pinned together: they depend on each other's exact versions)
|
|
1066
1132
|
const ZAG = '~1.45.0';
|