Skip to content

Commit 81e4ec8

Browse files
committed
initial commit
0 parents  commit 81e4ec8

File tree

15 files changed

+73105
-0
lines changed

15 files changed

+73105
-0
lines changed

.last_build_id

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
8b4ada48f54be8ccffc3a17e7c30d48b

assets/AssetManifest.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"assets/image/construction.png":["assets/image/construction.png"],"packages/cupertino_icons/assets/CupertinoIcons.ttf":["packages/cupertino_icons/assets/CupertinoIcons.ttf"]}

assets/FontManifest.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[{"family":"MaterialIcons","fonts":[{"asset":"fonts/MaterialIcons-Regular.otf"}]},{"family":"packages/cupertino_icons/CupertinoIcons","fonts":[{"asset":"packages/cupertino_icons/assets/CupertinoIcons.ttf"}]}]

assets/NOTICES

Lines changed: 15083 additions & 0 deletions
Large diffs are not rendered by default.

assets/assets/image/construction.png

186 KB
Loading
1.24 MB
Binary file not shown.
Binary file not shown.

favicon.png

917 Bytes
Loading

flutter_service_worker.js

Lines changed: 191 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,191 @@
1+
'use strict';
2+
const MANIFEST = 'flutter-app-manifest';
3+
const TEMP = 'flutter-temp-cache';
4+
const CACHE_NAME = 'flutter-app-cache';
5+
const RESOURCES = {
6+
"assets/AssetManifest.json": "97fc783525dc47c2fd11716962e26865",
7+
"assets/assets/image/construction.png": "53faa0de8d0dbd7a8ef98461044f5d8b",
8+
"assets/FontManifest.json": "dc3d03800ccca4601324923c0b1d6d57",
9+
"assets/fonts/MaterialIcons-Regular.otf": "4e6447691c9509f7acdbf8a931a85ca1",
10+
"assets/NOTICES": "663b21400892cd5c32825b6b5d3ad5e7",
11+
"assets/packages/cupertino_icons/assets/CupertinoIcons.ttf": "6d342eb68f170c97609e9da345464e5e",
12+
"favicon.png": "5dcef449791fa27946b3d35ad8803796",
13+
"icons/Icon-192.png": "ac9a721a12bbc803b44f645561ecb1e1",
14+
"icons/Icon-512.png": "96e752610906ba2a93c65f8abe1645f1",
15+
"index.html": "2687f8c8662c9d16df65a4c28f847e85",
16+
"/": "2687f8c8662c9d16df65a4c28f847e85",
17+
"main.dart.js": "f69d6a3e8fc105fdeabda1669e9c127c",
18+
"manifest.json": "5a2c0526f1fe73e6f211bc7a9d15c210",
19+
"version.json": "426313f2f3133c2f20415344c4a22df3"
20+
};
21+
22+
// The application shell files that are downloaded before a service worker can
23+
// start.
24+
const CORE = [
25+
"/",
26+
"main.dart.js",
27+
"index.html",
28+
"assets/NOTICES",
29+
"assets/AssetManifest.json",
30+
"assets/FontManifest.json"];
31+
// During install, the TEMP cache is populated with the application shell files.
32+
self.addEventListener("install", (event) => {
33+
self.skipWaiting();
34+
return event.waitUntil(
35+
caches.open(TEMP).then((cache) => {
36+
return cache.addAll(
37+
CORE.map((value) => new Request(value, {'cache': 'reload'})));
38+
})
39+
);
40+
});
41+
42+
// During activate, the cache is populated with the temp files downloaded in
43+
// install. If this service worker is upgrading from one with a saved
44+
// MANIFEST, then use this to retain unchanged resource files.
45+
self.addEventListener("activate", function(event) {
46+
return event.waitUntil(async function() {
47+
try {
48+
var contentCache = await caches.open(CACHE_NAME);
49+
var tempCache = await caches.open(TEMP);
50+
var manifestCache = await caches.open(MANIFEST);
51+
var manifest = await manifestCache.match('manifest');
52+
// When there is no prior manifest, clear the entire cache.
53+
if (!manifest) {
54+
await caches.delete(CACHE_NAME);
55+
contentCache = await caches.open(CACHE_NAME);
56+
for (var request of await tempCache.keys()) {
57+
var response = await tempCache.match(request);
58+
await contentCache.put(request, response);
59+
}
60+
await caches.delete(TEMP);
61+
// Save the manifest to make future upgrades efficient.
62+
await manifestCache.put('manifest', new Response(JSON.stringify(RESOURCES)));
63+
return;
64+
}
65+
var oldManifest = await manifest.json();
66+
var origin = self.location.origin;
67+
for (var request of await contentCache.keys()) {
68+
var key = request.url.substring(origin.length + 1);
69+
if (key == "") {
70+
key = "/";
71+
}
72+
// If a resource from the old manifest is not in the new cache, or if
73+
// the MD5 sum has changed, delete it. Otherwise the resource is left
74+
// in the cache and can be reused by the new service worker.
75+
if (!RESOURCES[key] || RESOURCES[key] != oldManifest[key]) {
76+
await contentCache.delete(request);
77+
}
78+
}
79+
// Populate the cache with the app shell TEMP files, potentially overwriting
80+
// cache files preserved above.
81+
for (var request of await tempCache.keys()) {
82+
var response = await tempCache.match(request);
83+
await contentCache.put(request, response);
84+
}
85+
await caches.delete(TEMP);
86+
// Save the manifest to make future upgrades efficient.
87+
await manifestCache.put('manifest', new Response(JSON.stringify(RESOURCES)));
88+
return;
89+
} catch (err) {
90+
// On an unhandled exception the state of the cache cannot be guaranteed.
91+
console.error('Failed to upgrade service worker: ' + err);
92+
await caches.delete(CACHE_NAME);
93+
await caches.delete(TEMP);
94+
await caches.delete(MANIFEST);
95+
}
96+
}());
97+
});
98+
99+
// The fetch handler redirects requests for RESOURCE files to the service
100+
// worker cache.
101+
self.addEventListener("fetch", (event) => {
102+
if (event.request.method !== 'GET') {
103+
return;
104+
}
105+
var origin = self.location.origin;
106+
var key = event.request.url.substring(origin.length + 1);
107+
// Redirect URLs to the index.html
108+
if (key.indexOf('?v=') != -1) {
109+
key = key.split('?v=')[0];
110+
}
111+
if (event.request.url == origin || event.request.url.startsWith(origin + '/#') || key == '') {
112+
key = '/';
113+
}
114+
// If the URL is not the RESOURCE list then return to signal that the
115+
// browser should take over.
116+
if (!RESOURCES[key]) {
117+
return;
118+
}
119+
// If the URL is the index.html, perform an online-first request.
120+
if (key == '/') {
121+
return onlineFirst(event);
122+
}
123+
event.respondWith(caches.open(CACHE_NAME)
124+
.then((cache) => {
125+
return cache.match(event.request).then((response) => {
126+
// Either respond with the cached resource, or perform a fetch and
127+
// lazily populate the cache.
128+
return response || fetch(event.request).then((response) => {
129+
cache.put(event.request, response.clone());
130+
return response;
131+
});
132+
})
133+
})
134+
);
135+
});
136+
137+
self.addEventListener('message', (event) => {
138+
// SkipWaiting can be used to immediately activate a waiting service worker.
139+
// This will also require a page refresh triggered by the main worker.
140+
if (event.data === 'skipWaiting') {
141+
self.skipWaiting();
142+
return;
143+
}
144+
if (event.data === 'downloadOffline') {
145+
downloadOffline();
146+
return;
147+
}
148+
});
149+
150+
// Download offline will check the RESOURCES for all files not in the cache
151+
// and populate them.
152+
async function downloadOffline() {
153+
var resources = [];
154+
var contentCache = await caches.open(CACHE_NAME);
155+
var currentContent = {};
156+
for (var request of await contentCache.keys()) {
157+
var key = request.url.substring(origin.length + 1);
158+
if (key == "") {
159+
key = "/";
160+
}
161+
currentContent[key] = true;
162+
}
163+
for (var resourceKey of Object.keys(RESOURCES)) {
164+
if (!currentContent[resourceKey]) {
165+
resources.push(resourceKey);
166+
}
167+
}
168+
return contentCache.addAll(resources);
169+
}
170+
171+
// Attempt to download the resource online before falling back to
172+
// the offline cache.
173+
function onlineFirst(event) {
174+
return event.respondWith(
175+
fetch(event.request).then((response) => {
176+
return caches.open(CACHE_NAME).then((cache) => {
177+
cache.put(event.request, response.clone());
178+
return response;
179+
});
180+
}).catch((error) => {
181+
return caches.open(CACHE_NAME).then((cache) => {
182+
return cache.match(event.request).then((response) => {
183+
if (response != null) {
184+
return response;
185+
}
186+
throw error;
187+
});
188+
});
189+
})
190+
);
191+
}

