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

Add service worker streaming #85

Merged
merged 25 commits into from
Oct 19, 2018
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
c4c5d13
Rename error-response-handling to navigation-routing
westonruter Oct 11, 2018
7b8e0bf
Adopt streaming logic first prototyped in AMP plugin
westonruter Oct 11, 2018
fcec82a
Hook up streams
westonruter Oct 12, 2018
6ae18b2
Add 500/offline error handling to streams
westonruter Oct 12, 2018
348840f
WIP: DOM Diffing
westonruter Oct 13, 2018
85e2efd
Pull back diffing logic to just target subset of AMP support
westonruter Oct 13, 2018
e7e4522
Prevent streaming from applying in admin
westonruter Oct 13, 2018
baf00f1
Update meta from body fragment and add scripts
westonruter Oct 13, 2018
52a71f6
WIP: Improve DOM diffing
westonruter Oct 14, 2018
992f479
Reduce amount of code needed to apply DOM changes
westonruter Oct 14, 2018
720d187
Prevent unnecessarily removing elements
westonruter Oct 14, 2018
ba3b3a4
Allow loading element to be customized
westonruter Oct 14, 2018
1811ec9
Populate comment nodes in header
westonruter Oct 14, 2018
2f760b6
Prevent streaming on the login screen and other PHP endpoints
westonruter Oct 15, 2018
293bfdb
Prevent streaming responses to direct fragment navigation
westonruter Oct 15, 2018
831bcb6
Fix handling of streaming body for URL that redirects
westonruter Oct 15, 2018
16852cf
WIP: Streaming non-AMP
westonruter Oct 16, 2018
0e6985a
WIP: Streaming non-AMP (2)
westonruter Oct 18, 2018
51fd288
Finish eliminating dependency on AMP
westonruter Oct 18, 2018
9855b53
Skip registering query var for fragment since causes front-page query…
westonruter Oct 18, 2018
9bfe7cc
Improve method ordering and phpdoc
westonruter Oct 18, 2018
3b11698
Add missing jsdoc, remove bad DOMDocument arg, clean up
westonruter Oct 18, 2018
7da958d
Prevent sending streamed responses when navigation preload happens
westonruter Oct 18, 2018
270ab2c
Expand pattern blacklist for non-template URLs
westonruter Oct 19, 2018
65d74ca
Fix copying request props
westonruter Oct 19, 2018
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
2 changes: 1 addition & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
"es6": true
},
"parserOptions": {
"ecmaVersion": 8
"ecmaVersion": 2018
}
}
3 changes: 2 additions & 1 deletion .jshintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
wp-includes/js/service-worker.js
wp-includes/js/service-worker-error-response-handling.js
wp-includes/js/service-worker-navigation-routing.js
wp-includes/js/service-worker-precaching.js
wp-includes/js/service-worker-stream-combiner.js
7 changes: 7 additions & 0 deletions .phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@
<rule ref="PHPCompatibilityWP">
<exclude-pattern>bin/*</exclude-pattern>
</rule>

<rule ref="WordPress.NamingConventions.ValidVariableName">
<properties>
<property name="customPropertiesWhitelist" value="childNodes,tagName,textContent,parentNode,nodeType,nodeName,nextSibling,firstChild,lastChild,nodeValue,DEFAULT_ARGS,documentElement,removeChild,ownerDocument,DEFAULT_WIDTH,DEFAULT_HEIGHT" />
</properties>
</rule>

<!-- For help in understanding this testVersion:
https://github.com/PHPCompatibility/PHPCompatibility#sniffing-your-code-for-compatibility-with-specific-php-versions -->
<config name="testVersion" value="5.2-"/>
Expand Down
2 changes: 1 addition & 1 deletion amp/class-amp-service-worker.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public function add_image_runtime_caching( $service_workers ) {
'/wp-content/.*\.(?:png|gif|jpg|jpeg|svg|webp)(\?.*)?$',
array(
'strategy' => WP_Service_Worker_Caching_Routes::STRATEGY_CACHE_FIRST,
'cacheName' => 'images',
'cacheName' => 'images', // @todo This needs to get the proper prefix in JS.
'plugins' => array(
'cacheableResponse' => array(
'statuses' => array( 0, 200 ),
Expand Down
2 changes: 1 addition & 1 deletion pwa.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@

/** WP_Service_Worker_Component Implementation Classes */
require_once PWA_PLUGIN_DIR . '/wp-includes/components/class-wp-service-worker-configuration-component.php';
require_once PWA_PLUGIN_DIR . '/wp-includes/components/class-wp-service-worker-error-response-component.php';
require_once PWA_PLUGIN_DIR . '/wp-includes/components/class-wp-service-worker-navigation-routing-component.php';
require_once PWA_PLUGIN_DIR . '/wp-includes/components/class-wp-service-worker-precaching-routes-component.php';
require_once PWA_PLUGIN_DIR . '/wp-includes/components/class-wp-service-worker-precaching-routes.php';
require_once PWA_PLUGIN_DIR . '/wp-includes/components/class-wp-service-worker-caching-routes-component.php';
Expand Down
18 changes: 9 additions & 9 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
![Banner](wp-assets/banner-1544x500.png)
WordPress feature plugin to bring Progressive Web App (PWA) capabilities to Core

