taro-bluetooth-print 2.15.2 → 2.15.3
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/CHANGELOG.md +53 -0
- package/dist/adapters/index.cjs.js +1 -0
- package/dist/adapters/index.es.js +1 -0
- package/dist/chunks/AdapterFactory-B91w5soC.js +1 -0
- package/dist/chunks/AdapterFactory-sRvkpRnt.js +1 -0
- package/dist/chunks/EscPosDriver-Byd1u4Jk.js +1 -0
- package/dist/chunks/EscPosDriver-DGK4usVf.js +1 -0
- package/dist/chunks/index-CNH0TeFh.js +1 -0
- package/dist/chunks/index-DI6d-y8j.js +1 -0
- package/dist/chunks/shared-C3EQK7YH.js +1 -0
- package/dist/chunks/shared-DuaS72fL.js +1 -0
- package/dist/core/index.cjs.js +1 -0
- package/dist/core/index.es.js +1 -0
- package/dist/drivers/index.cjs.js +1 -0
- package/dist/drivers/index.es.js +1 -0
- package/dist/encoding/index.cjs.js +1 -0
- package/dist/encoding/index.es.js +1 -0
- package/dist/index.cjs.js +1 -1
- package/dist/index.es.js +1 -1
- package/dist/types/core/BluetoothPrinter.d.ts +37 -0
- package/package.json +7 -3
- package/src/core/BluetoothPrinter.ts +66 -4
- package/dist/hero-illustration.svg +0 -44
- package/dist/index.umd.js +0 -1
- package/dist/logo.svg +0 -17
- package/dist/manifest.webmanifest +0 -17
- package/dist/offline.html +0 -146
- package/dist/service-worker.js +0 -161
package/dist/logo.svg
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64" fill="none">
|
|
2
|
-
<!-- Background circle -->
|
|
3
|
-
<circle cx="32" cy="32" r="30" fill="#10b981" opacity="0.1"/>
|
|
4
|
-
<circle cx="32" cy="32" r="28" fill="#10b981" opacity="0.2"/>
|
|
5
|
-
<!-- Printer body -->
|
|
6
|
-
<rect x="12" y="20" width="40" height="28" rx="4" fill="#10b981"/>
|
|
7
|
-
<!-- Paper slot -->
|
|
8
|
-
<rect x="16" y="8" width="32" height="16" rx="2" fill="#ffffff" stroke="#10b981" stroke-width="2"/>
|
|
9
|
-
<!-- Paper lines -->
|
|
10
|
-
<line x1="20" y1="14" x2="36" y2="14" stroke="#10b981" stroke-width="2" stroke-linecap="round"/>
|
|
11
|
-
<line x1="20" y1="18" x2="30" y2="18" stroke="#10b981" stroke-width="2" stroke-linecap="round"/>
|
|
12
|
-
<!-- Bluetooth symbol -->
|
|
13
|
-
<path d="M32 26 L36 30 L32 34 L28 30 Z" fill="#ffffff"/>
|
|
14
|
-
<line x1="32" y1="30" x2="32" y2="38" stroke="#ffffff" stroke-width="2" stroke-linecap="round"/>
|
|
15
|
-
<!-- Feed button -->
|
|
16
|
-
<rect x="46" y="36" width="4" height="6" rx="1" fill="#ffffff" opacity="0.6"/>
|
|
17
|
-
</svg>
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "taro-bluetooth-print",
|
|
3
|
-
"short_name": "蓝牙打印",
|
|
4
|
-
"description": "轻量级、高性能的热敏/标签蓝牙打印库",
|
|
5
|
-
"start_url": "/taro-bluetooth-print/",
|
|
6
|
-
"display": "standalone",
|
|
7
|
-
"background_color": "#ffffff",
|
|
8
|
-
"theme_color": "#10b981",
|
|
9
|
-
"icons": [
|
|
10
|
-
{
|
|
11
|
-
"src": "/logo.svg",
|
|
12
|
-
"sizes": "any",
|
|
13
|
-
"type": "image/svg+xml"
|
|
14
|
-
}
|
|
15
|
-
],
|
|
16
|
-
"categories": ["developer tools", "utilities"]
|
|
17
|
-
}
|
package/dist/offline.html
DELETED
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="zh-CN">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8">
|
|
5
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
|
-
<title>离线访问 - Taro打印</title>
|
|
7
|
-
<style>
|
|
8
|
-
body {
|
|
9
|
-
font-family: Arial, sans-serif;
|
|
10
|
-
margin: 0;
|
|
11
|
-
padding: 0;
|
|
12
|
-
background-color: #f8f9fa;
|
|
13
|
-
color: #333;
|
|
14
|
-
display: flex;
|
|
15
|
-
flex-direction: column;
|
|
16
|
-
align-items: center;
|
|
17
|
-
justify-content: center;
|
|
18
|
-
min-height: 100vh;
|
|
19
|
-
text-align: center;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
.offline-container {
|
|
23
|
-
max-width: 600px;
|
|
24
|
-
padding: 2rem;
|
|
25
|
-
background-color: white;
|
|
26
|
-
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
|
27
|
-
border-radius: 8px;
|
|
28
|
-
margin: 1rem;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
h1 {
|
|
32
|
-
color: #1976d2;
|
|
33
|
-
margin-bottom: 1rem;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
p {
|
|
37
|
-
line-height: 1.6;
|
|
38
|
-
margin-bottom: 1.5rem;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
.icon {
|
|
42
|
-
display: block;
|
|
43
|
-
width: 80px;
|
|
44
|
-
height: 80px;
|
|
45
|
-
margin: 0 auto 2rem;
|
|
46
|
-
background-color: #f5f5f5;
|
|
47
|
-
border-radius: 50%;
|
|
48
|
-
padding: 1rem;
|
|
49
|
-
box-sizing: content-box;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
.icon svg {
|
|
53
|
-
width: 100%;
|
|
54
|
-
height: 100%;
|
|
55
|
-
fill: #1976d2;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
.btn {
|
|
59
|
-
display: inline-block;
|
|
60
|
-
background-color: #1976d2;
|
|
61
|
-
color: white;
|
|
62
|
-
text-decoration: none;
|
|
63
|
-
padding: 0.8rem 1.5rem;
|
|
64
|
-
border-radius: 4px;
|
|
65
|
-
font-weight: bold;
|
|
66
|
-
margin-top: 1rem;
|
|
67
|
-
transition: background-color 0.3s;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
.btn:hover {
|
|
71
|
-
background-color: #1565c0;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
.tips {
|
|
75
|
-
margin-top: 2rem;
|
|
76
|
-
padding: 1rem;
|
|
77
|
-
background-color: #e8f5e9;
|
|
78
|
-
border-radius: 4px;
|
|
79
|
-
border-left: 4px solid #4caf50;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
.tips h3 {
|
|
83
|
-
margin-top: 0;
|
|
84
|
-
color: #2e7d32;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
.tips ul {
|
|
88
|
-
text-align: left;
|
|
89
|
-
padding-left: 1.5rem;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
.tips li {
|
|
93
|
-
margin-bottom: 0.5rem;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
@media (max-width: 480px) {
|
|
97
|
-
.offline-container {
|
|
98
|
-
padding: 1.5rem;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
h1 {
|
|
102
|
-
font-size: 1.5rem;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
</style>
|
|
106
|
-
</head>
|
|
107
|
-
<body>
|
|
108
|
-
<div class="offline-container">
|
|
109
|
-
<div class="icon">
|
|
110
|
-
<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
|
|
111
|
-
<path d="M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10 10-4.5 10-10S17.5 2 12 2zm0 18c-4.4 0-8-3.6-8-8 0-1.7.5-3.3 1.5-4.6l11.1 11.1c-1.3 1-2.9 1.5-4.6 1.5zm6.5-3.4L7.4 5.5C8.7 4.5 10.3 4 12 4c4.4 0 8 3.6 8 8 0 1.7-.5 3.3-1.5 4.6z"/>
|
|
112
|
-
</svg>
|
|
113
|
-
</div>
|
|
114
|
-
|
|
115
|
-
<h1>您当前处于离线状态</h1>
|
|
116
|
-
<p>无法连接到互联网。请检查您的网络连接并重试。</p>
|
|
117
|
-
|
|
118
|
-
<p>由于您之前访问过我们的应用,部分功能可以离线使用。</p>
|
|
119
|
-
|
|
120
|
-
<a href="/" class="btn">刷新页面</a>
|
|
121
|
-
|
|
122
|
-
<div class="tips">
|
|
123
|
-
<h3>离线功能提示</h3>
|
|
124
|
-
<ul>
|
|
125
|
-
<li>已缓存的图像可以继续查看</li>
|
|
126
|
-
<li>部分基本的打印设置可以继续使用</li>
|
|
127
|
-
<li>需要联网才能搜索设备和执行打印</li>
|
|
128
|
-
<li>恢复网络连接后所有功能将自动可用</li>
|
|
129
|
-
</ul>
|
|
130
|
-
</div>
|
|
131
|
-
</div>
|
|
132
|
-
|
|
133
|
-
<script>
|
|
134
|
-
// 检测网络状态变化
|
|
135
|
-
window.addEventListener('online', function() {
|
|
136
|
-
window.location.reload();
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
// 检查按钮点击
|
|
140
|
-
document.querySelector('.btn').addEventListener('click', function(e) {
|
|
141
|
-
e.preventDefault();
|
|
142
|
-
window.location.reload();
|
|
143
|
-
});
|
|
144
|
-
</script>
|
|
145
|
-
</body>
|
|
146
|
-
</html>
|
package/dist/service-worker.js
DELETED
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
const CACHE_NAME = 'taro-print-v1';
|
|
2
|
-
const STATIC_CACHE_NAME = 'taro-print-static-v1';
|
|
3
|
-
const DYNAMIC_CACHE_NAME = 'taro-print-dynamic-v1';
|
|
4
|
-
|
|
5
|
-
// 需要缓存的静态资源
|
|
6
|
-
const STATIC_ASSETS = [
|
|
7
|
-
'/',
|
|
8
|
-
'/index.html',
|
|
9
|
-
'/app.js',
|
|
10
|
-
'/app.css',
|
|
11
|
-
'/manifest.json',
|
|
12
|
-
'/favicon.ico',
|
|
13
|
-
'/logo.png',
|
|
14
|
-
'/offline.html',
|
|
15
|
-
'/workers/image-worker.js'
|
|
16
|
-
];
|
|
17
|
-
|
|
18
|
-
// 安装事件
|
|
19
|
-
self.addEventListener('install', (event) => {
|
|
20
|
-
event.waitUntil(
|
|
21
|
-
caches.open(STATIC_CACHE_NAME)
|
|
22
|
-
.then((cache) => {
|
|
23
|
-
console.log('缓存静态资源');
|
|
24
|
-
return cache.addAll(STATIC_ASSETS);
|
|
25
|
-
})
|
|
26
|
-
.then(() => {
|
|
27
|
-
return self.skipWaiting();
|
|
28
|
-
})
|
|
29
|
-
);
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
// 激活事件
|
|
33
|
-
self.addEventListener('activate', (event) => {
|
|
34
|
-
// 清理旧缓存
|
|
35
|
-
event.waitUntil(
|
|
36
|
-
caches.keys()
|
|
37
|
-
.then((cacheNames) => {
|
|
38
|
-
return Promise.all(
|
|
39
|
-
cacheNames.map((cacheName) => {
|
|
40
|
-
if (
|
|
41
|
-
cacheName !== STATIC_CACHE_NAME &&
|
|
42
|
-
cacheName !== DYNAMIC_CACHE_NAME &&
|
|
43
|
-
cacheName.startsWith('taro-print-')
|
|
44
|
-
) {
|
|
45
|
-
console.log('删除旧缓存', cacheName);
|
|
46
|
-
return caches.delete(cacheName);
|
|
47
|
-
}
|
|
48
|
-
})
|
|
49
|
-
);
|
|
50
|
-
})
|
|
51
|
-
.then(() => {
|
|
52
|
-
// 接管所有客户端
|
|
53
|
-
return self.clients.claim();
|
|
54
|
-
})
|
|
55
|
-
);
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
// 缓存优先策略
|
|
59
|
-
const cacheFirst = async (request) => {
|
|
60
|
-
const cachedResponse = await caches.match(request);
|
|
61
|
-
if (cachedResponse) {
|
|
62
|
-
return cachedResponse;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
try {
|
|
66
|
-
const networkResponse = await fetch(request);
|
|
67
|
-
|
|
68
|
-
// 只缓存成功的响应
|
|
69
|
-
if (networkResponse && networkResponse.status === 200) {
|
|
70
|
-
const cache = await caches.open(DYNAMIC_CACHE_NAME);
|
|
71
|
-
cache.put(request, networkResponse.clone());
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
return networkResponse;
|
|
75
|
-
} catch (error) {
|
|
76
|
-
// 无法获取网络响应
|
|
77
|
-
const url = new URL(request.url);
|
|
78
|
-
if (url.pathname.endsWith('.html')) {
|
|
79
|
-
return caches.match('/offline.html');
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
return new Response('网络请求失败', {
|
|
83
|
-
status: 408,
|
|
84
|
-
headers: { 'Content-Type': 'text/plain' }
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
// 网络优先策略
|
|
90
|
-
const networkFirst = async (request) => {
|
|
91
|
-
try {
|
|
92
|
-
const networkResponse = await fetch(request);
|
|
93
|
-
|
|
94
|
-
// 只缓存成功的响应
|
|
95
|
-
if (networkResponse && networkResponse.status === 200) {
|
|
96
|
-
const cache = await caches.open(DYNAMIC_CACHE_NAME);
|
|
97
|
-
cache.put(request, networkResponse.clone());
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
return networkResponse;
|
|
101
|
-
} catch (error) {
|
|
102
|
-
const cachedResponse = await caches.match(request);
|
|
103
|
-
|
|
104
|
-
if (cachedResponse) {
|
|
105
|
-
return cachedResponse;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
// 如果是HTML请求,返回离线页面
|
|
109
|
-
const url = new URL(request.url);
|
|
110
|
-
if (url.pathname.endsWith('.html')) {
|
|
111
|
-
return caches.match('/offline.html');
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
return new Response('网络请求失败', {
|
|
115
|
-
status: 408,
|
|
116
|
-
headers: { 'Content-Type': 'text/plain' }
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
};
|
|
120
|
-
|
|
121
|
-
// 拦截请求
|
|
122
|
-
self.addEventListener('fetch', (event) => {
|
|
123
|
-
const { request } = event;
|
|
124
|
-
const url = new URL(request.url);
|
|
125
|
-
|
|
126
|
-
// 跳过不是HTTP/HTTPS的请求
|
|
127
|
-
if (!url.protocol.startsWith('http')) {
|
|
128
|
-
return;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
// 静态资源使用缓存优先策略
|
|
132
|
-
if (
|
|
133
|
-
STATIC_ASSETS.includes(url.pathname) ||
|
|
134
|
-
url.pathname.startsWith('/workers/') ||
|
|
135
|
-
url.pathname.endsWith('.js') ||
|
|
136
|
-
url.pathname.endsWith('.css') ||
|
|
137
|
-
url.pathname.endsWith('.png') ||
|
|
138
|
-
url.pathname.endsWith('.jpg') ||
|
|
139
|
-
url.pathname.endsWith('.svg') ||
|
|
140
|
-
url.pathname.endsWith('.woff2')
|
|
141
|
-
) {
|
|
142
|
-
event.respondWith(cacheFirst(request));
|
|
143
|
-
return;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
// API请求使用网络优先策略
|
|
147
|
-
if (url.pathname.startsWith('/api/')) {
|
|
148
|
-
event.respondWith(networkFirst(request));
|
|
149
|
-
return;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
// 其他请求使用缓存优先策略
|
|
153
|
-
event.respondWith(cacheFirst(request));
|
|
154
|
-
});
|
|
155
|
-
|
|
156
|
-
// 消息处理
|
|
157
|
-
self.addEventListener('message', (event) => {
|
|
158
|
-
if (event.data && event.data.action === 'skipWaiting') {
|
|
159
|
-
self.skipWaiting();
|
|
160
|
-
}
|
|
161
|
-
});
|