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

Synchronize two Playground instances #727

Merged
merged 86 commits into from
Nov 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
86 commits
Select commit Hold shift + click to select a range
f8104e3
Record and replay Playground SQL queries
adamziel Oct 28, 2023
4d9894c
Make MemFS events observable in the BasePHP class
adamziel Oct 28, 2023
23df8da
Extract journalMemfs as a simpler abstraction
adamziel Oct 29, 2023
99d4188
Remove unused impoerts
adamziel Oct 29, 2023
598dcd5
Sync proof of concept
adamziel Oct 29, 2023
1a9ced3
Two way sync
adamziel Oct 29, 2023
7b75f63
Deduplicate code
adamziel Oct 29, 2023
c4a19e5
Two way sync with an attempt to use disjoint numerical spaces for aut…
adamziel Oct 30, 2023
a01c8ea
Sync IDs in separate numerical spaces
adamziel Oct 30, 2023
49c5086
Tiny cleanup
adamziel Oct 30, 2023
92267f0
Add TODO to handle CREATE TABLE, ALTER TABLE, etc.
adamziel Oct 30, 2023
355cf66
Rewrite autoincrement values to match the peer
adamziel Oct 31, 2023
7ff9df7
Don't report replayed queries instead of relying on a counter
adamziel Oct 31, 2023
5d8438e
Get rid of runSqlQueries, simplify onChangeReceived
adamziel Oct 31, 2023
f5e5737
Bump autoincrement sequences when a table is created or altered
adamziel Oct 31, 2023
31eb208
Execute FS updates serially and draft the normalize() function to tur…
adamziel Oct 31, 2023
f5bd640
A failed attempt to implement normalize() by executing filesystem ope…
adamziel Nov 2, 2023
7fd082a
Prevent journaling of replayed FS changes
adamziel Nov 2, 2023
ba2c0cc
SQL Transactions support
adamziel Nov 2, 2023
9bad00f
Support for rollbacks
adamziel Nov 2, 2023
30f768b
Reformat
adamziel Nov 2, 2023
fa4b9d7
Document TODOs
adamziel Nov 2, 2023
279f044
Start experimenting with a trigger to assign ID values
adamziel Nov 2, 2023
b807945
Add event emitter capabilities to BasePHP
adamziel Nov 2, 2023
1decf3a
Explore different techniques of assigning IDs
adamziel Nov 3, 2023
a4883bf
Support for syncing insert queries with peer-generated autoincrement ids
adamziel Nov 3, 2023
f82047e
Only run the ID assignment trigger when not replaying queries from a …
adamziel Nov 3, 2023
d0bdbf3
Simplify the logic
adamziel Nov 3, 2023
27f721b
Add documentation, clean up the PHP side of the sync feature
adamziel Nov 3, 2023
2ac2087
Rollback uncommitted queries when the PHP request ends
adamziel Nov 3, 2023
c6d7adb
Clean up the code and put it in a separate "sync" directory
adamziel Nov 3, 2023
92a564e
Move sync to the new sync package
adamziel Nov 3, 2023
36ea97c
Clean up the package a little bit
adamziel Nov 3, 2023
b3e0905
Document what does "pk" mean
adamziel Nov 3, 2023
3552f44
Fix most TS type errors
adamziel Nov 3, 2023
839f4f6
Remove batching and debouncing
adamziel Nov 4, 2023
389276a
Debounce data packets
adamziel Nov 4, 2023
533ced4
Extract installSqlSyncMuPlugin as a separate function
adamziel Nov 4, 2023
41db536
Simplify batching transported changes
adamziel Nov 4, 2023
504df11
Add setupPlaygroundSync
adamziel Nov 4, 2023
6dc1a7c
Add a notion of a transport middleware to log messages
adamziel Nov 4, 2023
56f75e1
Replace middlewares with custom loggers
adamziel Nov 4, 2023
5cc299f
A small cleanup
adamziel Nov 4, 2023
19be3ac
Clean up the demo
adamziel Nov 4, 2023
652ec5d
Format, adjust config files
adamziel Nov 4, 2023
3f151a8
Use a proxy object for the FS journal
adamziel Nov 4, 2023
75e86be
Simplify and clean up the journaling bindings
adamziel Nov 4, 2023
8ff28fc
Remove NoopOperation
adamziel Nov 4, 2023
4800d1a
Remove a commented out code from base-php.ts
adamziel Nov 4, 2023
57b19b3
export interface BasePHP -> interface BasePHP
adamziel Nov 4, 2023
7d75425
Rewrite site URL on sync
adamziel Nov 4, 2023
4d6ffad
Formatting
adamziel Nov 4, 2023
b76ac65
Add 1 to Math.random() to ensure the result will always be above one …
adamziel Nov 4, 2023
73bb01d
Move pruning SQL queries to a middleware
adamziel Nov 4, 2023
9ff9b20
Remove the manual debouncedFlush() call
adamziel Nov 4, 2023
b7411cb
Cleanup
adamziel Nov 4, 2023
5c9e5c7
Simplify the transported data structure, only use a single level of n…
adamziel Nov 4, 2023
e17848c
Fix the setTimeout call
adamziel Nov 4, 2023
1fb7ec2
Cleanup the comments
adamziel Nov 4, 2023
83398ea
Unify the language to talk about journals and envelopes
adamziel Nov 4, 2023
f7da8ee
Fix CI
adamziel Nov 4, 2023
1f4c3d1
Promote journalingAllowed to a BasePHP property
adamziel Nov 4, 2023
ffae1b0
Add time traveling demo
adamziel Nov 4, 2023
2a8a846
Start drafting unit tests
adamziel Nov 4, 2023
ab6d127
Ignore the generated wp data files
adamziel Nov 4, 2023
4a49ce8
Move journaling to a new package and add unit tests
adamziel Nov 5, 2023
b09c2b9
Prototype normalizeFilesystemOperations
adamziel Nov 5, 2023
103165d
Implement normalizeFilesystemOperations()
adamziel Nov 5, 2023
4cf5315
Simplify normalizeFilesystemOperations slightly
adamziel Nov 5, 2023
9d36b30
Simplify normalizeFilesystemOperations further
adamziel Nov 5, 2023
c7d4577
Further simplify normalizeFilesystemOperations
adamziel Nov 5, 2023
7fb04dc
Simplify the data shape for TransportEnvelope to remove some dozen co…
adamziel Nov 5, 2023
55b7a80
Simplify basename implementation
adamziel Nov 5, 2023
2ac177b
Document paths.ts
adamziel Nov 5, 2023
caf0553
Replace the "atomic()" method with a synchronous replayFSJournal() pr…
adamziel Nov 5, 2023
680e7c9
Use maps and sets for event emitting
adamziel Nov 5, 2023
3809cf3
Declare host and headers directly instead of destructuring them
adamziel Nov 5, 2023
ce943cd
Use base64 instead of json_encode to pass strings to php
adamziel Nov 5, 2023
67cf982
Simplify phpVars() further to use just a single code branch
adamziel Nov 5, 2023
5908edd
Fix the time-traveling demo
adamziel Nov 6, 2023
2cff941
Use the correct SERVER_NAME to startup PHP
adamziel Nov 6, 2023
58946c4
Regenerate package-lock.json
adamziel Nov 6, 2023
63e4fa9
Test phpVar() by actually executing its output
adamziel Nov 6, 2023
f4eb63a
Lint
adamziel Nov 6, 2023
5cf097c
Move sync demos to the playground-website project
adamziel Nov 6, 2023
2c2e9ff
Unit test commits and rollbacks
adamziel Nov 6, 2023
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
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ packages/playground/compile-wordpress/build-assets
__pycache__
packages/playground/remote/src/wordpress
packages/playground/remote/public
packages/playground/sync/src/test/wp-*
packages/php-wasm/node/src/test/__test*
*.timestamp-1678999213403.mjs
.local
Expand Down
3 changes: 2 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ packages/php-wasm/node/src/test/test-data/ linguist-generated
packages/php-wasm/web/public/kitchen-sink/ linguist-generated
packages/php-wasm/web/public/light/ linguist-generated
packages/playground/remote/public/wp-* linguist-generated
packages/playground/sync/src/test/wp-* linguist-generated
packages/playground/remote/src/wordpress/ linguist-generated
packages/playground/blueprints/public/ linguist-generated
packages/playground/blueprints/public/ linguist-generated
22 changes: 22 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions packages/php-wasm/fs-journal/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"extends": ["../../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {}
},
{
"files": ["*.ts", "*.tsx"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"rules": {}
}
]
}
Empty file.
44 changes: 44 additions & 0 deletions packages/php-wasm/fs-journal/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"name": "@php-wasm/fs-journal",
"version": "0.3.1",
"description": "Bindings to journal the PHP filesystem",
"repository": {
"type": "git",
"url": "https://github.com/WordPress/wordpress-playground"
},
"homepage": "https://developer.wordpress.org/playground",
"author": "The WordPress contributors",
"contributors": [
{
"name": "Adam Zielinski",
"email": "[email protected]",
"url": "https://github.com/adamziel"
}
],
"typedoc": {
"entryPoint": "./src/index.ts",
"readmeFile": "./README.md",
"displayName": "@php-wasm/universal",
"tsconfig": "./tsconfig.lib.json"
},
"exports": {
".": {
"import": "./index.js",
"require": "./index.cjs"
},
"./package.json": "./package.json"
},
"publishConfig": {
"access": "public",
"directory": "../../../dist/packages/php-wasm/universal"
},
"type": "module",
"main": "./index.cjs",
"module": "./index.js",
"license": "GPL-2.0-or-later",
"gitHead": "2fb8bb928071e308143e5895af19f4d13b6e90ba",
"engines": {
"node": ">=16.15.1",
"npm": ">=8.11.0"
}
}
50 changes: 50 additions & 0 deletions packages/php-wasm/fs-journal/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"name": "php-wasm-fs-journal",
"$schema": "../../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "packages/php-wasm/fs-journal/src",
"projectType": "library",
"targets": {
"build": {
"executor": "@nx/vite:build",
"outputs": ["{options.outputPath}"],
"options": {
"outputPath": "dist/packages/php-wasm/fs-journal"
}
},
"test": {
"executor": "nx:noop",
"dependsOn": ["test:vite"]
},
"test:esmcjs": {
"executor": "@wp-playground/nx-extensions:assert-built-esm-and-cjs",
"options": {
"outputPath": "dist/packages/php-wasm/fs-journal"
},
"dependsOn": ["build"]
},
"test:vite": {
"executor": "@nx/vite:test",
"outputs": ["coverage/packages/php-wasm/fs-journal"],
"options": {
"passWithNoTests": true,
"reportsDirectory": "../../../coverage/packages/php-wasm/fs-journal"
}
},
"lint": {
"executor": "@nx/linter:eslint",
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": ["packages/php-wasm/fs-journal/**/*.ts"]
}
}
},
"typecheck": {
"executor": "nx:run-commands",
"options": {
"commands": [
"tsc -p packages/php-wasm/fs-journal/tsconfig.lib.json --noEmit",
"tsc -p packages/php-wasm/fs-journal/tsconfig.spec.json --noEmit"
]
}
}
}
1 change: 1 addition & 0 deletions packages/php-wasm/fs-journal/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './lib';
Loading