qcobjects-cli 2.5.104-beta → 2.5.106-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.
Files changed (31) hide show
  1. package/VERSION +1 -1
  2. package/build-esbuild.js +64 -12
  3. package/package.json +1 -1
  4. package/public/browser/index.js +2 -1
  5. package/public/browser/index.js.map +2 -2
  6. package/public/browser/org.quickcorp.qcobjects.cli.js +2 -1
  7. package/public/browser/org.quickcorp.qcobjects.cli.js.map +2 -2
  8. package/public/browser/qcobjects-cli.js +2 -1
  9. package/public/browser/qcobjects-cli.js.map +2 -2
  10. package/public/browser/templates/apps/spa-local.html +28 -0
  11. package/public/browser/templates/apps/spa-local.js +65 -0
  12. package/public/browser/templates/pwa/sw.js +112 -0
  13. package/public/cjs/index.cjs +2 -1
  14. package/public/cjs/index.cjs.map +2 -2
  15. package/public/cjs/org.quickcorp.qcobjects.cli.cjs +2 -1
  16. package/public/cjs/org.quickcorp.qcobjects.cli.cjs.map +2 -2
  17. package/public/cjs/qcobjects-cli.cjs +2 -1
  18. package/public/cjs/qcobjects-cli.cjs.map +2 -2
  19. package/public/cjs/templates/apps/spa-local.html +28 -0
  20. package/public/cjs/templates/apps/spa-local.js +65 -0
  21. package/public/cjs/templates/pwa/sw.js +112 -0
  22. package/public/esm/index.mjs +2 -1
  23. package/public/esm/index.mjs.map +2 -2
  24. package/public/esm/org.quickcorp.qcobjects.cli.mjs +2 -1
  25. package/public/esm/org.quickcorp.qcobjects.cli.mjs.map +2 -2
  26. package/public/esm/qcobjects-cli.mjs +2 -1
  27. package/public/esm/qcobjects-cli.mjs.map +2 -2
  28. package/public/esm/templates/apps/spa-local.html +28 -0
  29. package/public/esm/templates/apps/spa-local.js +65 -0
  30. package/public/esm/templates/pwa/sw.js +112 -0
  31. package/src/org.quickcorp.qcobjects.cli.ts +2 -1
@@ -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
+ });
@@ -3859,7 +3859,7 @@ var SwitchCommander = class extends InheritClass4 {
3859
3859
  }
3860
3860
  generateServiceWorker(appName, dirPrefix = "./") {
3861
3861
  const writeContent = /* @__PURE__ */ __name((component) => {
3862
- const parsedText = component.parseTemplate(component.template);
3862
+ const parsedText = component.parsedAssignmentText;
3863
3863
  logger7.debug("Starting to write the sw file...");
3864
3864
  fs2.writeFile(`${dirPrefix}/sw.js`, parsedText, (err) => {
3865
3865
  if (err) {
@@ -3889,6 +3889,7 @@ var SwitchCommander = class extends InheritClass4 {
3889
3889
  template = "";
3890
3890
  constructor({ name, data }) {
3891
3891
  super({ name, data });
3892
+ this.data = data;
3892
3893
  }
3893
3894
  done({ request, component }) {
3894
3895
  super.done({ request, component });