qcobjects-cli 2.5.104-beta → 2.5.105-beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/VERSION +1 -1
- package/build-esbuild.js +64 -12
- package/package.json +1 -1
- package/public/browser/templates/apps/spa-local.html +28 -0
- package/public/browser/templates/apps/spa-local.js +65 -0
- package/public/browser/templates/pwa/sw.js +112 -0
- package/public/cjs/templates/apps/spa-local.html +28 -0
- package/public/cjs/templates/apps/spa-local.js +65 -0
- package/public/cjs/templates/pwa/sw.js +112 -0
- package/public/esm/templates/apps/spa-local.html +28 -0
- package/public/esm/templates/apps/spa-local.js +65 -0
- package/public/esm/templates/pwa/sw.js +112 -0
package/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.5.
|
|
1
|
+
2.5.105-beta
|
package/build-esbuild.js
CHANGED
|
@@ -1,7 +1,56 @@
|
|
|
1
1
|
// build.js
|
|
2
2
|
const esbuild = require("esbuild");
|
|
3
3
|
const alias = require("esbuild-plugin-alias");
|
|
4
|
-
const path = require("path");
|
|
4
|
+
const path = require("node:path");
|
|
5
|
+
const fs = require ("node:fs");
|
|
6
|
+
|
|
7
|
+
const logError = (e) => { console.error(e); process.exit(1); };
|
|
8
|
+
const logDebug = (e) => { console.debug(e); }
|
|
9
|
+
|
|
10
|
+
const copyDir = (source, dest, exclude) => {
|
|
11
|
+
source = path.resolve(source);
|
|
12
|
+
dest = path.resolve(dest);
|
|
13
|
+
const dname = path.basename(source);
|
|
14
|
+
const dirExcluded = (exclude.includes(dname));
|
|
15
|
+
|
|
16
|
+
const isDir = (d) => {
|
|
17
|
+
return (fs.existsSync(d) && fs.statSync(d).isDirectory()) ? (true) : (false);
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const isFile = (d) => {
|
|
21
|
+
return (fs.existsSync(d) && fs.statSync(d).isFile()) ? (true) : (false);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (isDir(source) && !dirExcluded) {
|
|
25
|
+
fs.mkdirSync(dest, { recursive: true });
|
|
26
|
+
const paths = fs.readdirSync(source, { withFileTypes: true })
|
|
27
|
+
const dirs = paths.filter(d => d.isDirectory());
|
|
28
|
+
const files = paths.filter(f => f.isFile());
|
|
29
|
+
(async function (paths, dirs, files, exclude) {
|
|
30
|
+
files.map((f) => {
|
|
31
|
+
const sourceFile = path.resolve(source, f.name);
|
|
32
|
+
const destFile = path.resolve(dest, f.name);
|
|
33
|
+
const fileExcluded = exclude.includes(f.name);
|
|
34
|
+
if (isFile(sourceFile) && !fileExcluded) {
|
|
35
|
+
logDebug(`[publish:static] Copying files from ${sourceFile} to ${destFile} excluding ${exclude}...`);
|
|
36
|
+
fs.copyFileSync(sourceFile, destFile);
|
|
37
|
+
logDebug(`[publish:static] Copying files from ${sourceFile} to ${destFile} excluding ${exclude}...DONE!`);
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
dirs.map((d) => {
|
|
41
|
+
const sourceDir = path.resolve(source, d.name);
|
|
42
|
+
const destDir = path.resolve(dest, d.name);
|
|
43
|
+
copyDir(sourceDir, destDir, exclude);
|
|
44
|
+
});
|
|
45
|
+
})(paths, dirs, files, exclude);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
copyDir("./src/templates", "./build/templates", []);
|
|
51
|
+
copyDir("./src/templates", "./public/cjs/templates", []);
|
|
52
|
+
copyDir("./src/templates", "./public/esm/templates", []);
|
|
53
|
+
copyDir("./src/templates", "./public/browser/templates", []);
|
|
5
54
|
|
|
6
55
|
const baseSettings = {
|
|
7
56
|
entryPoints: ["src/**/*.ts"], // Your entry file
|
|
@@ -11,7 +60,7 @@ const baseSettings = {
|
|
|
11
60
|
target: ["esnext"], // Adjust based on your target environment
|
|
12
61
|
tsconfig: "tsconfig.json", // Path to your tsconfig.json,
|
|
13
62
|
globalName: "global",
|
|
14
|
-
minify:false,
|
|
63
|
+
minify: false,
|
|
15
64
|
keepNames: true,
|
|
16
65
|
sourcemap: true,
|
|
17
66
|
splitting: false,
|
|
@@ -22,48 +71,51 @@ const baseSettings = {
|
|
|
22
71
|
})
|
|
23
72
|
],
|
|
24
73
|
external: ["os", "path", "http", "url",
|
|
25
|
-
"child_process", "events", "fs", "process",
|
|
26
|
-
"node:fs", "node:os", "node:child_process",
|
|
74
|
+
"child_process", "events", "fs", "process",
|
|
75
|
+
"node:fs", "node:os", "node:child_process",
|
|
27
76
|
"node:path", "readline", "node:net", "node:repl",
|
|
28
|
-
"node:vm", "http2", "vm", "qcobjects", "qcobjects-sdk",
|
|
77
|
+
"node:vm", "http2", "vm", "qcobjects", "qcobjects-sdk",
|
|
29
78
|
"../package.json", "package.json", "./package.json"
|
|
30
79
|
]
|
|
31
80
|
};
|
|
32
81
|
|
|
33
|
-
const cjsSettings = {
|
|
82
|
+
const cjsSettings = {
|
|
83
|
+
...baseSettings,
|
|
34
84
|
entryPoints: ["src/**/*.ts"], // Your entry file
|
|
35
85
|
outdir: "public/cjs", // Output dir
|
|
36
86
|
format: "cjs", // or "esm" depending on your module system
|
|
37
87
|
platform: "node", // or "browser" depending on your target environment
|
|
38
88
|
outExtension: {
|
|
39
|
-
".js":".cjs"
|
|
89
|
+
".js": ".cjs"
|
|
40
90
|
}
|
|
41
91
|
|
|
42
92
|
};
|
|
43
93
|
|
|
44
|
-
const esmSettings = {
|
|
94
|
+
const esmSettings = {
|
|
95
|
+
...baseSettings,
|
|
45
96
|
entryPoints: ["src/**/*.ts"], // Your entry file
|
|
46
97
|
outdir: "public/esm", // Output dir
|
|
47
98
|
format: "esm", // or "esm" depending on your module system
|
|
48
99
|
platform: "browser", // or "browser" depending on your target environment
|
|
49
100
|
outExtension: {
|
|
50
|
-
".js":".mjs"
|
|
101
|
+
".js": ".mjs"
|
|
51
102
|
}
|
|
52
103
|
|
|
53
104
|
};
|
|
54
105
|
|
|
55
|
-
const browserSettings = {
|
|
106
|
+
const browserSettings = {
|
|
107
|
+
...baseSettings,
|
|
56
108
|
entryPoints: ["src/**/*.ts"], // Your entry file
|
|
57
109
|
bundle: true,
|
|
58
110
|
outdir: "public/browser", // Output dir
|
|
59
111
|
format: "iife", // or "esm" depending on your module system
|
|
60
112
|
platform: "browser", // or "browser" depending on your target environment
|
|
61
113
|
outExtension: {
|
|
62
|
-
".js":".js"
|
|
114
|
+
".js": ".js"
|
|
63
115
|
}
|
|
64
116
|
};
|
|
65
117
|
|
|
66
|
-
|
|
118
|
+
|
|
67
119
|
|
|
68
120
|
esbuild.build(cjsSettings).catch(logError);
|
|
69
121
|
esbuild.build(esmSettings).catch(logError);
|
package/package.json
CHANGED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html class="no-js" lang="en">
|
|
3
|
+
|
|
4
|
+
<head>
|
|
5
|
+
<meta charset="utf-8" />
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
|
+
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width" />
|
|
8
|
+
<!-- This is a wide open CSP declaration. To lock this down for production, see below. -->
|
|
9
|
+
<meta http-equiv="Content-Security-Policy" content="default-src * 'self' 'unsafe-inline' 'unsafe-eval' data: gap: https://ssl.gstatic.com; img-src * 'self' data:; child-src *; style-src * 'self' 'unsafe-inline' 'unsafe-eval'; script-src * 'self' 'unsafe-inline' 'unsafe-eval'; connect-src * 'self' 'unsafe-inline' 'unsafe-eval';media-src *">
|
|
10
|
+
<title>{{title}}</title>
|
|
11
|
+
<script type="text/javascript" src="./node_modules/qcobjects/QCObjects.js"></script>
|
|
12
|
+
</head>
|
|
13
|
+
|
|
14
|
+
<body>
|
|
15
|
+
|
|
16
|
+
<component name="main">
|
|
17
|
+
<routing path="/" name="main" />
|
|
18
|
+
<routing path="#" name="main" />
|
|
19
|
+
<routing path="" name="main" />
|
|
20
|
+
<routing path="page1" name="page1" />
|
|
21
|
+
<routing path="page2" name="page2" />
|
|
22
|
+
</component>
|
|
23
|
+
|
|
24
|
+
<script type="text/javascript" src="js/init.js"></script>
|
|
25
|
+
|
|
26
|
+
</body>
|
|
27
|
+
|
|
28
|
+
</html>
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const path = require("path");
|
|
3
|
+
const absolutePath = path.resolve( __dirname, "./" );
|
|
4
|
+
|
|
5
|
+
const http2 = require("http2");
|
|
6
|
+
const fs = require("fs");
|
|
7
|
+
const mime = require("mime");
|
|
8
|
+
|
|
9
|
+
Import("org.quickcorp.qcobjects.main.file");
|
|
10
|
+
|
|
11
|
+
Package("org.quickcorp.cli.templates.app.spa_local",[
|
|
12
|
+
Class("AppTemplate",{
|
|
13
|
+
name:"app/index.html",
|
|
14
|
+
template:"",
|
|
15
|
+
templateURI:"spa-local.html",
|
|
16
|
+
body:"",
|
|
17
|
+
compileAndSave:false,
|
|
18
|
+
save:function (){
|
|
19
|
+
var appTemplateInstance = this;
|
|
20
|
+
fs.mkdir("app/",()=>{
|
|
21
|
+
fs.writeFile(appTemplateInstance.name, appTemplateInstance.body, err => {
|
|
22
|
+
if (err) {
|
|
23
|
+
return console.error(`Autsch! Failed to store template: ${err.message}.`);
|
|
24
|
+
}
|
|
25
|
+
logger.info("Saved template!");
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
},
|
|
29
|
+
done:function (){
|
|
30
|
+
var appTemplateInstance = this;
|
|
31
|
+
const source = appTemplateInstance.template;
|
|
32
|
+
|
|
33
|
+
(New(Component, {
|
|
34
|
+
name: "static_source",
|
|
35
|
+
template: source,
|
|
36
|
+
cached:false,
|
|
37
|
+
tplsource: "inline",
|
|
38
|
+
data: {
|
|
39
|
+
title: "QCObjects"
|
|
40
|
+
},
|
|
41
|
+
done ({request, component}) {
|
|
42
|
+
appTemplateInstance.body = component.parsedAssignmentText;
|
|
43
|
+
return Promise.resolve({request, component});
|
|
44
|
+
}
|
|
45
|
+
}));
|
|
46
|
+
|
|
47
|
+
if (appTemplateInstance.compileAndSave){
|
|
48
|
+
appTemplateInstance.save();
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
},
|
|
52
|
+
_new_:function (){
|
|
53
|
+
|
|
54
|
+
var appTemplateInstance = this;
|
|
55
|
+
const absolutePath = path.resolve( __dirname, "./" );
|
|
56
|
+
|
|
57
|
+
fs.readFile(absolutePath+"/"+appTemplateInstance.templateURI, function(err, data) {
|
|
58
|
+
appTemplateInstance.template = data.toString();
|
|
59
|
+
appTemplateInstance.done.call(appTemplateInstance);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
logger.info("App Template Manager Initialized");
|
|
63
|
+
}
|
|
64
|
+
})
|
|
65
|
+
]);
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* QCObjects Framework
|
|
3
|
+
* ____________________________________
|
|
4
|
+
*
|
|
5
|
+
* Author: Jean Machuca <correojean@gmail.com>
|
|
6
|
+
*
|
|
7
|
+
* Cross Browser Javascript Framework for MVC Patterns
|
|
8
|
+
* QuickCorp/QCObjects is licensed under the
|
|
9
|
+
* GNU Lesser General Public License v3.0
|
|
10
|
+
* [LICENSE] (https://github.com/QuickCorp/QCObjects/blob/master/LICENSE.txt)
|
|
11
|
+
*
|
|
12
|
+
* Permissions of this copyleft license are conditioned on making available
|
|
13
|
+
* complete source code of licensed works and modifications under the same
|
|
14
|
+
* license or the GNU GPLv3. Copyright and license notices must be preserved.
|
|
15
|
+
* Contributors provide an express grant of patent rights. However, a larger
|
|
16
|
+
* work using the licensed work through interfaces provided by the licensed
|
|
17
|
+
* work may be distributed under different terms and without source code for
|
|
18
|
+
* the larger work.
|
|
19
|
+
*
|
|
20
|
+
* Copyright (C) 2015 Jean Machuca,<correojean@gmail.com>
|
|
21
|
+
*
|
|
22
|
+
* Everyone is permitted to copy and distribute verbatim copies of this
|
|
23
|
+
* license document, but changing it is not allowed.
|
|
24
|
+
*/
|
|
25
|
+
"use strict";
|
|
26
|
+
// eslint-disable-next-line no-undef
|
|
27
|
+
|
|
28
|
+
/* eslint-disable no-undef */
|
|
29
|
+
// This is the service worker with the combined offline experience (Offline page + Offline copy of pages)
|
|
30
|
+
|
|
31
|
+
const CACHE = "{{appName}}-offline-page";
|
|
32
|
+
|
|
33
|
+
importScripts("https://storage.googleapis.com/workbox-cdn/releases/5.1.2/workbox-sw.js");
|
|
34
|
+
|
|
35
|
+
const offlineFallbackPage = "index-fallback.html";
|
|
36
|
+
|
|
37
|
+
self.addEventListener("message", (event) => {
|
|
38
|
+
if (event.data && event.data.type === "SKIP_WAITING") {
|
|
39
|
+
self.skipWaiting();
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
self.addEventListener("install", async (event) => {
|
|
44
|
+
event.waitUntil(
|
|
45
|
+
caches.open(CACHE)
|
|
46
|
+
.then((cache) => cache.add(offlineFallbackPage))
|
|
47
|
+
);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
if (workbox.navigationPreload.isSupported()) {
|
|
51
|
+
workbox.navigationPreload.enable();
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
workbox.routing.registerRoute(
|
|
55
|
+
// eslint-disable-next-line prefer-regex-literals
|
|
56
|
+
new RegExp("/*"),
|
|
57
|
+
new workbox.strategies.StaleWhileRevalidate({
|
|
58
|
+
cacheName: CACHE
|
|
59
|
+
})
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
self.addEventListener("fetch", (event) => {
|
|
63
|
+
if (event.request.mode === "navigate") {
|
|
64
|
+
event.respondWith((async () => {
|
|
65
|
+
try {
|
|
66
|
+
const preloadResp = await event.preloadResponse;
|
|
67
|
+
|
|
68
|
+
if (preloadResp) {
|
|
69
|
+
return preloadResp;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const networkResp = await fetch(event.request);
|
|
73
|
+
return networkResp;
|
|
74
|
+
} catch (error) {
|
|
75
|
+
|
|
76
|
+
const cache = await caches.open(CACHE);
|
|
77
|
+
const cachedResp = await cache.match(offlineFallbackPage);
|
|
78
|
+
return cachedResp;
|
|
79
|
+
}
|
|
80
|
+
})());
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
const version = "{{appVersion}}";
|
|
86
|
+
const appName = "{{appName}}";
|
|
87
|
+
const cacheSufix = (Math.round(Date.now()/(1000*3600))).toString(); // 1 hour
|
|
88
|
+
const cacheName = `qcobjects-app-${appName}-${version}-${cacheSufix}`;
|
|
89
|
+
const startUrl = "/?homescreen=1";
|
|
90
|
+
caches.delete(cacheName); // force to reload cache for the first time the sw is loaded
|
|
91
|
+
self.addEventListener("install", e => {
|
|
92
|
+
e.waitUntil(
|
|
93
|
+
caches.open(cacheName).then(cache => {
|
|
94
|
+
return cache.addAll([`${startUrl}`,{{filelist}}])
|
|
95
|
+
.then(() => self.skipWaiting());
|
|
96
|
+
})
|
|
97
|
+
);
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
self.addEventListener("activate", event => {
|
|
101
|
+
event.waitUntil(self.clients.claim());
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
self.addEventListener("fetch", event => {
|
|
105
|
+
event.respondWith(
|
|
106
|
+
caches.open(cacheName)
|
|
107
|
+
.then(cache => cache.match(event.request, { ignoreSearch: true }))
|
|
108
|
+
.then(response => {
|
|
109
|
+
return response || fetch(event.request);
|
|
110
|
+
})
|
|
111
|
+
);
|
|
112
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html class="no-js" lang="en">
|
|
3
|
+
|
|
4
|
+
<head>
|
|
5
|
+
<meta charset="utf-8" />
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
|
+
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width" />
|
|
8
|
+
<!-- This is a wide open CSP declaration. To lock this down for production, see below. -->
|
|
9
|
+
<meta http-equiv="Content-Security-Policy" content="default-src * 'self' 'unsafe-inline' 'unsafe-eval' data: gap: https://ssl.gstatic.com; img-src * 'self' data:; child-src *; style-src * 'self' 'unsafe-inline' 'unsafe-eval'; script-src * 'self' 'unsafe-inline' 'unsafe-eval'; connect-src * 'self' 'unsafe-inline' 'unsafe-eval';media-src *">
|
|
10
|
+
<title>{{title}}</title>
|
|
11
|
+
<script type="text/javascript" src="./node_modules/qcobjects/QCObjects.js"></script>
|
|
12
|
+
</head>
|
|
13
|
+
|
|
14
|
+
<body>
|
|
15
|
+
|
|
16
|
+
<component name="main">
|
|
17
|
+
<routing path="/" name="main" />
|
|
18
|
+
<routing path="#" name="main" />
|
|
19
|
+
<routing path="" name="main" />
|
|
20
|
+
<routing path="page1" name="page1" />
|
|
21
|
+
<routing path="page2" name="page2" />
|
|
22
|
+
</component>
|
|
23
|
+
|
|
24
|
+
<script type="text/javascript" src="js/init.js"></script>
|
|
25
|
+
|
|
26
|
+
</body>
|
|
27
|
+
|
|
28
|
+
</html>
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const path = require("path");
|
|
3
|
+
const absolutePath = path.resolve( __dirname, "./" );
|
|
4
|
+
|
|
5
|
+
const http2 = require("http2");
|
|
6
|
+
const fs = require("fs");
|
|
7
|
+
const mime = require("mime");
|
|
8
|
+
|
|
9
|
+
Import("org.quickcorp.qcobjects.main.file");
|
|
10
|
+
|
|
11
|
+
Package("org.quickcorp.cli.templates.app.spa_local",[
|
|
12
|
+
Class("AppTemplate",{
|
|
13
|
+
name:"app/index.html",
|
|
14
|
+
template:"",
|
|
15
|
+
templateURI:"spa-local.html",
|
|
16
|
+
body:"",
|
|
17
|
+
compileAndSave:false,
|
|
18
|
+
save:function (){
|
|
19
|
+
var appTemplateInstance = this;
|
|
20
|
+
fs.mkdir("app/",()=>{
|
|
21
|
+
fs.writeFile(appTemplateInstance.name, appTemplateInstance.body, err => {
|
|
22
|
+
if (err) {
|
|
23
|
+
return console.error(`Autsch! Failed to store template: ${err.message}.`);
|
|
24
|
+
}
|
|
25
|
+
logger.info("Saved template!");
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
},
|
|
29
|
+
done:function (){
|
|
30
|
+
var appTemplateInstance = this;
|
|
31
|
+
const source = appTemplateInstance.template;
|
|
32
|
+
|
|
33
|
+
(New(Component, {
|
|
34
|
+
name: "static_source",
|
|
35
|
+
template: source,
|
|
36
|
+
cached:false,
|
|
37
|
+
tplsource: "inline",
|
|
38
|
+
data: {
|
|
39
|
+
title: "QCObjects"
|
|
40
|
+
},
|
|
41
|
+
done ({request, component}) {
|
|
42
|
+
appTemplateInstance.body = component.parsedAssignmentText;
|
|
43
|
+
return Promise.resolve({request, component});
|
|
44
|
+
}
|
|
45
|
+
}));
|
|
46
|
+
|
|
47
|
+
if (appTemplateInstance.compileAndSave){
|
|
48
|
+
appTemplateInstance.save();
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
},
|
|
52
|
+
_new_:function (){
|
|
53
|
+
|
|
54
|
+
var appTemplateInstance = this;
|
|
55
|
+
const absolutePath = path.resolve( __dirname, "./" );
|
|
56
|
+
|
|
57
|
+
fs.readFile(absolutePath+"/"+appTemplateInstance.templateURI, function(err, data) {
|
|
58
|
+
appTemplateInstance.template = data.toString();
|
|
59
|
+
appTemplateInstance.done.call(appTemplateInstance);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
logger.info("App Template Manager Initialized");
|
|
63
|
+
}
|
|
64
|
+
})
|
|
65
|
+
]);
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* QCObjects Framework
|
|
3
|
+
* ____________________________________
|
|
4
|
+
*
|
|
5
|
+
* Author: Jean Machuca <correojean@gmail.com>
|
|
6
|
+
*
|
|
7
|
+
* Cross Browser Javascript Framework for MVC Patterns
|
|
8
|
+
* QuickCorp/QCObjects is licensed under the
|
|
9
|
+
* GNU Lesser General Public License v3.0
|
|
10
|
+
* [LICENSE] (https://github.com/QuickCorp/QCObjects/blob/master/LICENSE.txt)
|
|
11
|
+
*
|
|
12
|
+
* Permissions of this copyleft license are conditioned on making available
|
|
13
|
+
* complete source code of licensed works and modifications under the same
|
|
14
|
+
* license or the GNU GPLv3. Copyright and license notices must be preserved.
|
|
15
|
+
* Contributors provide an express grant of patent rights. However, a larger
|
|
16
|
+
* work using the licensed work through interfaces provided by the licensed
|
|
17
|
+
* work may be distributed under different terms and without source code for
|
|
18
|
+
* the larger work.
|
|
19
|
+
*
|
|
20
|
+
* Copyright (C) 2015 Jean Machuca,<correojean@gmail.com>
|
|
21
|
+
*
|
|
22
|
+
* Everyone is permitted to copy and distribute verbatim copies of this
|
|
23
|
+
* license document, but changing it is not allowed.
|
|
24
|
+
*/
|
|
25
|
+
"use strict";
|
|
26
|
+
// eslint-disable-next-line no-undef
|
|
27
|
+
|
|
28
|
+
/* eslint-disable no-undef */
|
|
29
|
+
// This is the service worker with the combined offline experience (Offline page + Offline copy of pages)
|
|
30
|
+
|
|
31
|
+
const CACHE = "{{appName}}-offline-page";
|
|
32
|
+
|
|
33
|
+
importScripts("https://storage.googleapis.com/workbox-cdn/releases/5.1.2/workbox-sw.js");
|
|
34
|
+
|
|
35
|
+
const offlineFallbackPage = "index-fallback.html";
|
|
36
|
+
|
|
37
|
+
self.addEventListener("message", (event) => {
|
|
38
|
+
if (event.data && event.data.type === "SKIP_WAITING") {
|
|
39
|
+
self.skipWaiting();
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
self.addEventListener("install", async (event) => {
|
|
44
|
+
event.waitUntil(
|
|
45
|
+
caches.open(CACHE)
|
|
46
|
+
.then((cache) => cache.add(offlineFallbackPage))
|
|
47
|
+
);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
if (workbox.navigationPreload.isSupported()) {
|
|
51
|
+
workbox.navigationPreload.enable();
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
workbox.routing.registerRoute(
|
|
55
|
+
// eslint-disable-next-line prefer-regex-literals
|
|
56
|
+
new RegExp("/*"),
|
|
57
|
+
new workbox.strategies.StaleWhileRevalidate({
|
|
58
|
+
cacheName: CACHE
|
|
59
|
+
})
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
self.addEventListener("fetch", (event) => {
|
|
63
|
+
if (event.request.mode === "navigate") {
|
|
64
|
+
event.respondWith((async () => {
|
|
65
|
+
try {
|
|
66
|
+
const preloadResp = await event.preloadResponse;
|
|
67
|
+
|
|
68
|
+
if (preloadResp) {
|
|
69
|
+
return preloadResp;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const networkResp = await fetch(event.request);
|
|
73
|
+
return networkResp;
|
|
74
|
+
} catch (error) {
|
|
75
|
+
|
|
76
|
+
const cache = await caches.open(CACHE);
|
|
77
|
+
const cachedResp = await cache.match(offlineFallbackPage);
|
|
78
|
+
return cachedResp;
|
|
79
|
+
}
|
|
80
|
+
})());
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
const version = "{{appVersion}}";
|
|
86
|
+
const appName = "{{appName}}";
|
|
87
|
+
const cacheSufix = (Math.round(Date.now()/(1000*3600))).toString(); // 1 hour
|
|
88
|
+
const cacheName = `qcobjects-app-${appName}-${version}-${cacheSufix}`;
|
|
89
|
+
const startUrl = "/?homescreen=1";
|
|
90
|
+
caches.delete(cacheName); // force to reload cache for the first time the sw is loaded
|
|
91
|
+
self.addEventListener("install", e => {
|
|
92
|
+
e.waitUntil(
|
|
93
|
+
caches.open(cacheName).then(cache => {
|
|
94
|
+
return cache.addAll([`${startUrl}`,{{filelist}}])
|
|
95
|
+
.then(() => self.skipWaiting());
|
|
96
|
+
})
|
|
97
|
+
);
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
self.addEventListener("activate", event => {
|
|
101
|
+
event.waitUntil(self.clients.claim());
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
self.addEventListener("fetch", event => {
|
|
105
|
+
event.respondWith(
|
|
106
|
+
caches.open(cacheName)
|
|
107
|
+
.then(cache => cache.match(event.request, { ignoreSearch: true }))
|
|
108
|
+
.then(response => {
|
|
109
|
+
return response || fetch(event.request);
|
|
110
|
+
})
|
|
111
|
+
);
|
|
112
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html class="no-js" lang="en">
|
|
3
|
+
|
|
4
|
+
<head>
|
|
5
|
+
<meta charset="utf-8" />
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
|
+
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width" />
|
|
8
|
+
<!-- This is a wide open CSP declaration. To lock this down for production, see below. -->
|
|
9
|
+
<meta http-equiv="Content-Security-Policy" content="default-src * 'self' 'unsafe-inline' 'unsafe-eval' data: gap: https://ssl.gstatic.com; img-src * 'self' data:; child-src *; style-src * 'self' 'unsafe-inline' 'unsafe-eval'; script-src * 'self' 'unsafe-inline' 'unsafe-eval'; connect-src * 'self' 'unsafe-inline' 'unsafe-eval';media-src *">
|
|
10
|
+
<title>{{title}}</title>
|
|
11
|
+
<script type="text/javascript" src="./node_modules/qcobjects/QCObjects.js"></script>
|
|
12
|
+
</head>
|
|
13
|
+
|
|
14
|
+
<body>
|
|
15
|
+
|
|
16
|
+
<component name="main">
|
|
17
|
+
<routing path="/" name="main" />
|
|
18
|
+
<routing path="#" name="main" />
|
|
19
|
+
<routing path="" name="main" />
|
|
20
|
+
<routing path="page1" name="page1" />
|
|
21
|
+
<routing path="page2" name="page2" />
|
|
22
|
+
</component>
|
|
23
|
+
|
|
24
|
+
<script type="text/javascript" src="js/init.js"></script>
|
|
25
|
+
|
|
26
|
+
</body>
|
|
27
|
+
|
|
28
|
+
</html>
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const path = require("path");
|
|
3
|
+
const absolutePath = path.resolve( __dirname, "./" );
|
|
4
|
+
|
|
5
|
+
const http2 = require("http2");
|
|
6
|
+
const fs = require("fs");
|
|
7
|
+
const mime = require("mime");
|
|
8
|
+
|
|
9
|
+
Import("org.quickcorp.qcobjects.main.file");
|
|
10
|
+
|
|
11
|
+
Package("org.quickcorp.cli.templates.app.spa_local",[
|
|
12
|
+
Class("AppTemplate",{
|
|
13
|
+
name:"app/index.html",
|
|
14
|
+
template:"",
|
|
15
|
+
templateURI:"spa-local.html",
|
|
16
|
+
body:"",
|
|
17
|
+
compileAndSave:false,
|
|
18
|
+
save:function (){
|
|
19
|
+
var appTemplateInstance = this;
|
|
20
|
+
fs.mkdir("app/",()=>{
|
|
21
|
+
fs.writeFile(appTemplateInstance.name, appTemplateInstance.body, err => {
|
|
22
|
+
if (err) {
|
|
23
|
+
return console.error(`Autsch! Failed to store template: ${err.message}.`);
|
|
24
|
+
}
|
|
25
|
+
logger.info("Saved template!");
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
},
|
|
29
|
+
done:function (){
|
|
30
|
+
var appTemplateInstance = this;
|
|
31
|
+
const source = appTemplateInstance.template;
|
|
32
|
+
|
|
33
|
+
(New(Component, {
|
|
34
|
+
name: "static_source",
|
|
35
|
+
template: source,
|
|
36
|
+
cached:false,
|
|
37
|
+
tplsource: "inline",
|
|
38
|
+
data: {
|
|
39
|
+
title: "QCObjects"
|
|
40
|
+
},
|
|
41
|
+
done ({request, component}) {
|
|
42
|
+
appTemplateInstance.body = component.parsedAssignmentText;
|
|
43
|
+
return Promise.resolve({request, component});
|
|
44
|
+
}
|
|
45
|
+
}));
|
|
46
|
+
|
|
47
|
+
if (appTemplateInstance.compileAndSave){
|
|
48
|
+
appTemplateInstance.save();
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
},
|
|
52
|
+
_new_:function (){
|
|
53
|
+
|
|
54
|
+
var appTemplateInstance = this;
|
|
55
|
+
const absolutePath = path.resolve( __dirname, "./" );
|
|
56
|
+
|
|
57
|
+
fs.readFile(absolutePath+"/"+appTemplateInstance.templateURI, function(err, data) {
|
|
58
|
+
appTemplateInstance.template = data.toString();
|
|
59
|
+
appTemplateInstance.done.call(appTemplateInstance);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
logger.info("App Template Manager Initialized");
|
|
63
|
+
}
|
|
64
|
+
})
|
|
65
|
+
]);
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* QCObjects Framework
|
|
3
|
+
* ____________________________________
|
|
4
|
+
*
|
|
5
|
+
* Author: Jean Machuca <correojean@gmail.com>
|
|
6
|
+
*
|
|
7
|
+
* Cross Browser Javascript Framework for MVC Patterns
|
|
8
|
+
* QuickCorp/QCObjects is licensed under the
|
|
9
|
+
* GNU Lesser General Public License v3.0
|
|
10
|
+
* [LICENSE] (https://github.com/QuickCorp/QCObjects/blob/master/LICENSE.txt)
|
|
11
|
+
*
|
|
12
|
+
* Permissions of this copyleft license are conditioned on making available
|
|
13
|
+
* complete source code of licensed works and modifications under the same
|
|
14
|
+
* license or the GNU GPLv3. Copyright and license notices must be preserved.
|
|
15
|
+
* Contributors provide an express grant of patent rights. However, a larger
|
|
16
|
+
* work using the licensed work through interfaces provided by the licensed
|
|
17
|
+
* work may be distributed under different terms and without source code for
|
|
18
|
+
* the larger work.
|
|
19
|
+
*
|
|
20
|
+
* Copyright (C) 2015 Jean Machuca,<correojean@gmail.com>
|
|
21
|
+
*
|
|
22
|
+
* Everyone is permitted to copy and distribute verbatim copies of this
|
|
23
|
+
* license document, but changing it is not allowed.
|
|
24
|
+
*/
|
|
25
|
+
"use strict";
|
|
26
|
+
// eslint-disable-next-line no-undef
|
|
27
|
+
|
|
28
|
+
/* eslint-disable no-undef */
|
|
29
|
+
// This is the service worker with the combined offline experience (Offline page + Offline copy of pages)
|
|
30
|
+
|
|
31
|
+
const CACHE = "{{appName}}-offline-page";
|
|
32
|
+
|
|
33
|
+
importScripts("https://storage.googleapis.com/workbox-cdn/releases/5.1.2/workbox-sw.js");
|
|
34
|
+
|
|
35
|
+
const offlineFallbackPage = "index-fallback.html";
|
|
36
|
+
|
|
37
|
+
self.addEventListener("message", (event) => {
|
|
38
|
+
if (event.data && event.data.type === "SKIP_WAITING") {
|
|
39
|
+
self.skipWaiting();
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
self.addEventListener("install", async (event) => {
|
|
44
|
+
event.waitUntil(
|
|
45
|
+
caches.open(CACHE)
|
|
46
|
+
.then((cache) => cache.add(offlineFallbackPage))
|
|
47
|
+
);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
if (workbox.navigationPreload.isSupported()) {
|
|
51
|
+
workbox.navigationPreload.enable();
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
workbox.routing.registerRoute(
|
|
55
|
+
// eslint-disable-next-line prefer-regex-literals
|
|
56
|
+
new RegExp("/*"),
|
|
57
|
+
new workbox.strategies.StaleWhileRevalidate({
|
|
58
|
+
cacheName: CACHE
|
|
59
|
+
})
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
self.addEventListener("fetch", (event) => {
|
|
63
|
+
if (event.request.mode === "navigate") {
|
|
64
|
+
event.respondWith((async () => {
|
|
65
|
+
try {
|
|
66
|
+
const preloadResp = await event.preloadResponse;
|
|
67
|
+
|
|
68
|
+
if (preloadResp) {
|
|
69
|
+
return preloadResp;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const networkResp = await fetch(event.request);
|
|
73
|
+
return networkResp;
|
|
74
|
+
} catch (error) {
|
|
75
|
+
|
|
76
|
+
const cache = await caches.open(CACHE);
|
|
77
|
+
const cachedResp = await cache.match(offlineFallbackPage);
|
|
78
|
+
return cachedResp;
|
|
79
|
+
}
|
|
80
|
+
})());
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
const version = "{{appVersion}}";
|
|
86
|
+
const appName = "{{appName}}";
|
|
87
|
+
const cacheSufix = (Math.round(Date.now()/(1000*3600))).toString(); // 1 hour
|
|
88
|
+
const cacheName = `qcobjects-app-${appName}-${version}-${cacheSufix}`;
|
|
89
|
+
const startUrl = "/?homescreen=1";
|
|
90
|
+
caches.delete(cacheName); // force to reload cache for the first time the sw is loaded
|
|
91
|
+
self.addEventListener("install", e => {
|
|
92
|
+
e.waitUntil(
|
|
93
|
+
caches.open(cacheName).then(cache => {
|
|
94
|
+
return cache.addAll([`${startUrl}`,{{filelist}}])
|
|
95
|
+
.then(() => self.skipWaiting());
|
|
96
|
+
})
|
|
97
|
+
);
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
self.addEventListener("activate", event => {
|
|
101
|
+
event.waitUntil(self.clients.claim());
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
self.addEventListener("fetch", event => {
|
|
105
|
+
event.respondWith(
|
|
106
|
+
caches.open(cacheName)
|
|
107
|
+
.then(cache => cache.match(event.request, { ignoreSearch: true }))
|
|
108
|
+
.then(response => {
|
|
109
|
+
return response || fetch(event.request);
|
|
110
|
+
})
|
|
111
|
+
);
|
|
112
|
+
});
|