vite-plugin-php 1.0.8 → 1.0.10

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.cjs CHANGED
@@ -34,7 +34,7 @@ function escapePHP(inputFile, outputFile) {
34
34
  const codeTokens = {};
35
35
  const isJS = inputFile.includes(".js") || inputFile.includes(".ts");
36
36
  const isML = inputFile.includes(".php") || inputFile.includes(".htm");
37
- const out = input.replaceAll(/<\?(?:php|).+?\?>/gis, (match) => {
37
+ const out = input.replace(/<\?(?:php|).+?(\?>|$)/gis, (match) => {
38
38
  let token = makeID();
39
39
  if (isJS) {
40
40
  token = `/*${token}*/`;
@@ -6913,6 +6913,7 @@ function usePHP(cfg = {}) {
6913
6913
  url.pathname = tempFile;
6914
6914
  const phpResult = await new Promise(
6915
6915
  (resolve2, reject) => {
6916
+ const chunks = [];
6916
6917
  http__default.request(
6917
6918
  url.toString(),
6918
6919
  {
@@ -6920,7 +6921,16 @@ function usePHP(cfg = {}) {
6920
6921
  headers: req.headers
6921
6922
  },
6922
6923
  (msg) => {
6923
- msg.on("data", resolve2);
6924
+ msg.on(
6925
+ "data",
6926
+ (data) => chunks.push(data)
6927
+ );
6928
+ msg.on("end", () => {
6929
+ const result = Buffer.concat(
6930
+ chunks
6931
+ ).toString("utf8");
6932
+ resolve2(result);
6933
+ });
6924
6934
  }
6925
6935
  ).on("error", reject).end();
6926
6936
  }
package/dist/index.mjs CHANGED
@@ -21,7 +21,7 @@ function escapePHP(inputFile, outputFile) {
21
21
  const codeTokens = {};
22
22
  const isJS = inputFile.includes(".js") || inputFile.includes(".ts");
23
23
  const isML = inputFile.includes(".php") || inputFile.includes(".htm");
24
- const out = input.replaceAll(/<\?(?:php|).+?\?>/gis, (match) => {
24
+ const out = input.replace(/<\?(?:php|).+?(\?>|$)/gis, (match) => {
25
25
  let token = makeID();
26
26
  if (isJS) {
27
27
  token = `/*${token}*/`;
@@ -6900,6 +6900,7 @@ function usePHP(cfg = {}) {
6900
6900
  url.pathname = tempFile;
6901
6901
  const phpResult = await new Promise(
6902
6902
  (resolve2, reject) => {
6903
+ const chunks = [];
6903
6904
  http.request(
6904
6905
  url.toString(),
6905
6906
  {
@@ -6907,7 +6908,16 @@ function usePHP(cfg = {}) {
6907
6908
  headers: req.headers
6908
6909
  },
6909
6910
  (msg) => {
6910
- msg.on("data", resolve2);
6911
+ msg.on(
6912
+ "data",
6913
+ (data) => chunks.push(data)
6914
+ );
6915
+ msg.on("end", () => {
6916
+ const result = Buffer.concat(
6917
+ chunks
6918
+ ).toString("utf8");
6919
+ resolve2(result);
6920
+ });
6911
6921
  }
6912
6922
  ).on("error", reject).end();
6913
6923
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite-plugin-php",
3
- "version": "1.0.8",
3
+ "version": "1.0.10",
4
4
  "description": "Precompile PHP-files with the speed of Vite",
5
5
  "keywords": [
6
6
  "vite",