Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

REPL #9365

Merged
merged 40 commits into from
Jan 4, 2024
Merged

REPL #9365

Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
02c7101
REPL
mischnic Oct 27, 2021
076ae18
REPL register serializer classes
mischnic Oct 26, 2023
1c667c9
REPL absolutes paths
mischnic Oct 25, 2023
c79fd8f
REPL experiment RemoteCache
mischnic Jul 10, 2022
d758b43
REPL patch fs.scandir
mischnic Nov 6, 2023
ef61b80
REPL Use buffer polyfill with fastpaths
mischnic Nov 6, 2023
f5eaac4
Expose TextDe/Encoder when executing tests
mischnic Nov 6, 2023
c619ccf
Build REPL on CI
mischnic Nov 6, 2023
0025d0e
REPL CI Alias for PRs
mischnic Nov 11, 2023
3ffa307
Merge branch 'v2' into repl-v2-ide
devongovett Nov 12, 2023
bcf6446
Pass ref to GH deployment api
mischnic Nov 12, 2023
3733258
Flow type ExtendedMemoryFS
mischnic Nov 13, 2023
06694d2
REPL Better HMR example
mischnic Nov 13, 2023
170a91c
REPL remove hmr-sse runtime
mischnic Nov 13, 2023
f1cfac4
Update versions
mischnic Nov 13, 2023
8fe737f
Remove unused remote caching experiments
mischnic Nov 13, 2023
879225e
Merge branch 'v2' into repl-v2-ide
mischnic Nov 15, 2023
4fb0f0c
Update Parcel version
mischnic Nov 15, 2023
beb8cbb
Bump lightningcss
mischnic Nov 15, 2023
4c7597c
REPL include CSS optimizer
mischnic Nov 15, 2023
dccc2b4
Bump terser
mischnic Nov 15, 2023
f173685
Merge branch 'v2' into repl-v2-ide
mischnic Nov 17, 2023
4d5f686
Merge branch 'v2' into repl-v2-ide
mischnic Nov 24, 2023
f4beb54
Update patch
mischnic Nov 24, 2023
8b4fb31
Bump lightnincss-wasm
mischnic Nov 24, 2023
7a65f21
Merge branch 'v2' into repl-v2-ide
mischnic Nov 25, 2023
49849dd
Use react
mischnic May 18, 2023
7370b45
Update codemirror
mischnic May 18, 2023
67971ee
react-resizable-panels
mischnic May 19, 2023
53f6482
Lint
mischnic Nov 25, 2023
7c40e98
Fixup runtime resolver paths
mischnic Nov 26, 2023
e1e10c9
Merge branch 'v2' into repl-v2-ide
mischnic Dec 5, 2023
dccf749
Revert __filename change
mischnic Nov 13, 2023
9ebb534
New REPLRuntimesResolver implementation
mischnic Dec 5, 2023
d753476
Merge branch 'v2' into repl-v2-ide
mischnic Dec 7, 2023
6a7f534
Merge branch 'v2' into repl-v2-ide
mischnic Dec 13, 2023
f1f584c
Merge branch 'v2' into repl-v2-ide
mischnic Dec 14, 2023
43b3a86
Merge branch 'v2' into repl-v2-ide
mischnic Jan 2, 2024
745d2d4
Fix versions
mischnic Jan 3, 2024
84b7388
Merge branch 'v2' into repl-v2-ide
mischnic Jan 4, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
79 changes: 79 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,15 @@ jobs:
- run: yarn --frozen-lockfile
- run: yarn build-native-release
- run: yarn test:unit
- name: Upload @parcel/rust Linux Binaries artifact
if: ${{matrix.os == 'ubuntu-latest' && matrix.node == 20}}
uses: actions/upload-artifact@v2
with:
name: Rust Linux Binaries
path: |
packages/core/rust/index.d.ts
packages/core/rust/index.js
packages/core/rust/*.node

integration_tests:
name: Integration tests (${{matrix.os}}, Node ${{matrix.node}})
Expand Down Expand Up @@ -109,6 +118,76 @@ jobs:
name: Integration tests (${{matrix.os}}, node ${{matrix.node}})
path: '**/junit-*.xml'

