This repository has been archived by the owner on Oct 11, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sw.js
142 lines (125 loc) · 6.3 KB
/
sw.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
self.addEventListener('install', async event => {
console.debug('install event')
});
self.addEventListener('fetch', async event => {
console.debug('fetch event')
});
var LP_Files=[
"res/ui/box/createBoxes.js", //Creates Preview, Properties, Elements, Pages and Code editor boxes
"res/js/cookies.js", //Writes and reads cookies
"res/js/theme-loader.js", //Theme loader
"res/ui/toolbar/toolbar.js", //Toolbar controller, creates tool bar HTML and handle onclick
"res/ui/toolbar/items.js", //Holds toolbar data
"res/pages/page.js", //Handles pages
"res/pages/ui/table/buttons.js", //Pages table row buttons generator
"res/pages/ui/table/row.js", //Pages table rows
"res/elements/element.js", //Elements handler
"res/elements/template.js", //Element templates
"res/elements/ui/table/buttons.js", //Elements table row buttons generator
"res/elements/ui/table/row.js", //Elements table rows
"res/ui/dialog/dialog.js", //Handles dialogs
"res/js/key-bindings.js", //Key bindings
"res/properties/generator.js", //Properties generator
"res/preview/preview.js", //Preview generator
"res/settings/settings.js", //Settings
"res/settings/fields/screen-size.js", //Settings - Screen size
"res/settings/fields/screen-brightness.js", //Settings - Screen brightness
"res/ui/notification/notification.js", // Create and manage notifications
"res/code-editor/code-editor.js", // Monaco editor
"res/file/save.js", // Save the project
"res/file/load.js", // Load the project
"res/file/migrate.js", // Migrate a project to a more recent format
"res/code-generator/config.js", // Generates Arduino config code
"res/code-generator/generateCode.js", // Generates Arduino code
"res/code-generator/loopCode.js", // Generates loop code
"res/ui/hint/hint.js",
"res/code-editor/editorOptionsEditor.js", // Monaco options editor
"res/ui/box/manageBoxes.js", // Manage boxes (move and float)
"res/ui/context-menu/context-menu.js", // Custom context menus
"res/ui/context-menu/items.js", // Custom context menus
"res/elements/types/button/createDefaultDataObject.js",
"res/elements/types/button/createProperties.js",
"res/elements/types/button/saveProperties.js",
"res/elements/types/button/generatePreview.js",
"res/elements/types/button/generateCode.js",
"res/elements/types/label/createDefaultDataObject.js",
"res/elements/types/label/createProperties.js",
"res/elements/types/label/saveProperties.js",
"res/elements/types/label/generatePreview.js",
"res/elements/types/label/generateCode.js",
"res/elements/types/check-box/createDefaultDataObject.js",
"res/elements/types/check-box/createProperties.js",
"res/elements/types/check-box/saveProperties.js",
"res/elements/types/check-box/generatePreview.js",
"res/elements/types/check-box/generateCode.js",
"res/elements/types/slider/createDefaultDataObject.js",
"res/elements/types/slider/createProperties.js",
"res/elements/types/slider/saveProperties.js",
"res/elements/types/slider/generatePreview.js",
"res/elements/types/slider/generateCode.js",
"res/elements/types/radio-button/createDefaultDataObject.js",
"res/elements/types/radio-button/createProperties.js",
"res/elements/types/radio-button/saveProperties.js",
"res/elements/types/radio-button/generatePreview.js",
"res/elements/types/radio-button/generateCode.js",
"res/ui/toolbar/handlers/file/import-from-json.js", //Import from JSON
"res/ui/toolbar/handlers/help/about.js", //About Gui900 UI editor
"res/ui/toolbar/handlers/help/design-tricks.js", //Gui900 Design tricks
"res/ui/toolbar/handlers/file/open-from-file.js", //Open from file
"res/ui/toolbar/handlers/file/save.js", //Save project
"res/ui/toolbar/handlers/elements/duplicate.js", //Duplicate element
"res/ui/toolbar/handlers/file/generateCode.js", //Generate code
"res/ui/toolbar/handlers/code/generateLoopCode.js", //Generate loop code
"res/ui/toolbar/handlers/page/duplicate.js", // Duplicate page
"res/ui/toolbar/handlers/page/clear.js", // Clear page
"res/ui/toolbar/toolbar.css", //Styles for the toolbar
"res/ui/css/constants.css", //Holds the UI constants
"res/ui/css/styles.css", //The main styles for the app
"res/ui/box/box.css", //box styles
"res/ui/table/table.css", //Table styles
"res/ui/button/button.css", //Button styles
"res/pages/ui/table/special-styles.css", //Styles specific to pages table
"res/ui/css/scroll-bar.css", //Custom scroll-bars
"res/ui/css/grid.css", //Multi-column rows
"res/ui/dialog/dialog.css", //Dialog styles
"res/properties/styles.css", //Properties special styles
"res/properties/input-styles.css", //Properties fields styles
"res/preview/styles.css", //Preview special styles
"res/elements/ui/table/special-styles.css", //Elements table special styles
"res/font-awesome/css/all.css", //Font awesome
"res/ui/css/tooltip.css", // Tooltips
"res/settings/input-styles.css", // Project settings input styles
"res/ui/notification/notification.css", // Notifications
"res/settings/special-styles.css", // Project settings special styles
"res/code-editor/styles.css", // Code editor styles
"res/ui/hint/styles.css",
"res/ui/context-menu/style.css", // Custom context menus
"res/js/loader-end.js", // Finishes loading
"res/code-editor/monaco-editor/min/vs/loader.js",
"res/code-editor/monaco-editor/min/vs/editor/editor.main.nls.js",
"res/code-editor/monaco-editor/min/vs/editor/editor.main.js",
"res/JQuery/JQuery UI/jquery-ui.min.css",
"res/JQuery/JQuery UI/jquery-ui.min.js",
"res/img/icon-square.png", // App icon
]
self.addEventListener('install', async event => {
console.debug("Installed")
const cache = await caches.open("gve-pwa-conf-1");
await cache.addAll([
"./",
"./Gui900 visual editor.html",
"./floatingBox.html",
]);
LP_Files.forEach(async function (e) {
await cache.add("./"+e);
});
});
self.addEventListener('fetch', event => {
const req = event.request;
event.respondWith(cacheFirst(req));
});
async function cacheFirst(req) {
const cache = await caches.open("gve-pwa-conf-1");
const cachedResponse = await cache.match(req);
return cachedResponse || fetch(req);
}