@rsc-kit/core 0.28.1 → 0.29.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/changed.d.ts +17 -9
- package/dist/changed.js +116 -2
- package/dist/changed.js.map +1 -1
- package/dist/conformance.d.ts +14 -1
- package/dist/conformance.js +116 -5
- package/dist/conformance.js.map +1 -1
- package/dist/host.js +5 -3
- package/dist/host.js.map +1 -1
- package/dist/hostCalls.d.ts +0 -6
- package/dist/hostCalls.js +27 -21
- package/dist/hostCalls.js.map +1 -1
- package/dist/js/refreshOn.d.ts +20 -2
- package/dist/js/refreshOn.js +33 -2
- package/dist/js/refreshOn.js.map +1 -1
- package/dist/js/section.d.ts +11 -0
- package/dist/js/section.js.map +1 -1
- package/dist/request.d.ts +8 -0
- package/dist/request.js +31 -0
- package/dist/request.js.map +1 -1
- package/dist/testHost.d.ts +2 -0
- package/dist/testHost.js +12 -1
- package/dist/testHost.js.map +1 -1
- package/dist/testing.d.ts +12 -0
- package/dist/testing.js +29 -10
- package/dist/testing.js.map +1 -1
- package/dist/vite.js +51 -2
- package/dist/vite.js.map +1 -1
- package/package.json +1 -1
package/dist/vite.js
CHANGED
|
@@ -221,6 +221,44 @@ const hostManifestRan = new Set();
|
|
|
221
221
|
* the ordinary case for an app that installs the engine from npm and runs
|
|
222
222
|
* `vite build` itself.
|
|
223
223
|
*/
|
|
224
|
+
/** This package's version, as published - what an AGENTS.md section is compared with. */
|
|
225
|
+
const PACKAGE_VERSION = (() => {
|
|
226
|
+
try {
|
|
227
|
+
return (JSON.parse(readFileSync(join(dirname(fileURLToPath(import.meta.url)), "..", "package.json"), "utf-8")).version ?? "");
|
|
228
|
+
}
|
|
229
|
+
catch {
|
|
230
|
+
return "";
|
|
231
|
+
}
|
|
232
|
+
})();
|
|
233
|
+
/**
|
|
234
|
+
* Say, once, when AGENTS.md's rsc-kit section is from an older rsc-kit than
|
|
235
|
+
* this one - so an agent is not left following rules that have moved on.
|
|
236
|
+
* Stamped sections only: an unstamped one is from before stamps, and says so.
|
|
237
|
+
*/
|
|
238
|
+
function agentsNotice(root) {
|
|
239
|
+
let text;
|
|
240
|
+
try {
|
|
241
|
+
text = readFileSync(join(root, "AGENTS.md"), "utf-8");
|
|
242
|
+
}
|
|
243
|
+
catch {
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
246
|
+
const at = text.indexOf("<!-- rsc-kit:start");
|
|
247
|
+
if (at === -1)
|
|
248
|
+
return;
|
|
249
|
+
const line = text.slice(at, text.indexOf("-->", at));
|
|
250
|
+
let stamped = "";
|
|
251
|
+
try {
|
|
252
|
+
stamped = JSON.parse(line.slice("<!-- rsc-kit:start".length).trim() || "{}").version ?? "";
|
|
253
|
+
}
|
|
254
|
+
catch {
|
|
255
|
+
// An unreadable stamp is as good as none.
|
|
256
|
+
}
|
|
257
|
+
if (stamped && (stamped === PACKAGE_VERSION || !PACKAGE_VERSION))
|
|
258
|
+
return;
|
|
259
|
+
console.log(`\n rsc-kit: AGENTS.md has the rules of ${stamped ? `rsc-kit ${stamped}` : "an earlier rsc-kit"}; this is ${PACKAGE_VERSION || "a newer one"}.` +
|
|
260
|
+
`\n Bring them up to date: bunx rsc-kit agents (review the change in git)\n`);
|
|
261
|
+
}
|
|
224
262
|
/** This package's name, for excluding it from dep optimization. */
|
|
225
263
|
const PACKAGE_NAME = (() => {
|
|
226
264
|
try {
|
|
@@ -2263,7 +2301,7 @@ const SECTION_FILE = /\.section\.(tsx|jsx|ts|js)$/;
|
|
|
2263
2301
|
function usesRefreshOn() {
|
|
2264
2302
|
for (const component of components.values()) {
|
|
2265
2303
|
const src = readFileSync(component.absPath, "utf-8");
|
|
2266
|
-
if (SECTION_FILE.test(component.absPath) ? /\brefreshOn\
|
|
2304
|
+
if (SECTION_FILE.test(component.absPath) ? /\brefreshOn\b/.test(src) : urlSchemaExports(component.absPath).refreshOn)
|
|
2267
2305
|
return true;
|
|
2268
2306
|
}
|
|
2269
2307
|
return false;
|
|
@@ -2555,7 +2593,14 @@ function urlSchemaExports(absPath) {
|
|
|
2555
2593
|
searchParams: /export\s+const\s+searchParams\s*[=:]/.test(src),
|
|
2556
2594
|
// What the page itself refreshes on, beside its url schemas: a change to
|
|
2557
2595
|
// one of its names refreshes the page, as refresh('page') does.
|
|
2558
|
-
|
|
2596
|
+
//
|
|
2597
|
+
// Every way of exporting it, not one: `export const`, `export function`,
|
|
2598
|
+
// and a list - `export { refreshOn }`, `export { names as refreshOn }`,
|
|
2599
|
+
// `export { refreshOn } from './names'`. A pattern for one silently did
|
|
2600
|
+
// nothing for the others. `export * from` cannot be read without
|
|
2601
|
+
// following the import; name it in a list instead.
|
|
2602
|
+
refreshOn: /export\s+(const|let|function|async\s+function)\s+refreshOn\b/.test(src) ||
|
|
2603
|
+
/export\s*(type\s+)?\{[^}]*\brefreshOn\b[^}]*\}/.test(src),
|
|
2559
2604
|
};
|
|
2560
2605
|
}
|
|
2561
2606
|
// ── Codegen ──────────────────────────────────────────────────────────────────
|
|
@@ -6958,6 +7003,10 @@ export function rscKit(options = {}) {
|
|
|
6958
7003
|
// Swapping the plugins in the app's config is not a fix: Nitro then loads
|
|
6959
7004
|
// .env too late for the app's first request.
|
|
6960
7005
|
configureServer: { order: "pre", handler(server) {
|
|
7006
|
+
// The rules an agent follows here say which rsc-kit wrote them. One
|
|
7007
|
+
// line when they are older than the rsc-kit running - never a rewrite:
|
|
7008
|
+
// the section is the app's to update, and git shows the change.
|
|
7009
|
+
agentsNotice(projectRoot);
|
|
6961
7010
|
// The icons and share images live in app/, which nothing serves; the
|
|
6962
7011
|
// build copies them beside the client output. There is no output while
|
|
6963
7012
|
// developing, so the same hrefs the head tags carry are answered from
|