# Deployment steps taken from https://github.com/colinwilson/static-site-to-vercel/blob/master/.github/workflows/deploy-preview.yml
repl_build:
name: Build REPL
runs-on: ubuntu-latest
needs: [unit_tests]
permissions:
deployments: write
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
cache: yarn
node-version: 20
- uses: dtolnay/rust-toolchain@stable
with:
targets: wasm32-unknown-unknown
- name: Install wasm-opt
run: |
curl -L -O https://github.com/WebAssembly/binaryen/releases/download/version_116/binaryen-version_116-x86_64-linux.tar.gz
tar -xf binaryen-version_116-x86_64-linux.tar.gz
echo "$PWD/binaryen-version_116/bin" >> $GITHUB_PATH
- uses: Swatinem/rust-cache@v1
with:
key: wasm
- name: Bump max inotify watches
run: echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p;
- run: yarn --frozen-lockfile
- name: Download @parcel/rust Linux Binaries artifact
uses: actions/download-artifact@v3
with:
name: Rust Linux Binaries
path: packages/core/rust
- run: yarn build
- run: yarn build-native-wasm
- run: yarn workspace @parcel/repl build
# - name: Upload REPL
# uses: actions/upload-artifact@v2
# with:
# name: REPL
# path: 'packages/dev/repl/dist'
- name: Start Deployment
uses: bobheadxi/deployments@v0.4.3
id: deployment
with:
step: start
token: ${{ secrets.GITHUB_TOKEN }}
ref: ${{ github.head_ref }}
env: Preview
- name: Deploy to Vercel
uses: amondnet/vercel-action@v25
id: vercel-action
with:
vercel-token: ${{ secrets.REPL_VERCEL_TOKEN }}
vercel-org-id: ${{ secrets.REPL_VERCEL_ORG_ID }}
vercel-project-id: ${{ secrets.REPL_VERCEL_PROJECT_ID }}
github-comment: false
working-directory: packages/dev/repl
# vercel-args: '--prod'
alias-domains: |
pr-{{PR_NUMBER}}.repl.parceljs.org
- name: Update Deployment Status
uses: bobheadxi/deployments@v0.4.3
if: always()
with:
step: finish
token: ${{ secrets.GITHUB_TOKEN }}
status: ${{ job.status }}
deployment_id: ${{ steps.deployment.outputs.deployment_id }}
env_url: ${{ steps.vercel-action.outputs.preview-url }}

test_report:
name: Test report
runs-on: ubuntu-latest
Expand Down
8 changes: 8 additions & 0 deletions .proxyrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = function (app) {
app.use(function (req, res, next) {
res.setHeader('Cross-Origin-Embedder-Policy', 'require-corp');
res.setHeader('Cross-Origin-Opener-Policy', 'same-origin');
res.setHeader('Cross-Origin-Resource-Policy', 'same-origin');
next();
});
};
19 changes: 19 additions & 0 deletions flow-libs/preact.js.flow
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// @flow

declare module 'preact/hooks' {
declare export function useState<T>(
initialState: T | (() => T),
): [T, (T) => void];
declare export function useMemo<T>(cb: T, deps: Array<mixed>): T;
declare export function useCallback<T>(cb: T, deps: Array<mixed>): T;
declare export function useEffect(
() => void | Promise<void> | (() => mixed),
Array<mixed>,
): void;
declare export function useRef<T>(T): {|current: T|};
declare export function useReducer<S, A>(
reducer: (S, A) => S,
initialState: ?S,
getInitialState: ?(?S) => S,
): [S, (A) => void];
}
269 changes: 269 additions & 0 deletions flow-typed/npm/express_v4.x.x.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,269 @@
// flow-typed signature: 5c17cfda258a9db73cd2282d14ff18d0
// flow-typed version: 2f514ea8dd/express_v4.x.x/flow_>=v0.104.x

declare type express$RouterOptions = {
caseSensitive?: boolean,
mergeParams?: boolean,
strict?: boolean,
...
};

declare class express$RequestResponseBase {
app: express$Application<any, any>;
get(field: string): string | void;
}

declare type express$RequestParams = { [param: string]: string, ... }