**Contributors:** [xwp](https://profiles.wordpress.org/xwp), [google](https://profiles.wordpress.org/google), [automattic](https://profiles.wordpress.org/automattic)
**Tags:** [pwa](https://wordpress.org/plugins/tags/pwa), [progressive web apps](https://wordpress.org/plugins/tags/progressive-web-apps), [service workers](https://wordpress.org/plugins/tags/service-workers), [web app manifest](https://wordpress.org/plugins/tags/web-app-manifest), [https](https://wordpress.org/plugins/tags/https)
**Requires at least:** 4.9
**Tested up to:** 4.9
**Stable tag:** 0.1.0
**License:** [GPLv2 or later](http://www.gnu.org/licenses/gpl-2.0.html)
**Requires PHP:** 5.2

[![Build Status](https://travis-ci.org/xwp/pwa-wp.svg?branch=master)](https://travis-ci.org/xwp/pwa-wp) [![Built with Grunt](https://cdn.gruntjs.com/builtwith.svg)](http://gruntjs.com)
**Contributors:** [xwp](https://profiles.wordpress.org/xwp), [google](https://profiles.wordpress.org/google), [automattic](https://profiles.wordpress.org/automattic)
**Tags:** [pwa](https://wordpress.org/plugins/tags/pwa), [progressive web apps](https://wordpress.org/plugins/tags/progressive-web-apps), [service workers](https://wordpress.org/plugins/tags/service-workers), [web app manifest](https://wordpress.org/plugins/tags/web-app-manifest), [https](https://wordpress.org/plugins/tags/https)
**Requires at least:** 4.9
**Tested up to:** 4.9
**Stable tag:** 0.1.0
**License:** [GPLv2 or later](http://www.gnu.org/licenses/gpl-2.0.html)
**Requires PHP:** 5.2

[![Build Status](https://travis-ci.org/xwp/pwa-wp.svg?branch=master)](https://travis-ci.org/xwp/pwa-wp) [![Built with Grunt](https://cdn.gruntjs.com/builtwith.svg)](http://gruntjs.com)

## Description ##

Expand Down
8 changes: 4 additions & 4 deletions wp-includes/class-wp-service-workers.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ class WP_Service_Workers implements WP_Service_Worker_Registry_Aware {
*/
public function __construct() {
$components = array(
'configuration' => new WP_Service_Worker_Configuration_Component(),
'error_response' => new WP_Service_Worker_Error_Response_Component(),
'precaching_routes' => new WP_Service_Worker_Precaching_Routes_Component(),
'caching_routes' => new WP_Service_Worker_Caching_Routes_Component(),
'configuration' => new WP_Service_Worker_Configuration_Component(),
'navigation_routing' => new WP_Service_Worker_Navigation_Routing_Component(),
'precaching_routes' => new WP_Service_Worker_Precaching_Routes_Component(),
'caching_routes' => new WP_Service_Worker_Caching_Routes_Component(),
);

$this->scripts = new WP_Service_Worker_Scripts( $components );
Expand Down

This file was deleted.

Loading