@farm.js/plugin 0.1.74 → 0.1.76

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/index.d.ts CHANGED
@@ -39,5 +39,5 @@
39
39
  * })
40
40
  * ```
41
41
  */
42
- export declare const version = "0.1.74";
42
+ export declare const version = "0.1.76";
43
43
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -39,7 +39,7 @@
39
39
  * })
40
40
  * ```
41
41
  */
42
- export const version = "0.1.74";
42
+ export const version = "0.1.76";
43
43
  // Note: Import plugins from their respective subpaths:
44
44
  // - @farm.js/plugin/rsc
45
45
  // - @farm.js/plugin/middleware
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/rsc/entries/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAIhD,eAAO,MAAM,yBAAyB,6IAK5B,CAAC;AAEX,kEAAkE;AAClE,eAAO,MAAM,yBAAyB,8DAG5B,CAAC;AAEX,eAAO,MAAM,mCAAmC,62BA6B9C,CAAC;AAEH;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,YAAY,GAAG,MAAM,CA6jB7D"}
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/rsc/entries/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAIhD,eAAO,MAAM,yBAAyB,6IAK5B,CAAC;AAEX,kEAAkE;AAClE,eAAO,MAAM,yBAAyB,8DAG5B,CAAC;AAEX,eAAO,MAAM,mCAAmC,62BA6B9C,CAAC;AAEH;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,YAAY,GAAG,MAAM,CAkkB7D"}
@@ -61,6 +61,11 @@ export function generateClientEntry(ctx) {
61
61
  query: '?url',
62
62
  });
63
63
  export const farmGlobalStylesheet = Object.values(farmGlobalStylesheets)[0];
64
+ // An edit keeps the stylesheet's URL and Vite refreshes the <link> itself, so this module need
65
+ // not re-run. Without the accept the edit propagates here, the entry, and reloads the page.
66
+ if (import.meta.hot) {
67
+ import.meta.hot.accept(${JSON.stringify(`${ctx.globalCssPath}?url`)}, () => {});
68
+ }
64
69
  `
65
70
  : "";
66
71
  let imports = `${globalStylesheetImport}
@@ -1 +1 @@
1
- {"version":3,"file":"ssr.d.ts","sourceRoot":"","sources":["../../../src/rsc/entries/ssr.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,YAAY,GAAG,MAAM,CAgP1D"}
1
+ {"version":3,"file":"ssr.d.ts","sourceRoot":"","sources":["../../../src/rsc/entries/ssr.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,YAAY,GAAG,MAAM,CAuP1D"}
@@ -55,6 +55,20 @@ function injectBeforeStream(markerText, tagOrResolve) {
55
55
  };
56
56
  let buffer = new Uint8Array(0);
57
57
  let injected = false;
58
+ // The closing marker sits at the end of the document, so every chunk of the page is searched:
59
+ // Node's native Buffer.indexOf, with a byte loop only where there is no Buffer (Workers).
60
+ const findMarker =
61
+ typeof Buffer === 'function' && typeof Buffer.from === 'function'
62
+ ? (haystack) => Buffer.from(haystack.buffer, haystack.byteOffset, haystack.byteLength).indexOf(marker)
63
+ : (haystack) => {
64
+ outer: for (let i = 0; i <= haystack.length - marker.length; i++) {
65
+ for (let j = 0; j < marker.length; j++) {
66
+ if (haystack[i + j] !== marker[j]) continue outer;
67
+ }
68
+ return i;
69
+ }
70
+ return -1;
71
+ };
58
72
 
59
73
  return new TransformStream({
60
74
  transform(chunk, controller) {
@@ -67,14 +81,7 @@ function injectBeforeStream(markerText, tagOrResolve) {
67
81
  const pending = new Uint8Array(buffer.length + bytes.length);
68
82
  pending.set(buffer);
69
83
  pending.set(bytes, buffer.length);
70
- let index = -1;
71
- outer: for (let i = 0; i <= pending.length - marker.length; i++) {
72
- for (let j = 0; j < marker.length; j++) {
73
- if (pending[i + j] !== marker[j]) continue outer;
74
- }
75
- index = i;
76
- break;
77
- }
84
+ const index = findMarker(pending);
78
85
  if (index >= 0) {
79
86
  if (index) controller.enqueue(pending.subarray(0, index));
80
87
  if (resolveTag()) controller.enqueue(insertion);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@farm.js/plugin",
3
- "version": "0.1.74",
3
+ "version": "0.1.76",
4
4
  "description": "Official plugins for Farm.js framework",
5
5
  "license": "MIT",
6
6
  "author": "Farm.js Team",
@@ -63,7 +63,7 @@
63
63
  "nitro": "3.0.260903-beta",
64
64
  "picocolors": "^1.0.0",
65
65
  "rsc-html-stream": "^0.0.4",
66
- "@farm.js/core": "0.1.74"
66
+ "@farm.js/core": "0.1.76"
67
67
  },
68
68
  "devDependencies": {
69
69
  "@types/node": "^22.20.5",
@@ -84,7 +84,7 @@
84
84
  "react-dom": "19.2.8",
85
85
  "react-server-dom-webpack": "19.2.8",
86
86
  "vite": ">=6.0.0",
87
- "@farm.js/core": "0.1.74"
87
+ "@farm.js/core": "0.1.76"
88
88
  },
89
89
  "peerDependenciesMeta": {
90
90
  "@vitejs/plugin-rsc": {