vite-plugin-php 1.0.20 → 1.0.31

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/README.md CHANGED
@@ -18,7 +18,13 @@ export default defineConfig({
18
18
  Check out the [starter repo](https://github.com/nititech/php-vite-starter) for an easy and convenient start:
19
19
  <a href="https://github.com/nititech/php-vite-starter" target="_blank"><img src="https://nititech.de/kosmo-starter-button.png" alt="Starter Repo"></a>
20
20
 
21
- #### ⚡️⚡️⚡️ New feature: URL rewrite!
21
+ ## Latest changes
22
+
23
+ | Version | Feature |
24
+ | ------- | ------------------------ |
25
+ | 1.0.30 | PHP header forwarding |
26
+ | 1.0.20 | URL rewrites |
27
+ | 1.0.11 | Improved Windows support |
22
28
 
23
29
  ## Write some PHP code in your `index.php`
24
30
 
@@ -119,7 +125,7 @@ usePHP({
119
125
  });
120
126
  ```
121
127
 
122
- ⚠️ **Attention:** If using the rewriteUrl property you will need to exclude (_return undefined_) assets like CSS, JavaScript, Images, etc.. on your own!
128
+ ⚠️ **Attention:** If using the rewriteUrl property you will need to exclude (_return undefined_) assets like CSS, JavaScript, Images, etc.., that match your transpiled php file names, on your own!
123
129
 
124
130
  ## Known issues
125
131
 
package/dist/index.cjs CHANGED
@@ -6936,36 +6936,41 @@ function usePHP(cfg = {}) {
6936
6936
  PHP_SELF: "/" + entry2
6937
6937
  }).toString()
6938
6938
  );
6939
- const phpResult = await new Promise(
6940
- (resolve2, reject) => {
6941
- const chunks = [];
6942
- http__default.request(
6943
- url.toString(),
6944
- {
6945
- method: req.method,
6946
- headers: req.headers
6947
- },
6948
- (msg) => {
6949
- msg.on(
6950
- "data",
6951
- (data) => chunks.push(data)
6952
- );
6953
- msg.on("end", () => {
6954
- const result = Buffer.concat(
6955
- chunks
6956
- ).toString("utf8");
6957
- resolve2(result);
6939
+ const phpResult = await new Promise((resolve2, reject) => {
6940
+ const chunks = [];
6941
+ http__default.request(
6942
+ url.toString(),
6943
+ {
6944
+ method: req.method,
6945
+ headers: req.headers
6946
+ },
6947
+ (msg) => {
6948
+ msg.on(
6949
+ "data",
6950
+ (data) => chunks.push(data)
6951
+ );
6952
+ msg.on("end", () => {
6953
+ const content = Buffer.concat(
6954
+ chunks
6955
+ ).toString("utf8");
6956
+ resolve2({
6957
+ statusCode: msg.statusCode,
6958
+ headers: msg.headers,
6959
+ content
6958
6960
  });
6959
- }
6960
- ).on("error", reject).end();
6961
- }
6962
- );
6963
- let out = phpResult.toString();
6964
- out = await server.transformIndexHtml(
6961
+ });
6962
+ }
6963
+ ).on("error", reject).end();
6964
+ });
6965
+ const out = await server.transformIndexHtml(
6965
6966
  entryPathname || "/",
6966
- out
6967
+ phpResult.content,
6968
+ req.originalUrl
6967
6969
  );
6968
- res.end(out);
6970
+ res.writeHead(phpResult.statusCode || 200, {
6971
+ ...req.headers,
6972
+ ...phpResult.headers
6973
+ }).end(out);
6969
6974
  return;
6970
6975
  }
6971
6976
  }
package/dist/index.mjs CHANGED
@@ -6923,36 +6923,41 @@ function usePHP(cfg = {}) {
6923
6923
  PHP_SELF: "/" + entry2
6924
6924
  }).toString()
6925
6925
  );
6926
- const phpResult = await new Promise(
6927
- (resolve2, reject) => {
6928
- const chunks = [];
6929
- http.request(
6930
- url.toString(),
6931
- {
6932
- method: req.method,
6933
- headers: req.headers
6934
- },
6935
- (msg) => {
6936
- msg.on(
6937
- "data",
6938
- (data) => chunks.push(data)
6939
- );
6940
- msg.on("end", () => {
6941
- const result = Buffer.concat(
6942
- chunks
6943
- ).toString("utf8");
6944
- resolve2(result);
6926
+ const phpResult = await new Promise((resolve2, reject) => {
6927
+ const chunks = [];
6928
+ http.request(
6929
+ url.toString(),
6930
+ {
6931
+ method: req.method,
6932
+ headers: req.headers
6933
+ },
6934
+ (msg) => {
6935
+ msg.on(
6936
+ "data",
6937
+ (data) => chunks.push(data)
6938
+ );
6939
+ msg.on("end", () => {
6940
+ const content = Buffer.concat(
6941
+ chunks
6942
+ ).toString("utf8");
6943
+ resolve2({
6944
+ statusCode: msg.statusCode,
6945
+ headers: msg.headers,
6946
+ content
6945
6947
  });
6946
- }
6947
- ).on("error", reject).end();
6948
- }
6949
- );
6950
- let out = phpResult.toString();
6951
- out = await server.transformIndexHtml(
6948
+ });
6949
+ }
6950
+ ).on("error", reject).end();
6951
+ });
6952
+ const out = await server.transformIndexHtml(
6952
6953
  entryPathname || "/",
6953
- out
6954
+ phpResult.content,
6955
+ req.originalUrl
6954
6956
  );
6955
- res.end(out);
6957
+ res.writeHead(phpResult.statusCode || 200, {
6958
+ ...req.headers,
6959
+ ...phpResult.headers
6960
+ }).end(out);
6956
6961
  return;
6957
6962
  }
6958
6963
  }
package/dist/router.php CHANGED
@@ -22,10 +22,11 @@ $source = str_replace(
22
22
  $source,
23
23
  );
24
24
 
25
- die((function ($__SOURCE) {
25
+ (function () {
26
26
  try {
27
- return eval("?> $__SOURCE <?php");
27
+ eval('?> ' . func_get_arg(0) . ' <?php');
28
+ die();
28
29
  } catch (\Throwable $th) {
29
- return $th->getMessage();
30
+ die($th->getMessage());
30
31
  }
31
- })($source));
32
+ })($source);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite-plugin-php",
3
- "version": "1.0.20",
3
+ "version": "1.0.31",
4
4
  "description": "Process PHP-files with the speed and tools of Vite",
5
5
  "keywords": [
6
6
  "vite",
@@ -12,6 +12,10 @@
12
12
  "php",
13
13
  "php-loader",
14
14
  "php-compiler",
15
+ "php processing",
16
+ "php transpilation",
17
+ "php-vite",
18
+ "vite-php",
15
19
  "loader",
16
20
  "url rewrite",
17
21
  "url router",
@@ -54,10 +58,10 @@
54
58
  },
55
59
  "dependencies": {},
56
60
  "devDependencies": {
57
- "@types/node": "^20.12.7",
61
+ "@types/node": "^20.14.11",
58
62
  "fast-glob": "^3.3.2",
59
- "typescript": "^5.4.5",
63
+ "typescript": "^5.5.3",
60
64
  "unbuild": "^2.0.0",
61
- "vite": "^5.2.8"
65
+ "vite": "^5.3.4"
62
66
  }
63
67
  }