@karpeleslab/klbfw 0.1.10 → 0.1.11

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 Karpelès Lab Inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,95 @@
1
+ # klbfw
2
+
3
+ Karpeles Lab framework lib
4
+
5
+ This lib is used on frontend sites to communicate through the KLB API.
6
+
7
+ # API
8
+
9
+ ## rest(api, method, params, context)
10
+
11
+ Performs a rest query and returns a promise to the response.
12
+
13
+ ## upload.init(api, params, context)
14
+
15
+ Perform an upload. This API will show a file selector and allow the user to select one or more files.
16
+
17
+ ## getPrefix()
18
+
19
+ Returns the language/etc prefix part of the URL, for example `/l/en-US`. The prefix should be inserted before the path in the URL.
20
+
21
+ ## getSettings()
22
+
23
+ Returns active settings if any.
24
+
25
+ ## getRealm()
26
+
27
+ Returns realm information.
28
+
29
+ ## getContext()
30
+
31
+ Returns current context.
32
+
33
+ ## setContext(ctx)
34
+
35
+ Modifies the current context.
36
+
37
+ ## getMode()
38
+
39
+ Returns the current rending mode `ssr`, `js` etc.
40
+
41
+ ## getHostname()
42
+
43
+ Returns the hostname part of the current URL.
44
+
45
+ ## getRegistry()
46
+
47
+ Returns data from the registry.
48
+
49
+ ## getLocale()
50
+
51
+ Returns the currently active locale, for example `en-US`.
52
+
53
+ ## getUserGroup()
54
+
55
+ Returns `g` from context, which is the current active user group.
56
+
57
+ ## getCurrency()
58
+
59
+ Returns the currently selected currency, such as `USD`.
60
+
61
+ ## getToken()
62
+
63
+ Returns the CSRF token.
64
+
65
+ ## getUrl()
66
+
67
+ Returns the active URL.
68
+
69
+ ## getPath()
70
+
71
+ Returns the non-prefixed request path.
72
+
73
+ ## getUuid()
74
+
75
+ Returns the UUID of the request.
76
+
77
+ ## getInitialState()
78
+
79
+ Returns the initial state passed from SSR execution (or null if no SSR was performed).
80
+
81
+ # Cookie functions
82
+
83
+ Those methods are a requirement as using things like `document.cookie` will not work in SSR mode. The methods described here will work when SSR is enabled, and will cause cookies to be added to the HTTP response.
84
+
85
+ ## getCookie(cookie)
86
+
87
+ Get the value of a specific cookie.
88
+
89
+ ## setCookie(cookie, value)
90
+
91
+ Sets value for a cookie.
92
+
93
+ ## hasCookie(cookie)
94
+
95
+ Checks for presence of a given cookie.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@karpeleslab/klbfw",
3
- "version": "0.1.10",
3
+ "version": "0.1.11",
4
4
  "description": "Frontend Framework",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/upload.js CHANGED
@@ -100,7 +100,7 @@ module.exports.upload = (function () {
100
100
 
101
101
 
102
102
  function sendprogress() {
103
- if (upload.onprogress == undefined) return;
103
+ if (typeof upload.onprogress === "undefined") return;
104
104
 
105
105
  upload.onprogress(upload.getStatus());
106
106
  }
@@ -162,9 +162,9 @@ module.exports.upload = (function () {
162
162
  return;
163
163
  }
164
164
  // invalid data
165
- up.reject();
166
165
  delete upload_running[up.up_id];
167
166
  upload_failed.push(up);
167
+ up.reject();
168
168
  return;
169
169
  })
170
170
  .catch(res => failure(up, res));
@@ -265,10 +265,10 @@ module.exports.upload = (function () {
265
265
  up["done"] = d;
266
266
 
267
267
  if (p == 0) {
268
+ up["status"] = "validating";
268
269
  switch(up.method) {
269
270
  case 'aws':
270
271
  // complete, see https://docs.aws.amazon.com/AmazonS3/latest/API/mpUploadComplete.html
271
- up["status"] = "validating";
272
272
  var xml = "<CompleteMultipartUpload>";
273
273
  for (var i = 0; i < up.blocks; i++) {
274
274
  xml += "<Part><PartNumber>" + (i + 1) + "</PartNumber><ETag>" + up.b[i] + "</ETag></Part>";
@@ -296,8 +296,8 @@ module.exports.upload = (function () {
296
296
  up["status"] = "complete";
297
297
  up["final"] = ares["data"];
298
298
  sendprogress();
299
- up.resolve(up);
300
299
  delete upload_running[up.up_id];
300
+ up.resolve(up);
301
301
  upload.run();
302
302
  }).catch(res => failure(up, res));
303
303
  break;