/*
NOTE: Use caution when extending `express$Request` or `express$Response`. When
a request first hits the server, its `req` and `res` will not have any
additional properties, even if you explicitly type them with your custom
subclass. Subsequent middleware may assign these properties, but you must be
cognizant of this ordering. One way to handle this is marking all properties
as optional to force refinement every time a property is accessed. Therefore,
we advise that you always mark properties as _optional_ in `express$Request`
and `express$Response` subclasses.

You may decide not to do this, in which case the typings will be unsound and
the behavior will be similar to how arrays work in Flow. See here for more
information: https://flow.org/en/docs/types/arrays/#toc-array-access-is-unsafe

See #3578 and #3337 for additional discussion. If you have ideas on how to
improve these typings, please share them in #3578 or open a new issue.

**BAD**
declare class test_express$CustomRequest extends express$Request {
foo: string;
}

**GOOD**
declare class test_express$CustomRequest extends express$Request {
foo: string | void;
}
*/
declare class express$Request extends http$IncomingMessage mixins express$RequestResponseBase {
baseUrl: string;
body: mixed;
cookies: { [cookie: string]: string, ... };
connection: net$Socket;
fresh: boolean;
hostname: string;
ip: string;
ips: Array<string>;
method: string;
originalUrl: string;
params: express$RequestParams;
path: string;
protocol: 'https' | 'http';
query: { [name: string]: string | Array<string>, ... };
route: string;
secure: boolean;
signedCookies: { [signedCookie: string]: string, ... };
stale: boolean;
subdomains: Array<string>;
xhr: boolean;
accepts(types: string): string | false;
accepts(types: Array<string>): string | false;
acceptsCharsets(...charsets: Array<string>): string | false;
acceptsEncodings(...encoding: Array<string>): string | false;
acceptsLanguages(...lang: Array<string>): string | false;
header(field: string): string | void;
is(type: string): string | false;
param(name: string, defaultValue?: string): string | void;
}

declare type express$CookieOptions = {
domain?: string,
encode?: (value: string) => string,
expires?: Date,
httpOnly?: boolean,
maxAge?: number,
path?: string,
secure?: boolean,
signed?: boolean,
...
};

declare type express$Path = string | RegExp;

declare type express$RenderCallback = (err: Error | null, html?: string) => mixed;

declare type express$SendFileOptions = {
maxAge?: number,
root?: string,
lastModified?: boolean,
headers?: { [name: string]: string, ... },
dotfiles?: 'allow' | 'deny' | 'ignore',
...
};

declare class express$Response extends http$ServerResponse mixins express$RequestResponseBase {
headersSent: boolean;
locals: { [name: string]: mixed, ... };
append(field: string, value?: string): this;
attachment(filename?: string): this;
cookie(name: string, value: string, options?: express$CookieOptions): this;
clearCookie(name: string, options?: express$CookieOptions): this;
download(path: string, filename?: string, callback?: (err?: ?Error) => void): this;
format(typesObject: { [type: string]: Function, ... }): this;
json(body?: mixed): this;
jsonp(body?: mixed): this;
links(links: { [name: string]: string, ... }): this;
location(path: string): this;
redirect(url: string, ...args: Array<void>): this;
redirect(status: number, url: string, ...args: Array<void>): this;
render(view: string, locals?: { [name: string]: mixed, ... }, callback?: express$RenderCallback): this;
send(body?: mixed): this;
sendFile(path: string, options?: express$SendFileOptions, callback?: (err?: ?Error) => mixed): this;
sendStatus(statusCode: number): this;
header(field: string, value?: string): this;
header(headers: { [name: string]: string, ... }): this;
set(field: string, value?: string|string[]): this;
set(headers: { [name: string]: string, ... }): this;
status(statusCode: number): this;
type(type: string): this;
vary(field: string): this;
req: express$Request;
}

declare type express$NextFunction = (err?: ?Error | 'route') => mixed;
declare type express$Middleware<
Req: express$Request = express$Request,
Res: express$Response = express$Response,
> =
((req: Req, res: Res, next: express$NextFunction) => mixed) |
((error: Error, req: Req, res: Res, next: express$NextFunction) => mixed);

declare interface express$RouteMethodType<
T,
Req: express$Request = express$Request,
Res: express$Response = express$Response,
> {
(middleware: express$Middleware<Req, Res>): T;
(...middleware: Array<express$Middleware<Req, Res>>): T;
(
path: express$Path | $ReadOnlyArray<express$Path>,
...middleware: Array<express$Middleware<Req, Res>>
): T;
}

