bun-plugin-stx 0.2.859 → 0.2.862

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.
@@ -2,7 +2,7 @@
2
2
  // src/index.ts
3
3
  import fs2 from "fs";
4
4
  import path2 from "path";
5
- import { buildWebComponents, cacheTemplate, checkCache, classifyAllScripts, defaultConfig, extractVariables, loadStxConfig, processClientScript, processDirectives, readMarkdownFile, withinBundlerCallback } from "@stacksjs/stx";
5
+ import { buildWebComponents, cacheTemplate, checkCache, classifyAllScripts, defaultConfig, extractVariables, insertBeforeBodyClose, loadStxConfig, processClientScript, processDirectives, readMarkdownFile, withinBundlerCallback } from "@stacksjs/stx";
6
6
 
7
7
  // src/watch.ts
8
8
  import fs from "fs";
@@ -431,14 +431,7 @@ export { content as default };
431
431
  }));
432
432
  const scriptsHtml = transformedScripts.join(`
433
433
  `);
434
- const bodyEndMatch = output.match(/(<\/body>)/i);
435
- if (bodyEndMatch) {
436
- output = output.replace(/(<\/body>)/i, `${scriptsHtml}
437
- $1`);
438
- } else {
439
- output += `
440
- ${scriptsHtml}`;
441
- }
434
+ output = insertBeforeBodyClose(output, scriptsHtml);
442
435
  context.__stx_event_bindings = [];
443
436
  }
444
437
  dependencies.forEach((dep) => allDependencies.add(dep));
package/dist/index.js CHANGED
@@ -8,7 +8,7 @@ import {
8
8
  createRoute2,
9
9
  readMarkdownFile2,
10
10
  src_default
11
- } from "./chunk-xmy0ax0w.js";
11
+ } from "./chunk-xyc2ydbw.js";
12
12
  export {
13
13
  createMiddleware2 as createMiddleware,
14
14
  createRoute2 as createRoute,
package/dist/preload.js CHANGED
@@ -1,7 +1,7 @@
1
1
  // @bun
2
2
  import {
3
3
  src_default
4
- } from "./chunk-xmy0ax0w.js";
4
+ } from "./chunk-xyc2ydbw.js";
5
5
 
6
6
  // src/preload.ts
7
7
  var {plugin } = globalThis.Bun;
package/dist/serve.js CHANGED
@@ -8755,10 +8755,10 @@ var defaultConfigDir4 = /* @__PURE__ */ resolve12(process19.cwd(), "config");
8755
8755
  var defaultGeneratedDir4 = /* @__PURE__ */ resolve12(process19.cwd(), "src/generated");
8756
8756
 
8757
8757
  // src/serve.ts
8758
- import { BUILD_ID_HEADER, decodeTitleEntities, externalScriptsOutsideContainer, extractPageResponseStatus, findContainerRegion, FRAGMENT_CACHE_CONTROL, getBuildId, mergeCssConfig, pageCssFragment, pageHeadFragment, readResponseHeaders, readResponseStatus, renderFontCSS, SPA_NAV_HEADER, spaNavVaryHeaders, stateDir, stateDirName } from "@stacksjs/stx";
8758
+ import { bodyCloseIndex, BUILD_ID_HEADER, decodeTitleEntities, externalScriptsOutsideContainer, extractPageResponseStatus, findContainerRegion, FRAGMENT_CACHE_CONTROL, getBuildId, insertBeforeHeadClose, mergeCssConfig, pageCssFragment, pageHeadFragment, readResponseHeaders, readResponseStatus, renderFontCSS, SPA_NAV_HEADER, spaNavVaryHeaders, stateDir, stateDirName } from "@stacksjs/stx";
8759
8759
  import { buildCodeFrame, locateFailureLine } from "@stacksjs/stx/build-message";
8760
8760
  import { clearBundleFailures, getBundleFailures } from "@stacksjs/stx/client-script-bundler";
8761
- import { actionRedirectResponse, compressResponse, runPageAction as sharedRunPageAction } from "@stacksjs/stx";
8761
+ import { insertBeforeBodyClose, actionRedirectResponse, compressResponse, runPageAction as sharedRunPageAction } from "@stacksjs/stx";
8762
8762
 
8763
8763
  // src/domain-routes.ts
8764
8764
  var LABEL = /^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/;
@@ -10004,7 +10004,7 @@ function __stxOverlay(errs){
10004
10004
  return html;
10005
10005
  refreshBuildErrors();
10006
10006
  const client = HMR_CLIENT_SCRIPT.replace("__STX_HMR_VERSION__", String(hmrVersion));
10007
- const closeBody = html.lastIndexOf("</body>");
10007
+ const closeBody = bodyCloseIndex(html);
10008
10008
  if (closeBody === -1) {
10009
10009
  return html + client;
10010
10010
  }
@@ -11002,8 +11002,7 @@ function __stxOverlay(errs){
11002
11002
  const serializedParams = cacheShell ? ROUTE_PARAMS_PLACEHOLDER : serializeRouteParams(paramsObj);
11003
11003
  const paramsScript = `<script data-stx-route-params>(function(){var p=${serializedParams};window.__stx_rp=p;if(window.stx){window.stx._rp=p;if(window.stx.setRouteParams)window.stx.setRouteParams(p)}})()</script>`;
11004
11004
  if (output.includes("</head>")) {
11005
- output = output.replace("</head>", `${paramsScript}
11006
- </head>`);
11005
+ output = insertBeforeHeadClose(output, paramsScript);
11007
11006
  } else {
11008
11007
  output = `${paramsScript}
11009
11008
  ${output}`;
@@ -11078,10 +11077,7 @@ ${output}`;
11078
11077
  const configTagRe = /<script>window\.__stxRouterConfig=\{[^<]*\}<\/script>\s*/i;
11079
11078
  if (configTagRe.test(html))
11080
11079
  return html.replace(configTagRe, block);
11081
- if (/<\/body>/i.test(html))
11082
- return html.replace(/<\/body>/i, `${block}</body>`);
11083
- return `${html}
11084
- ${block}`;
11080
+ return insertBeforeBodyClose(html, block);
11085
11081
  }
11086
11082
  async function applyI18nToResponse(res, locale, normalizedPath) {
11087
11083
  if (!siteStxPromise)
@@ -11107,8 +11103,7 @@ ${block}`;
11107
11103
  }
11108
11104
  if (i18nConfig && stx.buildLangPickerScript) {
11109
11105
  const pickerScript = stx.buildLangPickerScript(i18nConfig, locale);
11110
- html = /<\/body>/i.test(html) ? html.replace(/<\/body>/i, `${pickerScript}
11111
- </body>`) : html + pickerScript;
11106
+ html = insertBeforeBodyClose(html, pickerScript);
11112
11107
  }
11113
11108
  if (i18nConfig && stx.stampLocaleLayoutGroup)
11114
11109
  html = stx.stampLocaleLayoutGroup(html, locale);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bun-plugin-stx",
3
3
  "type": "module",
4
- "version": "0.2.859",
4
+ "version": "0.2.862",
5
5
  "description": "A Bun plugin that allows for using Laravel Blade-like syntax.",
6
6
  "author": "Chris Breuer <chris@stacksjs.org>",
7
7
  "license": "MIT",
@@ -74,7 +74,7 @@
74
74
  "typecheck": "bun tsc --noEmit"
75
75
  },
76
76
  "dependencies": {
77
- "@stacksjs/stx": "0.2.859",
78
- "stx-router": "0.2.859"
77
+ "@stacksjs/stx": "0.2.862",
78
+ "stx-router": "0.2.862"
79
79
  }
80
80
  }