package Progressive::Web::Application;
use 5.006;
use strict;
use warnings;
use Carp qw//;
use JSON;
use Colouring::In;
use Image::Scale;
use Cwd qw/abs_path/;
our $VERSION = '0.09';
our (%TOOL, %MANI
Colouring::In->new($_[0])->toCSS; },
JSON => JSON->new->utf8->pretty,
to_json => sub { $TOOL{JSON}->encode($_[0]); },
from_json => sub { return $TOOL{JSON}->decode($_[0]); },
make_path => sub
sprintf
q/Required field not passed for icon missing %s for %s/,
$_,
$TOOL{to_json}->($_[0])
);
}
$TOOL{scalar_check}->($_[0]->{$_}, $_);
}
$_[0]->{src} = q|/| .
package Progressive::Web::Application::Template::Base;
use strict;
use JSON qw//;
our $JSON;
BEGIN { $JSON = JSON->new->utf8->pretty(1)->allow_nonref->allow_blessed; }
sub new {
my $self = bless {},
lates->{$key} =~ s/\{($dataReg)\}/_encode_json($_[1]->{$1})/eg;
$templates->{$key} =~ s/\s*$//;
}
return $templates;
}
sub _encode_json {
my $val = $JSON->encode($_[0]);
chomp($val);
return $v
onse) {
return response ? response.clone() : requestWith === 'XMLHttpRequest' ? new Response(JSON.stringify({
error: "Network issues, try again when you're back online"
})) : htmlRespo
response for the passed request if found then this is returned else
it will fall back to either a JSON response or the Response that is cached via the 'offline_path' param based upon the requestWith h
tch(precache_endpoint).then(function(response) {
// expects a JSON encode ARRAY of resource/endpoint urls
return response.json();
}).then(function(urls) {
cache.add(offlineFile);
re
rom endpoint strategy.
An API request is made (precache_endpoint), this is expected to return an JSON ARRAY of resources/request uri's that would
then be fetched and cached for use in later requests
onse) {
return response ? response.clone() : requestWith === 'XMLHttpRequest' ? new Response(JSON.stringify({
error: "Network issues, try again when you're back online"
})) : htmlRespo
response for the passed request if found then this is returned else
it will fall back to either a JSON response or the Response that is cached via the 'offline_path' param based upon the requestWith h
'precache_endpoint',
field => 'Precache Endpoint',
info => 'An API endpoint that returns an JSON array containing a list of resources/endpoints to add to the precache.',
required => 1,
},
le q|PWA Manifest|;
say q|The web app manifest provides information about a web application in a JSON text file,|
. q| necessary for the web app to be downloaded and be presented to the user similar