declare class express$Route<
Req: express$Request = express$Request,
Res: express$Response = express$Response,
> {
all: express$RouteMethodType<this, Req, Res>;
get: express$RouteMethodType<this, Req, Res>;
post: express$RouteMethodType<this, Req, Res>;
put: express$RouteMethodType<this, Req, Res>;
head: express$RouteMethodType<this, Req, Res>;
delete: express$RouteMethodType<this, Req, Res>;
options: express$RouteMethodType<this, Req, Res>;
trace: express$RouteMethodType<this, Req, Res>;
copy: express$RouteMethodType<this, Req, Res>;
lock: express$RouteMethodType<this, Req, Res>;
mkcol: express$RouteMethodType<this, Req, Res>;
move: express$RouteMethodType<this, Req, Res>;
purge: express$RouteMethodType<this, Req, Res>;
propfind: express$RouteMethodType<this, Req, Res>;
proppatch: express$RouteMethodType<this, Req, Res>;
unlock: express$RouteMethodType<this, Req, Res>;
report: express$RouteMethodType<this, Req, Res>;
mkactivity: express$RouteMethodType<this, Req, Res>;
checkout: express$RouteMethodType<this, Req, Res>;
merge: express$RouteMethodType<this, Req, Res>;

// @TODO Missing 'm-search' but get flow illegal name error.

notify: express$RouteMethodType<this, Req, Res>;
subscribe: express$RouteMethodType<this, Req, Res>;
unsubscribe: express$RouteMethodType<this, Req, Res>;
patch: express$RouteMethodType<this, Req, Res>;
search: express$RouteMethodType<this, Req, Res>;
connect: express$RouteMethodType<this, Req, Res>;
}

declare class express$Router<
Req: express$Request = express$Request,
Res: express$Response = express$Response,
> extends express$Route<Req, Res> {
constructor(options?: express$RouterOptions): void;
route(path: string): express$Route<Req, Res>;
static <Req2: express$Request, Res2: express$Response>(
options?: express$RouterOptions,
): express$Router<Req2, Res2>;
use(middleware: express$Middleware<Req, Res>): this;
use(...middleware: Array<express$Middleware<Req, Res>>): this;
use(
path: express$Path | $ReadOnlyArray<express$Path>,
...middleware: Array<express$Middleware<Req, Res>>
): this;
use(path: string, router: express$Router<Req, Res>): this;
handle(req: http$IncomingMessage<>, res: http$ServerResponse, next: express$NextFunction): void;
param(
param: string,
callback: (
req: Req,
res: Res,
next: express$NextFunction,
value: string,
paramName: string,
) => mixed
): void;
(req: http$IncomingMessage<>, res: http$ServerResponse, next?: ?express$NextFunction): void;
}

declare class express$Application<
Req: express$Request = express$Request,
Res: express$Response = express$Response,
> extends express$Router<Req, Res> mixins events$EventEmitter {
constructor(): void;
locals: { [name: string]: mixed, ... };
mountpath: string;
listen(port: number, hostname?: string, backlog?: number, callback?: (err?: ?Error) => mixed): ?http$Server;
listen(port: number, hostname?: string, callback?: (err?: ?Error) => mixed): ?http$Server;
listen(port: number, callback?: (err?: ?Error) => mixed): ?http$Server;
listen(path: string, callback?: (err?: ?Error) => mixed): ?http$Server;
listen(handle: Object, callback?: (err?: ?Error) => mixed): ?http$Server;
disable(name: string): void;
disabled(name: string): boolean;
enable(name: string): this;
enabled(name: string): boolean;
engine(name: string, callback: Function): void;
/**
* Mixed will not be taken as a value option. Issue around using the GET http method name and the get for settings.
*/
// get(name: string): mixed;
set(name: string, value: mixed): mixed;
render(name: string, optionsOrFunction: { [name: string]: mixed, ... }, callback: express$RenderCallback): void;
handle(req: http$IncomingMessage<>, res: http$ServerResponse, next?: ?express$NextFunction): void;
// callable signature is not inherited
(req: http$IncomingMessage<>, res: http$ServerResponse, next?: ?express$NextFunction): void;
}

declare module 'express' {
declare export type RouterOptions = express$RouterOptions;
declare export type CookieOptions = express$CookieOptions;
declare export type Middleware<
Req: express$Request = express$Request,
Res: express$Response = express$Response,
> = express$Middleware<Req, Res>;
declare export type NextFunction = express$NextFunction;
declare export type RequestParams = express$RequestParams;
declare export type $Response = express$Response;
declare export type $Request = express$Request;
declare export type $Application<
Req: express$Request = express$Request,
Res: express$Response = express$Response,
> = express$Application<Req, Res>;

declare module.exports: {
// If you try to call like a function, it will use this signature
<Req: express$Request, Res: express$Response>(): express$Application<Req, Res>,
// `static` property on the function
static: <Req: express$Request, Res: express$Response>(root: string, options?: Object) => express$Middleware<Req, Res>,
// `Router` property on the function
Router: typeof express$Router,
...
};
}