diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b3ce7077..fc8e1866 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -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 @@ -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/setup-depot-tools@v1.0.1 - - # - 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: @@ -262,7 +216,7 @@ jobs: rewritertests: name: "Run Rewriter Tests" runs-on: ubuntu-latest - needs: [build] + needs: [build, package-validation] steps: - name: Checkout code @@ -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/setup-depot-tools@v1.0.1 + + # - 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 diff --git a/amplify.yml b/amplify.yml index 4b0f1c52..ce705503 100644 --- a/amplify.yml +++ b/amplify.yml @@ -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: diff --git a/packages/chrome/src/proxy/Controller.ts b/packages/chrome/src/proxy/Controller.ts index 98dd65c8..94c2595f 100644 --- a/packages/chrome/src/proxy/Controller.ts +++ b/packages/chrome/src/proxy/Controller.ts @@ -217,7 +217,7 @@ export async function controllerForURL(url: URL): Promise { 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); diff --git a/packages/chrome/src/proxy/scramjet.ts b/packages/chrome/src/proxy/scramjet.ts index b9c604ae..59502573 100644 --- a/packages/chrome/src/proxy/scramjet.ts +++ b/packages/chrome/src/proxy/scramjet.ts @@ -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; }; diff --git a/packages/inject/src/index.ts b/packages/inject/src/index.ts index 09bc1f59..07a17feb 100644 --- a/packages/inject/src/index.ts +++ b/packages/inject/src/index.ts @@ -178,6 +178,6 @@ function $injectLoadError( } // @ts-expect-error -window.$injectLoadError = $injectLoadError; +globalThis.$injectLoadError = $injectLoadError; // @ts-expect-error -window.$injectLoad = $injectLoad; +globalThis.$injectLoad = $injectLoad; diff --git a/packages/inject/src/scramjet.ts b/packages/inject/src/scramjet.ts index 0442fcdf..0b9aba5f 100644 --- a/packages/inject/src/scramjet.ts +++ b/packages/inject/src/scramjet.ts @@ -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: { @@ -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(); diff --git a/packages/scramjet/devserver.ts b/packages/scramjet/devserver.ts index e9eac4f6..4024873b 100644 --- a/packages/scramjet/devserver.ts +++ b/packages/scramjet/devserver.ts @@ -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 = diff --git a/packages/scramjet/jsconfig.json b/packages/scramjet/jsconfig.json index 94e5df32..78d31526 100644 --- a/packages/scramjet/jsconfig.json +++ b/packages/scramjet/jsconfig.json @@ -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/**/*"] } diff --git a/packages/scramjet/package.json b/packages/scramjet/package.json index 560f342a..362c30f1 100644 --- a/packages/scramjet/package.json +++ b/packages/scramjet/package.json @@ -8,6 +8,7 @@ "license": "AGPL-3.0-only", "packageManager": "pnpm@10.12.1", "scripts": { + "dev": "node --no-warnings=ExperimentalWarning devserver.ts", "preinstall": "npx only-allow pnpm" }, "devDependencies": { diff --git a/packages/scramjet/packages/controller/src/index.ts b/packages/scramjet/packages/controller/src/index.ts index ed10f0c5..abcc640c 100644 --- a/packages/scramjet/packages/controller/src/index.ts +++ b/packages/scramjet/packages/controller/src/index.ts @@ -1,4 +1,4 @@ -import { MethodsDefinition, RpcHelper } from "@mercuryworkshop/rpc"; +import { type MethodsDefinition, RpcHelper } from "@mercuryworkshop/rpc"; import type * as ScramjetGlobal from "@mercuryworkshop/scramjet"; declare const $scramjet: typeof ScramjetGlobal; @@ -11,11 +11,11 @@ declare const $scramjet: typeof ScramjetGlobal; // CookieJar, // } = $scramjet; -import { Controllerbound, SWbound } from "./types"; +import type { Controllerbound, SWbound } from "./types"; import LibcurlClient from "@mercuryworkshop/libcurl-transport"; import { BareClient, - BareResponseFetch, + type BareResponseFetch, } from "@mercuryworkshop/bare-mux-custom"; let lc = new LibcurlClient({ @@ -37,13 +37,17 @@ fetch("/scramjet/scramjet.wasm.wasm").then(async (resp) => { }); export const config: Config = { - prefix: "/~/sj", - virtualWasmPath: "/scramjet.wasm.js", + prefix: "/~/sj/", + virtualWasmPath: "scramjet.wasm.js", scramjetPath: "/scramjet/scramjet.js", wasmPath: "/scramjet/scramjet.wasm.wasm", }; const cfg = { + flags: { + ...$scramjet.defaultConfig.flags, + allowFailedIntercepts: true, + }, maskedfiles: ["inject.js", "scramjet.wasm.js"], }; @@ -87,12 +91,7 @@ export class Controller { const frame = this.frames.find((f) => path.startsWith(f.prefix)); if (!frame) throw new Error("No frame found for request"); - if ( - path.startsWith( - frame.prefix.substring(0, frame.prefix.length - 1) + - config.virtualWasmPath - ) - ) { + if (path === frame.prefix + config.virtualWasmPath) { console.log("???"); if (!wasmPayload) { const resp = await fetch(config.wasmPath); @@ -168,7 +167,7 @@ export class Controller { constructor(serviceworker: ServiceWorker) { this.id = makeId(); - this.prefix = config.prefix + "/" + this.id; + this.prefix = config.prefix + this.id + "/"; this.ready = new Promise((resolve) => { this.readyResolve = resolve; @@ -191,7 +190,7 @@ export class Controller { serviceworker.postMessage( { $controller$init: { - prefix: config.prefix + "/" + this.id, + prefix: config.prefix + this.id, id: this.id, }, }, @@ -220,10 +219,7 @@ function yieldGetInjectScripts( return function getInjectScripts(meta, handler, script) { return [ script(config.scramjetPath), - script( - prefix.href.substring(0, prefix.href.length - 1) + - config.virtualWasmPath - ), + script(prefix.href + config.virtualWasmPath), script( "data:text/javascript;base64," + btoa(` @@ -293,8 +289,6 @@ class Frame { id: string; prefix: string; - getInjectScripts(meta, handler, script) {} - get context() { let sjcfg = { ...$scramjet.defaultConfig, @@ -311,22 +305,11 @@ class Frame { { ...$scramjet.defaultConfig, ...cfg }, new URL(this.prefix, location.href) ), - getWorkerInjectScripts: (type: string) => { - const module = type === "module"; + getWorkerInjectScripts: (meta, type, script) => { let str = ""; - const script = (script: string) => { - if (module) { - str += `import "${script}"\n`; - } else { - str += `importScripts("${script}");\n`; - } - }; - script(config.scramjetPath); - script( - this.prefix.substring(0, this.prefix.length - 1) + - config.virtualWasmPath - ); + str += script(config.scramjetPath); + str += script(this.prefix + config.virtualWasmPath); str += ` (()=>{ const { ScramjetClient, CookieJar, setWasm } = $scramjet; @@ -371,7 +354,7 @@ class Frame { public element: HTMLIFrameElement ) { this.id = makeId(); - this.prefix = this.controller.prefix + "/" + this.id + "/"; + this.prefix = this.controller.prefix + this.id + "/"; this.fetchHandler = new $scramjet.ScramjetFetchHandler({ crossOriginIsolated: self.crossOriginIsolated, diff --git a/packages/scramjet/packages/controller/src/sw.ts b/packages/scramjet/packages/controller/src/sw.ts index 08102d5c..07642b56 100644 --- a/packages/scramjet/packages/controller/src/sw.ts +++ b/packages/scramjet/packages/controller/src/sw.ts @@ -1,6 +1,6 @@ declare var clients: Clients; import { RpcHelper } from "@mercuryworkshop/rpc"; -import { Controllerbound, SWbound } from "./types"; +import type { Controllerbound, SWbound } from "./types"; import type { BareHeaders } from "@mercuryworkshop/bare-mux-custom"; function makeId(): string { diff --git a/packages/scramjet/packages/controller/tsconfig.json b/packages/scramjet/packages/controller/tsconfig.json index a6d1f353..ee70ad81 100644 --- a/packages/scramjet/packages/controller/tsconfig.json +++ b/packages/scramjet/packages/controller/tsconfig.json @@ -1,7 +1,25 @@ +{ { "compilerOptions": { - "target": "es2022", - "lib": ["es2022", "webworker"], - "moduleResolution": "node" - } + "target": "ES2022", + "useDefineForClassFields": true, + "module": "ESNext", + "lib": ["ES2022", "webworker", "DOM", "DOM.Iterable"], + "types": [], + "skipLibCheck": true, + /* Bundler mode */ + "moduleResolution": "node", + "allowImportingTsExtensions": true, + "verbatimModuleSyntax": true, + "moduleDetection": "force", + "noEmit": true, + /* Linting */ + "strict": true, + "noUnusedLocals": true, + "noUnusedParameters": false, + "erasableSyntaxOnly": false, + "noFallthroughCasesInSwitch": true, + "noUncheckedSideEffectImports": true, + }, + "include": ["src"] } diff --git a/packages/scramjet/lib/index.cjs b/packages/scramjet/packages/core/lib/index.cjs similarity index 100% rename from packages/scramjet/lib/index.cjs rename to packages/scramjet/packages/core/lib/index.cjs diff --git a/packages/scramjet/lib/index.d.ts b/packages/scramjet/packages/core/lib/index.d.ts similarity index 100% rename from packages/scramjet/lib/index.d.ts rename to packages/scramjet/packages/core/lib/index.d.ts diff --git a/packages/scramjet/lib/types.d.ts b/packages/scramjet/packages/core/lib/types.d.ts similarity index 100% rename from packages/scramjet/lib/types.d.ts rename to packages/scramjet/packages/core/lib/types.d.ts diff --git a/packages/scramjet/packages/core/playwright.config.ts b/packages/scramjet/packages/core/playwright.config.ts new file mode 100644 index 00000000..e2ee67c3 --- /dev/null +++ b/packages/scramjet/packages/core/playwright.config.ts @@ -0,0 +1,52 @@ +import { defineConfig, devices } from "@playwright/test"; +import type { GitHubActionOptions } from "@estruyf/github-actions-reporter"; + +/** + * See https://playwright.dev/docs/test-configuration. + */ +export default defineConfig({ + testDir: "./tests/integration/site", + fullyParallel: true, + forbidOnly: !!process.env.CI, + retries: 2, + reporter: process.env.CI + ? [ + [ + "@estruyf/github-actions-reporter", + { + title: "Test summary", + useDetails: true, + showError: true, + } as GitHubActionOptions, + ], + ["github"], + ] + : "html", + timeout: 20000, + /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ + use: { + /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ + trace: "on-first-retry", + actionTimeout: 10000, + baseURL: "http://localhost:4141", + }, + + /* Configure projects for major browsers */ + projects: [ + { + name: "chromium", + use: { ...devices["Desktop Chrome"] }, + }, + // { + // name: "firefox", + // use: { ...devices["Desktop Firefox"] }, + // }, + ], + + /* Run your local dev server before starting the tests */ + webServer: { + command: "cd .. && pnpm run dev", + url: "http://localhost:4141", + reuseExistingServer: false, + }, +}); diff --git a/packages/scramjet/packages/core/src/fetch/index.ts b/packages/scramjet/packages/core/src/fetch/index.ts index 3eee835d..f5fb4b3c 100644 --- a/packages/scramjet/packages/core/src/fetch/index.ts +++ b/packages/scramjet/packages/core/src/fetch/index.ts @@ -40,7 +40,7 @@ export interface ScramjetFetchParsed { clientUrl?: URL; meta: URLMeta; - scriptType: string; + scriptType: "module" | "regular"; } export interface ScramjetFetchResponse { @@ -209,13 +209,13 @@ export function parseRequest( const strippedUrl = new URL(request.rawUrl.href); const extraParams: Record = {}; - let scriptType = ""; + let scriptType: "module" | "regular" = "regular"; let topFrameName: string | undefined; let parentFrameName: string | undefined; for (const [param, value] of [...request.rawUrl.searchParams.entries()]) { switch (param) { case "type": - scriptType = value; + if (value === "module") scriptType = value; break; case "dest": break; diff --git a/packages/scramjet/packages/core/src/shared/index.ts b/packages/scramjet/packages/core/src/shared/index.ts index 8e9c80df..31990fb3 100644 --- a/packages/scramjet/packages/core/src/shared/index.ts +++ b/packages/scramjet/packages/core/src/shared/index.ts @@ -36,9 +36,8 @@ export type ScramjetInterface = { ): Element[]; getWorkerInjectScripts?( meta: URLMeta, - js: string | Uint8Array, - type: string, - url: string + type: "module" | "regular", + script: (src: string) => string ): string; }; diff --git a/packages/scramjet/packages/core/src/shared/rewriters/worker.ts b/packages/scramjet/packages/core/src/shared/rewriters/worker.ts index 0d975cdf..b06d9ee7 100644 --- a/packages/scramjet/packages/core/src/shared/rewriters/worker.ts +++ b/packages/scramjet/packages/core/src/shared/rewriters/worker.ts @@ -5,12 +5,18 @@ import { URLMeta } from "@rewriters/url"; export function rewriteWorkers( context: ScramjetContext, js: string | Uint8Array, - type: string, + type: "module" | "regular", url: string, meta: URLMeta ) { const module = type === "module"; - let str = context.interface.getWorkerInjectScripts(meta, js, type, url); + const script = (script: string) => { + if (module) { + return `import "${script}"\n`; + } + return `importScripts("${script}");\n`; + }; + let str = context.interface.getWorkerInjectScripts(meta, type, script); let rewritten = rewriteJs(js, url, context, meta, module); if (rewritten instanceof Uint8Array) { rewritten = new TextDecoder().decode(rewritten); diff --git a/packages/scramjet/tests/ci/packageValidation.js b/packages/scramjet/packages/core/tests/ci/packageValidation.js similarity index 97% rename from packages/scramjet/tests/ci/packageValidation.js rename to packages/scramjet/packages/core/tests/ci/packageValidation.js index 66b8df8c..29713ac8 100644 --- a/packages/scramjet/tests/ci/packageValidation.js +++ b/packages/scramjet/packages/core/tests/ci/packageValidation.js @@ -14,9 +14,10 @@ import { existsSync } from "node:fs"; * These aren't globs. */ const EXPECTED_DIST_FILES = [ - "dist/scramjet.all.js", - "dist/scramjet.bundle.js", - "dist/scramjet.sync.js", + "dist/scramjet.js", + "dist/scramjet.mjs", + "dist/scramjet_bundled.js", + "dist/scramjet_bundled.mjs", "dist/scramjet.wasm.wasm", ]; diff --git a/packages/scramjet/tests/integration/site/google.spec.ts b/packages/scramjet/packages/core/tests/integration/site/google.spec.ts similarity index 100% rename from packages/scramjet/tests/integration/site/google.spec.ts rename to packages/scramjet/packages/core/tests/integration/site/google.spec.ts diff --git a/packages/scramjet/tests/integration/site/youtube.spec.ts b/packages/scramjet/packages/core/tests/integration/site/youtube.spec.ts similarity index 100% rename from packages/scramjet/tests/integration/site/youtube.spec.ts rename to packages/scramjet/packages/core/tests/integration/site/youtube.spec.ts diff --git a/packages/scramjet/tests/util/inspectConsole.ts b/packages/scramjet/packages/core/tests/util/inspectConsole.ts similarity index 100% rename from packages/scramjet/tests/util/inspectConsole.ts rename to packages/scramjet/packages/core/tests/util/inspectConsole.ts diff --git a/packages/scramjet/tests/util/setupPage.ts b/packages/scramjet/packages/core/tests/util/setupPage.ts similarity index 77% rename from packages/scramjet/tests/util/setupPage.ts rename to packages/scramjet/packages/core/tests/util/setupPage.ts index 00bf9c4f..9cff5c9c 100644 --- a/packages/scramjet/tests/util/setupPage.ts +++ b/packages/scramjet/packages/core/tests/util/setupPage.ts @@ -10,11 +10,9 @@ export async function setupPage( await page.route("**", (route) => route.continue()); // Goto base url defined in config. await page.goto("/"); - await page.waitForSelector(".version > b"); - const bar = page.locator(".bar"); - const title = await page.locator(".version > b").textContent(); + await page.waitForSelector("#search"); + const bar = page.locator("#search"); const frame = page.frameLocator("iframe"); - expect(title).toBe("scramjet"); expect(bar).not.toBeNull(); diff --git a/packages/scramjet/packages/demo/src/App.tsx b/packages/scramjet/packages/demo/src/App.tsx index 8feff282..d18a41f1 100644 --- a/packages/scramjet/packages/demo/src/App.tsx +++ b/packages/scramjet/packages/demo/src/App.tsx @@ -1,23 +1,38 @@ import { controller } from "."; import { css, type Component } from "dreamland/core"; -export const App: Component<{ frameel: HTMLIFrameElement }> = function (cx) { - let frame; +export const App: Component< + {}, + {}, + { + url: string; + frame: controller.Frame; + frameel: HTMLIFrameElement; + } +> = function (cx) { + this.url = "https://google.com"; cx.mount = () => { - frame = controller.createFrame(this.frameel); - - frame.go("https://google.com"); + this.frame = controller.createFrame(this.frameel); + let body = btoa( + `Welcome to Scramjet! Type in a URL in the omnibox above and press enter to get started.` + ); + this.frame.go(`data:text/html;base64,${body}`); }; - return (
- { - let url = (e.target as HTMLInputElement).value; - frame.go(url); +
{ + e.preventDefault(); + this.frame.go(this.url); }} - placeholder="Enter URL" - /> + > + +
); diff --git a/packages/scramjet/playwright.config.ts b/packages/scramjet/playwright.config.ts index 20e21e15..0f52a41f 100644 --- a/packages/scramjet/playwright.config.ts +++ b/packages/scramjet/playwright.config.ts @@ -28,7 +28,7 @@ export default defineConfig({ /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ trace: "on-first-retry", actionTimeout: 10000, - baseURL: "http://localhost:1337", + baseURL: "http://localhost:4141", }, /* Configure projects for major browsers */ @@ -45,8 +45,8 @@ export default defineConfig({ /* Run your local dev server before starting the tests */ webServer: { - command: "pnpm run dev", - url: "http://127.0.0.1:1337", - reuseExistingServer: false, + command: "cd .. && pnpm run dev", + url: "http://127.0.0.1:4141", + reuseExistingServer: !process.env.CI, }, }); diff --git a/packages/scramjet/typedoc b/packages/scramjet/typedoc deleted file mode 120000 index 368f4144..00000000 --- a/packages/scramjet/typedoc +++ /dev/null @@ -1 +0,0 @@ -../../../../../packages/scramjet/packages/typedoc \ No newline at end of file diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 81ec87a7..755931f2 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -12928,7 +12928,7 @@ snapshots: dependencies: eastasianwidth: 0.2.0 emoji-regex: 10.5.0 - strip-ansi: 7.1.0 + strip-ansi: 7.1.2 string-width@7.2.0: dependencies: