Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: hotwired/turbo
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 3bfd3a636cc69c62aafd0faa3f3793dd08bbc12b
Choose a base ref
..
head repository: hotwired/turbo
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 8c94c7c9dd8c32db403c634f52c46e11393188ec
Choose a head ref
Showing with 2,982 additions and 3,048 deletions.
  1. +0 −23 .eslintrc
  2. +42 −0 .eslintrc.js
  3. +6 −2 .github/workflows/ci.yml
  4. +1 −1 .github/workflows/dev-builds.yml
  5. +1 −4 .vscode/tasks.json
  6. +4 −4 CONTRIBUTING.md
  7. +1 −1 README.md
  8. +7 −19 package.json
  9. +40 −0 playwright.config.js
  10. +0 −28 playwright.config.ts
  11. +3 −7 rollup.config.js
  12. +9 −23 src/core/{bardo.ts → bardo.js}
  13. +40 −0 src/core/cache.js
  14. +0 −30 src/core/cache.ts
  15. +64 −0 src/core/drive/cache_stores/disk_store.js
  16. +13 −15 src/core/drive/{snapshot_cache.ts → cache_stores/memory_store.js}
  17. +3 −4 src/core/drive/{error_renderer.ts → error_renderer.js}
  18. +258 −0 src/core/drive/form_submission.js
  19. +0 −262 src/core/drive/form_submission.ts
  20. +27 −37 src/core/drive/{head_snapshot.ts → head_snapshot.js}
  21. +11 −26 src/core/drive/{history.ts → history.js}
  22. +19 −32 src/core/drive/{navigator.ts → navigator.js}
  23. +7 −9 src/core/drive/{page_renderer.ts → page_renderer.js}
  24. +15 −9 src/core/drive/{page_snapshot.ts → page_snapshot.js}
  25. +17 −16 src/core/drive/{page_view.ts → page_view.js}
  26. +8 −17 src/core/drive/{preloader.ts → preloader.js}
  27. +2 −6 src/core/drive/{progress_bar.ts → progress_bar.js}
  28. +35 −0 src/core/drive/snapshot_cache.js
  29. +21 −0 src/core/drive/view_transitioner.js
  30. +71 −119 src/core/drive/{visit.ts → visit.js}
  31. 0 src/core/{errors.ts → errors.js}
  32. +137 −162 src/core/frames/{frame_controller.ts → frame_controller.js}
  33. +85 −0 src/core/frames/frame_redirector.js
  34. +0 −86 src/core/frames/frame_redirector.ts
  35. +6 −21 src/core/frames/{frame_renderer.ts → frame_renderer.js}
  36. +12 −0 src/core/frames/frame_view.js
  37. +0 −15 src/core/frames/frame_view.ts
  38. +7 −18 src/core/frames/{link_interceptor.ts → link_interceptor.js}
  39. +9 −32 src/core/{index.ts → index.js}
  40. +0 −18 src/core/native/adapter.ts
  41. +22 −38 src/core/native/{browser_adapter.ts → browser_adapter.js}
  42. +82 −0 src/core/renderer.js
  43. +0 −100 src/core/renderer.ts
  44. +95 −122 src/core/{session.ts → session.js}
  45. +11 −20 src/core/{snapshot.ts → snapshot.js}
  46. +2 −7 src/core/streams/{stream_actions.ts → stream_actions.js}
  47. +5 −7 src/core/streams/{stream_message.ts → stream_message.js}
  48. +98 −0 src/core/streams/stream_message_renderer.js
  49. +0 −36 src/core/streams/stream_message_renderer.ts
  50. +0 −16 src/core/types.ts
  51. +14 −16 src/core/{url.ts → url.js}
  52. +21 −47 src/core/{view.ts → view.js}
  53. +14 −37 src/elements/{frame_element.ts → frame_element.js}
  54. 0 src/elements/{index.ts → index.js}
  55. +13 −19 src/elements/{stream_element.ts → stream_element.js}
  56. +5 −4 src/elements/{stream_source_element.ts → stream_source_element.js}
  57. +0 −13 src/globals.d.ts
  58. +235 −0 src/http/fetch_request.js
  59. +0 −194 src/http/fetch_request.ts
  60. +5 −7 src/http/{fetch_response.ts → fetch_response.js}
  61. +2 −0 src/http/index.js
  62. +0 −5 src/http/index.ts
  63. 0 src/{index.ts → index.js}
  64. +3 −10 src/observers/{appearance_observer.ts → appearance_observer.js}
  65. +4 −6 src/observers/{cache_observer.ts → cache_observer.js}
  66. +8 −14 src/observers/{form_link_click_observer.ts → form_link_click_observer.js}
  67. +5 −12 src/observers/{form_submit_observer.ts → form_submit_observer.js}
  68. +8 −15 src/observers/{link_click_observer.ts → link_click_observer.js}
  69. +6 −13 src/observers/{page_observer.ts → page_observer.js}
  70. +2 −9 src/observers/{scroll_observer.ts → scroll_observer.js}
  71. +18 −25 src/observers/{stream_observer.ts → stream_observer.js}
  72. +0 −50 src/polyfills/custom-elements-native-shim.ts
  73. +9 −8 src/polyfills/form-request-submit-polyfill.js
  74. +0 −1 src/polyfills/{index.ts → index.js}
  75. +15 −13 src/polyfills/{submit-event.ts → submit-event.js}
  76. +1 −1 src/{script_warning.ts → script_warning.js}
  77. +49 −0 src/tests/fixtures/disk_cache.html
  78. +16 −0 src/tests/fixtures/form.html
  79. +9 −11 src/tests/fixtures/frame_preloading.html
  80. +2 −0 src/tests/fixtures/frames.html
  81. +2 −1 src/tests/fixtures/frames/body_script.html
  82. +2 −1 src/tests/fixtures/frames/body_script_2.html
  83. +2 −1 src/tests/fixtures/frames/eval_false_script.html
  84. +1 −1 src/tests/fixtures/frames/form-redirect.html
  85. +1 −1 src/tests/fixtures/frames/form-redirected.html
  86. +1 −1 src/tests/fixtures/frames/form.html
  87. +2 −1 src/tests/fixtures/frames/frame.html
  88. +14 −3 src/tests/fixtures/frames/frame_for_eager.html
  89. +1 −1 src/tests/fixtures/frames/hello.html
  90. +14 −3 src/tests/fixtures/frames/part.html
  91. +15 −4 src/tests/fixtures/frames/preloading.html
  92. +2 −1 src/tests/fixtures/frames/recursive.html
  93. +1 −0 src/tests/fixtures/frames/self.html
  94. +2 −1 src/tests/fixtures/frames/unvisitable.html
  95. +0 −5 src/tests/fixtures/frames/without_layout.html
  96. +0 −1 src/tests/fixtures/rendering.html
  97. +4 −0 src/tests/fixtures/stream.html
  98. +1 −1 src/tests/fixtures/tabs.html
  99. +19 −8 src/tests/fixtures/tabs/three.html
  100. +19 −8 src/tests/fixtures/tabs/two.html
  101. +61 −44 src/tests/fixtures/test.js
  102. +31 −0 src/tests/fixtures/transitions/left.html
  103. +13 −0 src/tests/fixtures/transitions/other.html
  104. +30 −0 src/tests/fixtures/transitions/right.html
  105. 0 src/tests/functional/{async_script_tests.ts → async_script_tests.js}
  106. +56 −2 src/tests/functional/{autofocus_tests.ts → autofocus_tests.js}
  107. 0 src/tests/functional/{cache_observer_tests.ts → cache_observer_tests.js}
  108. +58 −0 src/tests/functional/disk_cache_tests.js
  109. +1 −1 src/tests/functional/{drive_disabled_tests.ts → drive_disabled_tests.js}
  110. +4 −3 src/tests/functional/{drive_tests.ts → drive_tests.js}
  111. +30 −0 src/tests/functional/drive_view_transition_tests.js
  112. +3 −3 src/tests/functional/{form_mode_tests.ts → form_mode_tests.js}
  113. +129 −30 src/tests/functional/{form_submission_tests.ts → form_submission_tests.js}
  114. 0 src/tests/functional/{frame_navigation_tests.ts → frame_navigation_tests.js}
  115. +72 −64 src/tests/functional/{frame_tests.ts → frame_tests.js}
  116. 0 src/tests/functional/{import_tests.ts → import_tests.js}
  117. +2 −8 src/tests/functional/{loading_tests.ts → loading_tests.js}
  118. +26 −20 src/tests/functional/{navigation_tests.ts → navigation_tests.js}
  119. 0 src/tests/functional/{pausable_rendering_tests.ts → pausable_rendering_tests.js}
  120. 0 src/tests/functional/{pausable_requests_tests.ts → pausable_requests_tests.js}
  121. +12 −12 src/tests/functional/{preloader_tests.ts → preloader_tests.js}
  122. +42 −49 src/tests/functional/{rendering_tests.ts → rendering_tests.js}
  123. 0 src/tests/functional/{scroll_restoration_tests.ts → scroll_restoration_tests.js}
  124. +81 −9 src/tests/functional/{stream_tests.ts → stream_tests.js}
  125. +12 −12 src/tests/functional/{visit_tests.ts → visit_tests.js}
  126. +3 −3 src/tests/helpers/{dom_test_case.ts → dom_test_case.js}
  127. +288 −0 src/tests/helpers/page.js
  128. +0 −313 src/tests/helpers/page.ts
  129. +2 −2 src/tests/integration/{ujs_tests.ts → ujs_tests.js}
  130. +16 −10 src/tests/{server.ts → server.mjs}
  131. +58 −0 src/tests/unit/deprecated_adapter_support_tests.js
  132. +0 −61 src/tests/unit/deprecated_adapter_support_tests.ts
  133. +0 −30 src/tests/unit/{export_tests.ts → export_tests.js}
  134. +3 −3 src/tests/unit/{stream_element_tests.ts → stream_element_tests.js}
  135. +46 −36 src/{util.ts → util.js}
  136. +0 −17 tsconfig.json
  137. +24 −8 web-test-runner.config.mjs
  138. +16 −343 yarn.lock
23 changes: 0 additions & 23 deletions .eslintrc

This file was deleted.

42 changes: 42 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
module.exports = {
env: {
browser: true,
es2021: true
},
extends: ["eslint:recommended"],
overrides: [
{
env: {
node: true
},
files: [".eslintrc.{js,cjs}"],
parserOptions: {
sourceType: "script"
}
}
],
parserOptions: {
ecmaVersion: "latest",
sourceType: "module"
},
rules: {
"comma-dangle": "error",
"curly": ["error", "multi-line"],
"getter-return": "off",
"no-console": "off",
"no-duplicate-imports": ["error"],
"no-multi-spaces": ["error", { "exceptions": { "VariableDeclarator": true }}],
"no-multiple-empty-lines": ["error", { "max": 2 }],
"no-self-assign": ["error", { "props": false }],
"no-trailing-spaces": ["error"],
"no-unused-vars": ["error", { argsIgnorePattern: "_*" }],
"no-useless-escape": "off",
"no-var": ["error"],
"prefer-const": ["error"],
"semi": ["error", "never"]
},
globals: {
test: true,
setup: true
}
}
8 changes: 6 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -13,8 +13,7 @@ jobs:
with:
node-version: '16'
cache: 'yarn'

- run: yarn install
- run: yarn install --frozen-lockfile
- run: yarn run playwright install --with-deps
- run: yarn build

@@ -35,3 +34,8 @@ jobs:

- name: Firefox Test
run: yarn test:browser --project=firefox

- uses: actions/upload-artifact@v3
with:
name: turbo-dist
path: dist/*
2 changes: 1 addition & 1 deletion .github/workflows/dev-builds.yml
Original file line number Diff line number Diff line change
@@ -17,7 +17,7 @@ jobs:
node-version: '16'
cache: 'yarn'

- run: yarn install
- run: yarn install --frozen-lockfile
- run: yarn build

- name: Publish dev build
5 changes: 1 addition & 4 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -10,10 +10,7 @@
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": [
"$tsc"
]
}
},
{
"label": "Turbo: Run tests",
8 changes: 4 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -37,7 +37,7 @@ git checkout -b <your_branch_name>

### Testing

Tests are run through `yarn` using [Web Test Runner](https://modern-web.dev/docs/test-runner/overview/) with [Playwright](https://github.com/microsoft/playwright) for browser testing. Browser and runtime configuration can be found in [`web-test-runner.config.mjs`](./web-test-runner.config.mjs) and [`playwright.config.ts`](./playwright.config.ts).
Tests are run through `yarn` using [Web Test Runner](https://modern-web.dev/docs/test-runner/overview/) with [Playwright](https://github.com/microsoft/playwright) for browser testing. Browser and runtime configuration can be found in [`web-test-runner.config.mjs`](./web-test-runner.config.mjs) and [`playwright.config.js`](./playwright.config.js).

To begin testing, install the browser drivers:

@@ -79,9 +79,9 @@ yarn test:browser --project=chrome --headed
To run a single test file, pass its path as an argument. To run a particular test case, append its starting line number after a colon.

```bash
yarn test:browser src/tests/functional/drive_tests.ts
yarn test:browser src/tests/functional/drive_tests.ts:11
yarn test:browser src/tests/functional/drive_tests.ts:11 --project=chrome
yarn test:browser src/tests/functional/drive_tests.js
yarn test:browser src/tests/functional/drive_tests.js:11
yarn test:browser src/tests/functional/drive_tests.js:11 --project=chrome
```

### Running the local web server
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -15,4 +15,4 @@ Read more on [turbo.hotwired.dev](https://turbo.hotwired.dev).

Please read [CONTRIBUTING.md](./CONTRIBUTING.md).

© 2021 37signals LLC.
© 2023 37signals LLC.
26 changes: 7 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
{
"name": "@hotwired/turbo",
"version": "7.2.5",
"version": "7.3.0",
"description": "The speed of a single-page web application without having to write any JavaScript",
"module": "dist/turbo.es2017-esm.js",
"main": "dist/turbo.es2017-umd.js",
"types": "dist/types/index.d.ts",
"files": [
"dist/*.js",
"dist/*.js.map",
"dist/types/**/*"
"dist/*.js.map"
],
"repository": {
"type": "git",
@@ -38,40 +36,30 @@
"@open-wc/testing": "^3.1.7",
"@playwright/test": "^1.28.0",
"@rollup/plugin-node-resolve": "13.1.3",
"@rollup/plugin-typescript": "^11.0.0",
"@types/multer": "^1.4.5",
"@typescript-eslint/eslint-plugin": "^5.50.0",
"@typescript-eslint/parser": "^5.50.0",
"@web/dev-server-esbuild": "^0.3.3",
"@web/test-runner": "^0.15.0",
"@web/test-runner-playwright": "^0.9.0",
"arg": "^5.0.1",
"body-parser": "^1.20.1",
"chai": "~4.3.4",
"eslint": "^8.13.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-prettier": "^4.0.0",
"express": "^4.18.2",
"multer": "^1.4.2",
"prettier": "2.6.2",
"rollup": "^2.35.1",
"ts-node": "^10.9.1",
"tslib": "^2.5.0",
"typescript": "^4.9.5"
"rollup": "^2.35.1"
},
"scripts": {
"clean": "rm -fr dist",
"clean:win": "rmdir /s /q dist",
"build": "tsc --noEmit false --declaration true --emitDeclarationOnly true --outDir dist/types && rollup -c",
"build:win": "tsc --noEmit false --declaration true --emitDeclarationOnly true --outDir dist/types & rollup -c",
"build": "rollup -c",
"build:win": "rollup -c",
"watch": "rollup -wc",
"start": "ts-node -O '{\"module\":\"commonjs\"}' src/tests/server.ts",
"start": "node src/tests/server.mjs",
"test": "yarn test:unit && yarn test:browser",
"test:browser": "playwright test",
"test:unit": "NODE_OPTIONS=--inspect web-test-runner",
"test:unit:win": "SET NODE_OPTIONS=--inspect & web-test-runner",
"release": "yarn build && npm publish",
"lint": "eslint . --ext .ts"
"lint": "eslint . --ext .js"
},
"engines": {
"node": ">= 14"
40 changes: 40 additions & 0 deletions playwright.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { devices } from "@playwright/test"

const config = {
projects: [
{
name: "chrome",
use: {
...devices["Desktop Chrome"],
contextOptions: {
timeout: 60000
}
}
},
{
name: "firefox",
use: {
...devices["Desktop Firefox"],
contextOptions: {
timeout: 60000
}
}
}
],
browserStartTimeout: 60000,
retries: 2,
testDir: "./src/tests/",
testMatch: /(functional|integration)\/.*_tests\.js/,
webServer: {
command: "yarn start",
url: "http://localhost:9000/src/tests/fixtures/test.js",
timeout: 120 * 1000,
// eslint-disable-next-line no-undef
reuseExistingServer: !process.env.CI
},
use: {
baseURL: "http://localhost:9000/"
}
}

export default config
28 changes: 0 additions & 28 deletions playwright.config.ts

This file was deleted.

10 changes: 3 additions & 7 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import resolve from "@rollup/plugin-node-resolve"
import typescript from "@rollup/plugin-typescript"

import { version } from "./package.json"
const year = new Date().getFullYear()
const banner = `/*\nTurbo ${version}\nCopyright © ${year} 37signals LLC\n */`
const banner = `/*!\nTurbo ${version}\nCopyright © ${year} 37signals LLC\n */`

export default [
{
input: "src/index.ts",
input: "src/index.js",
output: [
{
name: "Turbo",
@@ -21,10 +20,7 @@ export default [
banner
}
],
plugins: [
resolve(),
typescript()
],
plugins: [resolve()],
watch: {
include: "src/**"
}
32 changes: 9 additions & 23 deletions src/core/bardo.ts → src/core/bardo.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,12 @@
import { PermanentElementMap } from "./snapshot"

export interface BardoDelegate {
enteringBardo(currentPermanentElement: Element, newPermanentElement: Element): void
leavingBardo(currentPermanentElement: Element): void
}

export class Bardo {
readonly permanentElementMap: PermanentElementMap
readonly delegate: BardoDelegate

static async preservingPermanentElements(
delegate: BardoDelegate,
permanentElementMap: PermanentElementMap,
callback: () => void
) {
static async preservingPermanentElements(delegate, permanentElementMap, callback) {
const bardo = new this(delegate, permanentElementMap)
bardo.enter()
await callback()
bardo.leave()
}

constructor(delegate: BardoDelegate, permanentElementMap: PermanentElementMap) {
constructor(delegate, permanentElementMap) {
this.delegate = delegate
this.permanentElementMap = permanentElementMap
}
@@ -42,31 +28,31 @@ export class Bardo {
}
}

replaceNewPermanentElementWithPlaceholder(permanentElement: Element) {
replaceNewPermanentElementWithPlaceholder(permanentElement) {
const placeholder = createPlaceholderForPermanentElement(permanentElement)
permanentElement.replaceWith(placeholder)
}

replaceCurrentPermanentElementWithClone(permanentElement: Element) {
replaceCurrentPermanentElementWithClone(permanentElement) {
const clone = permanentElement.cloneNode(true)
permanentElement.replaceWith(clone)
}

replacePlaceholderWithPermanentElement(permanentElement: Element) {
replacePlaceholderWithPermanentElement(permanentElement) {
const placeholder = this.getPlaceholderById(permanentElement.id)
placeholder?.replaceWith(permanentElement)
}

getPlaceholderById(id: string) {
getPlaceholderById(id) {
return this.placeholders.find((element) => element.content == id)
}

get placeholders(): HTMLMetaElement[] {
return [...document.querySelectorAll<HTMLMetaElement>("meta[name=turbo-permanent-placeholder][content]")]
get placeholders() {
return [...document.querySelectorAll("meta[name=turbo-permanent-placeholder][content]")]
}
}

function createPlaceholderForPermanentElement(permanentElement: Element) {
function createPlaceholderForPermanentElement(permanentElement) {
const element = document.createElement("meta")
element.setAttribute("name", "turbo-permanent-placeholder")
element.setAttribute("content", permanentElement.id)
Loading