vite-plugin-php 1.0.62 → 1.0.66
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 +2 -0
- package/dist/index.cjs +158 -120
- package/dist/index.mjs +145 -106
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -22,6 +22,8 @@ Check out the [starter repo](https://github.com/nititech/php-vite-starter) for a
|
|
|
22
22
|
|
|
23
23
|
| Version | Feature |
|
|
24
24
|
| ------- | ----------------------------------------------------------------------------------------------------------- |
|
|
25
|
+
| 1.0.66 | Fixed file monitoring on Windows |
|
|
26
|
+
| 1.0.65 | Fixed request body forwarding for all request methods |
|
|
25
27
|
| 1.0.62 | HTML transforms are now only applied to HTML contents during dev |
|
|
26
28
|
| 1.0.60 | Fixed inline module transpiling -> PHP code is being properly inserted into transpiled inline module chunks |
|
|
27
29
|
| 1.0.55 | Fixed pure PHP file processing |
|
package/dist/index.cjs
CHANGED
|
@@ -1,28 +1,26 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const require$$0$
|
|
4
|
-
const require$$0
|
|
3
|
+
const require$$0$1 = require('fs');
|
|
4
|
+
const require$$0 = require('path');
|
|
5
5
|
const vite = require('vite');
|
|
6
|
-
const
|
|
7
|
-
const http = require('http');
|
|
6
|
+
const http = require('node:http');
|
|
8
7
|
const child_process = require('child_process');
|
|
9
8
|
const url = require('url');
|
|
10
|
-
const require$$0$
|
|
11
|
-
const require$$0$
|
|
12
|
-
const require$$0$
|
|
13
|
-
const require$$0$
|
|
9
|
+
const require$$0$2 = require('os');
|
|
10
|
+
const require$$0$3 = require('util');
|
|
11
|
+
const require$$0$4 = require('stream');
|
|
12
|
+
const require$$0$5 = require('events');
|
|
14
13
|
|
|
15
14
|
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
16
15
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
|
|
17
16
|
|
|
18
|
-
const require$$0__default$
|
|
19
|
-
const require$$0__default$
|
|
20
|
-
const require$$0__default = /*#__PURE__*/_interopDefaultCompat(require$$0);
|
|
17
|
+
const require$$0__default$4 = /*#__PURE__*/_interopDefaultCompat(require$$0$1);
|
|
18
|
+
const require$$0__default$1 = /*#__PURE__*/_interopDefaultCompat(require$$0);
|
|
21
19
|
const http__default = /*#__PURE__*/_interopDefaultCompat(http);
|
|
22
|
-
const require$$0__default
|
|
20
|
+
const require$$0__default = /*#__PURE__*/_interopDefaultCompat(require$$0$2);
|
|
21
|
+
const require$$0__default$2 = /*#__PURE__*/_interopDefaultCompat(require$$0$3);
|
|
23
22
|
const require$$0__default$3 = /*#__PURE__*/_interopDefaultCompat(require$$0$4);
|
|
24
|
-
const require$$0__default$
|
|
25
|
-
const require$$0__default$6 = /*#__PURE__*/_interopDefaultCompat(require$$0$6);
|
|
23
|
+
const require$$0__default$5 = /*#__PURE__*/_interopDefaultCompat(require$$0$5);
|
|
26
24
|
|
|
27
25
|
function makeID() {
|
|
28
26
|
return Date.now().toString(36) + Math.random() * 100;
|
|
@@ -34,35 +32,21 @@ function getDefaultExportFromCjs (x) {
|
|
|
34
32
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
35
33
|
}
|
|
36
34
|
|
|
37
|
-
function commonjsRequire(path) {
|
|
38
|
-
throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
|
|
39
|
-
}
|
|
40
|
-
|
|
41
35
|
var picocolors = {exports: {}};
|
|
42
36
|
|
|
43
|
-
let argv =
|
|
44
|
-
env = process.env;
|
|
37
|
+
let p = process || {}, argv = p.argv || [], env = p.env || {};
|
|
45
38
|
let isColorSupported =
|
|
46
|
-
!(
|
|
47
|
-
(
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
(commonjsRequire != null && require$$0__default.isatty(1) && env.TERM !== "dumb") ||
|
|
51
|
-
"CI" in env);
|
|
52
|
-
|
|
53
|
-
let formatter =
|
|
54
|
-
(open, close, replace = open) =>
|
|
39
|
+
!(!!env.NO_COLOR || argv.includes("--no-color")) &&
|
|
40
|
+
(!!env.FORCE_COLOR || argv.includes("--color") || p.platform === "win32" || ((p.stdout || {}).isTTY && env.TERM !== "dumb") || !!env.CI);
|
|
41
|
+
|
|
42
|
+
let formatter = (open, close, replace = open) =>
|
|
55
43
|
input => {
|
|
56
|
-
let string = "" + input;
|
|
57
|
-
|
|
58
|
-
return ~index
|
|
59
|
-
? open + replaceClose(string, close, replace, index) + close
|
|
60
|
-
: open + string + close
|
|
44
|
+
let string = "" + input, index = string.indexOf(close, open.length);
|
|
45
|
+
return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close
|
|
61
46
|
};
|
|
62
47
|
|
|
63
48
|
let replaceClose = (string, close, replace, index) => {
|
|
64
|
-
let result = "";
|
|
65
|
-
let cursor = 0;
|
|
49
|
+
let result = "", cursor = 0;
|
|
66
50
|
do {
|
|
67
51
|
result += string.substring(cursor, index) + replace;
|
|
68
52
|
cursor = index + close.length;
|
|
@@ -72,34 +56,54 @@ let replaceClose = (string, close, replace, index) => {
|
|
|
72
56
|
};
|
|
73
57
|
|
|
74
58
|
let createColors = (enabled = isColorSupported) => {
|
|
75
|
-
let
|
|
59
|
+
let f = enabled ? formatter : () => String;
|
|
76
60
|
return {
|
|
77
61
|
isColorSupported: enabled,
|
|
78
|
-
reset:
|
|
79
|
-
bold:
|
|
80
|
-
dim:
|
|
81
|
-
italic:
|
|
82
|
-
underline:
|
|
83
|
-
inverse:
|
|
84
|
-
hidden:
|
|
85
|
-
strikethrough:
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
62
|
+
reset: f("\x1b[0m", "\x1b[0m"),
|
|
63
|
+
bold: f("\x1b[1m", "\x1b[22m", "\x1b[22m\x1b[1m"),
|
|
64
|
+
dim: f("\x1b[2m", "\x1b[22m", "\x1b[22m\x1b[2m"),
|
|
65
|
+
italic: f("\x1b[3m", "\x1b[23m"),
|
|
66
|
+
underline: f("\x1b[4m", "\x1b[24m"),
|
|
67
|
+
inverse: f("\x1b[7m", "\x1b[27m"),
|
|
68
|
+
hidden: f("\x1b[8m", "\x1b[28m"),
|
|
69
|
+
strikethrough: f("\x1b[9m", "\x1b[29m"),
|
|
70
|
+
|
|
71
|
+
black: f("\x1b[30m", "\x1b[39m"),
|
|
72
|
+
red: f("\x1b[31m", "\x1b[39m"),
|
|
73
|
+
green: f("\x1b[32m", "\x1b[39m"),
|
|
74
|
+
yellow: f("\x1b[33m", "\x1b[39m"),
|
|
75
|
+
blue: f("\x1b[34m", "\x1b[39m"),
|
|
76
|
+
magenta: f("\x1b[35m", "\x1b[39m"),
|
|
77
|
+
cyan: f("\x1b[36m", "\x1b[39m"),
|
|
78
|
+
white: f("\x1b[37m", "\x1b[39m"),
|
|
79
|
+
gray: f("\x1b[90m", "\x1b[39m"),
|
|
80
|
+
|
|
81
|
+
bgBlack: f("\x1b[40m", "\x1b[49m"),
|
|
82
|
+
bgRed: f("\x1b[41m", "\x1b[49m"),
|
|
83
|
+
bgGreen: f("\x1b[42m", "\x1b[49m"),
|
|
84
|
+
bgYellow: f("\x1b[43m", "\x1b[49m"),
|
|
85
|
+
bgBlue: f("\x1b[44m", "\x1b[49m"),
|
|
86
|
+
bgMagenta: f("\x1b[45m", "\x1b[49m"),
|
|
87
|
+
bgCyan: f("\x1b[46m", "\x1b[49m"),
|
|
88
|
+
bgWhite: f("\x1b[47m", "\x1b[49m"),
|
|
89
|
+
|
|
90
|
+
blackBright: f("\x1b[90m", "\x1b[39m"),
|
|
91
|
+
redBright: f("\x1b[91m", "\x1b[39m"),
|
|
92
|
+
greenBright: f("\x1b[92m", "\x1b[39m"),
|
|
93
|
+
yellowBright: f("\x1b[93m", "\x1b[39m"),
|
|
94
|
+
blueBright: f("\x1b[94m", "\x1b[39m"),
|
|
95
|
+
magentaBright: f("\x1b[95m", "\x1b[39m"),
|
|
96
|
+
cyanBright: f("\x1b[96m", "\x1b[39m"),
|
|
97
|
+
whiteBright: f("\x1b[97m", "\x1b[39m"),
|
|
98
|
+
|
|
99
|
+
bgBlackBright: f("\x1b[100m", "\x1b[49m"),
|
|
100
|
+
bgRedBright: f("\x1b[101m", "\x1b[49m"),
|
|
101
|
+
bgGreenBright: f("\x1b[102m", "\x1b[49m"),
|
|
102
|
+
bgYellowBright: f("\x1b[103m", "\x1b[49m"),
|
|
103
|
+
bgBlueBright: f("\x1b[104m", "\x1b[49m"),
|
|
104
|
+
bgMagentaBright: f("\x1b[105m", "\x1b[49m"),
|
|
105
|
+
bgCyanBright: f("\x1b[106m", "\x1b[49m"),
|
|
106
|
+
bgWhiteBright: f("\x1b[107m", "\x1b[49m"),
|
|
103
107
|
}
|
|
104
108
|
};
|
|
105
109
|
|
|
@@ -144,7 +148,7 @@ function initReplaceEnv(config) {
|
|
|
144
148
|
} else {
|
|
145
149
|
if (envPrefix.some((prefix) => key.startsWith(prefix))) {
|
|
146
150
|
const relativeHtml = vite.normalizePath(
|
|
147
|
-
require$$0
|
|
151
|
+
require$$0.relative(config.root, filename)
|
|
148
152
|
);
|
|
149
153
|
config.logger.warn(
|
|
150
154
|
colors.yellow(
|
|
@@ -161,14 +165,14 @@ function initReplaceEnv(config) {
|
|
|
161
165
|
}
|
|
162
166
|
|
|
163
167
|
function writeFile(file, data) {
|
|
164
|
-
require$$0$
|
|
165
|
-
require$$0$
|
|
168
|
+
require$$0$1.mkdirSync(require$$0.dirname(file), { recursive: true });
|
|
169
|
+
require$$0$1.writeFileSync(file, data);
|
|
166
170
|
}
|
|
167
171
|
|
|
168
172
|
const phpTagPattern = /<\?(?:php|).+?(\?>|$)/gis;
|
|
169
173
|
function escapePHP({ inputFile, config }) {
|
|
170
174
|
const replaceEnv = initReplaceEnv(config);
|
|
171
|
-
const input = require$$0$
|
|
175
|
+
const input = require$$0$1.readFileSync(inputFile, "utf-8").toString();
|
|
172
176
|
const phpCodes = {};
|
|
173
177
|
const isJS = inputFile.includes(".js") || inputFile.includes(".ts");
|
|
174
178
|
const isML = inputFile.includes(".php") || inputFile.includes(".htm");
|
|
@@ -223,7 +227,7 @@ function start(root) {
|
|
|
223
227
|
}
|
|
224
228
|
function stop() {
|
|
225
229
|
if (globalThis.php) {
|
|
226
|
-
globalThis.php.stdin?.
|
|
230
|
+
globalThis.php.stdin?.destroy();
|
|
227
231
|
globalThis.php.stdout?.destroy();
|
|
228
232
|
globalThis.php.stderr?.destroy();
|
|
229
233
|
if (globalThis.php.kill()) {
|
|
@@ -302,8 +306,8 @@ var path$9 = {};
|
|
|
302
306
|
|
|
303
307
|
Object.defineProperty(path$9, "__esModule", { value: true });
|
|
304
308
|
path$9.convertPosixPathToPattern = path$9.convertWindowsPathToPattern = path$9.convertPathToPattern = path$9.escapePosixPath = path$9.escapeWindowsPath = path$9.escape = path$9.removeLeadingDotSegment = path$9.makeAbsolute = path$9.unixify = void 0;
|
|
305
|
-
const os = require$$0__default
|
|
306
|
-
const path$8 = require$$0__default$
|
|
309
|
+
const os = require$$0__default;
|
|
310
|
+
const path$8 = require$$0__default$1;
|
|
307
311
|
const IS_WINDOWS_PLATFORM = os.platform() === 'win32';
|
|
308
312
|
const LEADING_DOT_SEGMENT_CHARACTERS_COUNT = 2; // ./ or .\\
|
|
309
313
|
/**
|
|
@@ -543,8 +547,8 @@ var isGlob$1 = function isGlob(str, options) {
|
|
|
543
547
|
};
|
|
544
548
|
|
|
545
549
|
var isGlob = isGlob$1;
|
|
546
|
-
var pathPosixDirname = require$$0__default$
|
|
547
|
-
var isWin32 = require$$0__default
|
|
550
|
+
var pathPosixDirname = require$$0__default$1.posix.dirname;
|
|
551
|
+
var isWin32 = require$$0__default.platform() === 'win32';
|
|
548
552
|
|
|
549
553
|
var slash = '/';
|
|
550
554
|
var backslash = /\\/g;
|
|
@@ -1040,7 +1044,7 @@ var toRegexRange_1 = toRegexRange$1;
|
|
|
1040
1044
|
* Licensed under the MIT License.
|
|
1041
1045
|
*/
|
|
1042
1046
|
|
|
1043
|
-
const util$1 = require$$0__default$
|
|
1047
|
+
const util$1 = require$$0__default$2;
|
|
1044
1048
|
const toRegexRange = toRegexRange_1;
|
|
1045
1049
|
|
|
1046
1050
|
const isObject$1 = val => val !== null && typeof val === 'object' && !Array.isArray(val);
|
|
@@ -2005,7 +2009,7 @@ var braces_1 = braces$1;
|
|
|
2005
2009
|
|
|
2006
2010
|
var utils$f = {};
|
|
2007
2011
|
|
|
2008
|
-
const path$7 = require$$0__default$
|
|
2012
|
+
const path$7 = require$$0__default$1;
|
|
2009
2013
|
const WIN_SLASH = '\\\\/';
|
|
2010
2014
|
const WIN_NO_SLASH = `[^${WIN_SLASH}]`;
|
|
2011
2015
|
|
|
@@ -2185,7 +2189,7 @@ var constants$3 = {
|
|
|
2185
2189
|
|
|
2186
2190
|
(function (exports) {
|
|
2187
2191
|
|
|
2188
|
-
const path = require$$0__default$
|
|
2192
|
+
const path = require$$0__default$1;
|
|
2189
2193
|
const win32 = process.platform === 'win32';
|
|
2190
2194
|
const {
|
|
2191
2195
|
REGEX_BACKSLASH,
|
|
@@ -3729,7 +3733,7 @@ parse$1.fastpaths = (input, options) => {
|
|
|
3729
3733
|
|
|
3730
3734
|
var parse_1 = parse$1;
|
|
3731
3735
|
|
|
3732
|
-
const path$6 = require$$0__default$
|
|
3736
|
+
const path$6 = require$$0__default$1;
|
|
3733
3737
|
const scan = scan_1;
|
|
3734
3738
|
const parse = parse_1;
|
|
3735
3739
|
const utils$c = utils$f;
|
|
@@ -4072,7 +4076,7 @@ var picomatch_1 = picomatch$2;
|
|
|
4072
4076
|
|
|
4073
4077
|
var picomatch$1 = picomatch_1;
|
|
4074
4078
|
|
|
4075
|
-
const util = require$$0__default$
|
|
4079
|
+
const util = require$$0__default$2;
|
|
4076
4080
|
const braces = braces_1;
|
|
4077
4081
|
const picomatch = picomatch$1;
|
|
4078
4082
|
const utils$b = utils$f;
|
|
@@ -4540,7 +4544,7 @@ var micromatch_1 = micromatch$1;
|
|
|
4540
4544
|
|
|
4541
4545
|
Object.defineProperty(pattern$1, "__esModule", { value: true });
|
|
4542
4546
|
pattern$1.removeDuplicateSlashes = pattern$1.matchAny = pattern$1.convertPatternsToRe = pattern$1.makeRe = pattern$1.getPatternParts = pattern$1.expandBraceExpansion = pattern$1.expandPatternsWithBraceExpansion = pattern$1.isAffectDepthOfReadingPattern = pattern$1.endsWithSlashGlobStar = pattern$1.hasGlobStar = pattern$1.getBaseDirectory = pattern$1.isPatternRelatedToParentDirectory = pattern$1.getPatternsOutsideCurrentDirectory = pattern$1.getPatternsInsideCurrentDirectory = pattern$1.getPositivePatterns = pattern$1.getNegativePatterns = pattern$1.isPositivePattern = pattern$1.isNegativePattern = pattern$1.convertToNegativePattern = pattern$1.convertToPositivePattern = pattern$1.isDynamicPattern = pattern$1.isStaticPattern = void 0;
|
|
4543
|
-
const path$5 = require$$0__default$
|
|
4547
|
+
const path$5 = require$$0__default$1;
|
|
4544
4548
|
const globParent = globParent$1;
|
|
4545
4549
|
const micromatch = micromatch_1;
|
|
4546
4550
|
const GLOBSTAR = '**';
|
|
@@ -4735,7 +4739,7 @@ var stream$4 = {};
|
|
|
4735
4739
|
* Copyright (c) 2014-2020 Teambition
|
|
4736
4740
|
* Licensed under the MIT license.
|
|
4737
4741
|
*/
|
|
4738
|
-
const Stream = require$$0__default$
|
|
4742
|
+
const Stream = require$$0__default$3;
|
|
4739
4743
|
const PassThrough = Stream.PassThrough;
|
|
4740
4744
|
const slice = Array.prototype.slice;
|
|
4741
4745
|
|
|
@@ -5115,7 +5119,7 @@ var fs$5 = {};
|
|
|
5115
5119
|
(function (exports) {
|
|
5116
5120
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5117
5121
|
exports.createFileSystemAdapter = exports.FILE_SYSTEM_ADAPTER = void 0;
|
|
5118
|
-
const fs = require$$0__default$
|
|
5122
|
+
const fs = require$$0__default$4;
|
|
5119
5123
|
exports.FILE_SYSTEM_ADAPTER = {
|
|
5120
5124
|
lstat: fs.lstat,
|
|
5121
5125
|
stat: fs.stat,
|
|
@@ -5466,7 +5470,7 @@ var fs$1 = {};
|
|
|
5466
5470
|
(function (exports) {
|
|
5467
5471
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5468
5472
|
exports.createFileSystemAdapter = exports.FILE_SYSTEM_ADAPTER = void 0;
|
|
5469
|
-
const fs = require$$0__default$
|
|
5473
|
+
const fs = require$$0__default$4;
|
|
5470
5474
|
exports.FILE_SYSTEM_ADAPTER = {
|
|
5471
5475
|
lstat: fs.lstat,
|
|
5472
5476
|
stat: fs.stat,
|
|
@@ -5485,7 +5489,7 @@ var fs$1 = {};
|
|
|
5485
5489
|
} (fs$1));
|
|
5486
5490
|
|
|
5487
5491
|
Object.defineProperty(settings$2, "__esModule", { value: true });
|
|
5488
|
-
const path$3 = require$$0__default$
|
|
5492
|
+
const path$3 = require$$0__default$1;
|
|
5489
5493
|
const fsStat$3 = out$1;
|
|
5490
5494
|
const fs = fs$1;
|
|
5491
5495
|
let Settings$1 = class Settings {
|
|
@@ -5927,7 +5931,7 @@ let Reader$1 = class Reader {
|
|
|
5927
5931
|
reader$1.default = Reader$1;
|
|
5928
5932
|
|
|
5929
5933
|
Object.defineProperty(async$4, "__esModule", { value: true });
|
|
5930
|
-
const events_1 = require$$0__default$
|
|
5934
|
+
const events_1 = require$$0__default$5;
|
|
5931
5935
|
const fsScandir$2 = out$2;
|
|
5932
5936
|
const fastq = queueExports;
|
|
5933
5937
|
const common$1 = common$3;
|
|
@@ -6056,7 +6060,7 @@ function callSuccessCallback(callback, entries) {
|
|
|
6056
6060
|
var stream$2 = {};
|
|
6057
6061
|
|
|
6058
6062
|
Object.defineProperty(stream$2, "__esModule", { value: true });
|
|
6059
|
-
const stream_1$5 = require$$0__default$
|
|
6063
|
+
const stream_1$5 = require$$0__default$3;
|
|
6060
6064
|
const async_1$3 = async$4;
|
|
6061
6065
|
class StreamProvider {
|
|
6062
6066
|
constructor(_root, _settings) {
|
|
@@ -6169,7 +6173,7 @@ sync$3.default = SyncProvider;
|
|
|
6169
6173
|
var settings$1 = {};
|
|
6170
6174
|
|
|
6171
6175
|
Object.defineProperty(settings$1, "__esModule", { value: true });
|
|
6172
|
-
const path$2 = require$$0__default$
|
|
6176
|
+
const path$2 = require$$0__default$1;
|
|
6173
6177
|
const fsScandir = out$2;
|
|
6174
6178
|
class Settings {
|
|
6175
6179
|
constructor(_options = {}) {
|
|
@@ -6231,7 +6235,7 @@ function getSettings(settingsOrOptions = {}) {
|
|
|
6231
6235
|
var reader = {};
|
|
6232
6236
|
|
|
6233
6237
|
Object.defineProperty(reader, "__esModule", { value: true });
|
|
6234
|
-
const path$1 = require$$0__default$
|
|
6238
|
+
const path$1 = require$$0__default$1;
|
|
6235
6239
|
const fsStat$2 = out$1;
|
|
6236
6240
|
const utils$6 = utils$k;
|
|
6237
6241
|
class Reader {
|
|
@@ -6266,7 +6270,7 @@ reader.default = Reader;
|
|
|
6266
6270
|
var stream$1 = {};
|
|
6267
6271
|
|
|
6268
6272
|
Object.defineProperty(stream$1, "__esModule", { value: true });
|
|
6269
|
-
const stream_1$3 = require$$0__default$
|
|
6273
|
+
const stream_1$3 = require$$0__default$3;
|
|
6270
6274
|
const fsStat$1 = out$1;
|
|
6271
6275
|
const fsWalk$2 = out$3;
|
|
6272
6276
|
const reader_1$2 = reader;
|
|
@@ -6619,7 +6623,7 @@ class EntryTransformer {
|
|
|
6619
6623
|
entry.default = EntryTransformer;
|
|
6620
6624
|
|
|
6621
6625
|
Object.defineProperty(provider, "__esModule", { value: true });
|
|
6622
|
-
const path = require$$0__default$
|
|
6626
|
+
const path = require$$0__default$1;
|
|
6623
6627
|
const deep_1 = deep;
|
|
6624
6628
|
const entry_1 = entry$1;
|
|
6625
6629
|
const error_1 = error;
|
|
@@ -6692,7 +6696,7 @@ async$7.default = ProviderAsync;
|
|
|
6692
6696
|
var stream = {};
|
|
6693
6697
|
|
|
6694
6698
|
Object.defineProperty(stream, "__esModule", { value: true });
|
|
6695
|
-
const stream_1$1 = require$$0__default$
|
|
6699
|
+
const stream_1$1 = require$$0__default$3;
|
|
6696
6700
|
const stream_2 = stream$1;
|
|
6697
6701
|
const provider_1$1 = provider;
|
|
6698
6702
|
class ProviderStream extends provider_1$1.default {
|
|
@@ -6797,8 +6801,8 @@ var settings = {};
|
|
|
6797
6801
|
(function (exports) {
|
|
6798
6802
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6799
6803
|
exports.DEFAULT_FILE_SYSTEM_ADAPTER = void 0;
|
|
6800
|
-
const fs = require$$0__default$
|
|
6801
|
-
const os = require$$0__default
|
|
6804
|
+
const fs = require$$0__default$4;
|
|
6805
|
+
const os = require$$0__default;
|
|
6802
6806
|
/**
|
|
6803
6807
|
* The `os.cpus` method can return zero. We expect the number of cores to be greater than zero.
|
|
6804
6808
|
* https://github.com/nodejs/node/blob/7faeddf23a98c53896f8b574a6e66589e8fb1eb8/lib/os.js#L106-L107
|
|
@@ -6991,7 +6995,7 @@ function usePHP(cfg = {}) {
|
|
|
6991
6995
|
return `${tempDir}/${file}.html`;
|
|
6992
6996
|
}
|
|
6993
6997
|
function cleanupTemp() {
|
|
6994
|
-
require$$0$
|
|
6998
|
+
require$$0$1.rmSync(tempDir, { recursive: true, force: true });
|
|
6995
6999
|
}
|
|
6996
7000
|
function onExit() {
|
|
6997
7001
|
if (config?.command === "serve") {
|
|
@@ -7016,7 +7020,7 @@ function usePHP(cfg = {}) {
|
|
|
7016
7020
|
enforce: "post",
|
|
7017
7021
|
config(config2, env) {
|
|
7018
7022
|
const gitIgnoreFile = `${tempDir}/.gitignore`;
|
|
7019
|
-
if (!require$$0$
|
|
7023
|
+
if (!require$$0$1.existsSync(gitIgnoreFile)) {
|
|
7020
7024
|
writeFile(gitIgnoreFile, "*\n**/*.php.html");
|
|
7021
7025
|
}
|
|
7022
7026
|
entries = [
|
|
@@ -7065,9 +7069,18 @@ function usePHP(cfg = {}) {
|
|
|
7065
7069
|
phpServer.start(viteServer?.config.root);
|
|
7066
7070
|
server.middlewares.use(async (req, res, next) => {
|
|
7067
7071
|
try {
|
|
7068
|
-
if (req.url && ![
|
|
7069
|
-
|
|
7070
|
-
|
|
7072
|
+
if (req.url && ![
|
|
7073
|
+
"/@vite",
|
|
7074
|
+
"/@fs",
|
|
7075
|
+
"/@id/__x00__",
|
|
7076
|
+
"/node_modules"
|
|
7077
|
+
].some((path) => req.url.startsWith(path))) {
|
|
7078
|
+
req.on("error", (error) => {
|
|
7079
|
+
throw error;
|
|
7080
|
+
});
|
|
7081
|
+
res.on("error", (error) => {
|
|
7082
|
+
throw error;
|
|
7083
|
+
});
|
|
7071
7084
|
const url = new URL(req.url, "http://localhost");
|
|
7072
7085
|
if (config?.server.port) {
|
|
7073
7086
|
url.port = config.server.port.toString();
|
|
@@ -7088,7 +7101,7 @@ function usePHP(cfg = {}) {
|
|
|
7088
7101
|
});
|
|
7089
7102
|
if (entry2) {
|
|
7090
7103
|
const tempFile = getTempFileName(entry2);
|
|
7091
|
-
if (require$$0$
|
|
7104
|
+
if (require$$0$1.existsSync(require$$0.resolve(tempFile))) {
|
|
7092
7105
|
url.pathname = tempFile;
|
|
7093
7106
|
url.port = phpServer.port.toString();
|
|
7094
7107
|
url.searchParams.set(
|
|
@@ -7098,31 +7111,56 @@ function usePHP(cfg = {}) {
|
|
|
7098
7111
|
PHP_SELF: "/" + entry2
|
|
7099
7112
|
}).toString()
|
|
7100
7113
|
);
|
|
7101
|
-
const
|
|
7114
|
+
const body = await new Promise(
|
|
7115
|
+
(resolve2, reject) => {
|
|
7116
|
+
let data = [];
|
|
7117
|
+
req.on("data", (chunk) => {
|
|
7118
|
+
data.push(chunk);
|
|
7119
|
+
}).on("end", () => {
|
|
7120
|
+
resolve2(Buffer.concat(data));
|
|
7121
|
+
});
|
|
7122
|
+
}
|
|
7123
|
+
);
|
|
7124
|
+
const phpResult = await new Promise(async (resolve2, reject) => {
|
|
7102
7125
|
const chunks = [];
|
|
7103
|
-
|
|
7126
|
+
let statusCode;
|
|
7127
|
+
let incomingHeaders = {};
|
|
7128
|
+
const request = http__default.request(
|
|
7104
7129
|
url.toString(),
|
|
7105
7130
|
{
|
|
7106
7131
|
method: req.method,
|
|
7107
|
-
headers:
|
|
7132
|
+
headers: {
|
|
7133
|
+
...req.headers,
|
|
7134
|
+
"content-length": Buffer.byteLength(
|
|
7135
|
+
body
|
|
7136
|
+
)
|
|
7137
|
+
}
|
|
7108
7138
|
},
|
|
7109
7139
|
(msg) => {
|
|
7110
|
-
msg.
|
|
7111
|
-
|
|
7112
|
-
|
|
7113
|
-
|
|
7114
|
-
msg.on("end", () => {
|
|
7115
|
-
const content = Buffer.concat(
|
|
7116
|
-
chunks
|
|
7117
|
-
).toString("utf8");
|
|
7118
|
-
resolve2({
|
|
7119
|
-
statusCode: msg.statusCode,
|
|
7120
|
-
headers: msg.headers,
|
|
7121
|
-
content
|
|
7122
|
-
});
|
|
7140
|
+
statusCode = msg.statusCode;
|
|
7141
|
+
incomingHeaders = msg.headers;
|
|
7142
|
+
msg.on("data", (data) => {
|
|
7143
|
+
chunks.push(data);
|
|
7123
7144
|
});
|
|
7124
7145
|
}
|
|
7125
|
-
).on("error",
|
|
7146
|
+
).on("error", (error) => {
|
|
7147
|
+
reject(error);
|
|
7148
|
+
}).on("close", () => {
|
|
7149
|
+
const content = Buffer.concat(
|
|
7150
|
+
chunks
|
|
7151
|
+
).toString("utf8");
|
|
7152
|
+
resolve2({
|
|
7153
|
+
statusCode,
|
|
7154
|
+
headers: incomingHeaders,
|
|
7155
|
+
content
|
|
7156
|
+
});
|
|
7157
|
+
});
|
|
7158
|
+
request.write(body, (error) => {
|
|
7159
|
+
if (error) {
|
|
7160
|
+
reject(error);
|
|
7161
|
+
}
|
|
7162
|
+
});
|
|
7163
|
+
request.end();
|
|
7126
7164
|
});
|
|
7127
7165
|
let out = phpResult.content;
|
|
7128
7166
|
if (phpResult.headers["content-type"]?.includes("html")) {
|
|
@@ -7132,23 +7170,23 @@ function usePHP(cfg = {}) {
|
|
|
7132
7170
|
"/" + entryPathname
|
|
7133
7171
|
);
|
|
7134
7172
|
}
|
|
7135
|
-
res.writeHead(
|
|
7136
|
-
|
|
7137
|
-
|
|
7138
|
-
|
|
7173
|
+
res.writeHead(
|
|
7174
|
+
phpResult.statusCode || 200,
|
|
7175
|
+
phpResult.headers
|
|
7176
|
+
).end(out);
|
|
7139
7177
|
return;
|
|
7140
7178
|
}
|
|
7141
7179
|
}
|
|
7142
7180
|
}
|
|
7143
7181
|
} catch (error) {
|
|
7144
|
-
console.error(
|
|
7182
|
+
console.error("Vite-PHP Error: " + error);
|
|
7145
7183
|
}
|
|
7146
7184
|
next();
|
|
7147
7185
|
});
|
|
7148
7186
|
},
|
|
7149
7187
|
async handleHotUpdate({ server, file }) {
|
|
7150
7188
|
const entry2 = entries.find(
|
|
7151
|
-
(entryFile) => require$$0
|
|
7189
|
+
(entryFile) => require$$0.resolve(entryFile) === require$$0.resolve(file)
|
|
7152
7190
|
);
|
|
7153
7191
|
if (entry2) {
|
|
7154
7192
|
const outputFile = getTempFileName(entry2);
|
|
@@ -7158,7 +7196,7 @@ function usePHP(cfg = {}) {
|
|
|
7158
7196
|
}).write(outputFile);
|
|
7159
7197
|
server.moduleGraph.invalidateAll();
|
|
7160
7198
|
}
|
|
7161
|
-
if (entry2 || !file.startsWith(require$$0
|
|
7199
|
+
if (entry2 || !file.startsWith(require$$0.resolve(tempDir)) && file.includes(".php")) {
|
|
7162
7200
|
server.ws.send({
|
|
7163
7201
|
type: "full-reload"
|
|
7164
7202
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import require$$0$
|
|
2
|
-
import require$$0$
|
|
1
|
+
import require$$0$4, { mkdirSync, writeFileSync, readFileSync, existsSync, rmSync } from 'fs';
|
|
2
|
+
import require$$0$1, { relative, dirname, resolve } from 'path';
|
|
3
3
|
import { normalizePath } from 'vite';
|
|
4
|
-
import
|
|
5
|
-
import http from 'http';
|
|
4
|
+
import http from 'node:http';
|
|
6
5
|
import { spawn } from 'child_process';
|
|
7
6
|
import { fileURLToPath } from 'url';
|
|
8
|
-
import require$$0
|
|
9
|
-
import require$$0$
|
|
10
|
-
import require$$0$
|
|
11
|
-
import require$$0$
|
|
7
|
+
import require$$0 from 'os';
|
|
8
|
+
import require$$0$2 from 'util';
|
|
9
|
+
import require$$0$3 from 'stream';
|
|
10
|
+
import require$$0$5 from 'events';
|
|
12
11
|
|
|
13
12
|
function makeID() {
|
|
14
13
|
return Date.now().toString(36) + Math.random() * 100;
|
|
@@ -20,35 +19,21 @@ function getDefaultExportFromCjs (x) {
|
|
|
20
19
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
21
20
|
}
|
|
22
21
|
|
|
23
|
-
function commonjsRequire(path) {
|
|
24
|
-
throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
|
|
25
|
-
}
|
|
26
|
-
|
|
27
22
|
var picocolors = {exports: {}};
|
|
28
23
|
|
|
29
|
-
let argv =
|
|
30
|
-
env = process.env;
|
|
24
|
+
let p = process || {}, argv = p.argv || [], env = p.env || {};
|
|
31
25
|
let isColorSupported =
|
|
32
|
-
!(
|
|
33
|
-
(
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
(commonjsRequire != null && require$$0.isatty(1) && env.TERM !== "dumb") ||
|
|
37
|
-
"CI" in env);
|
|
38
|
-
|
|
39
|
-
let formatter =
|
|
40
|
-
(open, close, replace = open) =>
|
|
26
|
+
!(!!env.NO_COLOR || argv.includes("--no-color")) &&
|
|
27
|
+
(!!env.FORCE_COLOR || argv.includes("--color") || p.platform === "win32" || ((p.stdout || {}).isTTY && env.TERM !== "dumb") || !!env.CI);
|
|
28
|
+
|
|
29
|
+
let formatter = (open, close, replace = open) =>
|
|
41
30
|
input => {
|
|
42
|
-
let string = "" + input;
|
|
43
|
-
|
|
44
|
-
return ~index
|
|
45
|
-
? open + replaceClose(string, close, replace, index) + close
|
|
46
|
-
: open + string + close
|
|
31
|
+
let string = "" + input, index = string.indexOf(close, open.length);
|
|
32
|
+
return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close
|
|
47
33
|
};
|
|
48
34
|
|
|
49
35
|
let replaceClose = (string, close, replace, index) => {
|
|
50
|
-
let result = "";
|
|
51
|
-
let cursor = 0;
|
|
36
|
+
let result = "", cursor = 0;
|
|
52
37
|
do {
|
|
53
38
|
result += string.substring(cursor, index) + replace;
|
|
54
39
|
cursor = index + close.length;
|
|
@@ -58,34 +43,54 @@ let replaceClose = (string, close, replace, index) => {
|
|
|
58
43
|
};
|
|
59
44
|
|
|
60
45
|
let createColors = (enabled = isColorSupported) => {
|
|
61
|
-
let
|
|
46
|
+
let f = enabled ? formatter : () => String;
|
|
62
47
|
return {
|
|
63
48
|
isColorSupported: enabled,
|
|
64
|
-
reset:
|
|
65
|
-
bold:
|
|
66
|
-
dim:
|
|
67
|
-
italic:
|
|
68
|
-
underline:
|
|
69
|
-
inverse:
|
|
70
|
-
hidden:
|
|
71
|
-
strikethrough:
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
49
|
+
reset: f("\x1b[0m", "\x1b[0m"),
|
|
50
|
+
bold: f("\x1b[1m", "\x1b[22m", "\x1b[22m\x1b[1m"),
|
|
51
|
+
dim: f("\x1b[2m", "\x1b[22m", "\x1b[22m\x1b[2m"),
|
|
52
|
+
italic: f("\x1b[3m", "\x1b[23m"),
|
|
53
|
+
underline: f("\x1b[4m", "\x1b[24m"),
|
|
54
|
+
inverse: f("\x1b[7m", "\x1b[27m"),
|
|
55
|
+
hidden: f("\x1b[8m", "\x1b[28m"),
|
|
56
|
+
strikethrough: f("\x1b[9m", "\x1b[29m"),
|
|
57
|
+
|
|
58
|
+
black: f("\x1b[30m", "\x1b[39m"),
|
|
59
|
+
red: f("\x1b[31m", "\x1b[39m"),
|
|
60
|
+
green: f("\x1b[32m", "\x1b[39m"),
|
|
61
|
+
yellow: f("\x1b[33m", "\x1b[39m"),
|
|
62
|
+
blue: f("\x1b[34m", "\x1b[39m"),
|
|
63
|
+
magenta: f("\x1b[35m", "\x1b[39m"),
|
|
64
|
+
cyan: f("\x1b[36m", "\x1b[39m"),
|
|
65
|
+
white: f("\x1b[37m", "\x1b[39m"),
|
|
66
|
+
gray: f("\x1b[90m", "\x1b[39m"),
|
|
67
|
+
|
|
68
|
+
bgBlack: f("\x1b[40m", "\x1b[49m"),
|
|
69
|
+
bgRed: f("\x1b[41m", "\x1b[49m"),
|
|
70
|
+
bgGreen: f("\x1b[42m", "\x1b[49m"),
|
|
71
|
+
bgYellow: f("\x1b[43m", "\x1b[49m"),
|
|
72
|
+
bgBlue: f("\x1b[44m", "\x1b[49m"),
|
|
73
|
+
bgMagenta: f("\x1b[45m", "\x1b[49m"),
|
|
74
|
+
bgCyan: f("\x1b[46m", "\x1b[49m"),
|
|
75
|
+
bgWhite: f("\x1b[47m", "\x1b[49m"),
|
|
76
|
+
|
|
77
|
+
blackBright: f("\x1b[90m", "\x1b[39m"),
|
|
78
|
+
redBright: f("\x1b[91m", "\x1b[39m"),
|
|
79
|
+
greenBright: f("\x1b[92m", "\x1b[39m"),
|
|
80
|
+
yellowBright: f("\x1b[93m", "\x1b[39m"),
|
|
81
|
+
blueBright: f("\x1b[94m", "\x1b[39m"),
|
|
82
|
+
magentaBright: f("\x1b[95m", "\x1b[39m"),
|
|
83
|
+
cyanBright: f("\x1b[96m", "\x1b[39m"),
|
|
84
|
+
whiteBright: f("\x1b[97m", "\x1b[39m"),
|
|
85
|
+
|
|
86
|
+
bgBlackBright: f("\x1b[100m", "\x1b[49m"),
|
|
87
|
+
bgRedBright: f("\x1b[101m", "\x1b[49m"),
|
|
88
|
+
bgGreenBright: f("\x1b[102m", "\x1b[49m"),
|
|
89
|
+
bgYellowBright: f("\x1b[103m", "\x1b[49m"),
|
|
90
|
+
bgBlueBright: f("\x1b[104m", "\x1b[49m"),
|
|
91
|
+
bgMagentaBright: f("\x1b[105m", "\x1b[49m"),
|
|
92
|
+
bgCyanBright: f("\x1b[106m", "\x1b[49m"),
|
|
93
|
+
bgWhiteBright: f("\x1b[107m", "\x1b[49m"),
|
|
89
94
|
}
|
|
90
95
|
};
|
|
91
96
|
|
|
@@ -209,7 +214,7 @@ function start(root) {
|
|
|
209
214
|
}
|
|
210
215
|
function stop() {
|
|
211
216
|
if (globalThis.php) {
|
|
212
|
-
globalThis.php.stdin?.
|
|
217
|
+
globalThis.php.stdin?.destroy();
|
|
213
218
|
globalThis.php.stdout?.destroy();
|
|
214
219
|
globalThis.php.stderr?.destroy();
|
|
215
220
|
if (globalThis.php.kill()) {
|
|
@@ -288,8 +293,8 @@ var path$9 = {};
|
|
|
288
293
|
|
|
289
294
|
Object.defineProperty(path$9, "__esModule", { value: true });
|
|
290
295
|
path$9.convertPosixPathToPattern = path$9.convertWindowsPathToPattern = path$9.convertPathToPattern = path$9.escapePosixPath = path$9.escapeWindowsPath = path$9.escape = path$9.removeLeadingDotSegment = path$9.makeAbsolute = path$9.unixify = void 0;
|
|
291
|
-
const os = require$$0
|
|
292
|
-
const path$8 = require$$0$
|
|
296
|
+
const os = require$$0;
|
|
297
|
+
const path$8 = require$$0$1;
|
|
293
298
|
const IS_WINDOWS_PLATFORM = os.platform() === 'win32';
|
|
294
299
|
const LEADING_DOT_SEGMENT_CHARACTERS_COUNT = 2; // ./ or .\\
|
|
295
300
|
/**
|
|
@@ -529,8 +534,8 @@ var isGlob$1 = function isGlob(str, options) {
|
|
|
529
534
|
};
|
|
530
535
|
|
|
531
536
|
var isGlob = isGlob$1;
|
|
532
|
-
var pathPosixDirname = require$$0$
|
|
533
|
-
var isWin32 = require$$0
|
|
537
|
+
var pathPosixDirname = require$$0$1.posix.dirname;
|
|
538
|
+
var isWin32 = require$$0.platform() === 'win32';
|
|
534
539
|
|
|
535
540
|
var slash = '/';
|
|
536
541
|
var backslash = /\\/g;
|
|
@@ -1026,7 +1031,7 @@ var toRegexRange_1 = toRegexRange$1;
|
|
|
1026
1031
|
* Licensed under the MIT License.
|
|
1027
1032
|
*/
|
|
1028
1033
|
|
|
1029
|
-
const util$1 = require$$0$
|
|
1034
|
+
const util$1 = require$$0$2;
|
|
1030
1035
|
const toRegexRange = toRegexRange_1;
|
|
1031
1036
|
|
|
1032
1037
|
const isObject$1 = val => val !== null && typeof val === 'object' && !Array.isArray(val);
|
|
@@ -1991,7 +1996,7 @@ var braces_1 = braces$1;
|
|
|
1991
1996
|
|
|
1992
1997
|
var utils$f = {};
|
|
1993
1998
|
|
|
1994
|
-
const path$7 = require$$0$
|
|
1999
|
+
const path$7 = require$$0$1;
|
|
1995
2000
|
const WIN_SLASH = '\\\\/';
|
|
1996
2001
|
const WIN_NO_SLASH = `[^${WIN_SLASH}]`;
|
|
1997
2002
|
|
|
@@ -2171,7 +2176,7 @@ var constants$3 = {
|
|
|
2171
2176
|
|
|
2172
2177
|
(function (exports) {
|
|
2173
2178
|
|
|
2174
|
-
const path = require$$0$
|
|
2179
|
+
const path = require$$0$1;
|
|
2175
2180
|
const win32 = process.platform === 'win32';
|
|
2176
2181
|
const {
|
|
2177
2182
|
REGEX_BACKSLASH,
|
|
@@ -3715,7 +3720,7 @@ parse$1.fastpaths = (input, options) => {
|
|
|
3715
3720
|
|
|
3716
3721
|
var parse_1 = parse$1;
|
|
3717
3722
|
|
|
3718
|
-
const path$6 = require$$0$
|
|
3723
|
+
const path$6 = require$$0$1;
|
|
3719
3724
|
const scan = scan_1;
|
|
3720
3725
|
const parse = parse_1;
|
|
3721
3726
|
const utils$c = utils$f;
|
|
@@ -4058,7 +4063,7 @@ var picomatch_1 = picomatch$2;
|
|
|
4058
4063
|
|
|
4059
4064
|
var picomatch$1 = picomatch_1;
|
|
4060
4065
|
|
|
4061
|
-
const util = require$$0$
|
|
4066
|
+
const util = require$$0$2;
|
|
4062
4067
|
const braces = braces_1;
|
|
4063
4068
|
const picomatch = picomatch$1;
|
|
4064
4069
|
const utils$b = utils$f;
|
|
@@ -4526,7 +4531,7 @@ var micromatch_1 = micromatch$1;
|
|
|
4526
4531
|
|
|
4527
4532
|
Object.defineProperty(pattern$1, "__esModule", { value: true });
|
|
4528
4533
|
pattern$1.removeDuplicateSlashes = pattern$1.matchAny = pattern$1.convertPatternsToRe = pattern$1.makeRe = pattern$1.getPatternParts = pattern$1.expandBraceExpansion = pattern$1.expandPatternsWithBraceExpansion = pattern$1.isAffectDepthOfReadingPattern = pattern$1.endsWithSlashGlobStar = pattern$1.hasGlobStar = pattern$1.getBaseDirectory = pattern$1.isPatternRelatedToParentDirectory = pattern$1.getPatternsOutsideCurrentDirectory = pattern$1.getPatternsInsideCurrentDirectory = pattern$1.getPositivePatterns = pattern$1.getNegativePatterns = pattern$1.isPositivePattern = pattern$1.isNegativePattern = pattern$1.convertToNegativePattern = pattern$1.convertToPositivePattern = pattern$1.isDynamicPattern = pattern$1.isStaticPattern = void 0;
|
|
4529
|
-
const path$5 = require$$0$
|
|
4534
|
+
const path$5 = require$$0$1;
|
|
4530
4535
|
const globParent = globParent$1;
|
|
4531
4536
|
const micromatch = micromatch_1;
|
|
4532
4537
|
const GLOBSTAR = '**';
|
|
@@ -4721,7 +4726,7 @@ var stream$4 = {};
|
|
|
4721
4726
|
* Copyright (c) 2014-2020 Teambition
|
|
4722
4727
|
* Licensed under the MIT license.
|
|
4723
4728
|
*/
|
|
4724
|
-
const Stream = require$$0$
|
|
4729
|
+
const Stream = require$$0$3;
|
|
4725
4730
|
const PassThrough = Stream.PassThrough;
|
|
4726
4731
|
const slice = Array.prototype.slice;
|
|
4727
4732
|
|
|
@@ -5101,7 +5106,7 @@ var fs$5 = {};
|
|
|
5101
5106
|
(function (exports) {
|
|
5102
5107
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5103
5108
|
exports.createFileSystemAdapter = exports.FILE_SYSTEM_ADAPTER = void 0;
|
|
5104
|
-
const fs = require$$0$
|
|
5109
|
+
const fs = require$$0$4;
|
|
5105
5110
|
exports.FILE_SYSTEM_ADAPTER = {
|
|
5106
5111
|
lstat: fs.lstat,
|
|
5107
5112
|
stat: fs.stat,
|
|
@@ -5452,7 +5457,7 @@ var fs$1 = {};
|
|
|
5452
5457
|
(function (exports) {
|
|
5453
5458
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5454
5459
|
exports.createFileSystemAdapter = exports.FILE_SYSTEM_ADAPTER = void 0;
|
|
5455
|
-
const fs = require$$0$
|
|
5460
|
+
const fs = require$$0$4;
|
|
5456
5461
|
exports.FILE_SYSTEM_ADAPTER = {
|
|
5457
5462
|
lstat: fs.lstat,
|
|
5458
5463
|
stat: fs.stat,
|
|
@@ -5471,7 +5476,7 @@ var fs$1 = {};
|
|
|
5471
5476
|
} (fs$1));
|
|
5472
5477
|
|
|
5473
5478
|
Object.defineProperty(settings$2, "__esModule", { value: true });
|
|
5474
|
-
const path$3 = require$$0$
|
|
5479
|
+
const path$3 = require$$0$1;
|
|
5475
5480
|
const fsStat$3 = out$1;
|
|
5476
5481
|
const fs = fs$1;
|
|
5477
5482
|
let Settings$1 = class Settings {
|
|
@@ -5913,7 +5918,7 @@ let Reader$1 = class Reader {
|
|
|
5913
5918
|
reader$1.default = Reader$1;
|
|
5914
5919
|
|
|
5915
5920
|
Object.defineProperty(async$4, "__esModule", { value: true });
|
|
5916
|
-
const events_1 = require$$0$
|
|
5921
|
+
const events_1 = require$$0$5;
|
|
5917
5922
|
const fsScandir$2 = out$2;
|
|
5918
5923
|
const fastq = queueExports;
|
|
5919
5924
|
const common$1 = common$3;
|
|
@@ -6042,7 +6047,7 @@ function callSuccessCallback(callback, entries) {
|
|
|
6042
6047
|
var stream$2 = {};
|
|
6043
6048
|
|
|
6044
6049
|
Object.defineProperty(stream$2, "__esModule", { value: true });
|
|
6045
|
-
const stream_1$5 = require$$0$
|
|
6050
|
+
const stream_1$5 = require$$0$3;
|
|
6046
6051
|
const async_1$3 = async$4;
|
|
6047
6052
|
class StreamProvider {
|
|
6048
6053
|
constructor(_root, _settings) {
|
|
@@ -6155,7 +6160,7 @@ sync$3.default = SyncProvider;
|
|
|
6155
6160
|
var settings$1 = {};
|
|
6156
6161
|
|
|
6157
6162
|
Object.defineProperty(settings$1, "__esModule", { value: true });
|
|
6158
|
-
const path$2 = require$$0$
|
|
6163
|
+
const path$2 = require$$0$1;
|
|
6159
6164
|
const fsScandir = out$2;
|
|
6160
6165
|
class Settings {
|
|
6161
6166
|
constructor(_options = {}) {
|
|
@@ -6217,7 +6222,7 @@ function getSettings(settingsOrOptions = {}) {
|
|
|
6217
6222
|
var reader = {};
|
|
6218
6223
|
|
|
6219
6224
|
Object.defineProperty(reader, "__esModule", { value: true });
|
|
6220
|
-
const path$1 = require$$0$
|
|
6225
|
+
const path$1 = require$$0$1;
|
|
6221
6226
|
const fsStat$2 = out$1;
|
|
6222
6227
|
const utils$6 = utils$k;
|
|
6223
6228
|
class Reader {
|
|
@@ -6252,7 +6257,7 @@ reader.default = Reader;
|
|
|
6252
6257
|
var stream$1 = {};
|
|
6253
6258
|
|
|
6254
6259
|
Object.defineProperty(stream$1, "__esModule", { value: true });
|
|
6255
|
-
const stream_1$3 = require$$0$
|
|
6260
|
+
const stream_1$3 = require$$0$3;
|
|
6256
6261
|
const fsStat$1 = out$1;
|
|
6257
6262
|
const fsWalk$2 = out$3;
|
|
6258
6263
|
const reader_1$2 = reader;
|
|
@@ -6605,7 +6610,7 @@ class EntryTransformer {
|
|
|
6605
6610
|
entry.default = EntryTransformer;
|
|
6606
6611
|
|
|
6607
6612
|
Object.defineProperty(provider, "__esModule", { value: true });
|
|
6608
|
-
const path = require$$0$
|
|
6613
|
+
const path = require$$0$1;
|
|
6609
6614
|
const deep_1 = deep;
|
|
6610
6615
|
const entry_1 = entry$1;
|
|
6611
6616
|
const error_1 = error;
|
|
@@ -6678,7 +6683,7 @@ async$7.default = ProviderAsync;
|
|
|
6678
6683
|
var stream = {};
|
|
6679
6684
|
|
|
6680
6685
|
Object.defineProperty(stream, "__esModule", { value: true });
|
|
6681
|
-
const stream_1$1 = require$$0$
|
|
6686
|
+
const stream_1$1 = require$$0$3;
|
|
6682
6687
|
const stream_2 = stream$1;
|
|
6683
6688
|
const provider_1$1 = provider;
|
|
6684
6689
|
class ProviderStream extends provider_1$1.default {
|
|
@@ -6783,8 +6788,8 @@ var settings = {};
|
|
|
6783
6788
|
(function (exports) {
|
|
6784
6789
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6785
6790
|
exports.DEFAULT_FILE_SYSTEM_ADAPTER = void 0;
|
|
6786
|
-
const fs = require$$0$
|
|
6787
|
-
const os = require$$0
|
|
6791
|
+
const fs = require$$0$4;
|
|
6792
|
+
const os = require$$0;
|
|
6788
6793
|
/**
|
|
6789
6794
|
* The `os.cpus` method can return zero. We expect the number of cores to be greater than zero.
|
|
6790
6795
|
* https://github.com/nodejs/node/blob/7faeddf23a98c53896f8b574a6e66589e8fb1eb8/lib/os.js#L106-L107
|
|
@@ -7051,9 +7056,18 @@ function usePHP(cfg = {}) {
|
|
|
7051
7056
|
phpServer.start(viteServer?.config.root);
|
|
7052
7057
|
server.middlewares.use(async (req, res, next) => {
|
|
7053
7058
|
try {
|
|
7054
|
-
if (req.url && ![
|
|
7055
|
-
|
|
7056
|
-
|
|
7059
|
+
if (req.url && ![
|
|
7060
|
+
"/@vite",
|
|
7061
|
+
"/@fs",
|
|
7062
|
+
"/@id/__x00__",
|
|
7063
|
+
"/node_modules"
|
|
7064
|
+
].some((path) => req.url.startsWith(path))) {
|
|
7065
|
+
req.on("error", (error) => {
|
|
7066
|
+
throw error;
|
|
7067
|
+
});
|
|
7068
|
+
res.on("error", (error) => {
|
|
7069
|
+
throw error;
|
|
7070
|
+
});
|
|
7057
7071
|
const url = new URL(req.url, "http://localhost");
|
|
7058
7072
|
if (config?.server.port) {
|
|
7059
7073
|
url.port = config.server.port.toString();
|
|
@@ -7084,31 +7098,56 @@ function usePHP(cfg = {}) {
|
|
|
7084
7098
|
PHP_SELF: "/" + entry2
|
|
7085
7099
|
}).toString()
|
|
7086
7100
|
);
|
|
7087
|
-
const
|
|
7101
|
+
const body = await new Promise(
|
|
7102
|
+
(resolve2, reject) => {
|
|
7103
|
+
let data = [];
|
|
7104
|
+
req.on("data", (chunk) => {
|
|
7105
|
+
data.push(chunk);
|
|
7106
|
+
}).on("end", () => {
|
|
7107
|
+
resolve2(Buffer.concat(data));
|
|
7108
|
+
});
|
|
7109
|
+
}
|
|
7110
|
+
);
|
|
7111
|
+
const phpResult = await new Promise(async (resolve2, reject) => {
|
|
7088
7112
|
const chunks = [];
|
|
7089
|
-
|
|
7113
|
+
let statusCode;
|
|
7114
|
+
let incomingHeaders = {};
|
|
7115
|
+
const request = http.request(
|
|
7090
7116
|
url.toString(),
|
|
7091
7117
|
{
|
|
7092
7118
|
method: req.method,
|
|
7093
|
-
headers:
|
|
7119
|
+
headers: {
|
|
7120
|
+
...req.headers,
|
|
7121
|
+
"content-length": Buffer.byteLength(
|
|
7122
|
+
body
|
|
7123
|
+
)
|
|
7124
|
+
}
|
|
7094
7125
|
},
|
|
7095
7126
|
(msg) => {
|
|
7096
|
-
msg.
|
|
7097
|
-
|
|
7098
|
-
|
|
7099
|
-
|
|
7100
|
-
msg.on("end", () => {
|
|
7101
|
-
const content = Buffer.concat(
|
|
7102
|
-
chunks
|
|
7103
|
-
).toString("utf8");
|
|
7104
|
-
resolve2({
|
|
7105
|
-
statusCode: msg.statusCode,
|
|
7106
|
-
headers: msg.headers,
|
|
7107
|
-
content
|
|
7108
|
-
});
|
|
7127
|
+
statusCode = msg.statusCode;
|
|
7128
|
+
incomingHeaders = msg.headers;
|
|
7129
|
+
msg.on("data", (data) => {
|
|
7130
|
+
chunks.push(data);
|
|
7109
7131
|
});
|
|
7110
7132
|
}
|
|
7111
|
-
).on("error",
|
|
7133
|
+
).on("error", (error) => {
|
|
7134
|
+
reject(error);
|
|
7135
|
+
}).on("close", () => {
|
|
7136
|
+
const content = Buffer.concat(
|
|
7137
|
+
chunks
|
|
7138
|
+
).toString("utf8");
|
|
7139
|
+
resolve2({
|
|
7140
|
+
statusCode,
|
|
7141
|
+
headers: incomingHeaders,
|
|
7142
|
+
content
|
|
7143
|
+
});
|
|
7144
|
+
});
|
|
7145
|
+
request.write(body, (error) => {
|
|
7146
|
+
if (error) {
|
|
7147
|
+
reject(error);
|
|
7148
|
+
}
|
|
7149
|
+
});
|
|
7150
|
+
request.end();
|
|
7112
7151
|
});
|
|
7113
7152
|
let out = phpResult.content;
|
|
7114
7153
|
if (phpResult.headers["content-type"]?.includes("html")) {
|
|
@@ -7118,23 +7157,23 @@ function usePHP(cfg = {}) {
|
|
|
7118
7157
|
"/" + entryPathname
|
|
7119
7158
|
);
|
|
7120
7159
|
}
|
|
7121
|
-
res.writeHead(
|
|
7122
|
-
|
|
7123
|
-
|
|
7124
|
-
|
|
7160
|
+
res.writeHead(
|
|
7161
|
+
phpResult.statusCode || 200,
|
|
7162
|
+
phpResult.headers
|
|
7163
|
+
).end(out);
|
|
7125
7164
|
return;
|
|
7126
7165
|
}
|
|
7127
7166
|
}
|
|
7128
7167
|
}
|
|
7129
7168
|
} catch (error) {
|
|
7130
|
-
console.error(
|
|
7169
|
+
console.error("Vite-PHP Error: " + error);
|
|
7131
7170
|
}
|
|
7132
7171
|
next();
|
|
7133
7172
|
});
|
|
7134
7173
|
},
|
|
7135
7174
|
async handleHotUpdate({ server, file }) {
|
|
7136
7175
|
const entry2 = entries.find(
|
|
7137
|
-
(entryFile) => resolve(entryFile) === file
|
|
7176
|
+
(entryFile) => resolve(entryFile) === resolve(file)
|
|
7138
7177
|
);
|
|
7139
7178
|
if (entry2) {
|
|
7140
7179
|
const outputFile = getTempFileName(entry2);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-plugin-php",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.66",
|
|
4
4
|
"author": "Nikita 'donnikitos' Nitichevski <me@donnikitos.com> (https://donnikitos.com/)",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -9,12 +9,12 @@
|
|
|
9
9
|
"main": "./dist/index.mjs",
|
|
10
10
|
"module": "./dist/index.mjs",
|
|
11
11
|
"devDependencies": {
|
|
12
|
-
"@types/node": "^22.
|
|
12
|
+
"@types/node": "^22.9.0",
|
|
13
13
|
"fast-glob": "^3.3.2",
|
|
14
|
-
"picocolors": "^1.
|
|
15
|
-
"typescript": "^5.
|
|
14
|
+
"picocolors": "^1.1.1",
|
|
15
|
+
"typescript": "^5.6.3",
|
|
16
16
|
"unbuild": "^2.0.0",
|
|
17
|
-
"vite": "^5.4.
|
|
17
|
+
"vite": "^5.4.10"
|
|
18
18
|
},
|
|
19
19
|
"exports": {
|
|
20
20
|
".": {
|