Skip to content

Commit 67a743a

Browse files
committed
PHP Show & Tell Fun
1 parent 3ef41ed commit 67a743a

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

esm/interpreter/php-wasm.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { dedent } from '../utils.js';
2-
import { fetchFiles, fetchPaths, io, stdio, writeFileShim } from './_utils.js';
2+
import { io, stdio } from './_utils.js';
33

44
const type = 'php-wasm';
55

@@ -11,10 +11,17 @@ export default {
1111
type,
1212
module: (version = '0.0.3') => `https://cdn.jsdelivr.net/npm/@webreflection/php@${version}/es.js`,
1313
async engine({ PhpWeb }, _, url) {
14-
const { stderr, stdout, get } = stdio();
14+
const { stderr, get } = stdio();
1515
const interpreter = await new Promise(resolve => {
16+
let timer = 0, chunks = [];
1617
const php = new PhpWeb({
17-
print: stdout,
18+
print: (message) => {
19+
chunks.push(message);
20+
clearTimeout(timer);
21+
timer = setTimeout(() => {
22+
document.getElementById('target').innerHTML = chunks.splice(0).join('');
23+
});
24+
},
1825
printErr: (message) => {
1926
if (message) stderr(message);
2027
},

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,6 @@
7171
"html-escaper": "^3.0.3"
7272
},
7373
"worker": {
74-
"blob": "sha256-ixJNXrBnwM18zoc4l44JmnNzgD+eoNpGaOcZz3dXP94="
74+
"blob": "sha256-BDFBL6yh1wOU5tFuRvJ/0Eg3QHPu/yDsay/B77CbrGM="
7575
}
7676
}

test/php-wasm.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
</head>
1010
<body>
1111
<script type="php-wasm">
12-
echo 'Hello PHP';
13-
vrzno_run('alert', ['Hello, World!']);
12+
phpinfo();
1413
</script>
14+
<div id="target"></div>
1515
</body>
1616
</html>

0 commit comments

Comments
 (0)