@expressms/smartapp-sdk 1.2.9 → 1.4.0-alpha
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/README.md +82 -52
- package/build/main/index.d.ts +2 -2
- package/build/main/index.js +6 -2
- package/build/main/lib/client/events.d.ts +20 -0
- package/build/main/lib/client/events.js +78 -0
- package/build/main/lib/client/index.d.ts +18 -2
- package/build/main/lib/client/index.js +47 -2
- package/build/main/lib/logging/index.js +5 -2
- package/build/main/types/bridge.d.ts +14 -2
- package/build/main/types/bridge.js +16 -2
- package/build/main/types/client.d.ts +19 -0
- package/build/main/types/client.js +8 -0
- package/build/main/types/index.d.ts +2 -0
- package/build/main/types/index.js +3 -1
- package/build/module/index.d.ts +2 -2
- package/build/module/index.js +3 -3
- package/build/module/lib/client/events.d.ts +20 -0
- package/build/module/lib/client/events.js +71 -0
- package/build/module/lib/client/index.d.ts +18 -2
- package/build/module/lib/client/index.js +32 -3
- package/build/module/lib/logging/index.js +5 -2
- package/build/module/types/bridge.d.ts +14 -2
- package/build/module/types/bridge.js +15 -1
- package/build/module/types/client.d.ts +19 -0
- package/build/module/types/client.js +5 -0
- package/build/module/types/index.d.ts +2 -0
- package/build/module/types/index.js +3 -1
- package/build/umd/index.js +215 -145
- package/package.json +13 -21
- package/workers/workbox.js +0 -80
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@expressms/smartapp-sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0-alpha",
|
|
4
4
|
"description": "Smartapp SDK",
|
|
5
5
|
"main": "build/main/index.js",
|
|
6
6
|
"typings": "build/main/index.d.ts",
|
|
@@ -25,27 +25,20 @@
|
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@rollup/plugin-commonjs": "^17.1.0",
|
|
27
27
|
"@rollup/plugin-json": "^4.1.0",
|
|
28
|
-
"@rollup/plugin-node-resolve": "^13.
|
|
29
|
-
"@typescript-eslint/eslint-plugin": "^4.0
|
|
30
|
-
"@typescript-eslint/parser": "^4.0
|
|
31
|
-
"eslint": "^7.
|
|
32
|
-
"eslint-config-prettier": "^8.
|
|
28
|
+
"@rollup/plugin-node-resolve": "^13.3.0",
|
|
29
|
+
"@typescript-eslint/eslint-plugin": "^4.33.0",
|
|
30
|
+
"@typescript-eslint/parser": "^4.33.0",
|
|
31
|
+
"eslint": "^7.32.0",
|
|
32
|
+
"eslint-config-prettier": "^8.10.0",
|
|
33
33
|
"eslint-plugin-eslint-comments": "^3.2.0",
|
|
34
|
-
"eslint-plugin-import": "^2.
|
|
35
|
-
"prettier": "^2.
|
|
36
|
-
"rollup": "^2.
|
|
37
|
-
"tslib": "^2.
|
|
38
|
-
"typescript": "^4.
|
|
34
|
+
"eslint-plugin-import": "^2.29.0",
|
|
35
|
+
"prettier": "^2.8.8",
|
|
36
|
+
"rollup": "^2.79.1",
|
|
37
|
+
"tslib": "^2.6.2",
|
|
38
|
+
"typescript": "^4.9.5"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@expressms/smartapp-bridge": "
|
|
42
|
-
"webpack-manifest-plugin": "2.2.0",
|
|
43
|
-
"workbox-cacheable-response": "^6.5.4",
|
|
44
|
-
"workbox-expiration": "^6.5.4",
|
|
45
|
-
"workbox-precaching": "^6.5.4",
|
|
46
|
-
"workbox-routing": "^6.5.4",
|
|
47
|
-
"workbox-strategies": "^6.5.4",
|
|
48
|
-
"workbox-webpack-plugin": "^5.1.4"
|
|
41
|
+
"@expressms/smartapp-bridge": "1.2.3"
|
|
49
42
|
},
|
|
50
43
|
"files": [
|
|
51
44
|
"build/main",
|
|
@@ -54,7 +47,6 @@
|
|
|
54
47
|
".npmrc",
|
|
55
48
|
"README.md",
|
|
56
49
|
"!**/*.spec.*",
|
|
57
|
-
"!**/*.json"
|
|
58
|
-
"workers/workbox.js"
|
|
50
|
+
"!**/*.json"
|
|
59
51
|
]
|
|
60
52
|
}
|
package/workers/workbox.js
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import { CacheableResponsePlugin } from 'workbox-cacheable-response/CacheableResponsePlugin'
|
|
2
|
-
import { ExpirationPlugin } from 'workbox-expiration/ExpirationPlugin'
|
|
3
|
-
import { precacheAndRoute } from 'workbox-precaching'
|
|
4
|
-
import { registerRoute } from 'workbox-routing/registerRoute'
|
|
5
|
-
import { CacheFirst } from 'workbox-strategies/CacheFirst'
|
|
6
|
-
|
|
7
|
-
// need for uniq cache of each smart app
|
|
8
|
-
const LOCATION_HREF = self.location.href
|
|
9
|
-
const CACHE_NAME = `cache_smart_app_${LOCATION_HREF}`
|
|
10
|
-
const INDEX_URL = './index.html'
|
|
11
|
-
|
|
12
|
-
const isIndexPage = (url) => url.match(/\/index\.html/)
|
|
13
|
-
|
|
14
|
-
precacheAndRoute(self.__WB_MANIFEST)
|
|
15
|
-
|
|
16
|
-
registerRoute(
|
|
17
|
-
({ url }) => !isIndexPage(url.pathname),
|
|
18
|
-
new CacheFirst({
|
|
19
|
-
cacheName: `workbox_smart_app_${LOCATION_HREF}`,
|
|
20
|
-
plugins: [
|
|
21
|
-
new ExpirationPlugin({
|
|
22
|
-
maxAgeSeconds: 60 * 60 * 24 * 3, // 3 days
|
|
23
|
-
}),
|
|
24
|
-
new CacheableResponsePlugin({
|
|
25
|
-
statuses: [0, 200],
|
|
26
|
-
}),
|
|
27
|
-
],
|
|
28
|
-
}),
|
|
29
|
-
)
|
|
30
|
-
|
|
31
|
-
self.addEventListener('activate', (event) => {
|
|
32
|
-
// make claim for first load page fetch listening
|
|
33
|
-
event.waitUntil(self.clients.claim())
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
self.addEventListener('fetch', event => {
|
|
38
|
-
if (!isIndexPage(event.request.url)) return
|
|
39
|
-
// handle url request
|
|
40
|
-
event.respondWith(
|
|
41
|
-
// Open the cache
|
|
42
|
-
caches.open(CACHE_NAME)
|
|
43
|
-
.then(cache => {
|
|
44
|
-
// Go to the network first
|
|
45
|
-
return fetch(event.request)
|
|
46
|
-
.then(fetchedResponse => {
|
|
47
|
-
// cache index response
|
|
48
|
-
cache.put(INDEX_URL, fetchedResponse.clone())
|
|
49
|
-
return fetchedResponse
|
|
50
|
-
})
|
|
51
|
-
.catch(() => {
|
|
52
|
-
// If the network is unavailable, get
|
|
53
|
-
return cache.match(INDEX_URL)
|
|
54
|
-
})
|
|
55
|
-
}),
|
|
56
|
-
)
|
|
57
|
-
})
|
|
58
|
-
|
|
59
|
-
self.addEventListener('install', event => {
|
|
60
|
-
event.waitUntil(
|
|
61
|
-
// open cache
|
|
62
|
-
caches.open(CACHE_NAME)
|
|
63
|
-
.then(cache => {
|
|
64
|
-
return cache.match(URL)
|
|
65
|
-
.then(cachedResponse => {
|
|
66
|
-
// already cache skip
|
|
67
|
-
if (cachedResponse) {
|
|
68
|
-
return true
|
|
69
|
-
}
|
|
70
|
-
const request = new Request(INDEX_URL)
|
|
71
|
-
// fetch index url and cache it
|
|
72
|
-
return fetch(request)
|
|
73
|
-
.then(fetchedResponse => {
|
|
74
|
-
cache.put(INDEX_URL, fetchedResponse.clone())
|
|
75
|
-
return fetchedResponse
|
|
76
|
-
})
|
|
77
|
-
})
|
|
78
|
-
}),
|
|
79
|
-
)
|
|
80
|
-
})
|