Skip to content

Commit 4cb1123

Browse files
authored
Merge pull request #71 from glassmonkey/feat/add-build
Support PHP 8.3
2 parents 39b5683 + 10a25f4 commit 4cb1123

31 files changed

+10653
-17444
lines changed

assets/php-5.6.wasm

-9.12 KB
Binary file not shown.

assets/php-7.0.wasm

-4.15 KB
Binary file not shown.

assets/php-7.1.wasm

-3.47 KB
Binary file not shown.

assets/php-7.2.wasm

-3.27 KB
Binary file not shown.

assets/php-7.3.wasm

1.18 KB
Binary file not shown.

assets/php-7.4.wasm

-1.97 KB
Binary file not shown.

assets/php-8.0.wasm

-1.17 KB
Binary file not shown.

assets/php-8.1.wasm

-1.15 KB
Binary file not shown.

assets/php-8.2.wasm

-7.79 KB
Binary file not shown.

assets/php-8.3.wasm

3.57 MB
Binary file not shown.

src/__test__/__snapshots__/php.test.ts.snap

+544-32
Large diffs are not rendered by default.

src/app.tsx

+21-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,21 @@
11
import * as React from 'react';
22
import { useEffect } from 'react';
3-
import {Flex, Box, Spacer, Text, Link, Center, Button} from '@chakra-ui/react';
3+
import {
4+
Flex,
5+
Box,
6+
Spacer,
7+
Text,
8+
Link,
9+
Center,
10+
Button,
11+
} from '@chakra-ui/react';
412
import { useSearchParams } from 'react-router-dom';
513
import * as lzstring from 'lz-string';
614

7-
import { Version, versions, asVersion } from './php-wasm/php';
15+
import { Version, asVersion } from './php-wasm/php';
816
import SelectPHP from './select';
917
import { Editor } from './editor';
10-
import {SunIcon} from "@chakra-ui/icons";
18+
import { SunIcon } from '@chakra-ui/icons';
1119

1220
type UrlState = {
1321
v: Version;
@@ -22,13 +30,16 @@ export default function App() {
2230
) ?? '<?php\n// example code\nphpinfo();';
2331

2432
const currentVersion =
25-
asVersion(searchParams.get('v')) ?? versions[versions.length - 1];
33+
asVersion(searchParams.get('v')) ?? '8.2';
2634

2735
function updateVersion(v: Version) {
2836
const currentState = history.state as UrlState | null;
2937
const code = lzstring.decompressFromEncodedURIComponent(
3038
currentState?.c ?? initCode
3139
);
40+
if (code == null) {
41+
return;
42+
}
3243
setSearchParams({
3344
v: v,
3445
c: lzstring.compressToEncodedURIComponent(code),
@@ -87,7 +98,12 @@ export default function App() {
8798
<Spacer />
8899
<Flex direction={{ base: 'column', lg: 'row' }} gap="16px">
89100
<Center>
90-
<Button leftIcon={<SunIcon />} href="https://github.com/sponsors/glassmonkey" as="a" colorScheme="green">
101+
<Button
102+
leftIcon={<SunIcon />}
103+
href="https://github.com/sponsors/glassmonkey"
104+
as="a"
105+
colorScheme="green"
106+
>
91107
Donate
92108
</Button>
93109
</Center>

src/header.tsx

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {Heading, Text, Flex, Center} from '@chakra-ui/react';
1+
import { Heading, Text, Flex, Center } from '@chakra-ui/react';
22
import * as React from 'react';
33

44
export default function Header() {
@@ -11,7 +11,9 @@ export default function Header() {
1111
</Text>
1212
<Flex gap="24px" direction="row">
1313
<Center>
14-
<Text fontStyle="italic" href="#about" as="a">About PHP Playground?</Text>
14+
<Text fontStyle="italic" href="#about" as="a">
15+
About PHP Playground?
16+
</Text>
1517
</Center>
1618
</Flex>
1719
</Flex>

src/php-wasm/php.ts

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export const versions = [
1313
'8.0',
1414
'8.1',
1515
'8.2',
16+
'8.3',
1617
] as const;
1718

1819
export type Version = (typeof versions)[number];

src/php.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,14 @@ async function loadPHPLoaderModule(v: Version) {
3030
case '8.2':
3131
// @ts-ignore
3232
return import('./wasm-assets/php-8.2.js');
33+
case '8.3':
34+
// @ts-ignore
35+
return import('./wasm-assets/php-8.3.js');
3336
default:
34-
return Error('not defined version');
37+
/* eslint no-case-declarations: 0 */
38+
/* eslint @typescript-eslint/no-unused-vars: 0 */
39+
const x: never = v
40+
throw Error('not defined version');
3541
}
3642
}
3743

0 commit comments

Comments
 (0)