-
Notifications
You must be signed in to change notification settings - Fork 174
integrate conductor into frontend #3084
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
Merged
Merged
Changes from 5 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
ff284a3
integrate conductor into frontend
tsammeow 4667807
upgrade yarn(4.6.0)
tsammeow 0ce4f9c
Merge branch 'master'
tsammeow bef90bb
fix lint issues
tsammeow c9165a4
Merge branch 'master' into master
RichDom2185 b085079
fix gl resolution problem
tsammeow 711fd73
change github actions to use --immutable instead of --frozen-lockfile…
tsammeow 309eb9e
add sa-conductor to list of ignored module paths in jest config
tsammeow 2e3a25a
readd gl@^8.0.2 resolution to package.json
tsammeow b444a49
format with prettier
tsammeow 2a10429
update caniuse-lite
tsammeow 614ea2a
update sa-conductor(0.0.13)
tsammeow b575d9d
add ui to edit feature flags
tsammeow e788347
support repl, and use stop button to kill runner instead of timeout
tsammeow 2c1a17f
extract actual feature selector to separate function and rename selec…
tsammeow 4268f4d
stop replReducer setting isRunning to true when using conductor, as i…
tsammeow ce8c600
revert replReducer change as it causes an error when using the repl
tsammeow 6b16a6f
hide eval button if not running when using conductor
tsammeow 2a07968
Merge branch 'master' of https://github.com/source-academy/frontend i…
RichDom2185 1426f25
update lockfile after package.json change
tsammeow 47f7864
upgrade sa-conductor(0.1.3) to use new file communication protocol
tsammeow 5fc4dc6
upgrade sa-conductor(0.1.4)
tsammeow 76d0f6c
Merge branch 'master' into master
martin-henz 72ae405
update location of sa-languages repository
tsammeow File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| nodeLinker: node-modules |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| { | ||
| "private": true, | ||
| "name": "frontend", | ||
| "packageManager": "[email protected]", | ||
| "version": "1.4.3", | ||
| "scripts-info": { | ||
| "analyze": "Analyze bundle size breakdown", | ||
|
|
@@ -91,6 +92,8 @@ | |
| "redux-mock-store": "^1.5.4", | ||
| "redux-saga": "^1.2.3", | ||
| "rehype-react": "^8.0.0", | ||
| "sa-conductor": "https://github.com/tsammeow/sa-conductor.git#0.0.11", | ||
| "sa-languages": "https://github.com/tsammeow/sa-languages.git", | ||
| "showdown": "^2.1.0", | ||
| "sourceror": "^0.8.5", | ||
| "unified": "^11.0.0", | ||
|
|
@@ -138,7 +141,6 @@ | |
| "cross-env": "^7.0.3", | ||
| "eslint": "^9.9.0", | ||
| "eslint-plugin-react": "^7.35.0", | ||
| "//": "See: https://github.com/facebook/react/issues/28313#issuecomment-2076798972, https://github.com/t3-oss/create-t3-turbo/issues/984#issuecomment-2076413457", | ||
| "eslint-plugin-react-hooks": "5.1.0-canary-cb151849e1-20240424", | ||
| "eslint-plugin-react-refresh": "^0.4.9", | ||
| "eslint-plugin-simple-import-sort": "^12.1.1", | ||
|
|
@@ -163,9 +165,6 @@ | |
| "url": "^0.11.1", | ||
| "webpack-bundle-analyzer": "^4.9.0" | ||
| }, | ||
| "resolutions": { | ||
| "**/gl": "^8.0.2" | ||
| }, | ||
| "browserslist": { | ||
| "production": [ | ||
| "Firefox ESR", | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export type FeatureFlag<T> = readonly [string, T]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| import { createSlice } from "@reduxjs/toolkit"; | ||
|
|
||
| import { FeatureFlag } from "./FeatureFlag"; | ||
|
|
||
| export type FeatureFlagsState = { | ||
| modifiedFlags: Record<string, any> | ||
| }; | ||
|
|
||
| export const defaultFeatureFlags = { | ||
| modifiedFlags: {} | ||
| }; | ||
|
|
||
| const featureFlagsSlice = createSlice({ | ||
| name: "featureFlags", | ||
| initialState: defaultFeatureFlags, | ||
| reducers: { | ||
| setFlag<T>(state: FeatureFlagsState, action: { payload: { featureFlag: FeatureFlag<T>, value: T } }) { | ||
| state.modifiedFlags[action.payload.featureFlag[0]] = action.payload.value; | ||
| }, | ||
| resetFlag<T>(state: FeatureFlagsState, action: { payload: { featureFlag: FeatureFlag<T> } }) { | ||
| delete state.modifiedFlags[action.payload.featureFlag[0]]; | ||
| } | ||
| } | ||
| }); | ||
|
|
||
| export const FeatureFlagsActions = featureFlagsSlice.actions; | ||
|
|
||
| export const FeatureFlagsReducer = featureFlagsSlice.reducer; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| import { featureConductor } from "src/features/conductor/featureConductor"; | ||
|
|
||
| import { FeatureFlag } from "./FeatureFlag"; | ||
|
|
||
| export const publicFlags: FeatureFlag<any>[] = [ | ||
| featureConductor | ||
| ]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| import { SagaIterator } from "redux-saga"; | ||
| import { select } from "redux-saga/effects"; | ||
|
|
||
| import { FeatureFlag } from "./FeatureFlag"; | ||
|
|
||
| export function* selectFeature<T>(featureFlag: FeatureFlag<T>): SagaIterator<T> { | ||
| const [flag, defaultValue] = featureFlag; | ||
| const flagValue = yield select(state => state.featureFlags.modifiedFlags[flag]); | ||
| return flagValue ?? defaultValue; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| import { useTypedSelector } from "../utils/Hooks"; | ||
| import { FeatureFlag } from "./FeatureFlag"; | ||
|
|
||
| export function useFeature<T>(featureFlag: FeatureFlag<T>) { | ||
| const [flag, defaultValue] = featureFlag; | ||
| const flagValue = useTypedSelector(state => state.featureFlags.modifiedFlags[flag]); | ||
| return flagValue ?? defaultValue; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| import { BasicHostPlugin } from "sa-conductor/dist/conductor/host"; | ||
| import { IConduit } from "sa-conductor/dist/conduit"; | ||
|
|
||
| export class BrowserHostPlugin extends BasicHostPlugin { | ||
| requestFile: (fileName: string) => Promise<string | undefined>; | ||
|
|
||
| init(conduit: IConduit, channels: any): void { | ||
| super.init(conduit, channels); | ||
| console.log("browser-inited"); | ||
| } | ||
|
|
||
| constructor(onRequestFile: (fileName: string) => Promise<string | undefined>) { | ||
| super(); | ||
| this.requestFile = onRequestFile; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| import { Conduit, IConduit } from "sa-conductor/dist/conduit"; | ||
|
|
||
| import { BrowserHostPlugin } from "./BrowserHostPlugin"; | ||
|
|
||
| export function createConductor(evaluatorPath: string, onRequestFile: (fileName: string) => Promise<string | undefined>): { hostPlugin: BrowserHostPlugin, conduit: IConduit } { | ||
| const worker = new Worker(evaluatorPath); | ||
| const hostPlugin = new BrowserHostPlugin(onRequestFile); | ||
| const conduit = new Conduit(worker, true); | ||
| conduit.registerPlugin(hostPlugin); | ||
| return { hostPlugin, conduit }; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| import { FeatureFlag } from "src/commons/featureFlags/FeatureFlag"; | ||
|
|
||
| export const featureConductor: FeatureFlag<boolean> = ["conductor.enable", false] as const; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.