Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
185 changes: 126 additions & 59 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -129,17 +129,15 @@ jobs:
name: scramjet
path: |
packages/scramjet/packages/core/dist/*
frontend:
name: Build Frontend

package-validation:
name: Validate Package Structure
runs-on: ubuntu-latest
permissions: write-all
needs: [build]

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: recursive

- name: Setup pnpm
uses: pnpm/action-setup@v4
Expand All @@ -156,65 +154,21 @@ jobs:
- name: Get artifacts
uses: actions/download-artifact@v4
with:
name: scramjet
path: packages/scramjet/packages/core/dist

- name: Build Dreamland
run: pnpm build:dreamland

# - name: Get Chii submodule commit hash
# id: chii-hash
# run: echo "hash=$(git submodule status chii | awk '{print $1}')" >> $GITHUB_OUTPUT

# - name: Cache Chii build output
# id: chii-cache
# uses: actions/cache@v4
# with:
# path: |
# chii/public
# chii/front_end/dist
# key: chii-${{ runner.os }}-${{ steps.chii-hash.outputs.hash }}

# - name: Install Depot Tools
# if: steps.chii-cache.outputs.cache-hit != 'true'
# uses: newkdev/[email protected]

# - name: Initialize Chii front_end
# if: steps.chii-cache.outputs.cache-hit != 'true'
# run: |
# cd chii
# pnpm init:front_end

# - name: Build Chii
# if: steps.chii-cache.outputs.cache-hit != 'true'
# run: |
# cd chii
# pnpm build

- name: Build Frontend
run: |
SKIP_CORE=1 pnpm build
VITE_PUTER_BRANDING=1 VITE_ISOLATION_ORIGIN="https://puter.zone" pnpm build:chrome
name: packaged-scramjet
path: packages/scramjet/packages/core

- name: Upload Artifact (dist)
uses: actions/upload-artifact@v4
with:
name: frontend
path: |
./packages/chrome/dist
- name: Extract package
run: tar xvf mercuryworkshop-scramjet-*.tgz package --strip-components=1
working-directory: packages/scramjet/packages/core

- name: Upload pages artifact
uses: actions/upload-pages-artifact@v3
with:
path: "./packages/chrome/dist"
- name: Run package validation tests
run: pnpm test:package
working-directory: packages/scramjet/packages/core

- name: Deploy to github
id: deployment
uses: actions/deploy-pages@v4
tests:
name: Run Scramjet Tests
runs-on: ubuntu-latest
needs: build
needs: [build, package-validation]
env:
PLAYWRIGHT_BROWSERS_PATH: .playwright-browsers
steps:
Expand Down Expand Up @@ -262,7 +216,7 @@ jobs:
rewritertests:
name: "Run Rewriter Tests"
runs-on: ubuntu-latest
needs: [build]
needs: [build, package-validation]

steps:
- name: Checkout code
Expand Down Expand Up @@ -290,3 +244,116 @@ jobs:
- name: Run Tests
run: cargo test
working-directory: packages/scramjet/packages/core/rewriter/native

frontend:
name: Build Frontend
runs-on: ubuntu-latest
permissions: write-all
needs: [build, package-validation]

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: recursive

- name: Setup pnpm
uses: pnpm/action-setup@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "22"
cache: "pnpm"

- name: Install dependencies
run: pnpm install

- name: Get artifacts
uses: actions/download-artifact@v4
with:
name: scramjet
path: packages/scramjet/packages/core/dist

- name: Build Dreamland
run: pnpm build:dreamland

# - name: Get Chii submodule commit hash
# id: chii-hash
# run: echo "hash=$(git submodule status chii | awk '{print $1}')" >> $GITHUB_OUTPUT

# - name: Cache Chii build output
# id: chii-cache
# uses: actions/cache@v4
# with:
# path: |
# chii/public
# chii/front_end/dist
# key: chii-${{ runner.os }}-${{ steps.chii-hash.outputs.hash }}

# - name: Install Depot Tools
# if: steps.chii-cache.outputs.cache-hit != 'true'
# uses: newkdev/[email protected]

# - name: Initialize Chii front_end
# if: steps.chii-cache.outputs.cache-hit != 'true'
# run: |
# cd chii
# pnpm init:front_end

# - name: Build Chii
# if: steps.chii-cache.outputs.cache-hit != 'true'
# run: |
# cd chii
# pnpm build

- name: Build Frontend
run: |
SKIP_CORE=1 pnpm build
VITE_PUTER_BRANDING=1 VITE_ISOLATION_ORIGIN="https://puter.zone" pnpm build:chrome

- name: Upload Artifact (dist)
uses: actions/upload-artifact@v4
with:
name: frontend
path: |
./packages/chrome/dist

pages:
name: Upload to Github Pages
runs-on: ubuntu-latest
# make sure to add rewritertests and tests, omitting them due to bugs currently
needs: [frontend]
permissions: write-all
if: github.ref == 'refs/heads/main'

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup pnpm
uses: pnpm/action-setup@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "22"
cache: "pnpm"

- name: Install dependencies
run: pnpm install

- name: Get artifacts
uses: actions/download-artifact@v4
with:
name: frontend
path: "./packages/chrome/dist"

- name: Upload pages artifact
uses: actions/upload-pages-artifact@v3
with:
path: "./packages/chrome/dist"

- name: Deploy to github
id: deployment
uses: actions/deploy-pages@v4
1 change: 0 additions & 1 deletion amplify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ frontend:
- pnpm build
- VITE_PUTER_BRANDING=1 VITE_ISOLATION_ORIGIN="https://puter.zone" pnpm build:chrome


artifacts:
baseDirectory: packages/scramjet/packages/core/dist
files:
Expand Down
2 changes: 1 addition & 1 deletion packages/chrome/src/proxy/Controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ export async function controllerForURL(url: URL): Promise<Controller> {
let channel = new MessageChannel();

const controllerId = makeId();
let prefix = new URL(baseurl + basePrefix + controllerId);
let prefix = new URL(baseurl.origin + basePrefix + controllerId + "/");

controller = new Controller(prefix, controllerId, channel, rootdomain);
controllers.push(controller);
Expand Down
23 changes: 10 additions & 13 deletions packages/chrome/src/proxy/scramjet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,29 +244,26 @@ export function createFetchHandler(controller: Controller) {

const getWorkerInjectScripts: ScramjetInterface["getWorkerInjectScripts"] = (
meta,
js,
type
type,
script
) => {
const module = type === "module";
let str = "";
const script = (script: string) => {
if (module) {
str += `import "${script}"\n`;
} else {
str += `importScripts("${script}");\n`;
}
};

const injectLoad = `
$injectLoad({
config: ${JSON.stringify(makeConfig())},
cookies: null,
wisp: ${JSON.stringify(wispUrl)},
codecEncode: ${codecEncode.toString()},
codecDecode: ${codecDecode.toString()},
prefix: "${controller.prefix.href}",
});
`;
script(controller.prefix.href + virtualWasmPath);
script(controller.prefix.href + virtualInjectPath);
script(`data:application/javascript;base64,${base64Encode(injectLoad)}`);
str += script(controller.prefix.href + virtualWasmPath);
str += script(controller.prefix.href + virtualInjectPath);
str += script(
`data:application/javascript;base64,${base64Encode(injectLoad)}`
);

return str;
};
Expand Down
4 changes: 2 additions & 2 deletions packages/inject/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,6 @@ function $injectLoadError(
}

// @ts-expect-error
window.$injectLoadError = $injectLoadError;
globalThis.$injectLoadError = $injectLoadError;
// @ts-expect-error
window.$injectLoad = $injectLoad;
globalThis.$injectLoad = $injectLoad;
11 changes: 9 additions & 2 deletions packages/inject/src/scramjet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,13 @@ export function loadScramjet({
setWasm(Uint8Array.from(atob(self.WASM), (c) => c.charCodeAt(0)));
delete (self as any).WASM;

const transport = new LibcurlClient({ wisp });
if (SCRAMJETCLIENT in globalThis) {
//@ts-expect-error god bless america
client = globalThis[SCRAMJETCLIENT];
return;
}

if (SCRAMJETCLIENT in self) return;
const transport = new LibcurlClient({ wisp });

client = new ScramjetClient(globalThis, {
context: {
Expand All @@ -41,6 +45,9 @@ export function loadScramjet({
prefix: new URL(prefix),
},
transport,
shouldPassthroughWebsocket: (url) => {
return url === wisp;
},
sendSetCookie: async (url: URL, cookie: string) => {},
});
client.hook();
Expand Down
2 changes: 1 addition & 1 deletion packages/scramjet/devserver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const branch = execSync("git rev-parse --abbrev-ref HEAD", {
const packagejson = JSON.parse(await fs.readFile("./package.json", "utf-8"));
const version = packagejson.version;

const DEMO_PORT = process.env.CHROME_PORT || 4141;
const DEMO_PORT = process.env.DEMO_PORT || 4141;
const WISP_PORT = process.env.WISP_PORT || 4142;

process.env.VITE_WISP_URL =
Expand Down
2 changes: 1 addition & 1 deletion packages/scramjet/jsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@
"types": []
},
"include": ["static/**/*", "dist/types/index.d.ts"],
"exclude": ["node_modules", "dist", "src/**/*", "tests/**/*"]
"exclude": ["node_modules", "dist", "src/**/*", "packages/core/tests/**/*"]
}
1 change: 1 addition & 0 deletions packages/scramjet/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"license": "AGPL-3.0-only",
"packageManager": "[email protected]",
"scripts": {
"dev": "node --no-warnings=ExperimentalWarning devserver.ts",
"preinstall": "npx only-allow pnpm"
},
"devDependencies": {
Expand Down
Loading
Loading