icons/Icon-192.png

5.17 KB
Loading

icons/Icon-512.png

8.06 KB
Loading

index.html

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<!--
5+
If you are serving your web app in a path other than the root, change the
6+
href value below to reflect the base path you are serving from.
7+
8+
The path provided below has to start and end with a slash "/" in order for
9+
it to work correctly.
10+
11+
For more details:
12+
* https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base
13+
-->
14+
<base href="/">
15+
16+
<meta charset="UTF-8">
17+
<meta content="IE=Edge" http-equiv="X-UA-Compatible">
18+
<meta name="description" content="A new Flutter project.">
19+
20+
<!-- iOS meta tags & icons -->
21+
<meta name="apple-mobile-web-app-capable" content="yes">
22+
<meta name="apple-mobile-web-app-status-bar-style" content="black">
23+
<meta name="apple-mobile-web-app-title" content="portfolio">
24+
<link rel="apple-touch-icon" href="icons/Icon-192.png">
25+
26+
<title>portfolio</title>
27+
<link rel="manifest" href="manifest.json">
28+
</head>
29+
<body>
30+
<!-- This script installs service_worker.js to provide PWA functionality to
31+
application. For more information, see:
32+
https://developers.google.com/web/fundamentals/primers/service-workers -->
33+
<script>
34+
var serviceWorkerVersion = '962389267';
35+
var scriptLoaded = false;
36+
function loadMainDartJs() {
37+
if (scriptLoaded) {
38+
return;
39+
}
40+
scriptLoaded = true;
41+
var scriptTag = document.createElement('script');
42+
scriptTag.src = 'main.dart.js';
43+
scriptTag.type = 'application/javascript';
44+
document.body.append(scriptTag);
45+
}
46+
47+
if ('serviceWorker' in navigator) {
48+
// Service workers are supported. Use them.
49+
window.addEventListener('load', function () {
50+
// Wait for registration to finish before dropping the <script> tag.
51+
// Otherwise, the browser will load the script multiple times,
52+
// potentially different versions.
53+
var serviceWorkerUrl = 'flutter_service_worker.js?v=' + serviceWorkerVersion;
54+
navigator.serviceWorker.register(serviceWorkerUrl)
55+
.then((reg) => {
56+
function waitForActivation(serviceWorker) {
57+
serviceWorker.addEventListener('statechange', () => {
58+
if (serviceWorker.state == 'activated') {
59+
console.log('Installed new service worker.');
60+
loadMainDartJs();
61+
}
62+
});
63+
}
64+
if (!reg.active && (reg.installing || reg.waiting)) {
65+
// No active web worker and we have installed or are installing
66+
// one for the first time. Simply wait for it to activate.
67+
waitForActivation(reg.installing ?? reg.waiting);
68+
} else if (!reg.active.scriptURL.endsWith(serviceWorkerVersion)) {
69+
// When the app updates the serviceWorkerVersion changes, so we
70+
// need to ask the service worker to update.
71+
console.log('New service worker available.');
72+
reg.update();
73+
waitForActivation(reg.installing);
74+
} else {
75+
// Existing service worker is still good.
76+
console.log('Loading app from service worker.');
77+
loadMainDartJs();
78+
}
79+
});
80+
81+
// If service worker doesn't succeed in a reasonable amount of time,
82+
// fallback to plaint <script> tag.
83+
setTimeout(() => {
84+
if (!scriptLoaded) {
85+
console.warn(
86+
'Failed to load app from service worker. Falling back to plain <script> tag.',
87+
);
88+
loadMainDartJs();
89+
}
90+
}, 4000);
91+
});
92+
} else {
93+
// Service workers not supported. Just drop the <script> tag.
94+
loadMainDartJs();
95+
}
96+
</script>
97+
</body>
98+
</html>

0 commit comments

Comments
 (0)