profile-pane 2.0.0-newStyle-18c2e2e1 → 2.0.0-newStyle-cef3363a
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/lib/profile-pane.js +4390 -0
- package/lib/profile-pane.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,4390 @@
|
|
|
1
|
+
(function webpackUniversalModuleDefinition(root, factory) {
|
|
2
|
+
if(typeof exports === 'object' && typeof module === 'object')
|
|
3
|
+
module.exports = factory(require("SolidLogic"), require("UI"), require("rdflib"));
|
|
4
|
+
else if(typeof define === 'function' && define.amd)
|
|
5
|
+
define(["SolidLogic", "UI", "rdflib"], factory);
|
|
6
|
+
else if(typeof exports === 'object')
|
|
7
|
+
exports["ProfilePane"] = factory(require("SolidLogic"), require("UI"), require("rdflib"));
|
|
8
|
+
else
|
|
9
|
+
root["ProfilePane"] = factory(root["SolidLogic"], root["UI"], root["rdflib"]);
|
|
10
|
+
})(this, (__WEBPACK_EXTERNAL_MODULE__663__, __WEBPACK_EXTERNAL_MODULE__426__, __WEBPACK_EXTERNAL_MODULE__491__) => {
|
|
11
|
+
return /******/ (() => { // webpackBootstrap
|
|
12
|
+
/******/ var __webpack_modules__ = ({
|
|
13
|
+
|
|
14
|
+
/***/ 44:
|
|
15
|
+
/***/ ((__unused_webpack_module, exports) => {
|
|
16
|
+
|
|
17
|
+
const numeric = '[0-9]+'
|
|
18
|
+
const alphanumeric = '[A-Z $%*+\\-./:]+'
|
|
19
|
+
let kanji = '(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|' +
|
|
20
|
+
'[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|' +
|
|
21
|
+
'[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|' +
|
|
22
|
+
'[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+'
|
|
23
|
+
kanji = kanji.replace(/u/g, '\\u')
|
|
24
|
+
|
|
25
|
+
const byte = '(?:(?![A-Z0-9 $%*+\\-./:]|' + kanji + ')(?:.|[\r\n]))+'
|
|
26
|
+
|
|
27
|
+
exports.KANJI = new RegExp(kanji, 'g')
|
|
28
|
+
exports.BYTE_KANJI = new RegExp('[^A-Z0-9 $%*+\\-./:]+', 'g')
|
|
29
|
+
exports.BYTE = new RegExp(byte, 'g')
|
|
30
|
+
exports.NUMERIC = new RegExp(numeric, 'g')
|
|
31
|
+
exports.ALPHANUMERIC = new RegExp(alphanumeric, 'g')
|
|
32
|
+
|
|
33
|
+
const TEST_KANJI = new RegExp('^' + kanji + '$')
|
|
34
|
+
const TEST_NUMERIC = new RegExp('^' + numeric + '$')
|
|
35
|
+
const TEST_ALPHANUMERIC = new RegExp('^[A-Z0-9 $%*+\\-./:]+$')
|
|
36
|
+
|
|
37
|
+
exports.testKanji = function testKanji (str) {
|
|
38
|
+
return TEST_KANJI.test(str)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
exports.testNumeric = function testNumeric (str) {
|
|
42
|
+
return TEST_NUMERIC.test(str)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
exports.testAlphanumeric = function testAlphanumeric (str) {
|
|
46
|
+
return TEST_ALPHANUMERIC.test(str)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
/***/ }),
|
|
51
|
+
|
|
52
|
+
/***/ 77:
|
|
53
|
+
/***/ ((module) => {
|
|
54
|
+
|
|
55
|
+
module.exports=function(e){var r={};function t(n){if(r[n])return r[n].exports;var a=r[n]={i:n,l:!1,exports:{}};return e[n].call(a.exports,a,a.exports,t),a.l=!0,a.exports}return t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:n})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,r){if(1&r&&(e=t(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(t.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var a in e)t.d(n,a,function(r){return e[r]}.bind(null,a));return n},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},t.p="",t(t.s=0)}([function(e,r,t){"use strict";t.r(r),t.d(r,"validateHTMLColorName",(function(){return l})),t.d(r,"validateHTMLColorSpecialName",(function(){return i})),t.d(r,"validateHTMLColorHex",(function(){return u})),t.d(r,"validateHTMLColorRgb",(function(){return g})),t.d(r,"validateHTMLColorHsl",(function(){return y})),t.d(r,"validateHTMLColorHwb",(function(){return L})),t.d(r,"validateHTMLColorLab",(function(){return S})),t.d(r,"validateHTMLColorLch",(function(){return m})),t.d(r,"validateHTMLColor",(function(){return G}));const n=e=>e&&"string"==typeof e,a=["AliceBlue","AntiqueWhite","Aqua","Aquamarine","Azure","Beige","Bisque","Black","BlanchedAlmond","Blue","BlueViolet","Brown","BurlyWood","CadetBlue","Chartreuse","Chocolate","Coral","CornflowerBlue","Cornsilk","Crimson","Cyan","DarkBlue","DarkCyan","DarkGoldenrod","DarkGray","DarkGrey","DarkGreen","DarkKhaki","DarkMagenta","DarkOliveGreen","DarkOrange","DarkOrchid","DarkRed","DarkSalmon","DarkSeaGreen","DarkSlateBlue","DarkSlateGray","DarkSlateGrey","DarkTurquoise","DarkViolet","DeepPink","DeepSkyBlue","DimGray","DimGrey","DodgerBlue","FireBrick","FloralWhite","ForestGreen","Fuchsia","Gainsboro","GhostWhite","Gold","Goldenrod","Gray","Grey","Green","GreenYellow","HoneyDew","HotPink","IndianRed","Indigo","Ivory","Khaki","Lavender","LavenderBlush","LawnGreen","LemonChiffon","LightBlue","LightCoral","LightCyan","LightGoldenrodYellow","LightGray","LightGrey","LightGreen","LightPink","LightSalmon","LightSalmon","LightSeaGreen","LightSkyBlue","LightSlateGray","LightSlateGrey","LightSteelBlue","LightYellow","Lime","LimeGreen","Linen","Magenta","Maroon","MediumAquamarine","MediumBlue","MediumOrchid","MediumPurple","MediumSeaGreen","MediumSlateBlue","MediumSlateBlue","MediumSpringGreen","MediumTurquoise","MediumVioletRed","MidnightBlue","MintCream","MistyRose","Moccasin","NavajoWhite","Navy","OldLace","Olive","OliveDrab","Orange","OrangeRed","Orchid","PaleGoldenrod","PaleGreen","PaleTurquoise","PaleVioletRed","PapayaWhip","PeachPuff","Peru","Pink","Plum","PowderBlue","Purple","RebeccaPurple","Red","RosyBrown","RoyalBlue","SaddleBrown","Salmon","SandyBrown","SeaGreen","SeaShell","Sienna","Silver","SkyBlue","SlateBlue","SlateGray","SlateGrey","Snow","SpringGreen","SteelBlue","Tan","Teal","Thistle","Tomato","Turquoise","Violet","Wheat","White","WhiteSmoke","Yellow","YellowGreen"],o=["currentColor","inherit","transparent"],l=e=>{let r=!1;return n(e)&&a.map(t=>(e.toLowerCase()===t.toLowerCase()&&(r=!0),null)),r},i=e=>{let r=!1;return n(e)&&o.map(t=>(e.toLowerCase()===t.toLowerCase()&&(r=!0),null)),r},u=e=>{if(n(e)){const r=/^#([\da-f]{3}){1,2}$|^#([\da-f]{4}){1,2}$/i;return e&&r.test(e)}return!1},d="(([\\d]{0,5})((\\.([\\d]{1,5}))?))",s=`(${d}%)`,c="(([0-9]|[1-9][0-9]|100)%)",f=`(${c}|(0?((\\.([\\d]{1,5}))?))|1)`,h=`([\\s]{0,5})\\)?)(([\\s]{0,5})(\\/?)([\\s]{1,5})${`(((${c}))|(0?((\\.([\\d]{1,5}))?))|1))?`}([\\s]{0,5})\\)`,$="(-?(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-9][0-9]|3[0-5][0-9])((\\.([\\d]{1,5}))?)|360)(deg)?)",g=e=>{if(n(e)){const r="([\\s]{0,5})([\\d]{1,5})%?([\\s]{0,5}),?",t="((([\\s]{0,5}),?([\\s]{0,5}))|(([\\s]{1,5})))",n=new RegExp(`^(rgb)a?\\(${`${r}${t}`}${`${r}${t}`}${`${r}${t}`}(${"(\\/?([\\s]{0,5})(0?\\.?([\\d]{1,5})%?([\\s]{0,5}))?|1|0)"})?\\)$`);return e&&n.test(e)}return!1},y=e=>{if(n(e)){const r=new RegExp(`^(hsl)a?\\((([\\s]{0,5})(${$}|${"(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-9][0-9]|3[0-9][0-9]|400)grad)"}|${"((([0-5])?\\.([\\d]{1,5})|6\\.([0-9]|1[0-9]|2[0-8])|[0-6])rad)"}|${"((0?((\\.([\\d]{1,5}))?)|1)turn)"})((([\\s]{0,5}),([\\s]{0,5}))|(([\\s]{1,5}))))(([\\s]{0,5})(0|${c})((([\\s]{0,5}),([\\s]{0,5}))|(([\\s]{1,5}))))(([\\s]{0,5})(0|${c})([\\s]{0,5})\\)?)(([\\s]{0,5})(\\/?|,?)([\\s]{0,5})(((${c}))|(0?((\\.([\\d]{1,5}))?))|1))?\\)$`);return e&&r.test(e)}return!1},L=e=>{if(n(e)){const r=new RegExp(`^(hwb\\(([\\s]{0,5})${$}([\\s]{1,5}))((0|${c})([\\s]{1,5}))((0|${c})${h}$`);return e&&r.test(e)}return!1},S=e=>{if(n(e)){const r="(-?(([0-9]|[1-9][0-9]|1[0-5][0-9])((\\.([\\d]{1,5}))?)?|160))",t=new RegExp(`^(lab\\(([\\s]{0,5})${s}([\\s]{1,5})${r}([\\s]{1,5})${r}${h}$`);return e&&t.test(e)}return!1},m=e=>{if(n(e)){const r="((([0-9]|[1-9][0-9])?((\\.([\\d]{1,5}))?)|100)(%)?)",t=""+d,n=`((${$})|(0|${f})|(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-9][0-9]|3[0-5][0-9])((\\.([\\d]{1,5}))?)|360))`,a=`(\\/([\\s]{0,5})${f})`,o=new RegExp(`^lch\\(${`(([\\s]{0,5})${r}([\\s]{1,5})${t}([\\s]{1,5})${n}([\\s]{0,5})(${a})?)`}\\)$`);return e&&o.test(e)}return!1},G=e=>!!(e&&u(e)||g(e)||y(e)||L(e)||S(e)||m(e));r.default=e=>!!(e&&u(e)||l(e)||i(e)||g(e)||y(e)||L(e)||S(e)||m(e))}]);
|
|
56
|
+
|
|
57
|
+
/***/ }),
|
|
58
|
+
|
|
59
|
+
/***/ 157:
|
|
60
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
61
|
+
|
|
62
|
+
const Utils = __webpack_require__(886)
|
|
63
|
+
const ECLevel = __webpack_require__(953)
|
|
64
|
+
const BitBuffer = __webpack_require__(899)
|
|
65
|
+
const BitMatrix = __webpack_require__(820)
|
|
66
|
+
const AlignmentPattern = __webpack_require__(421)
|
|
67
|
+
const FinderPattern = __webpack_require__(756)
|
|
68
|
+
const MaskPattern = __webpack_require__(332)
|
|
69
|
+
const ECCode = __webpack_require__(518)
|
|
70
|
+
const ReedSolomonEncoder = __webpack_require__(764)
|
|
71
|
+
const Version = __webpack_require__(427)
|
|
72
|
+
const FormatInfo = __webpack_require__(565)
|
|
73
|
+
const Mode = __webpack_require__(208)
|
|
74
|
+
const Segments = __webpack_require__(801)
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* QRCode for JavaScript
|
|
78
|
+
*
|
|
79
|
+
* modified by Ryan Day for nodejs support
|
|
80
|
+
* Copyright (c) 2011 Ryan Day
|
|
81
|
+
*
|
|
82
|
+
* Licensed under the MIT license:
|
|
83
|
+
* http://www.opensource.org/licenses/mit-license.php
|
|
84
|
+
*
|
|
85
|
+
//---------------------------------------------------------------------
|
|
86
|
+
// QRCode for JavaScript
|
|
87
|
+
//
|
|
88
|
+
// Copyright (c) 2009 Kazuhiko Arase
|
|
89
|
+
//
|
|
90
|
+
// URL: http://www.d-project.com/
|
|
91
|
+
//
|
|
92
|
+
// Licensed under the MIT license:
|
|
93
|
+
// http://www.opensource.org/licenses/mit-license.php
|
|
94
|
+
//
|
|
95
|
+
// The word "QR Code" is registered trademark of
|
|
96
|
+
// DENSO WAVE INCORPORATED
|
|
97
|
+
// http://www.denso-wave.com/qrcode/faqpatent-e.html
|
|
98
|
+
//
|
|
99
|
+
//---------------------------------------------------------------------
|
|
100
|
+
*/
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Add finder patterns bits to matrix
|
|
104
|
+
*
|
|
105
|
+
* @param {BitMatrix} matrix Modules matrix
|
|
106
|
+
* @param {Number} version QR Code version
|
|
107
|
+
*/
|
|
108
|
+
function setupFinderPattern (matrix, version) {
|
|
109
|
+
const size = matrix.size
|
|
110
|
+
const pos = FinderPattern.getPositions(version)
|
|
111
|
+
|
|
112
|
+
for (let i = 0; i < pos.length; i++) {
|
|
113
|
+
const row = pos[i][0]
|
|
114
|
+
const col = pos[i][1]
|
|
115
|
+
|
|
116
|
+
for (let r = -1; r <= 7; r++) {
|
|
117
|
+
if (row + r <= -1 || size <= row + r) continue
|
|
118
|
+
|
|
119
|
+
for (let c = -1; c <= 7; c++) {
|
|
120
|
+
if (col + c <= -1 || size <= col + c) continue
|
|
121
|
+
|
|
122
|
+
if ((r >= 0 && r <= 6 && (c === 0 || c === 6)) ||
|
|
123
|
+
(c >= 0 && c <= 6 && (r === 0 || r === 6)) ||
|
|
124
|
+
(r >= 2 && r <= 4 && c >= 2 && c <= 4)) {
|
|
125
|
+
matrix.set(row + r, col + c, true, true)
|
|
126
|
+
} else {
|
|
127
|
+
matrix.set(row + r, col + c, false, true)
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Add timing pattern bits to matrix
|
|
136
|
+
*
|
|
137
|
+
* Note: this function must be called before {@link setupAlignmentPattern}
|
|
138
|
+
*
|
|
139
|
+
* @param {BitMatrix} matrix Modules matrix
|
|
140
|
+
*/
|
|
141
|
+
function setupTimingPattern (matrix) {
|
|
142
|
+
const size = matrix.size
|
|
143
|
+
|
|
144
|
+
for (let r = 8; r < size - 8; r++) {
|
|
145
|
+
const value = r % 2 === 0
|
|
146
|
+
matrix.set(r, 6, value, true)
|
|
147
|
+
matrix.set(6, r, value, true)
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Add alignment patterns bits to matrix
|
|
153
|
+
*
|
|
154
|
+
* Note: this function must be called after {@link setupTimingPattern}
|
|
155
|
+
*
|
|
156
|
+
* @param {BitMatrix} matrix Modules matrix
|
|
157
|
+
* @param {Number} version QR Code version
|
|
158
|
+
*/
|
|
159
|
+
function setupAlignmentPattern (matrix, version) {
|
|
160
|
+
const pos = AlignmentPattern.getPositions(version)
|
|
161
|
+
|
|
162
|
+
for (let i = 0; i < pos.length; i++) {
|
|
163
|
+
const row = pos[i][0]
|
|
164
|
+
const col = pos[i][1]
|
|
165
|
+
|
|
166
|
+
for (let r = -2; r <= 2; r++) {
|
|
167
|
+
for (let c = -2; c <= 2; c++) {
|
|
168
|
+
if (r === -2 || r === 2 || c === -2 || c === 2 ||
|
|
169
|
+
(r === 0 && c === 0)) {
|
|
170
|
+
matrix.set(row + r, col + c, true, true)
|
|
171
|
+
} else {
|
|
172
|
+
matrix.set(row + r, col + c, false, true)
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Add version info bits to matrix
|
|
181
|
+
*
|
|
182
|
+
* @param {BitMatrix} matrix Modules matrix
|
|
183
|
+
* @param {Number} version QR Code version
|
|
184
|
+
*/
|
|
185
|
+
function setupVersionInfo (matrix, version) {
|
|
186
|
+
const size = matrix.size
|
|
187
|
+
const bits = Version.getEncodedBits(version)
|
|
188
|
+
let row, col, mod
|
|
189
|
+
|
|
190
|
+
for (let i = 0; i < 18; i++) {
|
|
191
|
+
row = Math.floor(i / 3)
|
|
192
|
+
col = i % 3 + size - 8 - 3
|
|
193
|
+
mod = ((bits >> i) & 1) === 1
|
|
194
|
+
|
|
195
|
+
matrix.set(row, col, mod, true)
|
|
196
|
+
matrix.set(col, row, mod, true)
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Add format info bits to matrix
|
|
202
|
+
*
|
|
203
|
+
* @param {BitMatrix} matrix Modules matrix
|
|
204
|
+
* @param {ErrorCorrectionLevel} errorCorrectionLevel Error correction level
|
|
205
|
+
* @param {Number} maskPattern Mask pattern reference value
|
|
206
|
+
*/
|
|
207
|
+
function setupFormatInfo (matrix, errorCorrectionLevel, maskPattern) {
|
|
208
|
+
const size = matrix.size
|
|
209
|
+
const bits = FormatInfo.getEncodedBits(errorCorrectionLevel, maskPattern)
|
|
210
|
+
let i, mod
|
|
211
|
+
|
|
212
|
+
for (i = 0; i < 15; i++) {
|
|
213
|
+
mod = ((bits >> i) & 1) === 1
|
|
214
|
+
|
|
215
|
+
// vertical
|
|
216
|
+
if (i < 6) {
|
|
217
|
+
matrix.set(i, 8, mod, true)
|
|
218
|
+
} else if (i < 8) {
|
|
219
|
+
matrix.set(i + 1, 8, mod, true)
|
|
220
|
+
} else {
|
|
221
|
+
matrix.set(size - 15 + i, 8, mod, true)
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
// horizontal
|
|
225
|
+
if (i < 8) {
|
|
226
|
+
matrix.set(8, size - i - 1, mod, true)
|
|
227
|
+
} else if (i < 9) {
|
|
228
|
+
matrix.set(8, 15 - i - 1 + 1, mod, true)
|
|
229
|
+
} else {
|
|
230
|
+
matrix.set(8, 15 - i - 1, mod, true)
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
// fixed module
|
|
235
|
+
matrix.set(size - 8, 8, 1, true)
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* Add encoded data bits to matrix
|
|
240
|
+
*
|
|
241
|
+
* @param {BitMatrix} matrix Modules matrix
|
|
242
|
+
* @param {Uint8Array} data Data codewords
|
|
243
|
+
*/
|
|
244
|
+
function setupData (matrix, data) {
|
|
245
|
+
const size = matrix.size
|
|
246
|
+
let inc = -1
|
|
247
|
+
let row = size - 1
|
|
248
|
+
let bitIndex = 7
|
|
249
|
+
let byteIndex = 0
|
|
250
|
+
|
|
251
|
+
for (let col = size - 1; col > 0; col -= 2) {
|
|
252
|
+
if (col === 6) col--
|
|
253
|
+
|
|
254
|
+
while (true) {
|
|
255
|
+
for (let c = 0; c < 2; c++) {
|
|
256
|
+
if (!matrix.isReserved(row, col - c)) {
|
|
257
|
+
let dark = false
|
|
258
|
+
|
|
259
|
+
if (byteIndex < data.length) {
|
|
260
|
+
dark = (((data[byteIndex] >>> bitIndex) & 1) === 1)
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
matrix.set(row, col - c, dark)
|
|
264
|
+
bitIndex--
|
|
265
|
+
|
|
266
|
+
if (bitIndex === -1) {
|
|
267
|
+
byteIndex++
|
|
268
|
+
bitIndex = 7
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
row += inc
|
|
274
|
+
|
|
275
|
+
if (row < 0 || size <= row) {
|
|
276
|
+
row -= inc
|
|
277
|
+
inc = -inc
|
|
278
|
+
break
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* Create encoded codewords from data input
|
|
286
|
+
*
|
|
287
|
+
* @param {Number} version QR Code version
|
|
288
|
+
* @param {ErrorCorrectionLevel} errorCorrectionLevel Error correction level
|
|
289
|
+
* @param {ByteData} data Data input
|
|
290
|
+
* @return {Uint8Array} Buffer containing encoded codewords
|
|
291
|
+
*/
|
|
292
|
+
function createData (version, errorCorrectionLevel, segments) {
|
|
293
|
+
// Prepare data buffer
|
|
294
|
+
const buffer = new BitBuffer()
|
|
295
|
+
|
|
296
|
+
segments.forEach(function (data) {
|
|
297
|
+
// prefix data with mode indicator (4 bits)
|
|
298
|
+
buffer.put(data.mode.bit, 4)
|
|
299
|
+
|
|
300
|
+
// Prefix data with character count indicator.
|
|
301
|
+
// The character count indicator is a string of bits that represents the
|
|
302
|
+
// number of characters that are being encoded.
|
|
303
|
+
// The character count indicator must be placed after the mode indicator
|
|
304
|
+
// and must be a certain number of bits long, depending on the QR version
|
|
305
|
+
// and data mode
|
|
306
|
+
// @see {@link Mode.getCharCountIndicator}.
|
|
307
|
+
buffer.put(data.getLength(), Mode.getCharCountIndicator(data.mode, version))
|
|
308
|
+
|
|
309
|
+
// add binary data sequence to buffer
|
|
310
|
+
data.write(buffer)
|
|
311
|
+
})
|
|
312
|
+
|
|
313
|
+
// Calculate required number of bits
|
|
314
|
+
const totalCodewords = Utils.getSymbolTotalCodewords(version)
|
|
315
|
+
const ecTotalCodewords = ECCode.getTotalCodewordsCount(version, errorCorrectionLevel)
|
|
316
|
+
const dataTotalCodewordsBits = (totalCodewords - ecTotalCodewords) * 8
|
|
317
|
+
|
|
318
|
+
// Add a terminator.
|
|
319
|
+
// If the bit string is shorter than the total number of required bits,
|
|
320
|
+
// a terminator of up to four 0s must be added to the right side of the string.
|
|
321
|
+
// If the bit string is more than four bits shorter than the required number of bits,
|
|
322
|
+
// add four 0s to the end.
|
|
323
|
+
if (buffer.getLengthInBits() + 4 <= dataTotalCodewordsBits) {
|
|
324
|
+
buffer.put(0, 4)
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
// If the bit string is fewer than four bits shorter, add only the number of 0s that
|
|
328
|
+
// are needed to reach the required number of bits.
|
|
329
|
+
|
|
330
|
+
// After adding the terminator, if the number of bits in the string is not a multiple of 8,
|
|
331
|
+
// pad the string on the right with 0s to make the string's length a multiple of 8.
|
|
332
|
+
while (buffer.getLengthInBits() % 8 !== 0) {
|
|
333
|
+
buffer.putBit(0)
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
// Add pad bytes if the string is still shorter than the total number of required bits.
|
|
337
|
+
// Extend the buffer to fill the data capacity of the symbol corresponding to
|
|
338
|
+
// the Version and Error Correction Level by adding the Pad Codewords 11101100 (0xEC)
|
|
339
|
+
// and 00010001 (0x11) alternately.
|
|
340
|
+
const remainingByte = (dataTotalCodewordsBits - buffer.getLengthInBits()) / 8
|
|
341
|
+
for (let i = 0; i < remainingByte; i++) {
|
|
342
|
+
buffer.put(i % 2 ? 0x11 : 0xEC, 8)
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
return createCodewords(buffer, version, errorCorrectionLevel)
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
/**
|
|
349
|
+
* Encode input data with Reed-Solomon and return codewords with
|
|
350
|
+
* relative error correction bits
|
|
351
|
+
*
|
|
352
|
+
* @param {BitBuffer} bitBuffer Data to encode
|
|
353
|
+
* @param {Number} version QR Code version
|
|
354
|
+
* @param {ErrorCorrectionLevel} errorCorrectionLevel Error correction level
|
|
355
|
+
* @return {Uint8Array} Buffer containing encoded codewords
|
|
356
|
+
*/
|
|
357
|
+
function createCodewords (bitBuffer, version, errorCorrectionLevel) {
|
|
358
|
+
// Total codewords for this QR code version (Data + Error correction)
|
|
359
|
+
const totalCodewords = Utils.getSymbolTotalCodewords(version)
|
|
360
|
+
|
|
361
|
+
// Total number of error correction codewords
|
|
362
|
+
const ecTotalCodewords = ECCode.getTotalCodewordsCount(version, errorCorrectionLevel)
|
|
363
|
+
|
|
364
|
+
// Total number of data codewords
|
|
365
|
+
const dataTotalCodewords = totalCodewords - ecTotalCodewords
|
|
366
|
+
|
|
367
|
+
// Total number of blocks
|
|
368
|
+
const ecTotalBlocks = ECCode.getBlocksCount(version, errorCorrectionLevel)
|
|
369
|
+
|
|
370
|
+
// Calculate how many blocks each group should contain
|
|
371
|
+
const blocksInGroup2 = totalCodewords % ecTotalBlocks
|
|
372
|
+
const blocksInGroup1 = ecTotalBlocks - blocksInGroup2
|
|
373
|
+
|
|
374
|
+
const totalCodewordsInGroup1 = Math.floor(totalCodewords / ecTotalBlocks)
|
|
375
|
+
|
|
376
|
+
const dataCodewordsInGroup1 = Math.floor(dataTotalCodewords / ecTotalBlocks)
|
|
377
|
+
const dataCodewordsInGroup2 = dataCodewordsInGroup1 + 1
|
|
378
|
+
|
|
379
|
+
// Number of EC codewords is the same for both groups
|
|
380
|
+
const ecCount = totalCodewordsInGroup1 - dataCodewordsInGroup1
|
|
381
|
+
|
|
382
|
+
// Initialize a Reed-Solomon encoder with a generator polynomial of degree ecCount
|
|
383
|
+
const rs = new ReedSolomonEncoder(ecCount)
|
|
384
|
+
|
|
385
|
+
let offset = 0
|
|
386
|
+
const dcData = new Array(ecTotalBlocks)
|
|
387
|
+
const ecData = new Array(ecTotalBlocks)
|
|
388
|
+
let maxDataSize = 0
|
|
389
|
+
const buffer = new Uint8Array(bitBuffer.buffer)
|
|
390
|
+
|
|
391
|
+
// Divide the buffer into the required number of blocks
|
|
392
|
+
for (let b = 0; b < ecTotalBlocks; b++) {
|
|
393
|
+
const dataSize = b < blocksInGroup1 ? dataCodewordsInGroup1 : dataCodewordsInGroup2
|
|
394
|
+
|
|
395
|
+
// extract a block of data from buffer
|
|
396
|
+
dcData[b] = buffer.slice(offset, offset + dataSize)
|
|
397
|
+
|
|
398
|
+
// Calculate EC codewords for this data block
|
|
399
|
+
ecData[b] = rs.encode(dcData[b])
|
|
400
|
+
|
|
401
|
+
offset += dataSize
|
|
402
|
+
maxDataSize = Math.max(maxDataSize, dataSize)
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
// Create final data
|
|
406
|
+
// Interleave the data and error correction codewords from each block
|
|
407
|
+
const data = new Uint8Array(totalCodewords)
|
|
408
|
+
let index = 0
|
|
409
|
+
let i, r
|
|
410
|
+
|
|
411
|
+
// Add data codewords
|
|
412
|
+
for (i = 0; i < maxDataSize; i++) {
|
|
413
|
+
for (r = 0; r < ecTotalBlocks; r++) {
|
|
414
|
+
if (i < dcData[r].length) {
|
|
415
|
+
data[index++] = dcData[r][i]
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
// Apped EC codewords
|
|
421
|
+
for (i = 0; i < ecCount; i++) {
|
|
422
|
+
for (r = 0; r < ecTotalBlocks; r++) {
|
|
423
|
+
data[index++] = ecData[r][i]
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
return data
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
/**
|
|
431
|
+
* Build QR Code symbol
|
|
432
|
+
*
|
|
433
|
+
* @param {String} data Input string
|
|
434
|
+
* @param {Number} version QR Code version
|
|
435
|
+
* @param {ErrorCorretionLevel} errorCorrectionLevel Error level
|
|
436
|
+
* @param {MaskPattern} maskPattern Mask pattern
|
|
437
|
+
* @return {Object} Object containing symbol data
|
|
438
|
+
*/
|
|
439
|
+
function createSymbol (data, version, errorCorrectionLevel, maskPattern) {
|
|
440
|
+
let segments
|
|
441
|
+
|
|
442
|
+
if (Array.isArray(data)) {
|
|
443
|
+
segments = Segments.fromArray(data)
|
|
444
|
+
} else if (typeof data === 'string') {
|
|
445
|
+
let estimatedVersion = version
|
|
446
|
+
|
|
447
|
+
if (!estimatedVersion) {
|
|
448
|
+
const rawSegments = Segments.rawSplit(data)
|
|
449
|
+
|
|
450
|
+
// Estimate best version that can contain raw splitted segments
|
|
451
|
+
estimatedVersion = Version.getBestVersionForData(rawSegments, errorCorrectionLevel)
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
// Build optimized segments
|
|
455
|
+
// If estimated version is undefined, try with the highest version
|
|
456
|
+
segments = Segments.fromString(data, estimatedVersion || 40)
|
|
457
|
+
} else {
|
|
458
|
+
throw new Error('Invalid data')
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
// Get the min version that can contain data
|
|
462
|
+
const bestVersion = Version.getBestVersionForData(segments, errorCorrectionLevel)
|
|
463
|
+
|
|
464
|
+
// If no version is found, data cannot be stored
|
|
465
|
+
if (!bestVersion) {
|
|
466
|
+
throw new Error('The amount of data is too big to be stored in a QR Code')
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
// If not specified, use min version as default
|
|
470
|
+
if (!version) {
|
|
471
|
+
version = bestVersion
|
|
472
|
+
|
|
473
|
+
// Check if the specified version can contain the data
|
|
474
|
+
} else if (version < bestVersion) {
|
|
475
|
+
throw new Error('\n' +
|
|
476
|
+
'The chosen QR Code version cannot contain this amount of data.\n' +
|
|
477
|
+
'Minimum version required to store current data is: ' + bestVersion + '.\n'
|
|
478
|
+
)
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
const dataBits = createData(version, errorCorrectionLevel, segments)
|
|
482
|
+
|
|
483
|
+
// Allocate matrix buffer
|
|
484
|
+
const moduleCount = Utils.getSymbolSize(version)
|
|
485
|
+
const modules = new BitMatrix(moduleCount)
|
|
486
|
+
|
|
487
|
+
// Add function modules
|
|
488
|
+
setupFinderPattern(modules, version)
|
|
489
|
+
setupTimingPattern(modules)
|
|
490
|
+
setupAlignmentPattern(modules, version)
|
|
491
|
+
|
|
492
|
+
// Add temporary dummy bits for format info just to set them as reserved.
|
|
493
|
+
// This is needed to prevent these bits from being masked by {@link MaskPattern.applyMask}
|
|
494
|
+
// since the masking operation must be performed only on the encoding region.
|
|
495
|
+
// These blocks will be replaced with correct values later in code.
|
|
496
|
+
setupFormatInfo(modules, errorCorrectionLevel, 0)
|
|
497
|
+
|
|
498
|
+
if (version >= 7) {
|
|
499
|
+
setupVersionInfo(modules, version)
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
// Add data codewords
|
|
503
|
+
setupData(modules, dataBits)
|
|
504
|
+
|
|
505
|
+
if (isNaN(maskPattern)) {
|
|
506
|
+
// Find best mask pattern
|
|
507
|
+
maskPattern = MaskPattern.getBestMask(modules,
|
|
508
|
+
setupFormatInfo.bind(null, modules, errorCorrectionLevel))
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
// Apply mask pattern
|
|
512
|
+
MaskPattern.applyMask(maskPattern, modules)
|
|
513
|
+
|
|
514
|
+
// Replace format info bits with correct values
|
|
515
|
+
setupFormatInfo(modules, errorCorrectionLevel, maskPattern)
|
|
516
|
+
|
|
517
|
+
return {
|
|
518
|
+
modules: modules,
|
|
519
|
+
version: version,
|
|
520
|
+
errorCorrectionLevel: errorCorrectionLevel,
|
|
521
|
+
maskPattern: maskPattern,
|
|
522
|
+
segments: segments
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
/**
|
|
527
|
+
* QR Code
|
|
528
|
+
*
|
|
529
|
+
* @param {String | Array} data Input data
|
|
530
|
+
* @param {Object} options Optional configurations
|
|
531
|
+
* @param {Number} options.version QR Code version
|
|
532
|
+
* @param {String} options.errorCorrectionLevel Error correction level
|
|
533
|
+
* @param {Function} options.toSJISFunc Helper func to convert utf8 to sjis
|
|
534
|
+
*/
|
|
535
|
+
exports.create = function create (data, options) {
|
|
536
|
+
if (typeof data === 'undefined' || data === '') {
|
|
537
|
+
throw new Error('No input text')
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
let errorCorrectionLevel = ECLevel.M
|
|
541
|
+
let version
|
|
542
|
+
let mask
|
|
543
|
+
|
|
544
|
+
if (typeof options !== 'undefined') {
|
|
545
|
+
// Use higher error correction level as default
|
|
546
|
+
errorCorrectionLevel = ECLevel.from(options.errorCorrectionLevel, ECLevel.M)
|
|
547
|
+
version = Version.from(options.version)
|
|
548
|
+
mask = MaskPattern.from(options.maskPattern)
|
|
549
|
+
|
|
550
|
+
if (options.toSJISFunc) {
|
|
551
|
+
Utils.setToSJISFunction(options.toSJISFunc)
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
return createSymbol(data, version, errorCorrectionLevel, mask)
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
|
|
559
|
+
/***/ }),
|
|
560
|
+
|
|
561
|
+
/***/ 208:
|
|
562
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
563
|
+
|
|
564
|
+
const VersionCheck = __webpack_require__(878)
|
|
565
|
+
const Regex = __webpack_require__(44)
|
|
566
|
+
|
|
567
|
+
/**
|
|
568
|
+
* Numeric mode encodes data from the decimal digit set (0 - 9)
|
|
569
|
+
* (byte values 30HEX to 39HEX).
|
|
570
|
+
* Normally, 3 data characters are represented by 10 bits.
|
|
571
|
+
*
|
|
572
|
+
* @type {Object}
|
|
573
|
+
*/
|
|
574
|
+
exports.NUMERIC = {
|
|
575
|
+
id: 'Numeric',
|
|
576
|
+
bit: 1 << 0,
|
|
577
|
+
ccBits: [10, 12, 14]
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
/**
|
|
581
|
+
* Alphanumeric mode encodes data from a set of 45 characters,
|
|
582
|
+
* i.e. 10 numeric digits (0 - 9),
|
|
583
|
+
* 26 alphabetic characters (A - Z),
|
|
584
|
+
* and 9 symbols (SP, $, %, *, +, -, ., /, :).
|
|
585
|
+
* Normally, two input characters are represented by 11 bits.
|
|
586
|
+
*
|
|
587
|
+
* @type {Object}
|
|
588
|
+
*/
|
|
589
|
+
exports.ALPHANUMERIC = {
|
|
590
|
+
id: 'Alphanumeric',
|
|
591
|
+
bit: 1 << 1,
|
|
592
|
+
ccBits: [9, 11, 13]
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
/**
|
|
596
|
+
* In byte mode, data is encoded at 8 bits per character.
|
|
597
|
+
*
|
|
598
|
+
* @type {Object}
|
|
599
|
+
*/
|
|
600
|
+
exports.BYTE = {
|
|
601
|
+
id: 'Byte',
|
|
602
|
+
bit: 1 << 2,
|
|
603
|
+
ccBits: [8, 16, 16]
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
/**
|
|
607
|
+
* The Kanji mode efficiently encodes Kanji characters in accordance with
|
|
608
|
+
* the Shift JIS system based on JIS X 0208.
|
|
609
|
+
* The Shift JIS values are shifted from the JIS X 0208 values.
|
|
610
|
+
* JIS X 0208 gives details of the shift coded representation.
|
|
611
|
+
* Each two-byte character value is compacted to a 13-bit binary codeword.
|
|
612
|
+
*
|
|
613
|
+
* @type {Object}
|
|
614
|
+
*/
|
|
615
|
+
exports.KANJI = {
|
|
616
|
+
id: 'Kanji',
|
|
617
|
+
bit: 1 << 3,
|
|
618
|
+
ccBits: [8, 10, 12]
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
/**
|
|
622
|
+
* Mixed mode will contain a sequences of data in a combination of any of
|
|
623
|
+
* the modes described above
|
|
624
|
+
*
|
|
625
|
+
* @type {Object}
|
|
626
|
+
*/
|
|
627
|
+
exports.MIXED = {
|
|
628
|
+
bit: -1
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
/**
|
|
632
|
+
* Returns the number of bits needed to store the data length
|
|
633
|
+
* according to QR Code specifications.
|
|
634
|
+
*
|
|
635
|
+
* @param {Mode} mode Data mode
|
|
636
|
+
* @param {Number} version QR Code version
|
|
637
|
+
* @return {Number} Number of bits
|
|
638
|
+
*/
|
|
639
|
+
exports.getCharCountIndicator = function getCharCountIndicator (mode, version) {
|
|
640
|
+
if (!mode.ccBits) throw new Error('Invalid mode: ' + mode)
|
|
641
|
+
|
|
642
|
+
if (!VersionCheck.isValid(version)) {
|
|
643
|
+
throw new Error('Invalid version: ' + version)
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
if (version >= 1 && version < 10) return mode.ccBits[0]
|
|
647
|
+
else if (version < 27) return mode.ccBits[1]
|
|
648
|
+
return mode.ccBits[2]
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
/**
|
|
652
|
+
* Returns the most efficient mode to store the specified data
|
|
653
|
+
*
|
|
654
|
+
* @param {String} dataStr Input data string
|
|
655
|
+
* @return {Mode} Best mode
|
|
656
|
+
*/
|
|
657
|
+
exports.getBestModeForData = function getBestModeForData (dataStr) {
|
|
658
|
+
if (Regex.testNumeric(dataStr)) return exports.NUMERIC
|
|
659
|
+
else if (Regex.testAlphanumeric(dataStr)) return exports.ALPHANUMERIC
|
|
660
|
+
else if (Regex.testKanji(dataStr)) return exports.KANJI
|
|
661
|
+
else return exports.BYTE
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
/**
|
|
665
|
+
* Return mode name as string
|
|
666
|
+
*
|
|
667
|
+
* @param {Mode} mode Mode object
|
|
668
|
+
* @returns {String} Mode name
|
|
669
|
+
*/
|
|
670
|
+
exports.toString = function toString (mode) {
|
|
671
|
+
if (mode && mode.id) return mode.id
|
|
672
|
+
throw new Error('Invalid mode')
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
/**
|
|
676
|
+
* Check if input param is a valid mode object
|
|
677
|
+
*
|
|
678
|
+
* @param {Mode} mode Mode object
|
|
679
|
+
* @returns {Boolean} True if valid mode, false otherwise
|
|
680
|
+
*/
|
|
681
|
+
exports.isValid = function isValid (mode) {
|
|
682
|
+
return mode && mode.bit && mode.ccBits
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
/**
|
|
686
|
+
* Get mode object from its name
|
|
687
|
+
*
|
|
688
|
+
* @param {String} string Mode name
|
|
689
|
+
* @returns {Mode} Mode object
|
|
690
|
+
*/
|
|
691
|
+
function fromString (string) {
|
|
692
|
+
if (typeof string !== 'string') {
|
|
693
|
+
throw new Error('Param is not a string')
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
const lcStr = string.toLowerCase()
|
|
697
|
+
|
|
698
|
+
switch (lcStr) {
|
|
699
|
+
case 'numeric':
|
|
700
|
+
return exports.NUMERIC
|
|
701
|
+
case 'alphanumeric':
|
|
702
|
+
return exports.ALPHANUMERIC
|
|
703
|
+
case 'kanji':
|
|
704
|
+
return exports.KANJI
|
|
705
|
+
case 'byte':
|
|
706
|
+
return exports.BYTE
|
|
707
|
+
default:
|
|
708
|
+
throw new Error('Unknown mode: ' + string)
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
/**
|
|
713
|
+
* Returns mode from a value.
|
|
714
|
+
* If value is not a valid mode, returns defaultValue
|
|
715
|
+
*
|
|
716
|
+
* @param {Mode|String} value Encoding mode
|
|
717
|
+
* @param {Mode} defaultValue Fallback value
|
|
718
|
+
* @return {Mode} Encoding mode
|
|
719
|
+
*/
|
|
720
|
+
exports.from = function from (value, defaultValue) {
|
|
721
|
+
if (exports.isValid(value)) {
|
|
722
|
+
return value
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
try {
|
|
726
|
+
return fromString(value)
|
|
727
|
+
} catch (e) {
|
|
728
|
+
return defaultValue
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
|
|
733
|
+
/***/ }),
|
|
734
|
+
|
|
735
|
+
/***/ 280:
|
|
736
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
737
|
+
|
|
738
|
+
const Utils = __webpack_require__(726)
|
|
739
|
+
|
|
740
|
+
function clearCanvas (ctx, canvas, size) {
|
|
741
|
+
ctx.clearRect(0, 0, canvas.width, canvas.height)
|
|
742
|
+
|
|
743
|
+
if (!canvas.style) canvas.style = {}
|
|
744
|
+
canvas.height = size
|
|
745
|
+
canvas.width = size
|
|
746
|
+
canvas.style.height = size + 'px'
|
|
747
|
+
canvas.style.width = size + 'px'
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
function getCanvasElement () {
|
|
751
|
+
try {
|
|
752
|
+
return document.createElement('canvas')
|
|
753
|
+
} catch (e) {
|
|
754
|
+
throw new Error('You need to specify a canvas element')
|
|
755
|
+
}
|
|
756
|
+
}
|
|
757
|
+
|
|
758
|
+
exports.render = function render (qrData, canvas, options) {
|
|
759
|
+
let opts = options
|
|
760
|
+
let canvasEl = canvas
|
|
761
|
+
|
|
762
|
+
if (typeof opts === 'undefined' && (!canvas || !canvas.getContext)) {
|
|
763
|
+
opts = canvas
|
|
764
|
+
canvas = undefined
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
if (!canvas) {
|
|
768
|
+
canvasEl = getCanvasElement()
|
|
769
|
+
}
|
|
770
|
+
|
|
771
|
+
opts = Utils.getOptions(opts)
|
|
772
|
+
const size = Utils.getImageWidth(qrData.modules.size, opts)
|
|
773
|
+
|
|
774
|
+
const ctx = canvasEl.getContext('2d')
|
|
775
|
+
const image = ctx.createImageData(size, size)
|
|
776
|
+
Utils.qrToImageData(image.data, qrData, opts)
|
|
777
|
+
|
|
778
|
+
clearCanvas(ctx, canvasEl, size)
|
|
779
|
+
ctx.putImageData(image, 0, 0)
|
|
780
|
+
|
|
781
|
+
return canvasEl
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
exports.renderToDataURL = function renderToDataURL (qrData, canvas, options) {
|
|
785
|
+
let opts = options
|
|
786
|
+
|
|
787
|
+
if (typeof opts === 'undefined' && (!canvas || !canvas.getContext)) {
|
|
788
|
+
opts = canvas
|
|
789
|
+
canvas = undefined
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
if (!opts) opts = {}
|
|
793
|
+
|
|
794
|
+
const canvasEl = exports.render(qrData, canvas, opts)
|
|
795
|
+
|
|
796
|
+
const type = opts.type || 'image/png'
|
|
797
|
+
const rendererOpts = opts.rendererOpts || {}
|
|
798
|
+
|
|
799
|
+
return canvasEl.toDataURL(type, rendererOpts.quality)
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
|
|
803
|
+
/***/ }),
|
|
804
|
+
|
|
805
|
+
/***/ 320:
|
|
806
|
+
/***/ ((module) => {
|
|
807
|
+
|
|
808
|
+
"use strict";
|
|
809
|
+
|
|
810
|
+
|
|
811
|
+
/******************************************************************************
|
|
812
|
+
* Created 2008-08-19.
|
|
813
|
+
*
|
|
814
|
+
* Dijkstra path-finding functions. Adapted from the Dijkstar Python project.
|
|
815
|
+
*
|
|
816
|
+
* Copyright (C) 2008
|
|
817
|
+
* Wyatt Baldwin <self@wyattbaldwin.com>
|
|
818
|
+
* All rights reserved
|
|
819
|
+
*
|
|
820
|
+
* Licensed under the MIT license.
|
|
821
|
+
*
|
|
822
|
+
* http://www.opensource.org/licenses/mit-license.php
|
|
823
|
+
*
|
|
824
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
825
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
826
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
827
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
828
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
829
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
830
|
+
* THE SOFTWARE.
|
|
831
|
+
*****************************************************************************/
|
|
832
|
+
var dijkstra = {
|
|
833
|
+
single_source_shortest_paths: function(graph, s, d) {
|
|
834
|
+
// Predecessor map for each node that has been encountered.
|
|
835
|
+
// node ID => predecessor node ID
|
|
836
|
+
var predecessors = {};
|
|
837
|
+
|
|
838
|
+
// Costs of shortest paths from s to all nodes encountered.
|
|
839
|
+
// node ID => cost
|
|
840
|
+
var costs = {};
|
|
841
|
+
costs[s] = 0;
|
|
842
|
+
|
|
843
|
+
// Costs of shortest paths from s to all nodes encountered; differs from
|
|
844
|
+
// `costs` in that it provides easy access to the node that currently has
|
|
845
|
+
// the known shortest path from s.
|
|
846
|
+
// XXX: Do we actually need both `costs` and `open`?
|
|
847
|
+
var open = dijkstra.PriorityQueue.make();
|
|
848
|
+
open.push(s, 0);
|
|
849
|
+
|
|
850
|
+
var closest,
|
|
851
|
+
u, v,
|
|
852
|
+
cost_of_s_to_u,
|
|
853
|
+
adjacent_nodes,
|
|
854
|
+
cost_of_e,
|
|
855
|
+
cost_of_s_to_u_plus_cost_of_e,
|
|
856
|
+
cost_of_s_to_v,
|
|
857
|
+
first_visit;
|
|
858
|
+
while (!open.empty()) {
|
|
859
|
+
// In the nodes remaining in graph that have a known cost from s,
|
|
860
|
+
// find the node, u, that currently has the shortest path from s.
|
|
861
|
+
closest = open.pop();
|
|
862
|
+
u = closest.value;
|
|
863
|
+
cost_of_s_to_u = closest.cost;
|
|
864
|
+
|
|
865
|
+
// Get nodes adjacent to u...
|
|
866
|
+
adjacent_nodes = graph[u] || {};
|
|
867
|
+
|
|
868
|
+
// ...and explore the edges that connect u to those nodes, updating
|
|
869
|
+
// the cost of the shortest paths to any or all of those nodes as
|
|
870
|
+
// necessary. v is the node across the current edge from u.
|
|
871
|
+
for (v in adjacent_nodes) {
|
|
872
|
+
if (adjacent_nodes.hasOwnProperty(v)) {
|
|
873
|
+
// Get the cost of the edge running from u to v.
|
|
874
|
+
cost_of_e = adjacent_nodes[v];
|
|
875
|
+
|
|
876
|
+
// Cost of s to u plus the cost of u to v across e--this is *a*
|
|
877
|
+
// cost from s to v that may or may not be less than the current
|
|
878
|
+
// known cost to v.
|
|
879
|
+
cost_of_s_to_u_plus_cost_of_e = cost_of_s_to_u + cost_of_e;
|
|
880
|
+
|
|
881
|
+
// If we haven't visited v yet OR if the current known cost from s to
|
|
882
|
+
// v is greater than the new cost we just found (cost of s to u plus
|
|
883
|
+
// cost of u to v across e), update v's cost in the cost list and
|
|
884
|
+
// update v's predecessor in the predecessor list (it's now u).
|
|
885
|
+
cost_of_s_to_v = costs[v];
|
|
886
|
+
first_visit = (typeof costs[v] === 'undefined');
|
|
887
|
+
if (first_visit || cost_of_s_to_v > cost_of_s_to_u_plus_cost_of_e) {
|
|
888
|
+
costs[v] = cost_of_s_to_u_plus_cost_of_e;
|
|
889
|
+
open.push(v, cost_of_s_to_u_plus_cost_of_e);
|
|
890
|
+
predecessors[v] = u;
|
|
891
|
+
}
|
|
892
|
+
}
|
|
893
|
+
}
|
|
894
|
+
}
|
|
895
|
+
|
|
896
|
+
if (typeof d !== 'undefined' && typeof costs[d] === 'undefined') {
|
|
897
|
+
var msg = ['Could not find a path from ', s, ' to ', d, '.'].join('');
|
|
898
|
+
throw new Error(msg);
|
|
899
|
+
}
|
|
900
|
+
|
|
901
|
+
return predecessors;
|
|
902
|
+
},
|
|
903
|
+
|
|
904
|
+
extract_shortest_path_from_predecessor_list: function(predecessors, d) {
|
|
905
|
+
var nodes = [];
|
|
906
|
+
var u = d;
|
|
907
|
+
var predecessor;
|
|
908
|
+
while (u) {
|
|
909
|
+
nodes.push(u);
|
|
910
|
+
predecessor = predecessors[u];
|
|
911
|
+
u = predecessors[u];
|
|
912
|
+
}
|
|
913
|
+
nodes.reverse();
|
|
914
|
+
return nodes;
|
|
915
|
+
},
|
|
916
|
+
|
|
917
|
+
find_path: function(graph, s, d) {
|
|
918
|
+
var predecessors = dijkstra.single_source_shortest_paths(graph, s, d);
|
|
919
|
+
return dijkstra.extract_shortest_path_from_predecessor_list(
|
|
920
|
+
predecessors, d);
|
|
921
|
+
},
|
|
922
|
+
|
|
923
|
+
/**
|
|
924
|
+
* A very naive priority queue implementation.
|
|
925
|
+
*/
|
|
926
|
+
PriorityQueue: {
|
|
927
|
+
make: function (opts) {
|
|
928
|
+
var T = dijkstra.PriorityQueue,
|
|
929
|
+
t = {},
|
|
930
|
+
key;
|
|
931
|
+
opts = opts || {};
|
|
932
|
+
for (key in T) {
|
|
933
|
+
if (T.hasOwnProperty(key)) {
|
|
934
|
+
t[key] = T[key];
|
|
935
|
+
}
|
|
936
|
+
}
|
|
937
|
+
t.queue = [];
|
|
938
|
+
t.sorter = opts.sorter || T.default_sorter;
|
|
939
|
+
return t;
|
|
940
|
+
},
|
|
941
|
+
|
|
942
|
+
default_sorter: function (a, b) {
|
|
943
|
+
return a.cost - b.cost;
|
|
944
|
+
},
|
|
945
|
+
|
|
946
|
+
/**
|
|
947
|
+
* Add a new item to the queue and ensure the highest priority element
|
|
948
|
+
* is at the front of the queue.
|
|
949
|
+
*/
|
|
950
|
+
push: function (value, cost) {
|
|
951
|
+
var item = {value: value, cost: cost};
|
|
952
|
+
this.queue.push(item);
|
|
953
|
+
this.queue.sort(this.sorter);
|
|
954
|
+
},
|
|
955
|
+
|
|
956
|
+
/**
|
|
957
|
+
* Return the highest priority element in the queue.
|
|
958
|
+
*/
|
|
959
|
+
pop: function () {
|
|
960
|
+
return this.queue.shift();
|
|
961
|
+
},
|
|
962
|
+
|
|
963
|
+
empty: function () {
|
|
964
|
+
return this.queue.length === 0;
|
|
965
|
+
}
|
|
966
|
+
}
|
|
967
|
+
};
|
|
968
|
+
|
|
969
|
+
|
|
970
|
+
// node.js module exports
|
|
971
|
+
if (true) {
|
|
972
|
+
module.exports = dijkstra;
|
|
973
|
+
}
|
|
974
|
+
|
|
975
|
+
|
|
976
|
+
/***/ }),
|
|
977
|
+
|
|
978
|
+
/***/ 332:
|
|
979
|
+
/***/ ((__unused_webpack_module, exports) => {
|
|
980
|
+
|
|
981
|
+
/**
|
|
982
|
+
* Data mask pattern reference
|
|
983
|
+
* @type {Object}
|
|
984
|
+
*/
|
|
985
|
+
exports.Patterns = {
|
|
986
|
+
PATTERN000: 0,
|
|
987
|
+
PATTERN001: 1,
|
|
988
|
+
PATTERN010: 2,
|
|
989
|
+
PATTERN011: 3,
|
|
990
|
+
PATTERN100: 4,
|
|
991
|
+
PATTERN101: 5,
|
|
992
|
+
PATTERN110: 6,
|
|
993
|
+
PATTERN111: 7
|
|
994
|
+
}
|
|
995
|
+
|
|
996
|
+
/**
|
|
997
|
+
* Weighted penalty scores for the undesirable features
|
|
998
|
+
* @type {Object}
|
|
999
|
+
*/
|
|
1000
|
+
const PenaltyScores = {
|
|
1001
|
+
N1: 3,
|
|
1002
|
+
N2: 3,
|
|
1003
|
+
N3: 40,
|
|
1004
|
+
N4: 10
|
|
1005
|
+
}
|
|
1006
|
+
|
|
1007
|
+
/**
|
|
1008
|
+
* Check if mask pattern value is valid
|
|
1009
|
+
*
|
|
1010
|
+
* @param {Number} mask Mask pattern
|
|
1011
|
+
* @return {Boolean} true if valid, false otherwise
|
|
1012
|
+
*/
|
|
1013
|
+
exports.isValid = function isValid (mask) {
|
|
1014
|
+
return mask != null && mask !== '' && !isNaN(mask) && mask >= 0 && mask <= 7
|
|
1015
|
+
}
|
|
1016
|
+
|
|
1017
|
+
/**
|
|
1018
|
+
* Returns mask pattern from a value.
|
|
1019
|
+
* If value is not valid, returns undefined
|
|
1020
|
+
*
|
|
1021
|
+
* @param {Number|String} value Mask pattern value
|
|
1022
|
+
* @return {Number} Valid mask pattern or undefined
|
|
1023
|
+
*/
|
|
1024
|
+
exports.from = function from (value) {
|
|
1025
|
+
return exports.isValid(value) ? parseInt(value, 10) : undefined
|
|
1026
|
+
}
|
|
1027
|
+
|
|
1028
|
+
/**
|
|
1029
|
+
* Find adjacent modules in row/column with the same color
|
|
1030
|
+
* and assign a penalty value.
|
|
1031
|
+
*
|
|
1032
|
+
* Points: N1 + i
|
|
1033
|
+
* i is the amount by which the number of adjacent modules of the same color exceeds 5
|
|
1034
|
+
*/
|
|
1035
|
+
exports.getPenaltyN1 = function getPenaltyN1 (data) {
|
|
1036
|
+
const size = data.size
|
|
1037
|
+
let points = 0
|
|
1038
|
+
let sameCountCol = 0
|
|
1039
|
+
let sameCountRow = 0
|
|
1040
|
+
let lastCol = null
|
|
1041
|
+
let lastRow = null
|
|
1042
|
+
|
|
1043
|
+
for (let row = 0; row < size; row++) {
|
|
1044
|
+
sameCountCol = sameCountRow = 0
|
|
1045
|
+
lastCol = lastRow = null
|
|
1046
|
+
|
|
1047
|
+
for (let col = 0; col < size; col++) {
|
|
1048
|
+
let module = data.get(row, col)
|
|
1049
|
+
if (module === lastCol) {
|
|
1050
|
+
sameCountCol++
|
|
1051
|
+
} else {
|
|
1052
|
+
if (sameCountCol >= 5) points += PenaltyScores.N1 + (sameCountCol - 5)
|
|
1053
|
+
lastCol = module
|
|
1054
|
+
sameCountCol = 1
|
|
1055
|
+
}
|
|
1056
|
+
|
|
1057
|
+
module = data.get(col, row)
|
|
1058
|
+
if (module === lastRow) {
|
|
1059
|
+
sameCountRow++
|
|
1060
|
+
} else {
|
|
1061
|
+
if (sameCountRow >= 5) points += PenaltyScores.N1 + (sameCountRow - 5)
|
|
1062
|
+
lastRow = module
|
|
1063
|
+
sameCountRow = 1
|
|
1064
|
+
}
|
|
1065
|
+
}
|
|
1066
|
+
|
|
1067
|
+
if (sameCountCol >= 5) points += PenaltyScores.N1 + (sameCountCol - 5)
|
|
1068
|
+
if (sameCountRow >= 5) points += PenaltyScores.N1 + (sameCountRow - 5)
|
|
1069
|
+
}
|
|
1070
|
+
|
|
1071
|
+
return points
|
|
1072
|
+
}
|
|
1073
|
+
|
|
1074
|
+
/**
|
|
1075
|
+
* Find 2x2 blocks with the same color and assign a penalty value
|
|
1076
|
+
*
|
|
1077
|
+
* Points: N2 * (m - 1) * (n - 1)
|
|
1078
|
+
*/
|
|
1079
|
+
exports.getPenaltyN2 = function getPenaltyN2 (data) {
|
|
1080
|
+
const size = data.size
|
|
1081
|
+
let points = 0
|
|
1082
|
+
|
|
1083
|
+
for (let row = 0; row < size - 1; row++) {
|
|
1084
|
+
for (let col = 0; col < size - 1; col++) {
|
|
1085
|
+
const last = data.get(row, col) +
|
|
1086
|
+
data.get(row, col + 1) +
|
|
1087
|
+
data.get(row + 1, col) +
|
|
1088
|
+
data.get(row + 1, col + 1)
|
|
1089
|
+
|
|
1090
|
+
if (last === 4 || last === 0) points++
|
|
1091
|
+
}
|
|
1092
|
+
}
|
|
1093
|
+
|
|
1094
|
+
return points * PenaltyScores.N2
|
|
1095
|
+
}
|
|
1096
|
+
|
|
1097
|
+
/**
|
|
1098
|
+
* Find 1:1:3:1:1 ratio (dark:light:dark:light:dark) pattern in row/column,
|
|
1099
|
+
* preceded or followed by light area 4 modules wide
|
|
1100
|
+
*
|
|
1101
|
+
* Points: N3 * number of pattern found
|
|
1102
|
+
*/
|
|
1103
|
+
exports.getPenaltyN3 = function getPenaltyN3 (data) {
|
|
1104
|
+
const size = data.size
|
|
1105
|
+
let points = 0
|
|
1106
|
+
let bitsCol = 0
|
|
1107
|
+
let bitsRow = 0
|
|
1108
|
+
|
|
1109
|
+
for (let row = 0; row < size; row++) {
|
|
1110
|
+
bitsCol = bitsRow = 0
|
|
1111
|
+
for (let col = 0; col < size; col++) {
|
|
1112
|
+
bitsCol = ((bitsCol << 1) & 0x7FF) | data.get(row, col)
|
|
1113
|
+
if (col >= 10 && (bitsCol === 0x5D0 || bitsCol === 0x05D)) points++
|
|
1114
|
+
|
|
1115
|
+
bitsRow = ((bitsRow << 1) & 0x7FF) | data.get(col, row)
|
|
1116
|
+
if (col >= 10 && (bitsRow === 0x5D0 || bitsRow === 0x05D)) points++
|
|
1117
|
+
}
|
|
1118
|
+
}
|
|
1119
|
+
|
|
1120
|
+
return points * PenaltyScores.N3
|
|
1121
|
+
}
|
|
1122
|
+
|
|
1123
|
+
/**
|
|
1124
|
+
* Calculate proportion of dark modules in entire symbol
|
|
1125
|
+
*
|
|
1126
|
+
* Points: N4 * k
|
|
1127
|
+
*
|
|
1128
|
+
* k is the rating of the deviation of the proportion of dark modules
|
|
1129
|
+
* in the symbol from 50% in steps of 5%
|
|
1130
|
+
*/
|
|
1131
|
+
exports.getPenaltyN4 = function getPenaltyN4 (data) {
|
|
1132
|
+
let darkCount = 0
|
|
1133
|
+
const modulesCount = data.data.length
|
|
1134
|
+
|
|
1135
|
+
for (let i = 0; i < modulesCount; i++) darkCount += data.data[i]
|
|
1136
|
+
|
|
1137
|
+
const k = Math.abs(Math.ceil((darkCount * 100 / modulesCount) / 5) - 10)
|
|
1138
|
+
|
|
1139
|
+
return k * PenaltyScores.N4
|
|
1140
|
+
}
|
|
1141
|
+
|
|
1142
|
+
/**
|
|
1143
|
+
* Return mask value at given position
|
|
1144
|
+
*
|
|
1145
|
+
* @param {Number} maskPattern Pattern reference value
|
|
1146
|
+
* @param {Number} i Row
|
|
1147
|
+
* @param {Number} j Column
|
|
1148
|
+
* @return {Boolean} Mask value
|
|
1149
|
+
*/
|
|
1150
|
+
function getMaskAt (maskPattern, i, j) {
|
|
1151
|
+
switch (maskPattern) {
|
|
1152
|
+
case exports.Patterns.PATTERN000: return (i + j) % 2 === 0
|
|
1153
|
+
case exports.Patterns.PATTERN001: return i % 2 === 0
|
|
1154
|
+
case exports.Patterns.PATTERN010: return j % 3 === 0
|
|
1155
|
+
case exports.Patterns.PATTERN011: return (i + j) % 3 === 0
|
|
1156
|
+
case exports.Patterns.PATTERN100: return (Math.floor(i / 2) + Math.floor(j / 3)) % 2 === 0
|
|
1157
|
+
case exports.Patterns.PATTERN101: return (i * j) % 2 + (i * j) % 3 === 0
|
|
1158
|
+
case exports.Patterns.PATTERN110: return ((i * j) % 2 + (i * j) % 3) % 2 === 0
|
|
1159
|
+
case exports.Patterns.PATTERN111: return ((i * j) % 3 + (i + j) % 2) % 2 === 0
|
|
1160
|
+
|
|
1161
|
+
default: throw new Error('bad maskPattern:' + maskPattern)
|
|
1162
|
+
}
|
|
1163
|
+
}
|
|
1164
|
+
|
|
1165
|
+
/**
|
|
1166
|
+
* Apply a mask pattern to a BitMatrix
|
|
1167
|
+
*
|
|
1168
|
+
* @param {Number} pattern Pattern reference number
|
|
1169
|
+
* @param {BitMatrix} data BitMatrix data
|
|
1170
|
+
*/
|
|
1171
|
+
exports.applyMask = function applyMask (pattern, data) {
|
|
1172
|
+
const size = data.size
|
|
1173
|
+
|
|
1174
|
+
for (let col = 0; col < size; col++) {
|
|
1175
|
+
for (let row = 0; row < size; row++) {
|
|
1176
|
+
if (data.isReserved(row, col)) continue
|
|
1177
|
+
data.xor(row, col, getMaskAt(pattern, row, col))
|
|
1178
|
+
}
|
|
1179
|
+
}
|
|
1180
|
+
}
|
|
1181
|
+
|
|
1182
|
+
/**
|
|
1183
|
+
* Returns the best mask pattern for data
|
|
1184
|
+
*
|
|
1185
|
+
* @param {BitMatrix} data
|
|
1186
|
+
* @return {Number} Mask pattern reference number
|
|
1187
|
+
*/
|
|
1188
|
+
exports.getBestMask = function getBestMask (data, setupFormatFunc) {
|
|
1189
|
+
const numPatterns = Object.keys(exports.Patterns).length
|
|
1190
|
+
let bestPattern = 0
|
|
1191
|
+
let lowerPenalty = Infinity
|
|
1192
|
+
|
|
1193
|
+
for (let p = 0; p < numPatterns; p++) {
|
|
1194
|
+
setupFormatFunc(p)
|
|
1195
|
+
exports.applyMask(p, data)
|
|
1196
|
+
|
|
1197
|
+
// Calculate penalty
|
|
1198
|
+
const penalty =
|
|
1199
|
+
exports.getPenaltyN1(data) +
|
|
1200
|
+
exports.getPenaltyN2(data) +
|
|
1201
|
+
exports.getPenaltyN3(data) +
|
|
1202
|
+
exports.getPenaltyN4(data)
|
|
1203
|
+
|
|
1204
|
+
// Undo previously applied mask
|
|
1205
|
+
exports.applyMask(p, data)
|
|
1206
|
+
|
|
1207
|
+
if (penalty < lowerPenalty) {
|
|
1208
|
+
lowerPenalty = penalty
|
|
1209
|
+
bestPattern = p
|
|
1210
|
+
}
|
|
1211
|
+
}
|
|
1212
|
+
|
|
1213
|
+
return bestPattern
|
|
1214
|
+
}
|
|
1215
|
+
|
|
1216
|
+
|
|
1217
|
+
/***/ }),
|
|
1218
|
+
|
|
1219
|
+
/***/ 333:
|
|
1220
|
+
/***/ ((module) => {
|
|
1221
|
+
|
|
1222
|
+
// can-promise has a crash in some versions of react native that dont have
|
|
1223
|
+
// standard global objects
|
|
1224
|
+
// https://github.com/soldair/node-qrcode/issues/157
|
|
1225
|
+
|
|
1226
|
+
module.exports = function () {
|
|
1227
|
+
return typeof Promise === 'function' && Promise.prototype && Promise.prototype.then
|
|
1228
|
+
}
|
|
1229
|
+
|
|
1230
|
+
|
|
1231
|
+
/***/ }),
|
|
1232
|
+
|
|
1233
|
+
/***/ 357:
|
|
1234
|
+
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
1235
|
+
|
|
1236
|
+
const Mode = __webpack_require__(208)
|
|
1237
|
+
|
|
1238
|
+
function NumericData (data) {
|
|
1239
|
+
this.mode = Mode.NUMERIC
|
|
1240
|
+
this.data = data.toString()
|
|
1241
|
+
}
|
|
1242
|
+
|
|
1243
|
+
NumericData.getBitsLength = function getBitsLength (length) {
|
|
1244
|
+
return 10 * Math.floor(length / 3) + ((length % 3) ? ((length % 3) * 3 + 1) : 0)
|
|
1245
|
+
}
|
|
1246
|
+
|
|
1247
|
+
NumericData.prototype.getLength = function getLength () {
|
|
1248
|
+
return this.data.length
|
|
1249
|
+
}
|
|
1250
|
+
|
|
1251
|
+
NumericData.prototype.getBitsLength = function getBitsLength () {
|
|
1252
|
+
return NumericData.getBitsLength(this.data.length)
|
|
1253
|
+
}
|
|
1254
|
+
|
|
1255
|
+
NumericData.prototype.write = function write (bitBuffer) {
|
|
1256
|
+
let i, group, value
|
|
1257
|
+
|
|
1258
|
+
// The input data string is divided into groups of three digits,
|
|
1259
|
+
// and each group is converted to its 10-bit binary equivalent.
|
|
1260
|
+
for (i = 0; i + 3 <= this.data.length; i += 3) {
|
|
1261
|
+
group = this.data.substr(i, 3)
|
|
1262
|
+
value = parseInt(group, 10)
|
|
1263
|
+
|
|
1264
|
+
bitBuffer.put(value, 10)
|
|
1265
|
+
}
|
|
1266
|
+
|
|
1267
|
+
// If the number of input digits is not an exact multiple of three,
|
|
1268
|
+
// the final one or two digits are converted to 4 or 7 bits respectively.
|
|
1269
|
+
const remainingNum = this.data.length - i
|
|
1270
|
+
if (remainingNum > 0) {
|
|
1271
|
+
group = this.data.substr(i)
|
|
1272
|
+
value = parseInt(group, 10)
|
|
1273
|
+
|
|
1274
|
+
bitBuffer.put(value, remainingNum * 3 + 1)
|
|
1275
|
+
}
|
|
1276
|
+
}
|
|
1277
|
+
|
|
1278
|
+
module.exports = NumericData
|
|
1279
|
+
|
|
1280
|
+
|
|
1281
|
+
/***/ }),
|
|
1282
|
+
|
|
1283
|
+
/***/ 375:
|
|
1284
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
1285
|
+
|
|
1286
|
+
const Utils = __webpack_require__(726)
|
|
1287
|
+
|
|
1288
|
+
function getColorAttrib (color, attrib) {
|
|
1289
|
+
const alpha = color.a / 255
|
|
1290
|
+
const str = attrib + '="' + color.hex + '"'
|
|
1291
|
+
|
|
1292
|
+
return alpha < 1
|
|
1293
|
+
? str + ' ' + attrib + '-opacity="' + alpha.toFixed(2).slice(1) + '"'
|
|
1294
|
+
: str
|
|
1295
|
+
}
|
|
1296
|
+
|
|
1297
|
+
function svgCmd (cmd, x, y) {
|
|
1298
|
+
let str = cmd + x
|
|
1299
|
+
if (typeof y !== 'undefined') str += ' ' + y
|
|
1300
|
+
|
|
1301
|
+
return str
|
|
1302
|
+
}
|
|
1303
|
+
|
|
1304
|
+
function qrToPath (data, size, margin) {
|
|
1305
|
+
let path = ''
|
|
1306
|
+
let moveBy = 0
|
|
1307
|
+
let newRow = false
|
|
1308
|
+
let lineLength = 0
|
|
1309
|
+
|
|
1310
|
+
for (let i = 0; i < data.length; i++) {
|
|
1311
|
+
const col = Math.floor(i % size)
|
|
1312
|
+
const row = Math.floor(i / size)
|
|
1313
|
+
|
|
1314
|
+
if (!col && !newRow) newRow = true
|
|
1315
|
+
|
|
1316
|
+
if (data[i]) {
|
|
1317
|
+
lineLength++
|
|
1318
|
+
|
|
1319
|
+
if (!(i > 0 && col > 0 && data[i - 1])) {
|
|
1320
|
+
path += newRow
|
|
1321
|
+
? svgCmd('M', col + margin, 0.5 + row + margin)
|
|
1322
|
+
: svgCmd('m', moveBy, 0)
|
|
1323
|
+
|
|
1324
|
+
moveBy = 0
|
|
1325
|
+
newRow = false
|
|
1326
|
+
}
|
|
1327
|
+
|
|
1328
|
+
if (!(col + 1 < size && data[i + 1])) {
|
|
1329
|
+
path += svgCmd('h', lineLength)
|
|
1330
|
+
lineLength = 0
|
|
1331
|
+
}
|
|
1332
|
+
} else {
|
|
1333
|
+
moveBy++
|
|
1334
|
+
}
|
|
1335
|
+
}
|
|
1336
|
+
|
|
1337
|
+
return path
|
|
1338
|
+
}
|
|
1339
|
+
|
|
1340
|
+
exports.render = function render (qrData, options, cb) {
|
|
1341
|
+
const opts = Utils.getOptions(options)
|
|
1342
|
+
const size = qrData.modules.size
|
|
1343
|
+
const data = qrData.modules.data
|
|
1344
|
+
const qrcodesize = size + opts.margin * 2
|
|
1345
|
+
|
|
1346
|
+
const bg = !opts.color.light.a
|
|
1347
|
+
? ''
|
|
1348
|
+
: '<path ' + getColorAttrib(opts.color.light, 'fill') +
|
|
1349
|
+
' d="M0 0h' + qrcodesize + 'v' + qrcodesize + 'H0z"/>'
|
|
1350
|
+
|
|
1351
|
+
const path =
|
|
1352
|
+
'<path ' + getColorAttrib(opts.color.dark, 'stroke') +
|
|
1353
|
+
' d="' + qrToPath(data, size, opts.margin) + '"/>'
|
|
1354
|
+
|
|
1355
|
+
const viewBox = 'viewBox="' + '0 0 ' + qrcodesize + ' ' + qrcodesize + '"'
|
|
1356
|
+
|
|
1357
|
+
const width = !opts.width ? '' : 'width="' + opts.width + '" height="' + opts.width + '" '
|
|
1358
|
+
|
|
1359
|
+
const svgTag = '<svg xmlns="http://www.w3.org/2000/svg" ' + width + viewBox + ' shape-rendering="crispEdges">' + bg + path + '</svg>\n'
|
|
1360
|
+
|
|
1361
|
+
if (typeof cb === 'function') {
|
|
1362
|
+
cb(null, svgTag)
|
|
1363
|
+
}
|
|
1364
|
+
|
|
1365
|
+
return svgTag
|
|
1366
|
+
}
|
|
1367
|
+
|
|
1368
|
+
|
|
1369
|
+
/***/ }),
|
|
1370
|
+
|
|
1371
|
+
/***/ 421:
|
|
1372
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
1373
|
+
|
|
1374
|
+
/**
|
|
1375
|
+
* Alignment pattern are fixed reference pattern in defined positions
|
|
1376
|
+
* in a matrix symbology, which enables the decode software to re-synchronise
|
|
1377
|
+
* the coordinate mapping of the image modules in the event of moderate amounts
|
|
1378
|
+
* of distortion of the image.
|
|
1379
|
+
*
|
|
1380
|
+
* Alignment patterns are present only in QR Code symbols of version 2 or larger
|
|
1381
|
+
* and their number depends on the symbol version.
|
|
1382
|
+
*/
|
|
1383
|
+
|
|
1384
|
+
const getSymbolSize = (__webpack_require__(886).getSymbolSize)
|
|
1385
|
+
|
|
1386
|
+
/**
|
|
1387
|
+
* Calculate the row/column coordinates of the center module of each alignment pattern
|
|
1388
|
+
* for the specified QR Code version.
|
|
1389
|
+
*
|
|
1390
|
+
* The alignment patterns are positioned symmetrically on either side of the diagonal
|
|
1391
|
+
* running from the top left corner of the symbol to the bottom right corner.
|
|
1392
|
+
*
|
|
1393
|
+
* Since positions are simmetrical only half of the coordinates are returned.
|
|
1394
|
+
* Each item of the array will represent in turn the x and y coordinate.
|
|
1395
|
+
* @see {@link getPositions}
|
|
1396
|
+
*
|
|
1397
|
+
* @param {Number} version QR Code version
|
|
1398
|
+
* @return {Array} Array of coordinate
|
|
1399
|
+
*/
|
|
1400
|
+
exports.getRowColCoords = function getRowColCoords (version) {
|
|
1401
|
+
if (version === 1) return []
|
|
1402
|
+
|
|
1403
|
+
const posCount = Math.floor(version / 7) + 2
|
|
1404
|
+
const size = getSymbolSize(version)
|
|
1405
|
+
const intervals = size === 145 ? 26 : Math.ceil((size - 13) / (2 * posCount - 2)) * 2
|
|
1406
|
+
const positions = [size - 7] // Last coord is always (size - 7)
|
|
1407
|
+
|
|
1408
|
+
for (let i = 1; i < posCount - 1; i++) {
|
|
1409
|
+
positions[i] = positions[i - 1] - intervals
|
|
1410
|
+
}
|
|
1411
|
+
|
|
1412
|
+
positions.push(6) // First coord is always 6
|
|
1413
|
+
|
|
1414
|
+
return positions.reverse()
|
|
1415
|
+
}
|
|
1416
|
+
|
|
1417
|
+
/**
|
|
1418
|
+
* Returns an array containing the positions of each alignment pattern.
|
|
1419
|
+
* Each array's element represent the center point of the pattern as (x, y) coordinates
|
|
1420
|
+
*
|
|
1421
|
+
* Coordinates are calculated expanding the row/column coordinates returned by {@link getRowColCoords}
|
|
1422
|
+
* and filtering out the items that overlaps with finder pattern
|
|
1423
|
+
*
|
|
1424
|
+
* @example
|
|
1425
|
+
* For a Version 7 symbol {@link getRowColCoords} returns values 6, 22 and 38.
|
|
1426
|
+
* The alignment patterns, therefore, are to be centered on (row, column)
|
|
1427
|
+
* positions (6,22), (22,6), (22,22), (22,38), (38,22), (38,38).
|
|
1428
|
+
* Note that the coordinates (6,6), (6,38), (38,6) are occupied by finder patterns
|
|
1429
|
+
* and are not therefore used for alignment patterns.
|
|
1430
|
+
*
|
|
1431
|
+
* let pos = getPositions(7)
|
|
1432
|
+
* // [[6,22], [22,6], [22,22], [22,38], [38,22], [38,38]]
|
|
1433
|
+
*
|
|
1434
|
+
* @param {Number} version QR Code version
|
|
1435
|
+
* @return {Array} Array of coordinates
|
|
1436
|
+
*/
|
|
1437
|
+
exports.getPositions = function getPositions (version) {
|
|
1438
|
+
const coords = []
|
|
1439
|
+
const pos = exports.getRowColCoords(version)
|
|
1440
|
+
const posLength = pos.length
|
|
1441
|
+
|
|
1442
|
+
for (let i = 0; i < posLength; i++) {
|
|
1443
|
+
for (let j = 0; j < posLength; j++) {
|
|
1444
|
+
// Skip if position is occupied by finder patterns
|
|
1445
|
+
if ((i === 0 && j === 0) || // top-left
|
|
1446
|
+
(i === 0 && j === posLength - 1) || // bottom-left
|
|
1447
|
+
(i === posLength - 1 && j === 0)) { // top-right
|
|
1448
|
+
continue
|
|
1449
|
+
}
|
|
1450
|
+
|
|
1451
|
+
coords.push([pos[i], pos[j]])
|
|
1452
|
+
}
|
|
1453
|
+
}
|
|
1454
|
+
|
|
1455
|
+
return coords
|
|
1456
|
+
}
|
|
1457
|
+
|
|
1458
|
+
|
|
1459
|
+
/***/ }),
|
|
1460
|
+
|
|
1461
|
+
/***/ 426:
|
|
1462
|
+
/***/ ((module) => {
|
|
1463
|
+
|
|
1464
|
+
"use strict";
|
|
1465
|
+
module.exports = __WEBPACK_EXTERNAL_MODULE__426__;
|
|
1466
|
+
|
|
1467
|
+
/***/ }),
|
|
1468
|
+
|
|
1469
|
+
/***/ 427:
|
|
1470
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
1471
|
+
|
|
1472
|
+
const Utils = __webpack_require__(886)
|
|
1473
|
+
const ECCode = __webpack_require__(518)
|
|
1474
|
+
const ECLevel = __webpack_require__(953)
|
|
1475
|
+
const Mode = __webpack_require__(208)
|
|
1476
|
+
const VersionCheck = __webpack_require__(878)
|
|
1477
|
+
|
|
1478
|
+
// Generator polynomial used to encode version information
|
|
1479
|
+
const G18 = (1 << 12) | (1 << 11) | (1 << 10) | (1 << 9) | (1 << 8) | (1 << 5) | (1 << 2) | (1 << 0)
|
|
1480
|
+
const G18_BCH = Utils.getBCHDigit(G18)
|
|
1481
|
+
|
|
1482
|
+
function getBestVersionForDataLength (mode, length, errorCorrectionLevel) {
|
|
1483
|
+
for (let currentVersion = 1; currentVersion <= 40; currentVersion++) {
|
|
1484
|
+
if (length <= exports.getCapacity(currentVersion, errorCorrectionLevel, mode)) {
|
|
1485
|
+
return currentVersion
|
|
1486
|
+
}
|
|
1487
|
+
}
|
|
1488
|
+
|
|
1489
|
+
return undefined
|
|
1490
|
+
}
|
|
1491
|
+
|
|
1492
|
+
function getReservedBitsCount (mode, version) {
|
|
1493
|
+
// Character count indicator + mode indicator bits
|
|
1494
|
+
return Mode.getCharCountIndicator(mode, version) + 4
|
|
1495
|
+
}
|
|
1496
|
+
|
|
1497
|
+
function getTotalBitsFromDataArray (segments, version) {
|
|
1498
|
+
let totalBits = 0
|
|
1499
|
+
|
|
1500
|
+
segments.forEach(function (data) {
|
|
1501
|
+
const reservedBits = getReservedBitsCount(data.mode, version)
|
|
1502
|
+
totalBits += reservedBits + data.getBitsLength()
|
|
1503
|
+
})
|
|
1504
|
+
|
|
1505
|
+
return totalBits
|
|
1506
|
+
}
|
|
1507
|
+
|
|
1508
|
+
function getBestVersionForMixedData (segments, errorCorrectionLevel) {
|
|
1509
|
+
for (let currentVersion = 1; currentVersion <= 40; currentVersion++) {
|
|
1510
|
+
const length = getTotalBitsFromDataArray(segments, currentVersion)
|
|
1511
|
+
if (length <= exports.getCapacity(currentVersion, errorCorrectionLevel, Mode.MIXED)) {
|
|
1512
|
+
return currentVersion
|
|
1513
|
+
}
|
|
1514
|
+
}
|
|
1515
|
+
|
|
1516
|
+
return undefined
|
|
1517
|
+
}
|
|
1518
|
+
|
|
1519
|
+
/**
|
|
1520
|
+
* Returns version number from a value.
|
|
1521
|
+
* If value is not a valid version, returns defaultValue
|
|
1522
|
+
*
|
|
1523
|
+
* @param {Number|String} value QR Code version
|
|
1524
|
+
* @param {Number} defaultValue Fallback value
|
|
1525
|
+
* @return {Number} QR Code version number
|
|
1526
|
+
*/
|
|
1527
|
+
exports.from = function from (value, defaultValue) {
|
|
1528
|
+
if (VersionCheck.isValid(value)) {
|
|
1529
|
+
return parseInt(value, 10)
|
|
1530
|
+
}
|
|
1531
|
+
|
|
1532
|
+
return defaultValue
|
|
1533
|
+
}
|
|
1534
|
+
|
|
1535
|
+
/**
|
|
1536
|
+
* Returns how much data can be stored with the specified QR code version
|
|
1537
|
+
* and error correction level
|
|
1538
|
+
*
|
|
1539
|
+
* @param {Number} version QR Code version (1-40)
|
|
1540
|
+
* @param {Number} errorCorrectionLevel Error correction level
|
|
1541
|
+
* @param {Mode} mode Data mode
|
|
1542
|
+
* @return {Number} Quantity of storable data
|
|
1543
|
+
*/
|
|
1544
|
+
exports.getCapacity = function getCapacity (version, errorCorrectionLevel, mode) {
|
|
1545
|
+
if (!VersionCheck.isValid(version)) {
|
|
1546
|
+
throw new Error('Invalid QR Code version')
|
|
1547
|
+
}
|
|
1548
|
+
|
|
1549
|
+
// Use Byte mode as default
|
|
1550
|
+
if (typeof mode === 'undefined') mode = Mode.BYTE
|
|
1551
|
+
|
|
1552
|
+
// Total codewords for this QR code version (Data + Error correction)
|
|
1553
|
+
const totalCodewords = Utils.getSymbolTotalCodewords(version)
|
|
1554
|
+
|
|
1555
|
+
// Total number of error correction codewords
|
|
1556
|
+
const ecTotalCodewords = ECCode.getTotalCodewordsCount(version, errorCorrectionLevel)
|
|
1557
|
+
|
|
1558
|
+
// Total number of data codewords
|
|
1559
|
+
const dataTotalCodewordsBits = (totalCodewords - ecTotalCodewords) * 8
|
|
1560
|
+
|
|
1561
|
+
if (mode === Mode.MIXED) return dataTotalCodewordsBits
|
|
1562
|
+
|
|
1563
|
+
const usableBits = dataTotalCodewordsBits - getReservedBitsCount(mode, version)
|
|
1564
|
+
|
|
1565
|
+
// Return max number of storable codewords
|
|
1566
|
+
switch (mode) {
|
|
1567
|
+
case Mode.NUMERIC:
|
|
1568
|
+
return Math.floor((usableBits / 10) * 3)
|
|
1569
|
+
|
|
1570
|
+
case Mode.ALPHANUMERIC:
|
|
1571
|
+
return Math.floor((usableBits / 11) * 2)
|
|
1572
|
+
|
|
1573
|
+
case Mode.KANJI:
|
|
1574
|
+
return Math.floor(usableBits / 13)
|
|
1575
|
+
|
|
1576
|
+
case Mode.BYTE:
|
|
1577
|
+
default:
|
|
1578
|
+
return Math.floor(usableBits / 8)
|
|
1579
|
+
}
|
|
1580
|
+
}
|
|
1581
|
+
|
|
1582
|
+
/**
|
|
1583
|
+
* Returns the minimum version needed to contain the amount of data
|
|
1584
|
+
*
|
|
1585
|
+
* @param {Segment} data Segment of data
|
|
1586
|
+
* @param {Number} [errorCorrectionLevel=H] Error correction level
|
|
1587
|
+
* @param {Mode} mode Data mode
|
|
1588
|
+
* @return {Number} QR Code version
|
|
1589
|
+
*/
|
|
1590
|
+
exports.getBestVersionForData = function getBestVersionForData (data, errorCorrectionLevel) {
|
|
1591
|
+
let seg
|
|
1592
|
+
|
|
1593
|
+
const ecl = ECLevel.from(errorCorrectionLevel, ECLevel.M)
|
|
1594
|
+
|
|
1595
|
+
if (Array.isArray(data)) {
|
|
1596
|
+
if (data.length > 1) {
|
|
1597
|
+
return getBestVersionForMixedData(data, ecl)
|
|
1598
|
+
}
|
|
1599
|
+
|
|
1600
|
+
if (data.length === 0) {
|
|
1601
|
+
return 1
|
|
1602
|
+
}
|
|
1603
|
+
|
|
1604
|
+
seg = data[0]
|
|
1605
|
+
} else {
|
|
1606
|
+
seg = data
|
|
1607
|
+
}
|
|
1608
|
+
|
|
1609
|
+
return getBestVersionForDataLength(seg.mode, seg.getLength(), ecl)
|
|
1610
|
+
}
|
|
1611
|
+
|
|
1612
|
+
/**
|
|
1613
|
+
* Returns version information with relative error correction bits
|
|
1614
|
+
*
|
|
1615
|
+
* The version information is included in QR Code symbols of version 7 or larger.
|
|
1616
|
+
* It consists of an 18-bit sequence containing 6 data bits,
|
|
1617
|
+
* with 12 error correction bits calculated using the (18, 6) Golay code.
|
|
1618
|
+
*
|
|
1619
|
+
* @param {Number} version QR Code version
|
|
1620
|
+
* @return {Number} Encoded version info bits
|
|
1621
|
+
*/
|
|
1622
|
+
exports.getEncodedBits = function getEncodedBits (version) {
|
|
1623
|
+
if (!VersionCheck.isValid(version) || version < 7) {
|
|
1624
|
+
throw new Error('Invalid QR Code version')
|
|
1625
|
+
}
|
|
1626
|
+
|
|
1627
|
+
let d = version << 12
|
|
1628
|
+
|
|
1629
|
+
while (Utils.getBCHDigit(d) - G18_BCH >= 0) {
|
|
1630
|
+
d ^= (G18 << (Utils.getBCHDigit(d) - G18_BCH))
|
|
1631
|
+
}
|
|
1632
|
+
|
|
1633
|
+
return (version << 12) | d
|
|
1634
|
+
}
|
|
1635
|
+
|
|
1636
|
+
|
|
1637
|
+
/***/ }),
|
|
1638
|
+
|
|
1639
|
+
/***/ 433:
|
|
1640
|
+
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
1641
|
+
|
|
1642
|
+
const Mode = __webpack_require__(208)
|
|
1643
|
+
|
|
1644
|
+
/**
|
|
1645
|
+
* Array of characters available in alphanumeric mode
|
|
1646
|
+
*
|
|
1647
|
+
* As per QR Code specification, to each character
|
|
1648
|
+
* is assigned a value from 0 to 44 which in this case coincides
|
|
1649
|
+
* with the array index
|
|
1650
|
+
*
|
|
1651
|
+
* @type {Array}
|
|
1652
|
+
*/
|
|
1653
|
+
const ALPHA_NUM_CHARS = [
|
|
1654
|
+
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
|
|
1655
|
+
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
|
|
1656
|
+
'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
|
|
1657
|
+
' ', '$', '%', '*', '+', '-', '.', '/', ':'
|
|
1658
|
+
]
|
|
1659
|
+
|
|
1660
|
+
function AlphanumericData (data) {
|
|
1661
|
+
this.mode = Mode.ALPHANUMERIC
|
|
1662
|
+
this.data = data
|
|
1663
|
+
}
|
|
1664
|
+
|
|
1665
|
+
AlphanumericData.getBitsLength = function getBitsLength (length) {
|
|
1666
|
+
return 11 * Math.floor(length / 2) + 6 * (length % 2)
|
|
1667
|
+
}
|
|
1668
|
+
|
|
1669
|
+
AlphanumericData.prototype.getLength = function getLength () {
|
|
1670
|
+
return this.data.length
|
|
1671
|
+
}
|
|
1672
|
+
|
|
1673
|
+
AlphanumericData.prototype.getBitsLength = function getBitsLength () {
|
|
1674
|
+
return AlphanumericData.getBitsLength(this.data.length)
|
|
1675
|
+
}
|
|
1676
|
+
|
|
1677
|
+
AlphanumericData.prototype.write = function write (bitBuffer) {
|
|
1678
|
+
let i
|
|
1679
|
+
|
|
1680
|
+
// Input data characters are divided into groups of two characters
|
|
1681
|
+
// and encoded as 11-bit binary codes.
|
|
1682
|
+
for (i = 0; i + 2 <= this.data.length; i += 2) {
|
|
1683
|
+
// The character value of the first character is multiplied by 45
|
|
1684
|
+
let value = ALPHA_NUM_CHARS.indexOf(this.data[i]) * 45
|
|
1685
|
+
|
|
1686
|
+
// The character value of the second digit is added to the product
|
|
1687
|
+
value += ALPHA_NUM_CHARS.indexOf(this.data[i + 1])
|
|
1688
|
+
|
|
1689
|
+
// The sum is then stored as 11-bit binary number
|
|
1690
|
+
bitBuffer.put(value, 11)
|
|
1691
|
+
}
|
|
1692
|
+
|
|
1693
|
+
// If the number of input data characters is not a multiple of two,
|
|
1694
|
+
// the character value of the final character is encoded as a 6-bit binary number.
|
|
1695
|
+
if (this.data.length % 2) {
|
|
1696
|
+
bitBuffer.put(ALPHA_NUM_CHARS.indexOf(this.data[i]), 6)
|
|
1697
|
+
}
|
|
1698
|
+
}
|
|
1699
|
+
|
|
1700
|
+
module.exports = AlphanumericData
|
|
1701
|
+
|
|
1702
|
+
|
|
1703
|
+
/***/ }),
|
|
1704
|
+
|
|
1705
|
+
/***/ 491:
|
|
1706
|
+
/***/ ((module) => {
|
|
1707
|
+
|
|
1708
|
+
"use strict";
|
|
1709
|
+
module.exports = __WEBPACK_EXTERNAL_MODULE__491__;
|
|
1710
|
+
|
|
1711
|
+
/***/ }),
|
|
1712
|
+
|
|
1713
|
+
/***/ 518:
|
|
1714
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
1715
|
+
|
|
1716
|
+
const ECLevel = __webpack_require__(953)
|
|
1717
|
+
|
|
1718
|
+
const EC_BLOCKS_TABLE = [
|
|
1719
|
+
// L M Q H
|
|
1720
|
+
1, 1, 1, 1,
|
|
1721
|
+
1, 1, 1, 1,
|
|
1722
|
+
1, 1, 2, 2,
|
|
1723
|
+
1, 2, 2, 4,
|
|
1724
|
+
1, 2, 4, 4,
|
|
1725
|
+
2, 4, 4, 4,
|
|
1726
|
+
2, 4, 6, 5,
|
|
1727
|
+
2, 4, 6, 6,
|
|
1728
|
+
2, 5, 8, 8,
|
|
1729
|
+
4, 5, 8, 8,
|
|
1730
|
+
4, 5, 8, 11,
|
|
1731
|
+
4, 8, 10, 11,
|
|
1732
|
+
4, 9, 12, 16,
|
|
1733
|
+
4, 9, 16, 16,
|
|
1734
|
+
6, 10, 12, 18,
|
|
1735
|
+
6, 10, 17, 16,
|
|
1736
|
+
6, 11, 16, 19,
|
|
1737
|
+
6, 13, 18, 21,
|
|
1738
|
+
7, 14, 21, 25,
|
|
1739
|
+
8, 16, 20, 25,
|
|
1740
|
+
8, 17, 23, 25,
|
|
1741
|
+
9, 17, 23, 34,
|
|
1742
|
+
9, 18, 25, 30,
|
|
1743
|
+
10, 20, 27, 32,
|
|
1744
|
+
12, 21, 29, 35,
|
|
1745
|
+
12, 23, 34, 37,
|
|
1746
|
+
12, 25, 34, 40,
|
|
1747
|
+
13, 26, 35, 42,
|
|
1748
|
+
14, 28, 38, 45,
|
|
1749
|
+
15, 29, 40, 48,
|
|
1750
|
+
16, 31, 43, 51,
|
|
1751
|
+
17, 33, 45, 54,
|
|
1752
|
+
18, 35, 48, 57,
|
|
1753
|
+
19, 37, 51, 60,
|
|
1754
|
+
19, 38, 53, 63,
|
|
1755
|
+
20, 40, 56, 66,
|
|
1756
|
+
21, 43, 59, 70,
|
|
1757
|
+
22, 45, 62, 74,
|
|
1758
|
+
24, 47, 65, 77,
|
|
1759
|
+
25, 49, 68, 81
|
|
1760
|
+
]
|
|
1761
|
+
|
|
1762
|
+
const EC_CODEWORDS_TABLE = [
|
|
1763
|
+
// L M Q H
|
|
1764
|
+
7, 10, 13, 17,
|
|
1765
|
+
10, 16, 22, 28,
|
|
1766
|
+
15, 26, 36, 44,
|
|
1767
|
+
20, 36, 52, 64,
|
|
1768
|
+
26, 48, 72, 88,
|
|
1769
|
+
36, 64, 96, 112,
|
|
1770
|
+
40, 72, 108, 130,
|
|
1771
|
+
48, 88, 132, 156,
|
|
1772
|
+
60, 110, 160, 192,
|
|
1773
|
+
72, 130, 192, 224,
|
|
1774
|
+
80, 150, 224, 264,
|
|
1775
|
+
96, 176, 260, 308,
|
|
1776
|
+
104, 198, 288, 352,
|
|
1777
|
+
120, 216, 320, 384,
|
|
1778
|
+
132, 240, 360, 432,
|
|
1779
|
+
144, 280, 408, 480,
|
|
1780
|
+
168, 308, 448, 532,
|
|
1781
|
+
180, 338, 504, 588,
|
|
1782
|
+
196, 364, 546, 650,
|
|
1783
|
+
224, 416, 600, 700,
|
|
1784
|
+
224, 442, 644, 750,
|
|
1785
|
+
252, 476, 690, 816,
|
|
1786
|
+
270, 504, 750, 900,
|
|
1787
|
+
300, 560, 810, 960,
|
|
1788
|
+
312, 588, 870, 1050,
|
|
1789
|
+
336, 644, 952, 1110,
|
|
1790
|
+
360, 700, 1020, 1200,
|
|
1791
|
+
390, 728, 1050, 1260,
|
|
1792
|
+
420, 784, 1140, 1350,
|
|
1793
|
+
450, 812, 1200, 1440,
|
|
1794
|
+
480, 868, 1290, 1530,
|
|
1795
|
+
510, 924, 1350, 1620,
|
|
1796
|
+
540, 980, 1440, 1710,
|
|
1797
|
+
570, 1036, 1530, 1800,
|
|
1798
|
+
570, 1064, 1590, 1890,
|
|
1799
|
+
600, 1120, 1680, 1980,
|
|
1800
|
+
630, 1204, 1770, 2100,
|
|
1801
|
+
660, 1260, 1860, 2220,
|
|
1802
|
+
720, 1316, 1950, 2310,
|
|
1803
|
+
750, 1372, 2040, 2430
|
|
1804
|
+
]
|
|
1805
|
+
|
|
1806
|
+
/**
|
|
1807
|
+
* Returns the number of error correction block that the QR Code should contain
|
|
1808
|
+
* for the specified version and error correction level.
|
|
1809
|
+
*
|
|
1810
|
+
* @param {Number} version QR Code version
|
|
1811
|
+
* @param {Number} errorCorrectionLevel Error correction level
|
|
1812
|
+
* @return {Number} Number of error correction blocks
|
|
1813
|
+
*/
|
|
1814
|
+
exports.getBlocksCount = function getBlocksCount (version, errorCorrectionLevel) {
|
|
1815
|
+
switch (errorCorrectionLevel) {
|
|
1816
|
+
case ECLevel.L:
|
|
1817
|
+
return EC_BLOCKS_TABLE[(version - 1) * 4 + 0]
|
|
1818
|
+
case ECLevel.M:
|
|
1819
|
+
return EC_BLOCKS_TABLE[(version - 1) * 4 + 1]
|
|
1820
|
+
case ECLevel.Q:
|
|
1821
|
+
return EC_BLOCKS_TABLE[(version - 1) * 4 + 2]
|
|
1822
|
+
case ECLevel.H:
|
|
1823
|
+
return EC_BLOCKS_TABLE[(version - 1) * 4 + 3]
|
|
1824
|
+
default:
|
|
1825
|
+
return undefined
|
|
1826
|
+
}
|
|
1827
|
+
}
|
|
1828
|
+
|
|
1829
|
+
/**
|
|
1830
|
+
* Returns the number of error correction codewords to use for the specified
|
|
1831
|
+
* version and error correction level.
|
|
1832
|
+
*
|
|
1833
|
+
* @param {Number} version QR Code version
|
|
1834
|
+
* @param {Number} errorCorrectionLevel Error correction level
|
|
1835
|
+
* @return {Number} Number of error correction codewords
|
|
1836
|
+
*/
|
|
1837
|
+
exports.getTotalCodewordsCount = function getTotalCodewordsCount (version, errorCorrectionLevel) {
|
|
1838
|
+
switch (errorCorrectionLevel) {
|
|
1839
|
+
case ECLevel.L:
|
|
1840
|
+
return EC_CODEWORDS_TABLE[(version - 1) * 4 + 0]
|
|
1841
|
+
case ECLevel.M:
|
|
1842
|
+
return EC_CODEWORDS_TABLE[(version - 1) * 4 + 1]
|
|
1843
|
+
case ECLevel.Q:
|
|
1844
|
+
return EC_CODEWORDS_TABLE[(version - 1) * 4 + 2]
|
|
1845
|
+
case ECLevel.H:
|
|
1846
|
+
return EC_CODEWORDS_TABLE[(version - 1) * 4 + 3]
|
|
1847
|
+
default:
|
|
1848
|
+
return undefined
|
|
1849
|
+
}
|
|
1850
|
+
}
|
|
1851
|
+
|
|
1852
|
+
|
|
1853
|
+
/***/ }),
|
|
1854
|
+
|
|
1855
|
+
/***/ 565:
|
|
1856
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
1857
|
+
|
|
1858
|
+
const Utils = __webpack_require__(886)
|
|
1859
|
+
|
|
1860
|
+
const G15 = (1 << 10) | (1 << 8) | (1 << 5) | (1 << 4) | (1 << 2) | (1 << 1) | (1 << 0)
|
|
1861
|
+
const G15_MASK = (1 << 14) | (1 << 12) | (1 << 10) | (1 << 4) | (1 << 1)
|
|
1862
|
+
const G15_BCH = Utils.getBCHDigit(G15)
|
|
1863
|
+
|
|
1864
|
+
/**
|
|
1865
|
+
* Returns format information with relative error correction bits
|
|
1866
|
+
*
|
|
1867
|
+
* The format information is a 15-bit sequence containing 5 data bits,
|
|
1868
|
+
* with 10 error correction bits calculated using the (15, 5) BCH code.
|
|
1869
|
+
*
|
|
1870
|
+
* @param {Number} errorCorrectionLevel Error correction level
|
|
1871
|
+
* @param {Number} mask Mask pattern
|
|
1872
|
+
* @return {Number} Encoded format information bits
|
|
1873
|
+
*/
|
|
1874
|
+
exports.getEncodedBits = function getEncodedBits (errorCorrectionLevel, mask) {
|
|
1875
|
+
const data = ((errorCorrectionLevel.bit << 3) | mask)
|
|
1876
|
+
let d = data << 10
|
|
1877
|
+
|
|
1878
|
+
while (Utils.getBCHDigit(d) - G15_BCH >= 0) {
|
|
1879
|
+
d ^= (G15 << (Utils.getBCHDigit(d) - G15_BCH))
|
|
1880
|
+
}
|
|
1881
|
+
|
|
1882
|
+
// xor final data with mask pattern in order to ensure that
|
|
1883
|
+
// no combination of Error Correction Level and data mask pattern
|
|
1884
|
+
// will result in an all-zero data string
|
|
1885
|
+
return ((data << 10) | d) ^ G15_MASK
|
|
1886
|
+
}
|
|
1887
|
+
|
|
1888
|
+
|
|
1889
|
+
/***/ }),
|
|
1890
|
+
|
|
1891
|
+
/***/ 583:
|
|
1892
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
1893
|
+
|
|
1894
|
+
var __webpack_unused_export__;
|
|
1895
|
+
|
|
1896
|
+
const canPromise = __webpack_require__(333)
|
|
1897
|
+
|
|
1898
|
+
const QRCode = __webpack_require__(157)
|
|
1899
|
+
const CanvasRenderer = __webpack_require__(280)
|
|
1900
|
+
const SvgRenderer = __webpack_require__(375)
|
|
1901
|
+
|
|
1902
|
+
function renderCanvas (renderFunc, canvas, text, opts, cb) {
|
|
1903
|
+
const args = [].slice.call(arguments, 1)
|
|
1904
|
+
const argsNum = args.length
|
|
1905
|
+
const isLastArgCb = typeof args[argsNum - 1] === 'function'
|
|
1906
|
+
|
|
1907
|
+
if (!isLastArgCb && !canPromise()) {
|
|
1908
|
+
throw new Error('Callback required as last argument')
|
|
1909
|
+
}
|
|
1910
|
+
|
|
1911
|
+
if (isLastArgCb) {
|
|
1912
|
+
if (argsNum < 2) {
|
|
1913
|
+
throw new Error('Too few arguments provided')
|
|
1914
|
+
}
|
|
1915
|
+
|
|
1916
|
+
if (argsNum === 2) {
|
|
1917
|
+
cb = text
|
|
1918
|
+
text = canvas
|
|
1919
|
+
canvas = opts = undefined
|
|
1920
|
+
} else if (argsNum === 3) {
|
|
1921
|
+
if (canvas.getContext && typeof cb === 'undefined') {
|
|
1922
|
+
cb = opts
|
|
1923
|
+
opts = undefined
|
|
1924
|
+
} else {
|
|
1925
|
+
cb = opts
|
|
1926
|
+
opts = text
|
|
1927
|
+
text = canvas
|
|
1928
|
+
canvas = undefined
|
|
1929
|
+
}
|
|
1930
|
+
}
|
|
1931
|
+
} else {
|
|
1932
|
+
if (argsNum < 1) {
|
|
1933
|
+
throw new Error('Too few arguments provided')
|
|
1934
|
+
}
|
|
1935
|
+
|
|
1936
|
+
if (argsNum === 1) {
|
|
1937
|
+
text = canvas
|
|
1938
|
+
canvas = opts = undefined
|
|
1939
|
+
} else if (argsNum === 2 && !canvas.getContext) {
|
|
1940
|
+
opts = text
|
|
1941
|
+
text = canvas
|
|
1942
|
+
canvas = undefined
|
|
1943
|
+
}
|
|
1944
|
+
|
|
1945
|
+
return new Promise(function (resolve, reject) {
|
|
1946
|
+
try {
|
|
1947
|
+
const data = QRCode.create(text, opts)
|
|
1948
|
+
resolve(renderFunc(data, canvas, opts))
|
|
1949
|
+
} catch (e) {
|
|
1950
|
+
reject(e)
|
|
1951
|
+
}
|
|
1952
|
+
})
|
|
1953
|
+
}
|
|
1954
|
+
|
|
1955
|
+
try {
|
|
1956
|
+
const data = QRCode.create(text, opts)
|
|
1957
|
+
cb(null, renderFunc(data, canvas, opts))
|
|
1958
|
+
} catch (e) {
|
|
1959
|
+
cb(e)
|
|
1960
|
+
}
|
|
1961
|
+
}
|
|
1962
|
+
|
|
1963
|
+
__webpack_unused_export__ = QRCode.create
|
|
1964
|
+
__webpack_unused_export__ = renderCanvas.bind(null, CanvasRenderer.render)
|
|
1965
|
+
__webpack_unused_export__ = renderCanvas.bind(null, CanvasRenderer.renderToDataURL)
|
|
1966
|
+
|
|
1967
|
+
// only svg for now.
|
|
1968
|
+
exports.toString = renderCanvas.bind(null, function (data, _, opts) {
|
|
1969
|
+
return SvgRenderer.render(data, opts)
|
|
1970
|
+
})
|
|
1971
|
+
|
|
1972
|
+
|
|
1973
|
+
/***/ }),
|
|
1974
|
+
|
|
1975
|
+
/***/ 663:
|
|
1976
|
+
/***/ ((module) => {
|
|
1977
|
+
|
|
1978
|
+
"use strict";
|
|
1979
|
+
module.exports = __WEBPACK_EXTERNAL_MODULE__663__;
|
|
1980
|
+
|
|
1981
|
+
/***/ }),
|
|
1982
|
+
|
|
1983
|
+
/***/ 713:
|
|
1984
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
1985
|
+
|
|
1986
|
+
const GF = __webpack_require__(731)
|
|
1987
|
+
|
|
1988
|
+
/**
|
|
1989
|
+
* Multiplies two polynomials inside Galois Field
|
|
1990
|
+
*
|
|
1991
|
+
* @param {Uint8Array} p1 Polynomial
|
|
1992
|
+
* @param {Uint8Array} p2 Polynomial
|
|
1993
|
+
* @return {Uint8Array} Product of p1 and p2
|
|
1994
|
+
*/
|
|
1995
|
+
exports.mul = function mul (p1, p2) {
|
|
1996
|
+
const coeff = new Uint8Array(p1.length + p2.length - 1)
|
|
1997
|
+
|
|
1998
|
+
for (let i = 0; i < p1.length; i++) {
|
|
1999
|
+
for (let j = 0; j < p2.length; j++) {
|
|
2000
|
+
coeff[i + j] ^= GF.mul(p1[i], p2[j])
|
|
2001
|
+
}
|
|
2002
|
+
}
|
|
2003
|
+
|
|
2004
|
+
return coeff
|
|
2005
|
+
}
|
|
2006
|
+
|
|
2007
|
+
/**
|
|
2008
|
+
* Calculate the remainder of polynomials division
|
|
2009
|
+
*
|
|
2010
|
+
* @param {Uint8Array} divident Polynomial
|
|
2011
|
+
* @param {Uint8Array} divisor Polynomial
|
|
2012
|
+
* @return {Uint8Array} Remainder
|
|
2013
|
+
*/
|
|
2014
|
+
exports.mod = function mod (divident, divisor) {
|
|
2015
|
+
let result = new Uint8Array(divident)
|
|
2016
|
+
|
|
2017
|
+
while ((result.length - divisor.length) >= 0) {
|
|
2018
|
+
const coeff = result[0]
|
|
2019
|
+
|
|
2020
|
+
for (let i = 0; i < divisor.length; i++) {
|
|
2021
|
+
result[i] ^= GF.mul(divisor[i], coeff)
|
|
2022
|
+
}
|
|
2023
|
+
|
|
2024
|
+
// remove all zeros from buffer head
|
|
2025
|
+
let offset = 0
|
|
2026
|
+
while (offset < result.length && result[offset] === 0) offset++
|
|
2027
|
+
result = result.slice(offset)
|
|
2028
|
+
}
|
|
2029
|
+
|
|
2030
|
+
return result
|
|
2031
|
+
}
|
|
2032
|
+
|
|
2033
|
+
/**
|
|
2034
|
+
* Generate an irreducible generator polynomial of specified degree
|
|
2035
|
+
* (used by Reed-Solomon encoder)
|
|
2036
|
+
*
|
|
2037
|
+
* @param {Number} degree Degree of the generator polynomial
|
|
2038
|
+
* @return {Uint8Array} Buffer containing polynomial coefficients
|
|
2039
|
+
*/
|
|
2040
|
+
exports.generateECPolynomial = function generateECPolynomial (degree) {
|
|
2041
|
+
let poly = new Uint8Array([1])
|
|
2042
|
+
for (let i = 0; i < degree; i++) {
|
|
2043
|
+
poly = exports.mul(poly, new Uint8Array([1, GF.exp(i)]))
|
|
2044
|
+
}
|
|
2045
|
+
|
|
2046
|
+
return poly
|
|
2047
|
+
}
|
|
2048
|
+
|
|
2049
|
+
|
|
2050
|
+
/***/ }),
|
|
2051
|
+
|
|
2052
|
+
/***/ 726:
|
|
2053
|
+
/***/ ((__unused_webpack_module, exports) => {
|
|
2054
|
+
|
|
2055
|
+
function hex2rgba (hex) {
|
|
2056
|
+
if (typeof hex === 'number') {
|
|
2057
|
+
hex = hex.toString()
|
|
2058
|
+
}
|
|
2059
|
+
|
|
2060
|
+
if (typeof hex !== 'string') {
|
|
2061
|
+
throw new Error('Color should be defined as hex string')
|
|
2062
|
+
}
|
|
2063
|
+
|
|
2064
|
+
let hexCode = hex.slice().replace('#', '').split('')
|
|
2065
|
+
if (hexCode.length < 3 || hexCode.length === 5 || hexCode.length > 8) {
|
|
2066
|
+
throw new Error('Invalid hex color: ' + hex)
|
|
2067
|
+
}
|
|
2068
|
+
|
|
2069
|
+
// Convert from short to long form (fff -> ffffff)
|
|
2070
|
+
if (hexCode.length === 3 || hexCode.length === 4) {
|
|
2071
|
+
hexCode = Array.prototype.concat.apply([], hexCode.map(function (c) {
|
|
2072
|
+
return [c, c]
|
|
2073
|
+
}))
|
|
2074
|
+
}
|
|
2075
|
+
|
|
2076
|
+
// Add default alpha value
|
|
2077
|
+
if (hexCode.length === 6) hexCode.push('F', 'F')
|
|
2078
|
+
|
|
2079
|
+
const hexValue = parseInt(hexCode.join(''), 16)
|
|
2080
|
+
|
|
2081
|
+
return {
|
|
2082
|
+
r: (hexValue >> 24) & 255,
|
|
2083
|
+
g: (hexValue >> 16) & 255,
|
|
2084
|
+
b: (hexValue >> 8) & 255,
|
|
2085
|
+
a: hexValue & 255,
|
|
2086
|
+
hex: '#' + hexCode.slice(0, 6).join('')
|
|
2087
|
+
}
|
|
2088
|
+
}
|
|
2089
|
+
|
|
2090
|
+
exports.getOptions = function getOptions (options) {
|
|
2091
|
+
if (!options) options = {}
|
|
2092
|
+
if (!options.color) options.color = {}
|
|
2093
|
+
|
|
2094
|
+
const margin = typeof options.margin === 'undefined' ||
|
|
2095
|
+
options.margin === null ||
|
|
2096
|
+
options.margin < 0
|
|
2097
|
+
? 4
|
|
2098
|
+
: options.margin
|
|
2099
|
+
|
|
2100
|
+
const width = options.width && options.width >= 21 ? options.width : undefined
|
|
2101
|
+
const scale = options.scale || 4
|
|
2102
|
+
|
|
2103
|
+
return {
|
|
2104
|
+
width: width,
|
|
2105
|
+
scale: width ? 4 : scale,
|
|
2106
|
+
margin: margin,
|
|
2107
|
+
color: {
|
|
2108
|
+
dark: hex2rgba(options.color.dark || '#000000ff'),
|
|
2109
|
+
light: hex2rgba(options.color.light || '#ffffffff')
|
|
2110
|
+
},
|
|
2111
|
+
type: options.type,
|
|
2112
|
+
rendererOpts: options.rendererOpts || {}
|
|
2113
|
+
}
|
|
2114
|
+
}
|
|
2115
|
+
|
|
2116
|
+
exports.getScale = function getScale (qrSize, opts) {
|
|
2117
|
+
return opts.width && opts.width >= qrSize + opts.margin * 2
|
|
2118
|
+
? opts.width / (qrSize + opts.margin * 2)
|
|
2119
|
+
: opts.scale
|
|
2120
|
+
}
|
|
2121
|
+
|
|
2122
|
+
exports.getImageWidth = function getImageWidth (qrSize, opts) {
|
|
2123
|
+
const scale = exports.getScale(qrSize, opts)
|
|
2124
|
+
return Math.floor((qrSize + opts.margin * 2) * scale)
|
|
2125
|
+
}
|
|
2126
|
+
|
|
2127
|
+
exports.qrToImageData = function qrToImageData (imgData, qr, opts) {
|
|
2128
|
+
const size = qr.modules.size
|
|
2129
|
+
const data = qr.modules.data
|
|
2130
|
+
const scale = exports.getScale(size, opts)
|
|
2131
|
+
const symbolSize = Math.floor((size + opts.margin * 2) * scale)
|
|
2132
|
+
const scaledMargin = opts.margin * scale
|
|
2133
|
+
const palette = [opts.color.light, opts.color.dark]
|
|
2134
|
+
|
|
2135
|
+
for (let i = 0; i < symbolSize; i++) {
|
|
2136
|
+
for (let j = 0; j < symbolSize; j++) {
|
|
2137
|
+
let posDst = (i * symbolSize + j) * 4
|
|
2138
|
+
let pxColor = opts.color.light
|
|
2139
|
+
|
|
2140
|
+
if (i >= scaledMargin && j >= scaledMargin &&
|
|
2141
|
+
i < symbolSize - scaledMargin && j < symbolSize - scaledMargin) {
|
|
2142
|
+
const iSrc = Math.floor((i - scaledMargin) / scale)
|
|
2143
|
+
const jSrc = Math.floor((j - scaledMargin) / scale)
|
|
2144
|
+
pxColor = palette[data[iSrc * size + jSrc] ? 1 : 0]
|
|
2145
|
+
}
|
|
2146
|
+
|
|
2147
|
+
imgData[posDst++] = pxColor.r
|
|
2148
|
+
imgData[posDst++] = pxColor.g
|
|
2149
|
+
imgData[posDst++] = pxColor.b
|
|
2150
|
+
imgData[posDst] = pxColor.a
|
|
2151
|
+
}
|
|
2152
|
+
}
|
|
2153
|
+
}
|
|
2154
|
+
|
|
2155
|
+
|
|
2156
|
+
/***/ }),
|
|
2157
|
+
|
|
2158
|
+
/***/ 731:
|
|
2159
|
+
/***/ ((__unused_webpack_module, exports) => {
|
|
2160
|
+
|
|
2161
|
+
const EXP_TABLE = new Uint8Array(512)
|
|
2162
|
+
const LOG_TABLE = new Uint8Array(256)
|
|
2163
|
+
/**
|
|
2164
|
+
* Precompute the log and anti-log tables for faster computation later
|
|
2165
|
+
*
|
|
2166
|
+
* For each possible value in the galois field 2^8, we will pre-compute
|
|
2167
|
+
* the logarithm and anti-logarithm (exponential) of this value
|
|
2168
|
+
*
|
|
2169
|
+
* ref {@link https://en.wikiversity.org/wiki/Reed%E2%80%93Solomon_codes_for_coders#Introduction_to_mathematical_fields}
|
|
2170
|
+
*/
|
|
2171
|
+
;(function initTables () {
|
|
2172
|
+
let x = 1
|
|
2173
|
+
for (let i = 0; i < 255; i++) {
|
|
2174
|
+
EXP_TABLE[i] = x
|
|
2175
|
+
LOG_TABLE[x] = i
|
|
2176
|
+
|
|
2177
|
+
x <<= 1 // multiply by 2
|
|
2178
|
+
|
|
2179
|
+
// The QR code specification says to use byte-wise modulo 100011101 arithmetic.
|
|
2180
|
+
// This means that when a number is 256 or larger, it should be XORed with 0x11D.
|
|
2181
|
+
if (x & 0x100) { // similar to x >= 256, but a lot faster (because 0x100 == 256)
|
|
2182
|
+
x ^= 0x11D
|
|
2183
|
+
}
|
|
2184
|
+
}
|
|
2185
|
+
|
|
2186
|
+
// Optimization: double the size of the anti-log table so that we don't need to mod 255 to
|
|
2187
|
+
// stay inside the bounds (because we will mainly use this table for the multiplication of
|
|
2188
|
+
// two GF numbers, no more).
|
|
2189
|
+
// @see {@link mul}
|
|
2190
|
+
for (let i = 255; i < 512; i++) {
|
|
2191
|
+
EXP_TABLE[i] = EXP_TABLE[i - 255]
|
|
2192
|
+
}
|
|
2193
|
+
}())
|
|
2194
|
+
|
|
2195
|
+
/**
|
|
2196
|
+
* Returns log value of n inside Galois Field
|
|
2197
|
+
*
|
|
2198
|
+
* @param {Number} n
|
|
2199
|
+
* @return {Number}
|
|
2200
|
+
*/
|
|
2201
|
+
exports.log = function log (n) {
|
|
2202
|
+
if (n < 1) throw new Error('log(' + n + ')')
|
|
2203
|
+
return LOG_TABLE[n]
|
|
2204
|
+
}
|
|
2205
|
+
|
|
2206
|
+
/**
|
|
2207
|
+
* Returns anti-log value of n inside Galois Field
|
|
2208
|
+
*
|
|
2209
|
+
* @param {Number} n
|
|
2210
|
+
* @return {Number}
|
|
2211
|
+
*/
|
|
2212
|
+
exports.exp = function exp (n) {
|
|
2213
|
+
return EXP_TABLE[n]
|
|
2214
|
+
}
|
|
2215
|
+
|
|
2216
|
+
/**
|
|
2217
|
+
* Multiplies two number inside Galois Field
|
|
2218
|
+
*
|
|
2219
|
+
* @param {Number} x
|
|
2220
|
+
* @param {Number} y
|
|
2221
|
+
* @return {Number}
|
|
2222
|
+
*/
|
|
2223
|
+
exports.mul = function mul (x, y) {
|
|
2224
|
+
if (x === 0 || y === 0) return 0
|
|
2225
|
+
|
|
2226
|
+
// should be EXP_TABLE[(LOG_TABLE[x] + LOG_TABLE[y]) % 255] if EXP_TABLE wasn't oversized
|
|
2227
|
+
// @see {@link initTables}
|
|
2228
|
+
return EXP_TABLE[LOG_TABLE[x] + LOG_TABLE[y]]
|
|
2229
|
+
}
|
|
2230
|
+
|
|
2231
|
+
|
|
2232
|
+
/***/ }),
|
|
2233
|
+
|
|
2234
|
+
/***/ 756:
|
|
2235
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
2236
|
+
|
|
2237
|
+
const getSymbolSize = (__webpack_require__(886).getSymbolSize)
|
|
2238
|
+
const FINDER_PATTERN_SIZE = 7
|
|
2239
|
+
|
|
2240
|
+
/**
|
|
2241
|
+
* Returns an array containing the positions of each finder pattern.
|
|
2242
|
+
* Each array's element represent the top-left point of the pattern as (x, y) coordinates
|
|
2243
|
+
*
|
|
2244
|
+
* @param {Number} version QR Code version
|
|
2245
|
+
* @return {Array} Array of coordinates
|
|
2246
|
+
*/
|
|
2247
|
+
exports.getPositions = function getPositions (version) {
|
|
2248
|
+
const size = getSymbolSize(version)
|
|
2249
|
+
|
|
2250
|
+
return [
|
|
2251
|
+
// top-left
|
|
2252
|
+
[0, 0],
|
|
2253
|
+
// top-right
|
|
2254
|
+
[size - FINDER_PATTERN_SIZE, 0],
|
|
2255
|
+
// bottom-left
|
|
2256
|
+
[0, size - FINDER_PATTERN_SIZE]
|
|
2257
|
+
]
|
|
2258
|
+
}
|
|
2259
|
+
|
|
2260
|
+
|
|
2261
|
+
/***/ }),
|
|
2262
|
+
|
|
2263
|
+
/***/ 764:
|
|
2264
|
+
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
2265
|
+
|
|
2266
|
+
const Polynomial = __webpack_require__(713)
|
|
2267
|
+
|
|
2268
|
+
function ReedSolomonEncoder (degree) {
|
|
2269
|
+
this.genPoly = undefined
|
|
2270
|
+
this.degree = degree
|
|
2271
|
+
|
|
2272
|
+
if (this.degree) this.initialize(this.degree)
|
|
2273
|
+
}
|
|
2274
|
+
|
|
2275
|
+
/**
|
|
2276
|
+
* Initialize the encoder.
|
|
2277
|
+
* The input param should correspond to the number of error correction codewords.
|
|
2278
|
+
*
|
|
2279
|
+
* @param {Number} degree
|
|
2280
|
+
*/
|
|
2281
|
+
ReedSolomonEncoder.prototype.initialize = function initialize (degree) {
|
|
2282
|
+
// create an irreducible generator polynomial
|
|
2283
|
+
this.degree = degree
|
|
2284
|
+
this.genPoly = Polynomial.generateECPolynomial(this.degree)
|
|
2285
|
+
}
|
|
2286
|
+
|
|
2287
|
+
/**
|
|
2288
|
+
* Encodes a chunk of data
|
|
2289
|
+
*
|
|
2290
|
+
* @param {Uint8Array} data Buffer containing input data
|
|
2291
|
+
* @return {Uint8Array} Buffer containing encoded data
|
|
2292
|
+
*/
|
|
2293
|
+
ReedSolomonEncoder.prototype.encode = function encode (data) {
|
|
2294
|
+
if (!this.genPoly) {
|
|
2295
|
+
throw new Error('Encoder not initialized')
|
|
2296
|
+
}
|
|
2297
|
+
|
|
2298
|
+
// Calculate EC for this data block
|
|
2299
|
+
// extends data size to data+genPoly size
|
|
2300
|
+
const paddedData = new Uint8Array(data.length + this.degree)
|
|
2301
|
+
paddedData.set(data)
|
|
2302
|
+
|
|
2303
|
+
// The error correction codewords are the remainder after dividing the data codewords
|
|
2304
|
+
// by a generator polynomial
|
|
2305
|
+
const remainder = Polynomial.mod(paddedData, this.genPoly)
|
|
2306
|
+
|
|
2307
|
+
// return EC data blocks (last n byte, where n is the degree of genPoly)
|
|
2308
|
+
// If coefficients number in remainder are less than genPoly degree,
|
|
2309
|
+
// pad with 0s to the left to reach the needed number of coefficients
|
|
2310
|
+
const start = this.degree - remainder.length
|
|
2311
|
+
if (start > 0) {
|
|
2312
|
+
const buff = new Uint8Array(this.degree)
|
|
2313
|
+
buff.set(remainder, start)
|
|
2314
|
+
|
|
2315
|
+
return buff
|
|
2316
|
+
}
|
|
2317
|
+
|
|
2318
|
+
return remainder
|
|
2319
|
+
}
|
|
2320
|
+
|
|
2321
|
+
module.exports = ReedSolomonEncoder
|
|
2322
|
+
|
|
2323
|
+
|
|
2324
|
+
/***/ }),
|
|
2325
|
+
|
|
2326
|
+
/***/ 801:
|
|
2327
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
2328
|
+
|
|
2329
|
+
const Mode = __webpack_require__(208)
|
|
2330
|
+
const NumericData = __webpack_require__(357)
|
|
2331
|
+
const AlphanumericData = __webpack_require__(433)
|
|
2332
|
+
const ByteData = __webpack_require__(822)
|
|
2333
|
+
const KanjiData = __webpack_require__(861)
|
|
2334
|
+
const Regex = __webpack_require__(44)
|
|
2335
|
+
const Utils = __webpack_require__(886)
|
|
2336
|
+
const dijkstra = __webpack_require__(320)
|
|
2337
|
+
|
|
2338
|
+
/**
|
|
2339
|
+
* Returns UTF8 byte length
|
|
2340
|
+
*
|
|
2341
|
+
* @param {String} str Input string
|
|
2342
|
+
* @return {Number} Number of byte
|
|
2343
|
+
*/
|
|
2344
|
+
function getStringByteLength (str) {
|
|
2345
|
+
return unescape(encodeURIComponent(str)).length
|
|
2346
|
+
}
|
|
2347
|
+
|
|
2348
|
+
/**
|
|
2349
|
+
* Get a list of segments of the specified mode
|
|
2350
|
+
* from a string
|
|
2351
|
+
*
|
|
2352
|
+
* @param {Mode} mode Segment mode
|
|
2353
|
+
* @param {String} str String to process
|
|
2354
|
+
* @return {Array} Array of object with segments data
|
|
2355
|
+
*/
|
|
2356
|
+
function getSegments (regex, mode, str) {
|
|
2357
|
+
const segments = []
|
|
2358
|
+
let result
|
|
2359
|
+
|
|
2360
|
+
while ((result = regex.exec(str)) !== null) {
|
|
2361
|
+
segments.push({
|
|
2362
|
+
data: result[0],
|
|
2363
|
+
index: result.index,
|
|
2364
|
+
mode: mode,
|
|
2365
|
+
length: result[0].length
|
|
2366
|
+
})
|
|
2367
|
+
}
|
|
2368
|
+
|
|
2369
|
+
return segments
|
|
2370
|
+
}
|
|
2371
|
+
|
|
2372
|
+
/**
|
|
2373
|
+
* Extracts a series of segments with the appropriate
|
|
2374
|
+
* modes from a string
|
|
2375
|
+
*
|
|
2376
|
+
* @param {String} dataStr Input string
|
|
2377
|
+
* @return {Array} Array of object with segments data
|
|
2378
|
+
*/
|
|
2379
|
+
function getSegmentsFromString (dataStr) {
|
|
2380
|
+
const numSegs = getSegments(Regex.NUMERIC, Mode.NUMERIC, dataStr)
|
|
2381
|
+
const alphaNumSegs = getSegments(Regex.ALPHANUMERIC, Mode.ALPHANUMERIC, dataStr)
|
|
2382
|
+
let byteSegs
|
|
2383
|
+
let kanjiSegs
|
|
2384
|
+
|
|
2385
|
+
if (Utils.isKanjiModeEnabled()) {
|
|
2386
|
+
byteSegs = getSegments(Regex.BYTE, Mode.BYTE, dataStr)
|
|
2387
|
+
kanjiSegs = getSegments(Regex.KANJI, Mode.KANJI, dataStr)
|
|
2388
|
+
} else {
|
|
2389
|
+
byteSegs = getSegments(Regex.BYTE_KANJI, Mode.BYTE, dataStr)
|
|
2390
|
+
kanjiSegs = []
|
|
2391
|
+
}
|
|
2392
|
+
|
|
2393
|
+
const segs = numSegs.concat(alphaNumSegs, byteSegs, kanjiSegs)
|
|
2394
|
+
|
|
2395
|
+
return segs
|
|
2396
|
+
.sort(function (s1, s2) {
|
|
2397
|
+
return s1.index - s2.index
|
|
2398
|
+
})
|
|
2399
|
+
.map(function (obj) {
|
|
2400
|
+
return {
|
|
2401
|
+
data: obj.data,
|
|
2402
|
+
mode: obj.mode,
|
|
2403
|
+
length: obj.length
|
|
2404
|
+
}
|
|
2405
|
+
})
|
|
2406
|
+
}
|
|
2407
|
+
|
|
2408
|
+
/**
|
|
2409
|
+
* Returns how many bits are needed to encode a string of
|
|
2410
|
+
* specified length with the specified mode
|
|
2411
|
+
*
|
|
2412
|
+
* @param {Number} length String length
|
|
2413
|
+
* @param {Mode} mode Segment mode
|
|
2414
|
+
* @return {Number} Bit length
|
|
2415
|
+
*/
|
|
2416
|
+
function getSegmentBitsLength (length, mode) {
|
|
2417
|
+
switch (mode) {
|
|
2418
|
+
case Mode.NUMERIC:
|
|
2419
|
+
return NumericData.getBitsLength(length)
|
|
2420
|
+
case Mode.ALPHANUMERIC:
|
|
2421
|
+
return AlphanumericData.getBitsLength(length)
|
|
2422
|
+
case Mode.KANJI:
|
|
2423
|
+
return KanjiData.getBitsLength(length)
|
|
2424
|
+
case Mode.BYTE:
|
|
2425
|
+
return ByteData.getBitsLength(length)
|
|
2426
|
+
}
|
|
2427
|
+
}
|
|
2428
|
+
|
|
2429
|
+
/**
|
|
2430
|
+
* Merges adjacent segments which have the same mode
|
|
2431
|
+
*
|
|
2432
|
+
* @param {Array} segs Array of object with segments data
|
|
2433
|
+
* @return {Array} Array of object with segments data
|
|
2434
|
+
*/
|
|
2435
|
+
function mergeSegments (segs) {
|
|
2436
|
+
return segs.reduce(function (acc, curr) {
|
|
2437
|
+
const prevSeg = acc.length - 1 >= 0 ? acc[acc.length - 1] : null
|
|
2438
|
+
if (prevSeg && prevSeg.mode === curr.mode) {
|
|
2439
|
+
acc[acc.length - 1].data += curr.data
|
|
2440
|
+
return acc
|
|
2441
|
+
}
|
|
2442
|
+
|
|
2443
|
+
acc.push(curr)
|
|
2444
|
+
return acc
|
|
2445
|
+
}, [])
|
|
2446
|
+
}
|
|
2447
|
+
|
|
2448
|
+
/**
|
|
2449
|
+
* Generates a list of all possible nodes combination which
|
|
2450
|
+
* will be used to build a segments graph.
|
|
2451
|
+
*
|
|
2452
|
+
* Nodes are divided by groups. Each group will contain a list of all the modes
|
|
2453
|
+
* in which is possible to encode the given text.
|
|
2454
|
+
*
|
|
2455
|
+
* For example the text '12345' can be encoded as Numeric, Alphanumeric or Byte.
|
|
2456
|
+
* The group for '12345' will contain then 3 objects, one for each
|
|
2457
|
+
* possible encoding mode.
|
|
2458
|
+
*
|
|
2459
|
+
* Each node represents a possible segment.
|
|
2460
|
+
*
|
|
2461
|
+
* @param {Array} segs Array of object with segments data
|
|
2462
|
+
* @return {Array} Array of object with segments data
|
|
2463
|
+
*/
|
|
2464
|
+
function buildNodes (segs) {
|
|
2465
|
+
const nodes = []
|
|
2466
|
+
for (let i = 0; i < segs.length; i++) {
|
|
2467
|
+
const seg = segs[i]
|
|
2468
|
+
|
|
2469
|
+
switch (seg.mode) {
|
|
2470
|
+
case Mode.NUMERIC:
|
|
2471
|
+
nodes.push([seg,
|
|
2472
|
+
{ data: seg.data, mode: Mode.ALPHANUMERIC, length: seg.length },
|
|
2473
|
+
{ data: seg.data, mode: Mode.BYTE, length: seg.length }
|
|
2474
|
+
])
|
|
2475
|
+
break
|
|
2476
|
+
case Mode.ALPHANUMERIC:
|
|
2477
|
+
nodes.push([seg,
|
|
2478
|
+
{ data: seg.data, mode: Mode.BYTE, length: seg.length }
|
|
2479
|
+
])
|
|
2480
|
+
break
|
|
2481
|
+
case Mode.KANJI:
|
|
2482
|
+
nodes.push([seg,
|
|
2483
|
+
{ data: seg.data, mode: Mode.BYTE, length: getStringByteLength(seg.data) }
|
|
2484
|
+
])
|
|
2485
|
+
break
|
|
2486
|
+
case Mode.BYTE:
|
|
2487
|
+
nodes.push([
|
|
2488
|
+
{ data: seg.data, mode: Mode.BYTE, length: getStringByteLength(seg.data) }
|
|
2489
|
+
])
|
|
2490
|
+
}
|
|
2491
|
+
}
|
|
2492
|
+
|
|
2493
|
+
return nodes
|
|
2494
|
+
}
|
|
2495
|
+
|
|
2496
|
+
/**
|
|
2497
|
+
* Builds a graph from a list of nodes.
|
|
2498
|
+
* All segments in each node group will be connected with all the segments of
|
|
2499
|
+
* the next group and so on.
|
|
2500
|
+
*
|
|
2501
|
+
* At each connection will be assigned a weight depending on the
|
|
2502
|
+
* segment's byte length.
|
|
2503
|
+
*
|
|
2504
|
+
* @param {Array} nodes Array of object with segments data
|
|
2505
|
+
* @param {Number} version QR Code version
|
|
2506
|
+
* @return {Object} Graph of all possible segments
|
|
2507
|
+
*/
|
|
2508
|
+
function buildGraph (nodes, version) {
|
|
2509
|
+
const table = {}
|
|
2510
|
+
const graph = { start: {} }
|
|
2511
|
+
let prevNodeIds = ['start']
|
|
2512
|
+
|
|
2513
|
+
for (let i = 0; i < nodes.length; i++) {
|
|
2514
|
+
const nodeGroup = nodes[i]
|
|
2515
|
+
const currentNodeIds = []
|
|
2516
|
+
|
|
2517
|
+
for (let j = 0; j < nodeGroup.length; j++) {
|
|
2518
|
+
const node = nodeGroup[j]
|
|
2519
|
+
const key = '' + i + j
|
|
2520
|
+
|
|
2521
|
+
currentNodeIds.push(key)
|
|
2522
|
+
table[key] = { node: node, lastCount: 0 }
|
|
2523
|
+
graph[key] = {}
|
|
2524
|
+
|
|
2525
|
+
for (let n = 0; n < prevNodeIds.length; n++) {
|
|
2526
|
+
const prevNodeId = prevNodeIds[n]
|
|
2527
|
+
|
|
2528
|
+
if (table[prevNodeId] && table[prevNodeId].node.mode === node.mode) {
|
|
2529
|
+
graph[prevNodeId][key] =
|
|
2530
|
+
getSegmentBitsLength(table[prevNodeId].lastCount + node.length, node.mode) -
|
|
2531
|
+
getSegmentBitsLength(table[prevNodeId].lastCount, node.mode)
|
|
2532
|
+
|
|
2533
|
+
table[prevNodeId].lastCount += node.length
|
|
2534
|
+
} else {
|
|
2535
|
+
if (table[prevNodeId]) table[prevNodeId].lastCount = node.length
|
|
2536
|
+
|
|
2537
|
+
graph[prevNodeId][key] = getSegmentBitsLength(node.length, node.mode) +
|
|
2538
|
+
4 + Mode.getCharCountIndicator(node.mode, version) // switch cost
|
|
2539
|
+
}
|
|
2540
|
+
}
|
|
2541
|
+
}
|
|
2542
|
+
|
|
2543
|
+
prevNodeIds = currentNodeIds
|
|
2544
|
+
}
|
|
2545
|
+
|
|
2546
|
+
for (let n = 0; n < prevNodeIds.length; n++) {
|
|
2547
|
+
graph[prevNodeIds[n]].end = 0
|
|
2548
|
+
}
|
|
2549
|
+
|
|
2550
|
+
return { map: graph, table: table }
|
|
2551
|
+
}
|
|
2552
|
+
|
|
2553
|
+
/**
|
|
2554
|
+
* Builds a segment from a specified data and mode.
|
|
2555
|
+
* If a mode is not specified, the more suitable will be used.
|
|
2556
|
+
*
|
|
2557
|
+
* @param {String} data Input data
|
|
2558
|
+
* @param {Mode | String} modesHint Data mode
|
|
2559
|
+
* @return {Segment} Segment
|
|
2560
|
+
*/
|
|
2561
|
+
function buildSingleSegment (data, modesHint) {
|
|
2562
|
+
let mode
|
|
2563
|
+
const bestMode = Mode.getBestModeForData(data)
|
|
2564
|
+
|
|
2565
|
+
mode = Mode.from(modesHint, bestMode)
|
|
2566
|
+
|
|
2567
|
+
// Make sure data can be encoded
|
|
2568
|
+
if (mode !== Mode.BYTE && mode.bit < bestMode.bit) {
|
|
2569
|
+
throw new Error('"' + data + '"' +
|
|
2570
|
+
' cannot be encoded with mode ' + Mode.toString(mode) +
|
|
2571
|
+
'.\n Suggested mode is: ' + Mode.toString(bestMode))
|
|
2572
|
+
}
|
|
2573
|
+
|
|
2574
|
+
// Use Mode.BYTE if Kanji support is disabled
|
|
2575
|
+
if (mode === Mode.KANJI && !Utils.isKanjiModeEnabled()) {
|
|
2576
|
+
mode = Mode.BYTE
|
|
2577
|
+
}
|
|
2578
|
+
|
|
2579
|
+
switch (mode) {
|
|
2580
|
+
case Mode.NUMERIC:
|
|
2581
|
+
return new NumericData(data)
|
|
2582
|
+
|
|
2583
|
+
case Mode.ALPHANUMERIC:
|
|
2584
|
+
return new AlphanumericData(data)
|
|
2585
|
+
|
|
2586
|
+
case Mode.KANJI:
|
|
2587
|
+
return new KanjiData(data)
|
|
2588
|
+
|
|
2589
|
+
case Mode.BYTE:
|
|
2590
|
+
return new ByteData(data)
|
|
2591
|
+
}
|
|
2592
|
+
}
|
|
2593
|
+
|
|
2594
|
+
/**
|
|
2595
|
+
* Builds a list of segments from an array.
|
|
2596
|
+
* Array can contain Strings or Objects with segment's info.
|
|
2597
|
+
*
|
|
2598
|
+
* For each item which is a string, will be generated a segment with the given
|
|
2599
|
+
* string and the more appropriate encoding mode.
|
|
2600
|
+
*
|
|
2601
|
+
* For each item which is an object, will be generated a segment with the given
|
|
2602
|
+
* data and mode.
|
|
2603
|
+
* Objects must contain at least the property "data".
|
|
2604
|
+
* If property "mode" is not present, the more suitable mode will be used.
|
|
2605
|
+
*
|
|
2606
|
+
* @param {Array} array Array of objects with segments data
|
|
2607
|
+
* @return {Array} Array of Segments
|
|
2608
|
+
*/
|
|
2609
|
+
exports.fromArray = function fromArray (array) {
|
|
2610
|
+
return array.reduce(function (acc, seg) {
|
|
2611
|
+
if (typeof seg === 'string') {
|
|
2612
|
+
acc.push(buildSingleSegment(seg, null))
|
|
2613
|
+
} else if (seg.data) {
|
|
2614
|
+
acc.push(buildSingleSegment(seg.data, seg.mode))
|
|
2615
|
+
}
|
|
2616
|
+
|
|
2617
|
+
return acc
|
|
2618
|
+
}, [])
|
|
2619
|
+
}
|
|
2620
|
+
|
|
2621
|
+
/**
|
|
2622
|
+
* Builds an optimized sequence of segments from a string,
|
|
2623
|
+
* which will produce the shortest possible bitstream.
|
|
2624
|
+
*
|
|
2625
|
+
* @param {String} data Input string
|
|
2626
|
+
* @param {Number} version QR Code version
|
|
2627
|
+
* @return {Array} Array of segments
|
|
2628
|
+
*/
|
|
2629
|
+
exports.fromString = function fromString (data, version) {
|
|
2630
|
+
const segs = getSegmentsFromString(data, Utils.isKanjiModeEnabled())
|
|
2631
|
+
|
|
2632
|
+
const nodes = buildNodes(segs)
|
|
2633
|
+
const graph = buildGraph(nodes, version)
|
|
2634
|
+
const path = dijkstra.find_path(graph.map, 'start', 'end')
|
|
2635
|
+
|
|
2636
|
+
const optimizedSegs = []
|
|
2637
|
+
for (let i = 1; i < path.length - 1; i++) {
|
|
2638
|
+
optimizedSegs.push(graph.table[path[i]].node)
|
|
2639
|
+
}
|
|
2640
|
+
|
|
2641
|
+
return exports.fromArray(mergeSegments(optimizedSegs))
|
|
2642
|
+
}
|
|
2643
|
+
|
|
2644
|
+
/**
|
|
2645
|
+
* Splits a string in various segments with the modes which
|
|
2646
|
+
* best represent their content.
|
|
2647
|
+
* The produced segments are far from being optimized.
|
|
2648
|
+
* The output of this function is only used to estimate a QR Code version
|
|
2649
|
+
* which may contain the data.
|
|
2650
|
+
*
|
|
2651
|
+
* @param {string} data Input string
|
|
2652
|
+
* @return {Array} Array of segments
|
|
2653
|
+
*/
|
|
2654
|
+
exports.rawSplit = function rawSplit (data) {
|
|
2655
|
+
return exports.fromArray(
|
|
2656
|
+
getSegmentsFromString(data, Utils.isKanjiModeEnabled())
|
|
2657
|
+
)
|
|
2658
|
+
}
|
|
2659
|
+
|
|
2660
|
+
|
|
2661
|
+
/***/ }),
|
|
2662
|
+
|
|
2663
|
+
/***/ 820:
|
|
2664
|
+
/***/ ((module) => {
|
|
2665
|
+
|
|
2666
|
+
/**
|
|
2667
|
+
* Helper class to handle QR Code symbol modules
|
|
2668
|
+
*
|
|
2669
|
+
* @param {Number} size Symbol size
|
|
2670
|
+
*/
|
|
2671
|
+
function BitMatrix (size) {
|
|
2672
|
+
if (!size || size < 1) {
|
|
2673
|
+
throw new Error('BitMatrix size must be defined and greater than 0')
|
|
2674
|
+
}
|
|
2675
|
+
|
|
2676
|
+
this.size = size
|
|
2677
|
+
this.data = new Uint8Array(size * size)
|
|
2678
|
+
this.reservedBit = new Uint8Array(size * size)
|
|
2679
|
+
}
|
|
2680
|
+
|
|
2681
|
+
/**
|
|
2682
|
+
* Set bit value at specified location
|
|
2683
|
+
* If reserved flag is set, this bit will be ignored during masking process
|
|
2684
|
+
*
|
|
2685
|
+
* @param {Number} row
|
|
2686
|
+
* @param {Number} col
|
|
2687
|
+
* @param {Boolean} value
|
|
2688
|
+
* @param {Boolean} reserved
|
|
2689
|
+
*/
|
|
2690
|
+
BitMatrix.prototype.set = function (row, col, value, reserved) {
|
|
2691
|
+
const index = row * this.size + col
|
|
2692
|
+
this.data[index] = value
|
|
2693
|
+
if (reserved) this.reservedBit[index] = true
|
|
2694
|
+
}
|
|
2695
|
+
|
|
2696
|
+
/**
|
|
2697
|
+
* Returns bit value at specified location
|
|
2698
|
+
*
|
|
2699
|
+
* @param {Number} row
|
|
2700
|
+
* @param {Number} col
|
|
2701
|
+
* @return {Boolean}
|
|
2702
|
+
*/
|
|
2703
|
+
BitMatrix.prototype.get = function (row, col) {
|
|
2704
|
+
return this.data[row * this.size + col]
|
|
2705
|
+
}
|
|
2706
|
+
|
|
2707
|
+
/**
|
|
2708
|
+
* Applies xor operator at specified location
|
|
2709
|
+
* (used during masking process)
|
|
2710
|
+
*
|
|
2711
|
+
* @param {Number} row
|
|
2712
|
+
* @param {Number} col
|
|
2713
|
+
* @param {Boolean} value
|
|
2714
|
+
*/
|
|
2715
|
+
BitMatrix.prototype.xor = function (row, col, value) {
|
|
2716
|
+
this.data[row * this.size + col] ^= value
|
|
2717
|
+
}
|
|
2718
|
+
|
|
2719
|
+
/**
|
|
2720
|
+
* Check if bit at specified location is reserved
|
|
2721
|
+
*
|
|
2722
|
+
* @param {Number} row
|
|
2723
|
+
* @param {Number} col
|
|
2724
|
+
* @return {Boolean}
|
|
2725
|
+
*/
|
|
2726
|
+
BitMatrix.prototype.isReserved = function (row, col) {
|
|
2727
|
+
return this.reservedBit[row * this.size + col]
|
|
2728
|
+
}
|
|
2729
|
+
|
|
2730
|
+
module.exports = BitMatrix
|
|
2731
|
+
|
|
2732
|
+
|
|
2733
|
+
/***/ }),
|
|
2734
|
+
|
|
2735
|
+
/***/ 822:
|
|
2736
|
+
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
2737
|
+
|
|
2738
|
+
const Mode = __webpack_require__(208)
|
|
2739
|
+
|
|
2740
|
+
function ByteData (data) {
|
|
2741
|
+
this.mode = Mode.BYTE
|
|
2742
|
+
if (typeof (data) === 'string') {
|
|
2743
|
+
this.data = new TextEncoder().encode(data)
|
|
2744
|
+
} else {
|
|
2745
|
+
this.data = new Uint8Array(data)
|
|
2746
|
+
}
|
|
2747
|
+
}
|
|
2748
|
+
|
|
2749
|
+
ByteData.getBitsLength = function getBitsLength (length) {
|
|
2750
|
+
return length * 8
|
|
2751
|
+
}
|
|
2752
|
+
|
|
2753
|
+
ByteData.prototype.getLength = function getLength () {
|
|
2754
|
+
return this.data.length
|
|
2755
|
+
}
|
|
2756
|
+
|
|
2757
|
+
ByteData.prototype.getBitsLength = function getBitsLength () {
|
|
2758
|
+
return ByteData.getBitsLength(this.data.length)
|
|
2759
|
+
}
|
|
2760
|
+
|
|
2761
|
+
ByteData.prototype.write = function (bitBuffer) {
|
|
2762
|
+
for (let i = 0, l = this.data.length; i < l; i++) {
|
|
2763
|
+
bitBuffer.put(this.data[i], 8)
|
|
2764
|
+
}
|
|
2765
|
+
}
|
|
2766
|
+
|
|
2767
|
+
module.exports = ByteData
|
|
2768
|
+
|
|
2769
|
+
|
|
2770
|
+
/***/ }),
|
|
2771
|
+
|
|
2772
|
+
/***/ 861:
|
|
2773
|
+
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
2774
|
+
|
|
2775
|
+
const Mode = __webpack_require__(208)
|
|
2776
|
+
const Utils = __webpack_require__(886)
|
|
2777
|
+
|
|
2778
|
+
function KanjiData (data) {
|
|
2779
|
+
this.mode = Mode.KANJI
|
|
2780
|
+
this.data = data
|
|
2781
|
+
}
|
|
2782
|
+
|
|
2783
|
+
KanjiData.getBitsLength = function getBitsLength (length) {
|
|
2784
|
+
return length * 13
|
|
2785
|
+
}
|
|
2786
|
+
|
|
2787
|
+
KanjiData.prototype.getLength = function getLength () {
|
|
2788
|
+
return this.data.length
|
|
2789
|
+
}
|
|
2790
|
+
|
|
2791
|
+
KanjiData.prototype.getBitsLength = function getBitsLength () {
|
|
2792
|
+
return KanjiData.getBitsLength(this.data.length)
|
|
2793
|
+
}
|
|
2794
|
+
|
|
2795
|
+
KanjiData.prototype.write = function (bitBuffer) {
|
|
2796
|
+
let i
|
|
2797
|
+
|
|
2798
|
+
// In the Shift JIS system, Kanji characters are represented by a two byte combination.
|
|
2799
|
+
// These byte values are shifted from the JIS X 0208 values.
|
|
2800
|
+
// JIS X 0208 gives details of the shift coded representation.
|
|
2801
|
+
for (i = 0; i < this.data.length; i++) {
|
|
2802
|
+
let value = Utils.toSJIS(this.data[i])
|
|
2803
|
+
|
|
2804
|
+
// For characters with Shift JIS values from 0x8140 to 0x9FFC:
|
|
2805
|
+
if (value >= 0x8140 && value <= 0x9FFC) {
|
|
2806
|
+
// Subtract 0x8140 from Shift JIS value
|
|
2807
|
+
value -= 0x8140
|
|
2808
|
+
|
|
2809
|
+
// For characters with Shift JIS values from 0xE040 to 0xEBBF
|
|
2810
|
+
} else if (value >= 0xE040 && value <= 0xEBBF) {
|
|
2811
|
+
// Subtract 0xC140 from Shift JIS value
|
|
2812
|
+
value -= 0xC140
|
|
2813
|
+
} else {
|
|
2814
|
+
throw new Error(
|
|
2815
|
+
'Invalid SJIS character: ' + this.data[i] + '\n' +
|
|
2816
|
+
'Make sure your charset is UTF-8')
|
|
2817
|
+
}
|
|
2818
|
+
|
|
2819
|
+
// Multiply most significant byte of result by 0xC0
|
|
2820
|
+
// and add least significant byte to product
|
|
2821
|
+
value = (((value >>> 8) & 0xff) * 0xC0) + (value & 0xff)
|
|
2822
|
+
|
|
2823
|
+
// Convert result to a 13-bit binary string
|
|
2824
|
+
bitBuffer.put(value, 13)
|
|
2825
|
+
}
|
|
2826
|
+
}
|
|
2827
|
+
|
|
2828
|
+
module.exports = KanjiData
|
|
2829
|
+
|
|
2830
|
+
|
|
2831
|
+
/***/ }),
|
|
2832
|
+
|
|
2833
|
+
/***/ 878:
|
|
2834
|
+
/***/ ((__unused_webpack_module, exports) => {
|
|
2835
|
+
|
|
2836
|
+
/**
|
|
2837
|
+
* Check if QR Code version is valid
|
|
2838
|
+
*
|
|
2839
|
+
* @param {Number} version QR Code version
|
|
2840
|
+
* @return {Boolean} true if valid version, false otherwise
|
|
2841
|
+
*/
|
|
2842
|
+
exports.isValid = function isValid (version) {
|
|
2843
|
+
return !isNaN(version) && version >= 1 && version <= 40
|
|
2844
|
+
}
|
|
2845
|
+
|
|
2846
|
+
|
|
2847
|
+
/***/ }),
|
|
2848
|
+
|
|
2849
|
+
/***/ 886:
|
|
2850
|
+
/***/ ((__unused_webpack_module, exports) => {
|
|
2851
|
+
|
|
2852
|
+
let toSJISFunction
|
|
2853
|
+
const CODEWORDS_COUNT = [
|
|
2854
|
+
0, // Not used
|
|
2855
|
+
26, 44, 70, 100, 134, 172, 196, 242, 292, 346,
|
|
2856
|
+
404, 466, 532, 581, 655, 733, 815, 901, 991, 1085,
|
|
2857
|
+
1156, 1258, 1364, 1474, 1588, 1706, 1828, 1921, 2051, 2185,
|
|
2858
|
+
2323, 2465, 2611, 2761, 2876, 3034, 3196, 3362, 3532, 3706
|
|
2859
|
+
]
|
|
2860
|
+
|
|
2861
|
+
/**
|
|
2862
|
+
* Returns the QR Code size for the specified version
|
|
2863
|
+
*
|
|
2864
|
+
* @param {Number} version QR Code version
|
|
2865
|
+
* @return {Number} size of QR code
|
|
2866
|
+
*/
|
|
2867
|
+
exports.getSymbolSize = function getSymbolSize (version) {
|
|
2868
|
+
if (!version) throw new Error('"version" cannot be null or undefined')
|
|
2869
|
+
if (version < 1 || version > 40) throw new Error('"version" should be in range from 1 to 40')
|
|
2870
|
+
return version * 4 + 17
|
|
2871
|
+
}
|
|
2872
|
+
|
|
2873
|
+
/**
|
|
2874
|
+
* Returns the total number of codewords used to store data and EC information.
|
|
2875
|
+
*
|
|
2876
|
+
* @param {Number} version QR Code version
|
|
2877
|
+
* @return {Number} Data length in bits
|
|
2878
|
+
*/
|
|
2879
|
+
exports.getSymbolTotalCodewords = function getSymbolTotalCodewords (version) {
|
|
2880
|
+
return CODEWORDS_COUNT[version]
|
|
2881
|
+
}
|
|
2882
|
+
|
|
2883
|
+
/**
|
|
2884
|
+
* Encode data with Bose-Chaudhuri-Hocquenghem
|
|
2885
|
+
*
|
|
2886
|
+
* @param {Number} data Value to encode
|
|
2887
|
+
* @return {Number} Encoded value
|
|
2888
|
+
*/
|
|
2889
|
+
exports.getBCHDigit = function (data) {
|
|
2890
|
+
let digit = 0
|
|
2891
|
+
|
|
2892
|
+
while (data !== 0) {
|
|
2893
|
+
digit++
|
|
2894
|
+
data >>>= 1
|
|
2895
|
+
}
|
|
2896
|
+
|
|
2897
|
+
return digit
|
|
2898
|
+
}
|
|
2899
|
+
|
|
2900
|
+
exports.setToSJISFunction = function setToSJISFunction (f) {
|
|
2901
|
+
if (typeof f !== 'function') {
|
|
2902
|
+
throw new Error('"toSJISFunc" is not a valid function.')
|
|
2903
|
+
}
|
|
2904
|
+
|
|
2905
|
+
toSJISFunction = f
|
|
2906
|
+
}
|
|
2907
|
+
|
|
2908
|
+
exports.isKanjiModeEnabled = function () {
|
|
2909
|
+
return typeof toSJISFunction !== 'undefined'
|
|
2910
|
+
}
|
|
2911
|
+
|
|
2912
|
+
exports.toSJIS = function toSJIS (kanji) {
|
|
2913
|
+
return toSJISFunction(kanji)
|
|
2914
|
+
}
|
|
2915
|
+
|
|
2916
|
+
|
|
2917
|
+
/***/ }),
|
|
2918
|
+
|
|
2919
|
+
/***/ 899:
|
|
2920
|
+
/***/ ((module) => {
|
|
2921
|
+
|
|
2922
|
+
function BitBuffer () {
|
|
2923
|
+
this.buffer = []
|
|
2924
|
+
this.length = 0
|
|
2925
|
+
}
|
|
2926
|
+
|
|
2927
|
+
BitBuffer.prototype = {
|
|
2928
|
+
|
|
2929
|
+
get: function (index) {
|
|
2930
|
+
const bufIndex = Math.floor(index / 8)
|
|
2931
|
+
return ((this.buffer[bufIndex] >>> (7 - index % 8)) & 1) === 1
|
|
2932
|
+
},
|
|
2933
|
+
|
|
2934
|
+
put: function (num, length) {
|
|
2935
|
+
for (let i = 0; i < length; i++) {
|
|
2936
|
+
this.putBit(((num >>> (length - i - 1)) & 1) === 1)
|
|
2937
|
+
}
|
|
2938
|
+
},
|
|
2939
|
+
|
|
2940
|
+
getLengthInBits: function () {
|
|
2941
|
+
return this.length
|
|
2942
|
+
},
|
|
2943
|
+
|
|
2944
|
+
putBit: function (bit) {
|
|
2945
|
+
const bufIndex = Math.floor(this.length / 8)
|
|
2946
|
+
if (this.buffer.length <= bufIndex) {
|
|
2947
|
+
this.buffer.push(0)
|
|
2948
|
+
}
|
|
2949
|
+
|
|
2950
|
+
if (bit) {
|
|
2951
|
+
this.buffer[bufIndex] |= (0x80 >>> (this.length % 8))
|
|
2952
|
+
}
|
|
2953
|
+
|
|
2954
|
+
this.length++
|
|
2955
|
+
}
|
|
2956
|
+
}
|
|
2957
|
+
|
|
2958
|
+
module.exports = BitBuffer
|
|
2959
|
+
|
|
2960
|
+
|
|
2961
|
+
/***/ }),
|
|
2962
|
+
|
|
2963
|
+
/***/ 953:
|
|
2964
|
+
/***/ ((__unused_webpack_module, exports) => {
|
|
2965
|
+
|
|
2966
|
+
exports.L = { bit: 1 }
|
|
2967
|
+
exports.M = { bit: 0 }
|
|
2968
|
+
exports.Q = { bit: 3 }
|
|
2969
|
+
exports.H = { bit: 2 }
|
|
2970
|
+
|
|
2971
|
+
function fromString (string) {
|
|
2972
|
+
if (typeof string !== 'string') {
|
|
2973
|
+
throw new Error('Param is not a string')
|
|
2974
|
+
}
|
|
2975
|
+
|
|
2976
|
+
const lcStr = string.toLowerCase()
|
|
2977
|
+
|
|
2978
|
+
switch (lcStr) {
|
|
2979
|
+
case 'l':
|
|
2980
|
+
case 'low':
|
|
2981
|
+
return exports.L
|
|
2982
|
+
|
|
2983
|
+
case 'm':
|
|
2984
|
+
case 'medium':
|
|
2985
|
+
return exports.M
|
|
2986
|
+
|
|
2987
|
+
case 'q':
|
|
2988
|
+
case 'quartile':
|
|
2989
|
+
return exports.Q
|
|
2990
|
+
|
|
2991
|
+
case 'h':
|
|
2992
|
+
case 'high':
|
|
2993
|
+
return exports.H
|
|
2994
|
+
|
|
2995
|
+
default:
|
|
2996
|
+
throw new Error('Unknown EC Level: ' + string)
|
|
2997
|
+
}
|
|
2998
|
+
}
|
|
2999
|
+
|
|
3000
|
+
exports.isValid = function isValid (level) {
|
|
3001
|
+
return level && typeof level.bit !== 'undefined' &&
|
|
3002
|
+
level.bit >= 0 && level.bit < 4
|
|
3003
|
+
}
|
|
3004
|
+
|
|
3005
|
+
exports.from = function from (value, defaultValue) {
|
|
3006
|
+
if (exports.isValid(value)) {
|
|
3007
|
+
return value
|
|
3008
|
+
}
|
|
3009
|
+
|
|
3010
|
+
try {
|
|
3011
|
+
return fromString(value)
|
|
3012
|
+
} catch (e) {
|
|
3013
|
+
return defaultValue
|
|
3014
|
+
}
|
|
3015
|
+
}
|
|
3016
|
+
|
|
3017
|
+
|
|
3018
|
+
/***/ })
|
|
3019
|
+
|
|
3020
|
+
/******/ });
|
|
3021
|
+
/************************************************************************/
|
|
3022
|
+
/******/ // The module cache
|
|
3023
|
+
/******/ var __webpack_module_cache__ = {};
|
|
3024
|
+
/******/
|
|
3025
|
+
/******/ // The require function
|
|
3026
|
+
/******/ function __webpack_require__(moduleId) {
|
|
3027
|
+
/******/ // Check if module is in cache
|
|
3028
|
+
/******/ var cachedModule = __webpack_module_cache__[moduleId];
|
|
3029
|
+
/******/ if (cachedModule !== undefined) {
|
|
3030
|
+
/******/ return cachedModule.exports;
|
|
3031
|
+
/******/ }
|
|
3032
|
+
/******/ // Create a new module (and put it into the cache)
|
|
3033
|
+
/******/ var module = __webpack_module_cache__[moduleId] = {
|
|
3034
|
+
/******/ // no module.id needed
|
|
3035
|
+
/******/ // no module.loaded needed
|
|
3036
|
+
/******/ exports: {}
|
|
3037
|
+
/******/ };
|
|
3038
|
+
/******/
|
|
3039
|
+
/******/ // Execute the module function
|
|
3040
|
+
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
3041
|
+
/******/
|
|
3042
|
+
/******/ // Return the exports of the module
|
|
3043
|
+
/******/ return module.exports;
|
|
3044
|
+
/******/ }
|
|
3045
|
+
/******/
|
|
3046
|
+
/************************************************************************/
|
|
3047
|
+
/******/ /* webpack/runtime/define property getters */
|
|
3048
|
+
/******/ (() => {
|
|
3049
|
+
/******/ // define getter functions for harmony exports
|
|
3050
|
+
/******/ __webpack_require__.d = (exports, definition) => {
|
|
3051
|
+
/******/ for(var key in definition) {
|
|
3052
|
+
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
|
|
3053
|
+
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
|
|
3054
|
+
/******/ }
|
|
3055
|
+
/******/ }
|
|
3056
|
+
/******/ };
|
|
3057
|
+
/******/ })();
|
|
3058
|
+
/******/
|
|
3059
|
+
/******/ /* webpack/runtime/hasOwnProperty shorthand */
|
|
3060
|
+
/******/ (() => {
|
|
3061
|
+
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
|
3062
|
+
/******/ })();
|
|
3063
|
+
/******/
|
|
3064
|
+
/************************************************************************/
|
|
3065
|
+
var __webpack_exports__ = {};
|
|
3066
|
+
// This entry needs to be wrapped in an IIFE because it needs to be in strict mode.
|
|
3067
|
+
(() => {
|
|
3068
|
+
"use strict";
|
|
3069
|
+
|
|
3070
|
+
// EXPORTS
|
|
3071
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
3072
|
+
"default": () => (/* binding */ src)
|
|
3073
|
+
});
|
|
3074
|
+
|
|
3075
|
+
;// ./node_modules/lit-html/lit-html.js
|
|
3076
|
+
/**
|
|
3077
|
+
* @license
|
|
3078
|
+
* Copyright 2017 Google LLC
|
|
3079
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
3080
|
+
*/
|
|
3081
|
+
const t=globalThis,i=t.trustedTypes,s=i?i.createPolicy("lit-html",{createHTML:t=>t}):void 0,e="$lit$",h=`lit$${Math.random().toFixed(9).slice(2)}$`,o="?"+h,n=`<${o}>`,r=document,l=()=>r.createComment(""),c=t=>null===t||"object"!=typeof t&&"function"!=typeof t,a=Array.isArray,u=t=>a(t)||"function"==typeof t?.[Symbol.iterator],d="[ \t\n\f\r]",f=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,v=/-->/g,_=/>/g,m=RegExp(`>|${d}(?:([^\\s"'>=/]+)(${d}*=${d}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),p=/'/g,g=/"/g,$=/^(?:script|style|textarea|title)$/i,y=t=>(i,...s)=>({_$litType$:t,strings:i,values:s}),x=y(1),b=y(2),w=y(3),T=Symbol.for("lit-noChange"),E=Symbol.for("lit-nothing"),A=new WeakMap,C=r.createTreeWalker(r,129);function P(t,i){if(!a(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==s?s.createHTML(i):i}const V=(t,i)=>{const s=t.length-1,o=[];let r,l=2===i?"<svg>":3===i?"<math>":"",c=f;for(let i=0;i<s;i++){const s=t[i];let a,u,d=-1,y=0;for(;y<s.length&&(c.lastIndex=y,u=c.exec(s),null!==u);)y=c.lastIndex,c===f?"!--"===u[1]?c=v:void 0!==u[1]?c=_:void 0!==u[2]?($.test(u[2])&&(r=RegExp("</"+u[2],"g")),c=m):void 0!==u[3]&&(c=m):c===m?">"===u[0]?(c=r??f,d=-1):void 0===u[1]?d=-2:(d=c.lastIndex-u[2].length,a=u[1],c=void 0===u[3]?m:'"'===u[3]?g:p):c===g||c===p?c=m:c===v||c===_?c=f:(c=m,r=void 0);const x=c===m&&t[i+1].startsWith("/>")?" ":"";l+=c===f?s+n:d>=0?(o.push(a),s.slice(0,d)+e+s.slice(d)+h+x):s+h+(-2===d?i:x)}return[P(t,l+(t[s]||"<?>")+(2===i?"</svg>":3===i?"</math>":"")),o]};class N{constructor({strings:t,_$litType$:s},n){let r;this.parts=[];let c=0,a=0;const u=t.length-1,d=this.parts,[f,v]=V(t,s);if(this.el=N.createElement(f,n),C.currentNode=this.el.content,2===s||3===s){const t=this.el.content.firstChild;t.replaceWith(...t.childNodes)}for(;null!==(r=C.nextNode())&&d.length<u;){if(1===r.nodeType){if(r.hasAttributes())for(const t of r.getAttributeNames())if(t.endsWith(e)){const i=v[a++],s=r.getAttribute(t).split(h),e=/([.?@])?(.*)/.exec(i);d.push({type:1,index:c,name:e[2],strings:s,ctor:"."===e[1]?H:"?"===e[1]?I:"@"===e[1]?L:k}),r.removeAttribute(t)}else t.startsWith(h)&&(d.push({type:6,index:c}),r.removeAttribute(t));if($.test(r.tagName)){const t=r.textContent.split(h),s=t.length-1;if(s>0){r.textContent=i?i.emptyScript:"";for(let i=0;i<s;i++)r.append(t[i],l()),C.nextNode(),d.push({type:2,index:++c});r.append(t[s],l())}}}else if(8===r.nodeType)if(r.data===o)d.push({type:2,index:c});else{let t=-1;for(;-1!==(t=r.data.indexOf(h,t+1));)d.push({type:7,index:c}),t+=h.length-1}c++}}static createElement(t,i){const s=r.createElement("template");return s.innerHTML=t,s}}function S(t,i,s=t,e){if(i===T)return i;let h=void 0!==e?s._$Co?.[e]:s._$Cl;const o=c(i)?void 0:i._$litDirective$;return h?.constructor!==o&&(h?._$AO?.(!1),void 0===o?h=void 0:(h=new o(t),h._$AT(t,s,e)),void 0!==e?(s._$Co??=[])[e]=h:s._$Cl=h),void 0!==h&&(i=S(t,h._$AS(t,i.values),h,e)),i}class M{constructor(t,i){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=i}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:i},parts:s}=this._$AD,e=(t?.creationScope??r).importNode(i,!0);C.currentNode=e;let h=C.nextNode(),o=0,n=0,l=s[0];for(;void 0!==l;){if(o===l.index){let i;2===l.type?i=new R(h,h.nextSibling,this,t):1===l.type?i=new l.ctor(h,l.name,l.strings,this,t):6===l.type&&(i=new z(h,this,t)),this._$AV.push(i),l=s[++n]}o!==l?.index&&(h=C.nextNode(),o++)}return C.currentNode=r,e}p(t){let i=0;for(const s of this._$AV)void 0!==s&&(void 0!==s.strings?(s._$AI(t,s,i),i+=s.strings.length-2):s._$AI(t[i])),i++}}class R{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,i,s,e){this.type=2,this._$AH=E,this._$AN=void 0,this._$AA=t,this._$AB=i,this._$AM=s,this.options=e,this._$Cv=e?.isConnected??!0}get parentNode(){let t=this._$AA.parentNode;const i=this._$AM;return void 0!==i&&11===t?.nodeType&&(t=i.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,i=this){t=S(this,t,i),c(t)?t===E||null==t||""===t?(this._$AH!==E&&this._$AR(),this._$AH=E):t!==this._$AH&&t!==T&&this._(t):void 0!==t._$litType$?this.$(t):void 0!==t.nodeType?this.T(t):u(t)?this.k(t):this._(t)}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}_(t){this._$AH!==E&&c(this._$AH)?this._$AA.nextSibling.data=t:this.T(r.createTextNode(t)),this._$AH=t}$(t){const{values:i,_$litType$:s}=t,e="number"==typeof s?this._$AC(t):(void 0===s.el&&(s.el=N.createElement(P(s.h,s.h[0]),this.options)),s);if(this._$AH?._$AD===e)this._$AH.p(i);else{const t=new M(e,this),s=t.u(this.options);t.p(i),this.T(s),this._$AH=t}}_$AC(t){let i=A.get(t.strings);return void 0===i&&A.set(t.strings,i=new N(t)),i}k(t){a(this._$AH)||(this._$AH=[],this._$AR());const i=this._$AH;let s,e=0;for(const h of t)e===i.length?i.push(s=new R(this.O(l()),this.O(l()),this,this.options)):s=i[e],s._$AI(h),e++;e<i.length&&(this._$AR(s&&s._$AB.nextSibling,e),i.length=e)}_$AR(t=this._$AA.nextSibling,i){for(this._$AP?.(!1,!0,i);t!==this._$AB;){const i=t.nextSibling;t.remove(),t=i}}setConnected(t){void 0===this._$AM&&(this._$Cv=t,this._$AP?.(t))}}class k{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,i,s,e,h){this.type=1,this._$AH=E,this._$AN=void 0,this.element=t,this.name=i,this._$AM=e,this.options=h,s.length>2||""!==s[0]||""!==s[1]?(this._$AH=Array(s.length-1).fill(new String),this.strings=s):this._$AH=E}_$AI(t,i=this,s,e){const h=this.strings;let o=!1;if(void 0===h)t=S(this,t,i,0),o=!c(t)||t!==this._$AH&&t!==T,o&&(this._$AH=t);else{const e=t;let n,r;for(t=h[0],n=0;n<h.length-1;n++)r=S(this,e[s+n],i,n),r===T&&(r=this._$AH[n]),o||=!c(r)||r!==this._$AH[n],r===E?t=E:t!==E&&(t+=(r??"")+h[n+1]),this._$AH[n]=r}o&&!e&&this.j(t)}j(t){t===E?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}class H extends k{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===E?void 0:t}}class I extends k{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==E)}}class L extends k{constructor(t,i,s,e,h){super(t,i,s,e,h),this.type=5}_$AI(t,i=this){if((t=S(this,t,i,0)??E)===T)return;const s=this._$AH,e=t===E&&s!==E||t.capture!==s.capture||t.once!==s.once||t.passive!==s.passive,h=t!==E&&(s===E||e);e&&this.element.removeEventListener(this.name,this,s),h&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){"function"==typeof this._$AH?this._$AH.call(this.options?.host??this.element,t):this._$AH.handleEvent(t)}}class z{constructor(t,i,s){this.element=t,this.type=6,this._$AN=void 0,this._$AM=i,this.options=s}get _$AU(){return this._$AM._$AU}_$AI(t){S(this,t)}}const Z={M:e,P:h,A:o,C:1,L:V,R:M,D:u,V:S,I:R,H:k,N:I,U:L,B:H,F:z},j=t.litHtmlPolyfillSupport;j?.(N,R),(t.litHtmlVersions??=[]).push("3.3.1");const B=(t,i,s)=>{const e=s?.renderBefore??i;let h=e._$litPart$;if(void 0===h){const t=s?.renderBefore??null;e._$litPart$=h=new R(i.insertBefore(l(),t),t,void 0,s??{})}return h._$AI(t),h};
|
|
3082
|
+
//# sourceMappingURL=lit-html.js.map
|
|
3083
|
+
|
|
3084
|
+
// EXTERNAL MODULE: external "UI"
|
|
3085
|
+
var external_UI_ = __webpack_require__(426);
|
|
3086
|
+
// EXTERNAL MODULE: external "SolidLogic"
|
|
3087
|
+
var external_SolidLogic_ = __webpack_require__(663);
|
|
3088
|
+
;// ./node_modules/lit-html/directive-helpers.js
|
|
3089
|
+
|
|
3090
|
+
/**
|
|
3091
|
+
* @license
|
|
3092
|
+
* Copyright 2020 Google LLC
|
|
3093
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
3094
|
+
*/const{I:directive_helpers_t}=Z,directive_helpers_i=o=>null===o||"object"!=typeof o&&"function"!=typeof o,directive_helpers_n={HTML:1,SVG:2,MATHML:3},directive_helpers_e=(o,t)=>void 0===t?void 0!==o?._$litType$:o?._$litType$===t,directive_helpers_l=o=>null!=o?._$litType$?.h,directive_helpers_d=o=>void 0!==o?._$litDirective$,directive_helpers_c=o=>o?._$litDirective$,directive_helpers_f=o=>void 0===o.strings,directive_helpers_r=()=>document.createComment(""),directive_helpers_s=(o,i,n)=>{const e=o._$AA.parentNode,l=void 0===i?o._$AB:i._$AA;if(void 0===n){const i=e.insertBefore(directive_helpers_r(),l),d=e.insertBefore(directive_helpers_r(),l);n=new directive_helpers_t(i,d,o,o.options)}else{const t=n._$AB.nextSibling,i=n._$AM,d=i!==o;if(d){let t;n._$AQ?.(o),n._$AM=o,void 0!==n._$AP&&(t=o._$AU)!==i._$AU&&n._$AP(t)}if(t!==l||d){let o=n._$AA;for(;o!==t;){const t=o.nextSibling;e.insertBefore(o,l),o=t}}}return n},directive_helpers_v=(o,t,i=o)=>(o._$AI(t,i),o),directive_helpers_u={},directive_helpers_m=(o,t=directive_helpers_u)=>o._$AH=t,directive_helpers_p=o=>o._$AH,directive_helpers_M=o=>{o._$AR(),o._$AA.remove()},directive_helpers_h=o=>{o._$AR()};
|
|
3095
|
+
//# sourceMappingURL=directive-helpers.js.map
|
|
3096
|
+
|
|
3097
|
+
;// ./node_modules/lit-html/directive.js
|
|
3098
|
+
/**
|
|
3099
|
+
* @license
|
|
3100
|
+
* Copyright 2017 Google LLC
|
|
3101
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
3102
|
+
*/
|
|
3103
|
+
const directive_t={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},directive_e=t=>(...e)=>({_$litDirective$:t,values:e});class directive_i{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,e,i){this._$Ct=t,this._$AM=e,this._$Ci=i}_$AS(t,e){return this.update(t,e)}update(t,e){return this.render(...e)}}
|
|
3104
|
+
//# sourceMappingURL=directive.js.map
|
|
3105
|
+
|
|
3106
|
+
;// ./node_modules/lit-html/async-directive.js
|
|
3107
|
+
|
|
3108
|
+
/**
|
|
3109
|
+
* @license
|
|
3110
|
+
* Copyright 2017 Google LLC
|
|
3111
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
3112
|
+
*/const async_directive_s=(i,t)=>{const e=i._$AN;if(void 0===e)return!1;for(const i of e)i._$AO?.(t,!1),async_directive_s(i,t);return!0},async_directive_o=i=>{let t,e;do{if(void 0===(t=i._$AM))break;e=t._$AN,e.delete(i),i=t}while(0===e?.size)},async_directive_r=i=>{for(let t;t=i._$AM;i=t){let e=t._$AN;if(void 0===e)t._$AN=e=new Set;else if(e.has(i))break;e.add(i),async_directive_c(t)}};function async_directive_h(i){void 0!==this._$AN?(async_directive_o(this),this._$AM=i,async_directive_r(this)):this._$AM=i}function async_directive_n(i,t=!1,e=0){const r=this._$AH,h=this._$AN;if(void 0!==h&&0!==h.size)if(t)if(Array.isArray(r))for(let i=e;i<r.length;i++)async_directive_s(r[i],!1),async_directive_o(r[i]);else null!=r&&(async_directive_s(r,!1),async_directive_o(r));else async_directive_s(this,i)}const async_directive_c=i=>{i.type==directive_t.CHILD&&(i._$AP??=async_directive_n,i._$AQ??=async_directive_h)};class async_directive_f extends directive_i{constructor(){super(...arguments),this._$AN=void 0}_$AT(i,t,e){super._$AT(i,t,e),async_directive_r(this),this.isConnected=i._$AU}_$AO(i,t=!0){i!==this.isConnected&&(this.isConnected=i,i?this.reconnected?.():this.disconnected?.()),t&&(async_directive_s(this,i),async_directive_o(this))}setValue(t){if(directive_helpers_f(this._$Ct))this._$Ct._$AI(t,this);else{const i=[...this._$Ct._$AH];i[this._$Ci]=t,this._$Ct._$AI(i,this,0)}}disconnected(){}reconnected(){}}
|
|
3113
|
+
//# sourceMappingURL=async-directive.js.map
|
|
3114
|
+
|
|
3115
|
+
;// ./node_modules/lit-html/directives/private-async-helpers.js
|
|
3116
|
+
/**
|
|
3117
|
+
* @license
|
|
3118
|
+
* Copyright 2021 Google LLC
|
|
3119
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
3120
|
+
*/
|
|
3121
|
+
const private_async_helpers_t=async(t,s)=>{for await(const i of t)if(!1===await s(i))return};class private_async_helpers_s{constructor(t){this.G=t}disconnect(){this.G=void 0}reconnect(t){this.G=t}deref(){return this.G}}class private_async_helpers_i{constructor(){this.Y=void 0,this.Z=void 0}get(){return this.Y}pause(){this.Y??=new Promise((t=>this.Z=t))}resume(){this.Z?.(),this.Y=this.Z=void 0}}
|
|
3122
|
+
//# sourceMappingURL=private-async-helpers.js.map
|
|
3123
|
+
|
|
3124
|
+
;// ./node_modules/lit-html/directives/async-replace.js
|
|
3125
|
+
|
|
3126
|
+
/**
|
|
3127
|
+
* @license
|
|
3128
|
+
* Copyright 2017 Google LLC
|
|
3129
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
3130
|
+
*/class async_replace_o extends async_directive_f{constructor(){super(...arguments),this._$CK=new private_async_helpers_s(this),this._$CX=new private_async_helpers_i}render(i,s){return T}update(i,[s,r]){if(this.isConnected||this.disconnected(),s===this._$CJ)return T;this._$CJ=s;let n=0;const{_$CK:o,_$CX:h}=this;return private_async_helpers_t(s,(async t=>{for(;h.get();)await h.get();const i=o.deref();if(void 0!==i){if(i._$CJ!==s)return!1;void 0!==r&&(t=r(t,n)),i.commitValue(t,n),n++}return!0})),T}commitValue(t,i){this.setValue(t)}disconnected(){this._$CK.disconnect(),this._$CX.pause()}reconnected(){this._$CK.reconnect(this),this._$CX.resume()}}const async_replace_h=directive_e(async_replace_o);
|
|
3131
|
+
//# sourceMappingURL=async-replace.js.map
|
|
3132
|
+
|
|
3133
|
+
;// ./src/texts.ts
|
|
3134
|
+
// QR CODE
|
|
3135
|
+
const scanQrToConnectText = 'Scan the QR code to connect with me';
|
|
3136
|
+
//ERRORS & SUCCESS
|
|
3137
|
+
//Same 'not logged in' error message like on 'Chat with me' button
|
|
3138
|
+
const userNotLoggedInErrorMessage = 'Current user not found! Not logged in?';
|
|
3139
|
+
const internalErrorMessage = 'An internal error occured!';
|
|
3140
|
+
const friendWasAddedSuccesMessage = 'Friend was added!';
|
|
3141
|
+
//OTHER
|
|
3142
|
+
const friendExistsMessage = 'Friend already exists';
|
|
3143
|
+
const loadingMessage = 'Loading...';
|
|
3144
|
+
//BUTTONS
|
|
3145
|
+
const addMeToYourFriendsButtonText = 'Add me to your friends';
|
|
3146
|
+
const logInAddMeToYourFriendsButtonText = 'Login to add me to your friends';
|
|
3147
|
+
const logInToChatWithMeButtonText = 'Login to chat with me';
|
|
3148
|
+
const friendExistsAlreadyButtonText = 'Already part of friends';
|
|
3149
|
+
const chatWithMeButtonText = 'Chat with me';
|
|
3150
|
+
|
|
3151
|
+
;// ./src/buttonsHelper.ts
|
|
3152
|
+
|
|
3153
|
+
function complain(buttonContainer, context, error) {
|
|
3154
|
+
const errorBlock = external_UI_.widgets.errorMessageBlock(context.dom, error);
|
|
3155
|
+
errorBlock.setAttribute('role', 'alert');
|
|
3156
|
+
errorBlock.setAttribute('aria-live', 'assertive');
|
|
3157
|
+
errorBlock.setAttribute('tabindex', '0');
|
|
3158
|
+
// Focus the error message for screen readers
|
|
3159
|
+
setTimeout(() => {
|
|
3160
|
+
errorBlock.focus();
|
|
3161
|
+
}, 100);
|
|
3162
|
+
buttonContainer.appendChild(errorBlock);
|
|
3163
|
+
}
|
|
3164
|
+
function mention(buttonContainer, message) {
|
|
3165
|
+
const positiveFrontendMessageDiv = document.createElement('div');
|
|
3166
|
+
positiveFrontendMessageDiv.setAttribute('role', 'status');
|
|
3167
|
+
positiveFrontendMessageDiv.setAttribute('aria-live', 'polite');
|
|
3168
|
+
positiveFrontendMessageDiv.setAttribute('tabindex', '0');
|
|
3169
|
+
positiveFrontendMessageDiv.setAttribute('style', 'margin: 0.1em; padding: 0.5em; border: 0.05em solid gray; background-color: #efe; color:black;');
|
|
3170
|
+
positiveFrontendMessageDiv.innerHTML = message;
|
|
3171
|
+
// Focus the success message for screen readers
|
|
3172
|
+
setTimeout(() => {
|
|
3173
|
+
positiveFrontendMessageDiv.focus();
|
|
3174
|
+
}, 100);
|
|
3175
|
+
buttonContainer.appendChild(positiveFrontendMessageDiv);
|
|
3176
|
+
}
|
|
3177
|
+
function clearPreviousMessage(buttonContainer) {
|
|
3178
|
+
while (buttonContainer.childNodes.length > 1) {
|
|
3179
|
+
buttonContainer.removeChild(buttonContainer.lastChild);
|
|
3180
|
+
}
|
|
3181
|
+
}
|
|
3182
|
+
function checkIfAnyUserLoggedIn(me) {
|
|
3183
|
+
if (me)
|
|
3184
|
+
return true;
|
|
3185
|
+
else
|
|
3186
|
+
return false;
|
|
3187
|
+
}
|
|
3188
|
+
|
|
3189
|
+
|
|
3190
|
+
;// ./src/ChatWithMe.ts
|
|
3191
|
+
|
|
3192
|
+
|
|
3193
|
+
|
|
3194
|
+
|
|
3195
|
+
|
|
3196
|
+
|
|
3197
|
+
|
|
3198
|
+
const ChatWithMe = (subject, context) => {
|
|
3199
|
+
const logic = context.session.logic;
|
|
3200
|
+
const longChatPane = context.session.paneRegistry.byName('long chat');
|
|
3201
|
+
async function* chatContainer() {
|
|
3202
|
+
const chatContainer = context.dom.createElement('section');
|
|
3203
|
+
chatContainer.setAttribute('class', 'chatSection');
|
|
3204
|
+
chatContainer.setAttribute('aria-labelledby', 'chat-section-title');
|
|
3205
|
+
chatContainer.setAttribute('role', 'region');
|
|
3206
|
+
chatContainer.setAttribute('data-testid', 'chat');
|
|
3207
|
+
// Add hidden title for screen readers
|
|
3208
|
+
const title = context.dom.createElement('h3');
|
|
3209
|
+
title.id = 'chat-section-title';
|
|
3210
|
+
title.className = 'sr-only';
|
|
3211
|
+
title.textContent = 'Communication';
|
|
3212
|
+
chatContainer.appendChild(title);
|
|
3213
|
+
let exists;
|
|
3214
|
+
try {
|
|
3215
|
+
yield x `
|
|
3216
|
+
<div class="chatLoading" role="status" aria-live="polite">
|
|
3217
|
+
${loadingMessage.toUpperCase()}
|
|
3218
|
+
</div>
|
|
3219
|
+
`;
|
|
3220
|
+
exists = await logic.chat.getChat(subject, false);
|
|
3221
|
+
}
|
|
3222
|
+
catch (e) {
|
|
3223
|
+
exists = false;
|
|
3224
|
+
}
|
|
3225
|
+
if (exists) {
|
|
3226
|
+
const chatArea = context.dom.createElement('div');
|
|
3227
|
+
chatArea.setAttribute('role', 'log');
|
|
3228
|
+
chatArea.setAttribute('aria-label', 'Chat conversation');
|
|
3229
|
+
chatArea.appendChild(longChatPane.render(exists, context, {}));
|
|
3230
|
+
chatContainer.appendChild(chatArea);
|
|
3231
|
+
yield chatContainer;
|
|
3232
|
+
}
|
|
3233
|
+
else {
|
|
3234
|
+
const me = external_SolidLogic_.authn.currentUser();
|
|
3235
|
+
let label = checkIfAnyUserLoggedIn(me) ? chatWithMeButtonText.toUpperCase() : logInToChatWithMeButtonText.toUpperCase();
|
|
3236
|
+
const button = external_UI_.widgets.button(context.dom, undefined, label, setButtonHandler, { needsBorder: true });
|
|
3237
|
+
async function setButtonHandler(event) {
|
|
3238
|
+
event.preventDefault();
|
|
3239
|
+
try {
|
|
3240
|
+
const chat = await logic.chat.getChat(subject, true);
|
|
3241
|
+
chatContainer.innerHTML = '';
|
|
3242
|
+
chatContainer.appendChild(longChatPane.render(chat, context, {}));
|
|
3243
|
+
}
|
|
3244
|
+
catch (error) {
|
|
3245
|
+
complain(chatContainer, context, error);
|
|
3246
|
+
}
|
|
3247
|
+
}
|
|
3248
|
+
button.refresh = refreshButton();
|
|
3249
|
+
function refreshButton() {
|
|
3250
|
+
const me = external_SolidLogic_.authn.currentUser();
|
|
3251
|
+
if (checkIfAnyUserLoggedIn(me)) {
|
|
3252
|
+
button.innerHTML = chatWithMeButtonText.toUpperCase();
|
|
3253
|
+
button.className = 'button';
|
|
3254
|
+
button.setAttribute('class', external_UI_.style.primaryButton);
|
|
3255
|
+
}
|
|
3256
|
+
else {
|
|
3257
|
+
//not logged in
|
|
3258
|
+
button.innerHTML = logInToChatWithMeButtonText.toUpperCase();
|
|
3259
|
+
button.className = 'button';
|
|
3260
|
+
button.setAttribute('class', external_UI_.style.primaryButton);
|
|
3261
|
+
}
|
|
3262
|
+
}
|
|
3263
|
+
button.setAttribute('type', 'button');
|
|
3264
|
+
button.setAttribute('aria-describedby', 'chat-button-description');
|
|
3265
|
+
const description = context.dom.createElement('span');
|
|
3266
|
+
description.id = 'chat-button-description';
|
|
3267
|
+
description.className = 'sr-only';
|
|
3268
|
+
description.textContent = 'Start a new conversation or sign in to continue existing chat';
|
|
3269
|
+
chatContainer.appendChild(button);
|
|
3270
|
+
chatContainer.appendChild(description);
|
|
3271
|
+
yield chatContainer;
|
|
3272
|
+
}
|
|
3273
|
+
}
|
|
3274
|
+
return x ` ${async_replace_h(chatContainer())} `;
|
|
3275
|
+
};
|
|
3276
|
+
|
|
3277
|
+
;// ./src/FriendList.ts
|
|
3278
|
+
|
|
3279
|
+
|
|
3280
|
+
|
|
3281
|
+
const FriendList = (subject, context) => {
|
|
3282
|
+
var _a;
|
|
3283
|
+
const friends = extractFriends(subject, context);
|
|
3284
|
+
if (!friends || !((_a = friends.textContent) === null || _a === void 0 ? void 0 : _a.trim()))
|
|
3285
|
+
return null;
|
|
3286
|
+
return x `
|
|
3287
|
+
<section
|
|
3288
|
+
class="friendListSection"
|
|
3289
|
+
role="region"
|
|
3290
|
+
aria-labelledby="friends-section-title"
|
|
3291
|
+
data-testid="friend-list"
|
|
3292
|
+
>
|
|
3293
|
+
<header>
|
|
3294
|
+
<h3 id="friends-section-title" class="sr-only">Friend Connections</h3>
|
|
3295
|
+
</header>
|
|
3296
|
+
<nav aria-label="Friend profiles">
|
|
3297
|
+
<ul class="friendList" role="list">
|
|
3298
|
+
${friends}
|
|
3299
|
+
</ul>
|
|
3300
|
+
</nav>
|
|
3301
|
+
</section>
|
|
3302
|
+
`;
|
|
3303
|
+
};
|
|
3304
|
+
const extractFriends = (subject, { dom }) => {
|
|
3305
|
+
const target = dom.createElement('div');
|
|
3306
|
+
external_UI_.widgets.attachmentList(dom, subject, target, {
|
|
3307
|
+
doc: subject.doc(),
|
|
3308
|
+
modify: false,
|
|
3309
|
+
predicate: external_UI_.ns.foaf('knows'),
|
|
3310
|
+
noun: 'friend',
|
|
3311
|
+
});
|
|
3312
|
+
if (target.textContent === '')
|
|
3313
|
+
return null;
|
|
3314
|
+
// Add 'friendItem' class to each <li> for zebra striping
|
|
3315
|
+
target.querySelectorAll('li').forEach(li => li.classList.add('friendItem'));
|
|
3316
|
+
return target;
|
|
3317
|
+
};
|
|
3318
|
+
|
|
3319
|
+
// EXTERNAL MODULE: ./node_modules/validate-color/lib/index.js
|
|
3320
|
+
var lib = __webpack_require__(77);
|
|
3321
|
+
;// ./src/presenter.ts
|
|
3322
|
+
|
|
3323
|
+
|
|
3324
|
+
|
|
3325
|
+
function pronounsAsText(subject) {
|
|
3326
|
+
let pronouns = external_SolidLogic_.store.anyJS(subject, external_UI_.ns.solid('preferredSubjectPronoun')) || '';
|
|
3327
|
+
if (pronouns) {
|
|
3328
|
+
const them = external_SolidLogic_.store.anyJS(subject, external_UI_.ns.solid('preferredObjectPronoun'));
|
|
3329
|
+
if (them) {
|
|
3330
|
+
pronouns += '/' + them;
|
|
3331
|
+
const their = external_SolidLogic_.store.anyJS(subject, external_UI_.ns.solid('preferredRelativePronoun'));
|
|
3332
|
+
if (their) {
|
|
3333
|
+
pronouns += '/' + their;
|
|
3334
|
+
}
|
|
3335
|
+
}
|
|
3336
|
+
pronouns = ' (' + pronouns + ') ';
|
|
3337
|
+
}
|
|
3338
|
+
return pronouns || '';
|
|
3339
|
+
}
|
|
3340
|
+
const presentProfile = (subject, store) => {
|
|
3341
|
+
const name = external_UI_.utils.label(subject);
|
|
3342
|
+
const imageSrc = external_UI_.widgets.findImage(subject);
|
|
3343
|
+
const role = store.anyValue(subject, external_UI_.ns.vcard('role'));
|
|
3344
|
+
const orgName = store.anyValue(subject, external_UI_.ns.vcard('organization-name')); // @@ Search whole store
|
|
3345
|
+
const address = store.any(subject, external_UI_.ns.vcard('hasAddress'));
|
|
3346
|
+
const countryName = address != null
|
|
3347
|
+
? store.anyValue(address, external_UI_.ns.vcard('country-name'))
|
|
3348
|
+
: null;
|
|
3349
|
+
const locality = address != null
|
|
3350
|
+
? store.anyValue(address, external_UI_.ns.vcard('locality'))
|
|
3351
|
+
: null;
|
|
3352
|
+
const { backgroundColor, highlightColor } = getColors(subject, store);
|
|
3353
|
+
const pronouns = pronounsAsText(subject);
|
|
3354
|
+
return {
|
|
3355
|
+
name,
|
|
3356
|
+
imageSrc,
|
|
3357
|
+
introduction: formatIntroduction(role, orgName),
|
|
3358
|
+
location: formatLocation(countryName, locality),
|
|
3359
|
+
backgroundColor,
|
|
3360
|
+
pronouns,
|
|
3361
|
+
highlightColor,
|
|
3362
|
+
};
|
|
3363
|
+
};
|
|
3364
|
+
function formatLocation(countryName, locality) {
|
|
3365
|
+
return countryName && locality
|
|
3366
|
+
? `${locality}, ${countryName}`
|
|
3367
|
+
: countryName || locality || null;
|
|
3368
|
+
}
|
|
3369
|
+
function formatIntroduction(role, orgName) {
|
|
3370
|
+
return role && orgName ? `${role} at ${orgName}` : orgName || role || null;
|
|
3371
|
+
}
|
|
3372
|
+
function getColors(subject, store) {
|
|
3373
|
+
const backgroundColor = store.anyValue(subject, external_UI_.ns.solid('profileBackgroundColor'), null, subject.doc());
|
|
3374
|
+
const highlightColor = store.anyValue(subject, external_UI_.ns.solid('profileHighlightColor'), null, subject.doc());
|
|
3375
|
+
return {
|
|
3376
|
+
backgroundColor: validColorOrDefault(backgroundColor, '#eee'),
|
|
3377
|
+
highlightColor: validColorOrDefault(highlightColor, '#090'),
|
|
3378
|
+
};
|
|
3379
|
+
}
|
|
3380
|
+
function validColorOrDefault(color, fallback) {
|
|
3381
|
+
return color && (0,lib.validateHTMLColorHex)(color) ? color : fallback;
|
|
3382
|
+
}
|
|
3383
|
+
|
|
3384
|
+
// EXTERNAL MODULE: external "rdflib"
|
|
3385
|
+
var external_rdflib_ = __webpack_require__(491);
|
|
3386
|
+
;// ./src/CVPresenter.ts
|
|
3387
|
+
|
|
3388
|
+
|
|
3389
|
+
const ORG = (0,external_rdflib_.Namespace)('http://www.w3.org/ns/org#');
|
|
3390
|
+
const typesOfRole = ['PastRole', 'CurrentRole', 'FutureRole'];
|
|
3391
|
+
function skillAsText(store, sk) {
|
|
3392
|
+
if (sk.termType === 'Literal')
|
|
3393
|
+
return sk.value; // Not normal but allow this
|
|
3394
|
+
const publicId = store.anyJS(sk, external_UI_.ns.solid('publicId'));
|
|
3395
|
+
if (publicId) {
|
|
3396
|
+
const name = store.anyJS(publicId, external_UI_.ns.schema('name'));
|
|
3397
|
+
if (name)
|
|
3398
|
+
return name; // @@ check language and get name in diff language if necessary
|
|
3399
|
+
}
|
|
3400
|
+
const manual = store.anyJS(sk, external_UI_.ns.vcard('role'));
|
|
3401
|
+
if (manual && manual[0] > '')
|
|
3402
|
+
return manual;
|
|
3403
|
+
return '¿¿¿ skill ???';
|
|
3404
|
+
}
|
|
3405
|
+
function languageAsText(store, lan) {
|
|
3406
|
+
if (lan.termType === 'Literal')
|
|
3407
|
+
return lan.value; // Not normal but allow this
|
|
3408
|
+
const publicId = store.anyJS(lan, external_UI_.ns.solid('publicId'));
|
|
3409
|
+
if (publicId)
|
|
3410
|
+
return external_UI_.utils.label(publicId, true); // @@ check language and get name in diff language if necessary
|
|
3411
|
+
return '-';
|
|
3412
|
+
}
|
|
3413
|
+
function datesAsText(startDate, endDate) {
|
|
3414
|
+
return startDate ? '(' + startDate.value.slice(0, 10) + ' to ' +
|
|
3415
|
+
(endDate ? endDate.value.slice(0, 10) : '') + ')'
|
|
3416
|
+
: '';
|
|
3417
|
+
}
|
|
3418
|
+
function getRolesByType(store, subject) {
|
|
3419
|
+
const memberships = store.each(null, ORG('member'), subject, null);
|
|
3420
|
+
const rolesByType = { PastRole: [], CurrentRole: [], FutureRole: [] };
|
|
3421
|
+
for (const membership of memberships) {
|
|
3422
|
+
let orgHomePage, orgNameGiven, publicIdName, roleName, publicId;
|
|
3423
|
+
// Things should have start dates but we will be very lenient in this view
|
|
3424
|
+
const startDate = store.any(membership, external_UI_.ns.schema('startDate'));
|
|
3425
|
+
const endDate = store.any(membership, external_UI_.ns.schema('endDate'));
|
|
3426
|
+
const dates = datesAsText(startDate, endDate);
|
|
3427
|
+
const organization = store.any(membership, ORG('organization'));
|
|
3428
|
+
if (organization) {
|
|
3429
|
+
orgNameGiven = store.anyJS(organization, external_UI_.ns.schema('name'));
|
|
3430
|
+
orgHomePage = store.any(organization, external_UI_.ns.schema('uri'));
|
|
3431
|
+
publicId = store.any(organization, external_UI_.ns.solid('publicId'));
|
|
3432
|
+
}
|
|
3433
|
+
if (publicId) {
|
|
3434
|
+
publicIdName = store.anyJS(publicId, external_UI_.ns.schema('name'));
|
|
3435
|
+
}
|
|
3436
|
+
const orgName = publicIdName || orgNameGiven;
|
|
3437
|
+
const escoRole = store.any(membership, ORG('role'));
|
|
3438
|
+
if (escoRole) {
|
|
3439
|
+
roleName = store.anyJS(escoRole, external_UI_.ns.schema('name'));
|
|
3440
|
+
}
|
|
3441
|
+
const roleText0 = store.anyJS(membership, external_UI_.ns.vcard('role'));
|
|
3442
|
+
const roleText = (roleText0 && roleName) ? roleName + ' - ' + roleText0
|
|
3443
|
+
: roleText0 || roleName;
|
|
3444
|
+
const item = {
|
|
3445
|
+
startDate: startDate, endDate, orgName, roleText, dates, orgHomePage
|
|
3446
|
+
};
|
|
3447
|
+
for (const t of typesOfRole) {
|
|
3448
|
+
if (store.holds(membership, external_UI_.ns.rdf('type'), external_UI_.ns.solid(t))) {
|
|
3449
|
+
rolesByType[t].push(item);
|
|
3450
|
+
}
|
|
3451
|
+
}
|
|
3452
|
+
}
|
|
3453
|
+
return rolesByType;
|
|
3454
|
+
}
|
|
3455
|
+
function presentCV(subject, store) {
|
|
3456
|
+
const rolesByType = getRolesByType(store, subject);
|
|
3457
|
+
// Most recent thing most relevant -> sort by end date
|
|
3458
|
+
for (const t of typesOfRole) {
|
|
3459
|
+
rolesByType[t].sort(function (x, y) {
|
|
3460
|
+
if (x.endDate && y.endDate) {
|
|
3461
|
+
return x.endDate > y.endDate ? -1 : 1;
|
|
3462
|
+
}
|
|
3463
|
+
return x.startDate > y.startDate ? -1 : 1;
|
|
3464
|
+
});
|
|
3465
|
+
}
|
|
3466
|
+
const skills = store.each(subject, external_UI_.ns.schema('skills')).map(sk => skillAsText(store, sk));
|
|
3467
|
+
const languagesInStore = store.anyJS(subject, external_UI_.ns.schema('knowsLanguage'));
|
|
3468
|
+
let languages = [];
|
|
3469
|
+
if (languagesInStore)
|
|
3470
|
+
languages = languagesInStore.map(lan => languageAsText(store, lan));
|
|
3471
|
+
return { rolesByType, skills, languages };
|
|
3472
|
+
}
|
|
3473
|
+
|
|
3474
|
+
;// ./src/ontology/profileForm.ttl
|
|
3475
|
+
const profileForm_namespaceObject = "@prefix os: <http://www.w3.org/2000/10/swap/os#> .\n@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.\n@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.\n@prefix foaf: <http://xmlns.com/foaf/0.1/>.\n@prefix owl: <http://www.w3.org/2002/07/owl#>.\n@prefix solid: <http://www.w3.org/ns/solid/terms#>.\n@prefix ui: <http://www.w3.org/ns/ui#>.\n@prefix schema: <http://schema.org/>.\n@prefix vcard: <http://www.w3.org/2006/vcard/ns#>.\n\n@prefix org: <http://www.w3.org/ns/org#>.\n@prefix esco: <http://data.europa.eu/esco/model#>.\n@prefix wd: <http://www.wikidata.org/entity/>.\n@prefix wdt: <http://www.wikidata.org/prop/direct/>.\n\n@prefix : <https://solidos.github.io/profile-pane/src/ontology/profileForm.ttl#>.\n@prefix soc: <https://solidos.github.io/profile-pane/src/ontology/socialMedia.ttl#>.\n\n# was: https://solidos.github.io/solid-panes/dashboard/profileStyle.ttl#this\n# moved to: https://solidos.github.io/profile-pane/src/ontology/profileForm.ttl#this\n\n\n\n\n# About forms: https://solidos.github.io/solid-ui/Documentation/forms-intro.html\n# About personal public data: https://www.w3.org/DesignIssues/PersonalPublic.html\n#\n\n:this\n <http://purl.org/dc/elements/1.1/title> \"Profile form\" ;\n a ui:Form ;\n # ui:part :backgroundColor, :highlightColor;\n ui:parts (\n :styleGroup\n :nicknameField\n :pronounsForm\n :LanguagesPrompt :LanguagesForm\n :SocialsPrompt :SocialsForm\n :CVGroup\n :SkillsPrompt :SkillsForm\n ).\n\n:styleGroup a ui:Group; ui:weight 0; ui:parts ( :styleHeading :backgroundColor :highlightColor ).\n :styleHeading a ui:Heading; ui:contents \"The style of your public profile.\".\n :backgroundColor a ui:ColorField; ui:property solid:profileBackgroundColor;\n ui:label \"Background color\"; ui:default \"#ffffff\".\n :highlightColor a ui:ColorField; ui:property solid:profileHighlightColor;\n ui:label \"Highlight color\"; ui:default \"#000000\".\n\n# Nickname\n\n:nicknameField a ui:SingleLineTextField; ui:size 12; ui:property foaf:nick;\n ui:label \"Short name for chats, etc.\"@en, \"nom court\"@fr.\n\n # Pronouns\n\n :pronounsForm a ui:Group; ui:weight 0; ui:parts ( :pronounsPrompt :subjectPronounForm :objectPronounForm :relativePronounForm) .\n\n :pronounsPrompt a ui:Comment; ui:contents \"What are your pronouns?\" .\n\n :subjectPronounForm a ui:SingleLineTextField; ui:property solid:preferredSubjectPronoun;\n ui:size 10; ui:label \"he/she/they...\" .\n :objectPronounForm a ui:SingleLineTextField; ui:property solid:preferredObjectPronoun;\n ui:size 10; ui:label \"him/her/them...\" .\n :relativePronounForm a ui:SingleLineTextField; ui:property solid:preferredRelativePronoun;\n ui:size 10; ui:label \"his/hers/theirs...\" .\n\n # Curriculum Vitae: membership of organizations\n\n :CVHeading a ui:Heading; ui:contents \"Public Curriculum Vitae\".\n :CVPrompt a ui:Comment; ui:contents \"What organizations have you been involved with?\" .\n\n :CVGroup a ui:Group; ui:weight 1; ui:parts ( :CVHeading :CVPrompt :involvementWithOrganizationsForm ).\n\n\n solid:Role a rdfs:Class; owl:oneOf ( solid:CurrentRole solid:FormerRole solid:FutureRole ). # Future Role too?\n\n org:member owl:inverse [ ui:label \"involvement with company, org etc\" ]. # timelimited involvement\n\n :involvementWithOrganizationsForm a ui:Multiple;\n ui:label \"Involvement with Organization\";\n ui:property org:member; ui:reverse true; # link back from role to member\n ui:ordered false; # Allow user to order CV secions rather than force date order? No.\n ui:part :RoleMembershipForm.\n\n# This is a big important form for one of a series of roles in the list.\n\n :RoleMembershipForm a ui:Group; ui:weight 3; ui:parts ( :MembershipFormHeading :roleNameField\n :escoOccupationField :orgField :RoleClassifier :RoleDatesForm :RoleDescriptionForm).\n\n :MembershipFormHeading a ui:Heading; ui:contents \"Details of this role\"@en, \"Détailes de ce rôle\"@fr .\n\n :orgField a ui:Choice; ui:label \"Organization\"@en, \"Organization\"@fr;\n ui:canMintNew true; ui:use :OrganizationCreationForm ;\n ui:property org:organization;\n ui:from vcard:Organization .\n :roleNameField a ui:SingleLineTextField; ui:property vcard:role; ui:size 60 .\n\n :escoOccupationField a ui:AutocompleteField;\n ui:label \"occupation\"; ui:size 60;\n ui:property org:role;\n ui:dataSource :ESCO_Occupation_DataSource;\n ui:targetClass schema:Occupation .\n\n :ESCO_Occupation_DataSource a ui:DataSource;\n schema:name \"ESCO\";\n ui:targetClass schema:Occupation ;\n schema:logo <https://ec.europa.eu/esco/portal/static_resource2/images/logo/logo_en.gif>;\n ui:searchByNameURI \"https://ec.europa.eu/esco/api/search?language=$(language)&type=occupation&text=$(name)\".\n\n :instituteIdentityField a ui:AutocompleteField; ui:label \"in wikidata\";\n ui:size 60;\n ui:property solid:publicId; ui:dataSource :WikidataOnOrganizations.\n\n :WikidataOnOrganizations a ui:DataSource ;\n schema:name \"Wikidata\";\n ui:endpoint \"https://query.wikidata.org/sparql\" ;\n ui:targetClass <http://www.wikidata.org/entity/Q43229>; # Use if nothing else\n ui:searchByNameQuery \"\"\"SELECT ?subject ?name\n WHERE {\n ?klass wdt:P279* $(targetClass) .\n ?subject wdt:P31 ?klass .\n ?subject rdfs:label ?name.\n FILTER regex(?name, \"$(name)\", \"i\")\n } LIMIT $(limit) \"\"\" .\n\n :WikidataOnOrganizations ui:classMap\n [ ui:internalClass schema:Corporation; ui:externalClass <http://www.wikidata.org/entity/Q6881511>], #Enterprise is for-profit\n [ ui:internalClass schema:EducationalOrganization; ui:externalClass <http://www.wikidata.org/entity/Q178706>], #insitution\n [ ui:internalClass schema:ResearchOrganization; ui:externalClass <http://www.wikidata.org/entity/Q31855>], # reearch insitutie\n [ ui:internalClass schema:GovernmentOrganization; ui:externalClass <http://www.wikidata.org/entity/Q327333>], #government agency\n [ ui:internalClass schema:MedicalOrganization; ui:externalClass <http://www.wikidata.org/entity/Q4287745>],\n [ ui:internalClass schema:MusicGroup; ui:externalClass <http://www.wikidata.org/entity/Q32178211>], #music organization\n [ ui:internalClass schema:NGO; ui:externalClass <http://www.wikidata.org/entity/Q163740>], #nonprofit organization @@\n [ ui:internalClass schema:Occupation; ui:externalClass <http://www.wikidata.org/entity/Q28640>], # superclass: Profession\n [ ui:internalClass schema:Organization; ui:externalClass <http://www.wikidata.org/entity/Q43229>], # Superclass; Organization\n [ ui:internalClass schema:Project; ui:externalClass <http://www.wikidata.org/entity/Q170584>],\n [ ui:internalClass schema:SportsOrganization; ui:externalClass <http://www.wikidata.org/entity/Q4438121>] .\n\n\n# eposodes in one's career - Roles\n\nsolid:Role owl:disjointUnionOf ( solid:PastRole solid:CurrentRole solid:FutureRole ) .\nsolid:PastRole a rdfs:Class; rdfs:label \"former role\"@en, \"ancien rôle\"@fr, \"vergangene Rolle\"@de, \"rol anterior\"@es .\nsolid:CurrentRole a rdfs:Class; rdfs:label \"current role\"@en, \"rôle actuel\"@fr, \"momentane Rolle\"@de , \"rol actual\"@es .\nsolid:FutureRole a rdfs:Class; rdfs:label \"future role\"@en, \"rôle à venir\"@fr, \"zukünftige Rolle\"@de, \"rol futuro\"@es .\n\n:RoleDatesGroup a ui:Group; ui:weight 0; ui:parts ( :RoleClassifier :RoleDatesForm ) .\n :RoleClassifier a ui:Classifier; ui:label \"What sort of role?\"@en;\n ui:category solid:Role .\n\n :RoleDatesForm a ui:Options; ui:dependingOn rdf:type; ui:case\n [ ui:for solid:PastRole; ui:use :TwoDateForm ],\n [ ui:for solid:CurrentRole; ui:use :StartDateForm ],\n [ ui:for solid:FutureRole; ui:use :StartDateForm ].\n\n :StartDateForm a ui:DateField; ui:label \"start\"@en,\"début\"@fr;\n ui:property schema:startDate .\n :TwoDateForm a ui:Group; ui:weight 0; ui:parts ( :StartDateForm :EndDateForm ) .\n :EndDateForm a ui:DateField; ui:label \"end\"@en,\"fin\"@fr;\n ui:property schema:endDate .\n\n:RoleDescriptionForm a ui:MultiLineTextField; ui:property schema:description;\n ui:label \"Describe your role\" .\n\n# Organizations\n\n vcard:Organization ui:creationForm :OrganizationCreationForm .\n\n# Ontology data to drive the classifier\n\nsolid:InterestingOrganization owl:disjointUnionOf (\n# Airline - a Corporation\n# Consortium - a Corporation or a NGO\n schema:Corporation\n schema:EducationalOrganization\n schema:ResearchOrganization # Proposed. https://github.com/schemaorg/schemaorg/issues/2877\n# FundingScheme - eh?\n schema:GovernmentOrganization\n# LibrarySystem\n# LocalBusiness - Corporation\n# MedicalOrganization - a Corporation or a NGO\n schema:NGO\n # NewsMediaOrganization - a Corporation or a NGO\nschema:PerformingGroup # a band\nschema:Project # like Solid\nschema:SportsOrganization # a Team\nsolid:OtherOrganization\n ) .\n\n# This until the schema.org ontology adopts it\nschema:ResearchOrganization a rdfs:Class; rdfs:label \"Research Organization\"@en, \"Organization de Recherche\"@fr ,\n \"organización de investigación\"@es, \"منظمة البحث\"@ar, \"अनुसंधान संगठन\"@hi, \"Forschungsorganisation\"@de, \"shirika la utafiti\"@sw .\n\n :OrganizationCreationForm a ui:Form; schema:name \"Form for editing an organization using public data\" ;\n ui:parts ( :OrgClassifier :OrgSwitch :OrganizationNameField :homePageURIField ) .\n\n\n :OrgClassifier a ui:Classifier; ui:label \"What sort of organization?\"@en;\n ui:category solid:InterestingOrganization .\n\n :OrganizationNameField\n a ui:SingleLineTextField ;\n ui:label \"Organization Name\";\n ui:maxLength \"200\" ;\n ui:property schema:name ;\n ui:size 80 .\n\n :homePageURIField a ui:NamedNodeURIField; ui:size 80;\n ui:label \"Home page URI\"@en;\n ui:property schema:uri . # @@ ??\n\n :initituteTypeField a ui:Classifier;\n ui:label \"What sort of organization\";\n ui:category solid:InterestingOrganization .\n\n# Depending on the type of org, chose a different form\n\n :OrgSwitch a ui:Options; ui:dependingOn rdf:type;\n ui:case\n [ ui:for schema:Corporation; ui:use :CorporationForm ],\n [ ui:for schema:GovernmentOrganization; ui:use :GovernmentOrganizationForm ],\n [ ui:for schema:PerformingGroup; ui:use :PerformingGroupForm ],\n [ ui:for schema:Project; ui:use :ProjectForm ],\n [ ui:for schema:NGO; ui:use :NGOForm ],\n [ ui:for schema:EducationalOrganization; ui:use :EducationalOrganizationForm ],\n [ ui:for schema:ResearchOrganization; ui:use :ResearchOrganizationForm ],\n [ ui:for :SportsOrganization; ui:use :SportsOrganizationForm ],\n [ ui:for solid:OtherOrganization; ui:use :OtherOrganizationForm ].\n\n\n :CorporationForm a ui:Group; ui:weight 0; ui:parts ( :CorporationPrompt :CorporationAutocomplete ) .\n\n :CorporationPrompt a ui:Comment; ui:contents \"Which corporation?\".\n\n :CorporationAutocomplete a ui:AutocompleteField;\n a ui:AutocompleteField; ui:label \"Corporation in wikidata\";\n ui:size 60;\n ui:targetClass <http://www.wikidata.org/entity/Q6881511>; # Enterprise\n ui:property solid:publicId; ui:dataSource :WikidataInstancesByName.\n\n :WikidataInstancesByName a ui:DataSource ;\n schema:name \"Wikidata instances by name\";\n ui:endpoint \"https://query.wikidata.org/sparql\" ;\n ui:searchByNameQuery \"\"\"SELECT ?subject ?name\n WHERE {\n ?klass wdt:P279* $(targetClass) .\n ?subject wdt:P31 ?klass .\n ?subject rdfs:label ?name.\n FILTER regex(?name, \"$(name)\", \"i\")\n } LIMIT $(limit) \"\"\" ;\n\n # Note this form of the query is very experimental\n ui:searchByName [ ui:construct { ?subject schema:name ?name } ;\n ui:where { ?klass wdt:P279 ?targetClass .\n ?subject wdt:P31 ?klass; rdfs:label ?name .\n };\n ].\n\n :GovernmentOrganizationForm a ui:Group; ui:weight 0; ui:parts ( :GovernmentOrganizationPrompt :GovernmentOrganizationAutocomplete ) .\n\n :GovernmentOrganizationPrompt a ui:Comment; ui:contents \"Which GovernmentOrganization?\".\n\n :GovernmentOrganizationAutocomplete\n a ui:AutocompleteField; ui:label \"GovernmentOrganization in wikidata\";\n ui:size 60;\n ui:targetClass <http://www.wikidata.org/entity/Q327333>; # GovernmentOrganization\n ui:property solid:publicId; ui:dataSource :WikidataInstancesByName.\n\n :EducationalOrganizationForm a ui:Group; ui:weight 1; ui:parts ( :EducationalOrganizationPrompt :EducationalOrganizationAutocomplete ) .\n\n :EducationalOrganizationPrompt a ui:Comment; ui:contents \"Which Educational Organization?\".\n\n :EducationalOrganizationAutocomplete\n a ui:AutocompleteField; ui:label \"Educational Organization in wikidata\";\n ui:size 60;\n ui:targetClass <http://www.wikidata.org/entity/Q2385804>; # EducationalOrganization\n ui:property solid:publicId; ui:dataSource :WikidataInstancesByName.\n\n\n :ResearchOrganizationForm a ui:Group; ui:weight 0; ui:parts ( :ResearchOrganizationPrompt :ResearchOrganizationAutocomplete ) .\n\n :ResearchOrganizationPrompt a ui:Comment; ui:contents \"Which Research Organization?\".\n\n :ResearchOrganizationAutocomplete\n a ui:AutocompleteField; ui:label \"Research Insitute in wikidata\";\n ui:size 60;\n ui:targetClass <http://www.wikidata.org/entity/Q31855>; # research institute\n ui:property solid:publicId; ui:dataSource :WikidataInstancesByName.\n\n\n :NGOForm a ui:Group; ui:weight 0; ui:parts ( :NGOPrompt :NGOAutocomplete ) .\n\n :NGOPrompt a ui:Comment; ui:contents \"Which NGO?\".\n\n :NGOAutocomplete\n a ui:AutocompleteField; ui:label \"NGO in wikidata\";\n ui:size 60;\n ui:targetClass <http://www.wikidata.org/entity/Q163740>; # Non-profit org\n ui:property solid:publicId; ui:dataSource :WikidataInstancesByName.\n\n :PerformingGroupForm a ui:Group; ui:weight 0; ui:parts ( :PerformingGroupPrompt :PerformingGroupAutocomplete ) .\n\n :PerformingGroupPrompt a ui:Comment; ui:contents \"Which PerformingGroup?\".\n\n :PerformingGroupAutocomplete\n a ui:AutocompleteField; ui:label \"PerformingGroup in wikidata\";\n ui:size 60;\n ui:targetClass <http://www.wikidata.org/entity/Q32178211>; # Music Org\n ui:property solid:publicId; ui:dataSource :WikidataInstancesByName.\n\n\n :ProjectForm a ui:Group; ui:weight 0; ui:parts ( :ProjectPrompt :ProjectAutocomplete ) . # :ProjectAutocomplete - no: supress, as not in WD\n\n :ProjectPrompt a ui:Comment; ui:contents \"Which Project?\".\n\n :ProjectAutocomplete\n a ui:AutocompleteField; ui:label \"Project in wikidata\";\n ui:size 60;\n ui:targetClass <http://www.wikidata.org/entity/Q170584>; # Project\n ui:property solid:publicId; ui:dataSource :WikidataInstancesByName.\n\n :SportsOrganizationForm a ui:Group; ui:weight 0; ui:parts ( :SportsOrganizationPrompt :SportsOrganizationAutocomplete ) .\n\n :SportsOrganizationPrompt a ui:Comment; ui:contents \"Which Sports Organization?\".\n\n :SportsOrganizationAutocomplete\n a ui:AutocompleteField; ui:label \"SportsOrganization in wikidata\";\n ui:size 60;\n ui:targetClass <http://www.wikidata.org/entity/Q4438121>; # SportsOrganization\n ui:property solid:publicId; ui:dataSource :WikidataInstancesByName.\n\n :OtherOrganizationForm a ui:Group; ui:weight 0; ui:parts ( :OrganizationNameField :homePageURIField ) .\n\n #################### Skills\n\n :SkillsPrompt a ui:Comment; ui:contents \"Skills?\" .\n\n :SkillsForm a ui:Multiple;\n ui:label \"Skills\";\n ui:property schema:skills;\n ui:ordered false; # Allow reader to order skills\n ui:part :SkillForm.\n\n :SkillForm a ui:Group; ui:weight 1; ui:parts ( :escoSkillField ).\n\n # :skillNameField a ui:SingleLineTextField; ui:property vcard:role; ui:size 30 .\n\n :escoSkillField a ui:AutocompleteField;\n ui:label \"skill\"; ui:size 30;\n ui:property solid:publicId;\n ui:dataSource :ESCO_Skill_DataSource;\n ui:targetClass schema:Skill .\n\n :ESCO_Skill_DataSource a ui:DataSource;\n schema:name \"ESCO Skill\";\n ui:targetClass esco:Skill ;\n schema:logo <https://ec.europa.eu/esco/portal/static_resource2/images/logo/logo_en.gif>;\n ui:searchByNameURI \"https://ec.europa.eu/esco/api/search?language=$(language)&limit=$(limit)&type=skill&text=$(name)\".\n\n# Language\n\n:LanguagesPrompt a ui:Comment; ui:contents \"Languages?\" .\n\n:LanguagesForm a ui:Multiple;\n ui:label \"Languages\";\n ui:property schema:knowsLanguage; # @@@\n ui:ordered true; # Allow user to order languages most important first.\n ui:part :LanguageForm.\n\n:LanguageForm a ui:Group; ui:weight 1; ui:parts ( :WikidataLanguageField ).\n\n :WikidataLanguageField a ui:AutocompleteField;\n ui:label \"Language\"; ui:size 30;\n ui:property solid:publicId; # @@\n ui:dataSource :WikidataLanguageDataSource;\n ui:targetClass schema:Language .\n\n :WikidataLanguageDataSource\n schema:name \"Wikidata languages\";\n ui:endpoint \"https://query.wikidata.org/sparql\" ;\n ui:objectURIBase <https://www.w3.org/ns/iana/language-code/>;\n # Add this to any literal string returned as ?subject\n\n ui:searchByNameQuery \"\"\"SELECT ?item ?subject ?name\nWHERE\n{ ?item wdt:P305 ?subject .\n OPTIONAL {?item rdfs:label ?name}\n OPTIONAL {?item wdt:P1705 ?name}\n FILTER regex(?name, \"$(name)\", \"i\")\n FILTER regex(?subject, \"^..$\", \"i\")\n}\"\"\" .\n # Note we restrict code to two-letter codes with the second regex, so as to limit the deluge of languages\n # Hope there are not any important ones which have three-letter codes.\n # Omitted: SERVICE wikibase:label { bd:serviceParam wikibase:language \"$(languages)\". }\n\n########### Social Media - other accounts\n#\n# Twitter, Linked In, Orkid, Mastodon, Matrix, Bluesky, Instagram, Facebook, Github,\n# Snapchat, TikTok, etc\n\n:SocialsPrompt a ui:Heading; ui:contents \"Social Media etc?\" .\n:SocialsPrompt a ui:Comment; ui:contents \"Link to accounts in social media sites, etc\" .\n\n:SocialsForm a ui:Multiple;\n ui:label \"online account\";\n ui:property foaf:account;\n ui:ordered true; # Allow user to order occounts most important first.\n ui:part :AccountsForm.\n\n:AccountsForm a ui:Group; ui:weight 1; ui:parts ( :AccountField :AccountIdField ).\n\n:AccountField a ui:Classifier; ui:label \"What sort of account?\"@en;\n ui:multiple false ; \n ui:category foaf:Account .\n\n:AccountIdField a ui:Options . \n\n :AccountIdField a ui:Options; ui:dependingOn rdf:type; ui:case\n [ ui:for soc:BlueSkyAccount; ui:use :BlueSkyIdField ],\n [ ui:for soc:FacebookAccount; ui:use :FacebookIdField ],\n [ ui:for soc:GithubAccount; ui:use :GithubIdField ],\n [ ui:for soc:InstagramAccount; ui:use :InstagramIdField ],\n [ ui:for soc:LinkedInAccount; ui:use :LinkedInIdField ],\n [ ui:for soc:MastodonAccount; ui:use :MastodonIdField ],\n [ ui:for soc:MatrixAccount; ui:use :MatrixIdField ],\n [ ui:for soc:MediumAccount; ui:use :MediumIdField ],\n [ ui:for soc:NostrAccount; ui:use :NostrIdField ],\n [ ui:for soc:OrcidAccount; ui:use :OrcidIdField ],\n [ ui:for soc:PinterestAccount; ui:use :PinterestIdField ],\n [ ui:for soc:RedditAccount; ui:use :RedditIdField ],\n [ ui:for soc:StravaAccount; ui:use :StravaIdField ],\n [ ui:for soc:SnapchatAccount; ui:use :SnapchatIdField ],\n [ ui:for soc:TiktokAccount; ui:use :TiktokIdField ],\n [ ui:for soc:TumblrAccount; ui:use :TumblrIdField ],\n [ ui:for soc:TwitterAccount; ui:use :TwitterIdField ],\n [ ui:for soc:OtherAccount; ui:use :OtherIdForm ] .\n\n :BlueSkyIdField\n a ui:SingleLineTextField ;\n ui:label \"Bluesky Id\";\n ui:maxLength \"200\" ;\n ui:property foaf:accountName ; \n ui:pattern \"@[a-z0-9A-Z_-](.[a-z0-9A-Z_-])*\"; # @@\n ui:size 40 .\n\n :FacebookIdField\n a ui:SingleLineTextField ;\n ui:label \"Facebook Id\";\n ui:maxLength \"200\" ;\n ui:property foaf:accountName ; \n ui:pattern \"[a-z0-9A-Z_-]*\"; # @@\n ui:size 40 .\n\n :GithubIdField\n a ui:SingleLineTextField ;\n ui:label \"Github Id\";\n ui:maxLength \"200\" ;\n ui:property foaf:accountName ; \n ui:pattern \"[a-z0-9A-Z_-]*\"; # @@\n ui:size 40 .\n\n :InstagramIdField\n a ui:SingleLineTextField ;\n ui:label \"Instagram Id\";\n ui:maxLength \"200\" ;\n ui:property foaf:accountName ; \n ui:pattern \"[a-z0-9A-Z_-]*\"; # @@\n ui:size 40 .\n\n :LinkedInIdField\n a ui:SingleLineTextField ;\n ui:label \"Linked In Id\";\n ui:maxLength \"200\" ;\n ui:property foaf:accountName ; \n ui:pattern \"[a-z0-9A-Z_-]*(.[a-z0-9A-Z_-])*\"; # @@\n ui:size 40 .\n\n :MastodonIdField\n a ui:SingleLineTextField ;\n ui:label \"Mastodon (Activity Pub) Id\";\n ui:maxLength \"200\" ;\n ui:property foaf:accountName ; \n ui:pattern \"@[a-z0-9A-Z_-]*(.[a-z0-9A-Z_-])*\"; # @@\n ui:size 40 .\n\n :MatrixIdField\n a ui:SingleLineTextField ;\n ui:label \"Matrix Username\";\n ui:maxLength \"200\" ;\n ui:property foaf:accountName ; \n ui:pattern \"@[a-z0-9A-Z_-]*(.[a-z0-9A-Z_-])*\"; # @@\n ui:size 40 .\n\n :MediumIdField\n a ui:SingleLineTextField ;\n ui:label \"Medium Username\";\n ui:maxLength \"200\" ;\n ui:property foaf:accountName ; \n ui:pattern \"@[a-z0-9A-Z_-]*(.[a-z0-9A-Z_-])*\"; # @@\n ui:size 40 .\n\n :NostrIdField\n a ui:SingleLineTextField ;\n ui:label \"Nostr public key\";\n ui:maxLength \"200\" ;\n ui:property foaf:accountName ; \n ui:pattern \"[a-z0-9A-Z_-]*(.[a-z0-9A-Z_-])*\"; # @@\n ui:size 70 .\n\n :OrcidIdField\n a ui:SingleLineTextField ;\n ui:label \"ORCiD id\";\n ui:maxLength \"200\" ;\n ui:property foaf:accountName ; \n ui:pattern \"[a-z0-9A-Z_-]*\"; # @@\n ui:size 40 .\n\n :PinterestIdField\n a ui:SingleLineTextField ;\n ui:label \"Pinterest id\";\n ui:maxLength \"200\" ;\n ui:property foaf:accountName ; \n ui:pattern \"[a-z0-9A-Z_-]*\"; # @@\n ui:size 40 .\n\n :RedditIdField\n a ui:SingleLineTextField ;\n ui:label \"Reddit Id\";\n ui:maxLength \"200\" ;\n ui:property foaf:accountName ; \n ui:pattern \"[a-z0-9A-Z_-]*\"; # @@\n ui:size 40 .\n\n :StravaIdField\n a ui:SingleLineTextField ;\n ui:label \"Strava Id\";\n ui:maxLength \"200\" ;\n ui:property foaf:accountName ; \n ui:pattern \"[a-z0-9A-Z_-]*\"; # @@\n ui:size 40 .\n\n :SnapchatIdField\n a ui:SingleLineTextField ;\n ui:label \"Snapchat Id\";\n ui:maxLength \"200\" ;\n ui:property foaf:accountName ; \n ui:pattern \"@[a-z0-9A-Z_-]*\"; # @@\n ui:size 40 .\n\n :TiktokIdField\n a ui:SingleLineTextField ;\n ui:label \"Tiktok Id\";\n ui:maxLength \"200\" ;\n ui:property foaf:accountName ; \n ui:pattern \"@[a-z0-9A-Z_-]*\"; # @@\n ui:size 40 .\n\n :TumblrIdField\n a ui:SingleLineTextField ;\n ui:label \"Tumblr user name\";\n ui:maxLength \"200\" ;\n ui:property foaf:accountName ; \n ui:pattern \"@[a-z0-9A-Z_-]*\"; # @@\n ui:size 40 .\n\n :TwitterIdField\n a ui:SingleLineTextField ;\n ui:label \"Twitter Id\";\n ui:maxLength \"200\" ;\n ui:property foaf:accountName ; \n ui:pattern \"@[a-z0-9A-Z_-]*\"; # @@\n ui:size 40 .\n\n# an unknown SN account needs more info\n\n :OtherIdForm a ui:Group; ui:weight 0; ui:parts ( :OtherIdField :OtherIconField :OtherLabelield ).\n\n :OtherIdField\n a ui:NamedNodeURIField ;\n ui:label \"URL of account to link to\";\n ui:maxLength \"200\" ;\n ui:property foaf:homepage ; \n ui:size 60 .\n\n :OtherLabelield\n a ui:SingleLineTextField ;\n ui:label \"Label\";\n ui:maxLength \"200\" ;\n ui:property rdfs:label ; \n ui:size 40 .\n\n :OtherIconField\n a ui:NamedNodeURIField ;\n ui:label \"URL of icon to display\";\n ui:maxLength \"200\" ;\n ui:property foaf:icon ;\n ui:size 60 .\n\n\n\n\n\n# ENDS\n";
|
|
3476
|
+
;// ./src/SocialPresenter.ts
|
|
3477
|
+
|
|
3478
|
+
|
|
3479
|
+
|
|
3480
|
+
const DEFAULT_ICON_URI = external_UI_.icons.iconBase + 'noun_10636_grey.svg'; // grey disc
|
|
3481
|
+
function loadProfileForm(store) {
|
|
3482
|
+
const preferencesForm = store.sym('https://solidos.github.io/profile-pane/src/ontology/profileForm.ttl#this');
|
|
3483
|
+
const preferencesFormDoc = preferencesForm.doc();
|
|
3484
|
+
if (!store.holds(undefined, undefined, undefined, preferencesFormDoc)) {
|
|
3485
|
+
// If not loaded already
|
|
3486
|
+
(0,external_rdflib_.parse)(profileForm_namespaceObject, store, preferencesFormDoc.uri, 'text/turtle', () => null); // Load form directly
|
|
3487
|
+
}
|
|
3488
|
+
}
|
|
3489
|
+
function presentSocial(subject, store) {
|
|
3490
|
+
function nameForAccount(subject) {
|
|
3491
|
+
const acIcon = store.any(subject, external_UI_.ns.foaf('name')) ||
|
|
3492
|
+
store.any(subject, external_UI_.ns.rdfs('label')); // on the account itself?
|
|
3493
|
+
if (acIcon)
|
|
3494
|
+
return acIcon.value;
|
|
3495
|
+
const classes = store.each(subject, external_UI_.ns.rdf('type'));
|
|
3496
|
+
for (const k of classes) {
|
|
3497
|
+
const classIcon = store.any(k, external_UI_.ns.rdfs('label'));
|
|
3498
|
+
if (classIcon) {
|
|
3499
|
+
return classIcon.value;
|
|
3500
|
+
}
|
|
3501
|
+
return external_UI_.utils.label(k);
|
|
3502
|
+
}
|
|
3503
|
+
return '';
|
|
3504
|
+
}
|
|
3505
|
+
function iconForAccount(subject) {
|
|
3506
|
+
const acIcon = store.any(subject, external_UI_.ns.foaf('icon')); // on the account itself?
|
|
3507
|
+
if (acIcon)
|
|
3508
|
+
return acIcon.value;
|
|
3509
|
+
const classes = store.each(subject, external_UI_.ns.rdf('type'));
|
|
3510
|
+
if (classes.length > 0) {
|
|
3511
|
+
console.log('@@ classes[0].termType 2 ', classes[0].termType);
|
|
3512
|
+
for (const k of classes) {
|
|
3513
|
+
const classIcon = store.any(k, external_UI_.ns.foaf('icon'));
|
|
3514
|
+
if (classIcon !== null) {
|
|
3515
|
+
return classIcon.value;
|
|
3516
|
+
}
|
|
3517
|
+
}
|
|
3518
|
+
}
|
|
3519
|
+
return DEFAULT_ICON_URI;
|
|
3520
|
+
}
|
|
3521
|
+
function homepageForAccount(subject) {
|
|
3522
|
+
const acHomepage = store.any(subject, external_UI_.ns.foaf('homepage')); // on the account itself?
|
|
3523
|
+
if (acHomepage)
|
|
3524
|
+
return acHomepage.value;
|
|
3525
|
+
const id = store.anyJS(subject, external_UI_.ns.foaf('accountName'), null, subject.doc()) || 'No_account_Name';
|
|
3526
|
+
const classes = store.each(subject, external_UI_.ns.rdf('type'));
|
|
3527
|
+
for (const k of classes) {
|
|
3528
|
+
const userProfilePrefix = store.any(k, external_UI_.ns.foaf('userProfilePrefix'));
|
|
3529
|
+
if (userProfilePrefix) {
|
|
3530
|
+
return userProfilePrefix.value + id.trim();
|
|
3531
|
+
}
|
|
3532
|
+
}
|
|
3533
|
+
return 'no userProfilePrefix?';
|
|
3534
|
+
}
|
|
3535
|
+
function accountAsObject(ac) {
|
|
3536
|
+
return {
|
|
3537
|
+
name: nameForAccount(ac),
|
|
3538
|
+
icon: iconForAccount(ac),
|
|
3539
|
+
homepage: homepageForAccount(ac)
|
|
3540
|
+
};
|
|
3541
|
+
}
|
|
3542
|
+
loadProfileForm(store); // get ontology info
|
|
3543
|
+
const accountThings = store.anyJS(subject, external_UI_.ns.foaf('account')); // load the collection
|
|
3544
|
+
if (!accountThings)
|
|
3545
|
+
return { accounts: [] }; // could have been undefined
|
|
3546
|
+
//console.log('Social: accountThings', accountThings)
|
|
3547
|
+
const accounts = accountThings.map(ac => accountAsObject(ac));
|
|
3548
|
+
//console.log('Social: account objects', accounts)
|
|
3549
|
+
return { accounts };
|
|
3550
|
+
}
|
|
3551
|
+
|
|
3552
|
+
;// ./src/StuffPresenter.ts
|
|
3553
|
+
|
|
3554
|
+
|
|
3555
|
+
|
|
3556
|
+
const { iconForClass } = external_UI_.widgets;
|
|
3557
|
+
const { typeIndex } = external_SolidLogic_.solidLogicSingleton;
|
|
3558
|
+
const { getScopedAppInstances } = typeIndex;
|
|
3559
|
+
const iconForClassMap = {}; // @@ move to buttons in solid-ui
|
|
3560
|
+
for (const k in iconForClass) {
|
|
3561
|
+
const pref = k.split(':')[0];
|
|
3562
|
+
const id = k.split(':')[1];
|
|
3563
|
+
const theClass = external_UI_.ns[pref](id);
|
|
3564
|
+
iconForClassMap[theClass.uri] = external_rdflib_.uri.join(iconForClass[k], external_UI_.icons.iconBase);
|
|
3565
|
+
}
|
|
3566
|
+
function getIconForClass(klass) {
|
|
3567
|
+
const icon0 = iconForClassMap[klass.uri];
|
|
3568
|
+
return icon0 || external_UI_.icons.iconBase + 'noun_10636.svg'; // fall back to black disk
|
|
3569
|
+
}
|
|
3570
|
+
async function presentStuff(subject) {
|
|
3571
|
+
const scopedItems = await getScopedAppInstances(null, subject);
|
|
3572
|
+
// console.log('scopedItems', scopedItems)
|
|
3573
|
+
const stuff = scopedItems.map(item => {
|
|
3574
|
+
const icon = getIconForClass(item.type || external_UI_.ns.rdf('Resource'));
|
|
3575
|
+
const href = item.instance.uri;
|
|
3576
|
+
const name = external_UI_.utils.label(item.instance);
|
|
3577
|
+
const instance = item.instance;
|
|
3578
|
+
// console.log(` href=${href} name=${name} icon=${icon}`)
|
|
3579
|
+
return { href, name, icon, instance };
|
|
3580
|
+
});
|
|
3581
|
+
return { stuff };
|
|
3582
|
+
}
|
|
3583
|
+
|
|
3584
|
+
;// ./src/addMeToYourFriends.ts
|
|
3585
|
+
|
|
3586
|
+
|
|
3587
|
+
|
|
3588
|
+
|
|
3589
|
+
|
|
3590
|
+
|
|
3591
|
+
|
|
3592
|
+
let buttonContainer = document.createElement('div');
|
|
3593
|
+
const addMeToYourFriendsDiv = (subject, context) => {
|
|
3594
|
+
buttonContainer = context.dom.createElement('section');
|
|
3595
|
+
buttonContainer.setAttribute('class', 'buttonSubSection');
|
|
3596
|
+
buttonContainer.setAttribute('aria-labelledby', 'add-me-to-your-friends-button-section');
|
|
3597
|
+
buttonContainer.setAttribute('role', 'region');
|
|
3598
|
+
buttonContainer.setAttribute('data-testid', 'button');
|
|
3599
|
+
const button = createAddMeToYourFriendsButton(subject, context);
|
|
3600
|
+
buttonContainer.appendChild(button);
|
|
3601
|
+
return x `<div class="center">${buttonContainer}</div>`;
|
|
3602
|
+
};
|
|
3603
|
+
const createAddMeToYourFriendsButton = (subject, context) => {
|
|
3604
|
+
const me = external_SolidLogic_.authn.currentUser();
|
|
3605
|
+
let label = addMeToYourFriends_checkIfAnyUserLoggedIn(me) ? addMeToYourFriendsButtonText.toUpperCase() : logInAddMeToYourFriendsButtonText.toUpperCase();
|
|
3606
|
+
const button = external_UI_.widgets.button(context.dom, undefined, label, setButtonHandler, //sets an onclick event listener
|
|
3607
|
+
{
|
|
3608
|
+
needsBorder: true,
|
|
3609
|
+
});
|
|
3610
|
+
function setButtonHandler(event) {
|
|
3611
|
+
event.preventDefault();
|
|
3612
|
+
saveNewFriend(subject, context)
|
|
3613
|
+
.then(() => {
|
|
3614
|
+
clearPreviousMessage(buttonContainer);
|
|
3615
|
+
mention(buttonContainer, friendWasAddedSuccesMessage);
|
|
3616
|
+
refreshButton();
|
|
3617
|
+
})
|
|
3618
|
+
.catch((error) => {
|
|
3619
|
+
clearPreviousMessage(buttonContainer);
|
|
3620
|
+
//else UI.widgets.complain(buttonContainer, message); //displays an error message at the top of the window
|
|
3621
|
+
complain(buttonContainer, context, error);
|
|
3622
|
+
});
|
|
3623
|
+
}
|
|
3624
|
+
button.refresh = refreshButton();
|
|
3625
|
+
function refreshButton() {
|
|
3626
|
+
const me = external_SolidLogic_.authn.currentUser();
|
|
3627
|
+
const store = context.session.store;
|
|
3628
|
+
if (addMeToYourFriends_checkIfAnyUserLoggedIn(me)) {
|
|
3629
|
+
checkIfFriendExists(store, me, subject).then((friendExists) => {
|
|
3630
|
+
if (friendExists) {
|
|
3631
|
+
//logged in and friend exists or friend was just added
|
|
3632
|
+
button.innerHTML = friendExistsAlreadyButtonText.toUpperCase();
|
|
3633
|
+
button.className = 'button';
|
|
3634
|
+
button.setAttribute('class', external_UI_.style.primaryButton);
|
|
3635
|
+
}
|
|
3636
|
+
else {
|
|
3637
|
+
//logged in and friend does not exist yet
|
|
3638
|
+
button.innerHTML = addMeToYourFriendsButtonText.toUpperCase();
|
|
3639
|
+
button.className = 'button';
|
|
3640
|
+
button.setAttribute('class', external_UI_.style.primaryButtonNoBorder);
|
|
3641
|
+
}
|
|
3642
|
+
});
|
|
3643
|
+
}
|
|
3644
|
+
else {
|
|
3645
|
+
//not logged in
|
|
3646
|
+
button.innerHTML = logInAddMeToYourFriendsButtonText.toUpperCase();
|
|
3647
|
+
button.className = 'button';
|
|
3648
|
+
button.setAttribute('class', external_UI_.style.primaryButton);
|
|
3649
|
+
}
|
|
3650
|
+
}
|
|
3651
|
+
return button;
|
|
3652
|
+
};
|
|
3653
|
+
async function saveNewFriend(subject, context) {
|
|
3654
|
+
const me = external_SolidLogic_.authn.currentUser();
|
|
3655
|
+
const store = context.session.store;
|
|
3656
|
+
if (addMeToYourFriends_checkIfAnyUserLoggedIn(me)) {
|
|
3657
|
+
if (!(await checkIfFriendExists(store, me, subject))) {
|
|
3658
|
+
//if friend does not exist, we add her/him
|
|
3659
|
+
await store.fetcher.load(me);
|
|
3660
|
+
const updater = store.updater;
|
|
3661
|
+
const toBeInserted = [(0,external_rdflib_.st)(me, external_UI_.ns.foaf('knows'), subject, me.doc())];
|
|
3662
|
+
try {
|
|
3663
|
+
await updater.update([], toBeInserted);
|
|
3664
|
+
}
|
|
3665
|
+
catch (error) {
|
|
3666
|
+
let errorMessage = error;
|
|
3667
|
+
if (errorMessage.toString().includes('Unauthenticated'))
|
|
3668
|
+
errorMessage = userNotLoggedInErrorMessage;
|
|
3669
|
+
throw new Error(errorMessage);
|
|
3670
|
+
}
|
|
3671
|
+
}
|
|
3672
|
+
else
|
|
3673
|
+
throw new Error(friendExistsMessage);
|
|
3674
|
+
}
|
|
3675
|
+
else
|
|
3676
|
+
throw new Error(userNotLoggedInErrorMessage);
|
|
3677
|
+
}
|
|
3678
|
+
function addMeToYourFriends_checkIfAnyUserLoggedIn(me) {
|
|
3679
|
+
if (me)
|
|
3680
|
+
return true;
|
|
3681
|
+
else
|
|
3682
|
+
return false;
|
|
3683
|
+
}
|
|
3684
|
+
async function checkIfFriendExists(store, me, subject) {
|
|
3685
|
+
await store.fetcher.load(me);
|
|
3686
|
+
if (store.whether(me, external_UI_.ns.foaf('knows'), subject, me.doc()) === 0)
|
|
3687
|
+
return false;
|
|
3688
|
+
else
|
|
3689
|
+
return true;
|
|
3690
|
+
}
|
|
3691
|
+
|
|
3692
|
+
|
|
3693
|
+
;// ./src/QRCodeCard.ts
|
|
3694
|
+
|
|
3695
|
+
|
|
3696
|
+
|
|
3697
|
+
|
|
3698
|
+
const QRCodeCard = (highlightColor, backgroundColor, subject) => {
|
|
3699
|
+
const hC = highlightColor || '#000000';
|
|
3700
|
+
const bC = backgroundColor || '#ffffff';
|
|
3701
|
+
const name = external_UI_.utils.label(subject);
|
|
3702
|
+
const BEGIN = 'BEGIN:VCARD\r\n';
|
|
3703
|
+
const END = 'END:VCARD\r\n';
|
|
3704
|
+
const FN = 'FN:' + name + '\r\n';
|
|
3705
|
+
const URL = 'URL:' + subject.uri + 'r\n';
|
|
3706
|
+
const VERSIONV = 'VERSION:4.0\r\n';
|
|
3707
|
+
// find out how to import values from presenter.ts
|
|
3708
|
+
// once those values are imported, make sure any user input aligns
|
|
3709
|
+
const vCard = BEGIN + FN + URL + END + VERSIONV;
|
|
3710
|
+
// console.log(`@@ qrcodes colours highlightColor ${highlightColor}, backgroundColor ${backgroundColor}`)
|
|
3711
|
+
return x `
|
|
3712
|
+
<figure
|
|
3713
|
+
class="QRCode"
|
|
3714
|
+
data-value="${vCard}"
|
|
3715
|
+
highlightColor="${hC}"
|
|
3716
|
+
backgroundColor="${bC}"
|
|
3717
|
+
data-testid="qrcode-card"
|
|
3718
|
+
aria-labelledby="qr-code-caption"
|
|
3719
|
+
role="img"
|
|
3720
|
+
aria-describedby="qr-code-description"
|
|
3721
|
+
>
|
|
3722
|
+
<div
|
|
3723
|
+
aria-label="QR code containing contact information for ${name}"
|
|
3724
|
+
role="img"
|
|
3725
|
+
></div>
|
|
3726
|
+
<figcaption
|
|
3727
|
+
id="qr-code-caption"
|
|
3728
|
+
class="qrCaption"
|
|
3729
|
+
>
|
|
3730
|
+
${scanQrToConnectText}
|
|
3731
|
+
</figcaption>
|
|
3732
|
+
<div
|
|
3733
|
+
id="qr-code-description"
|
|
3734
|
+
class="sr-only"
|
|
3735
|
+
>
|
|
3736
|
+
QR code contains vCard information for ${name} including profile URL ${subject.uri}
|
|
3737
|
+
</div>
|
|
3738
|
+
</figure>
|
|
3739
|
+
`;
|
|
3740
|
+
};
|
|
3741
|
+
|
|
3742
|
+
;// ./src/ProfileCard.ts
|
|
3743
|
+
|
|
3744
|
+
|
|
3745
|
+
|
|
3746
|
+
|
|
3747
|
+
const ProfileCard = ({ name, imageSrc, introduction, location, pronouns, highlightColor, backgroundColor }, context, subject) => {
|
|
3748
|
+
return x `
|
|
3749
|
+
<article class="profileCard" role="main" aria-labelledby="profile-name">
|
|
3750
|
+
<header class="header" aria-label="Profile information">
|
|
3751
|
+
${Image(imageSrc, name)}
|
|
3752
|
+
</header>
|
|
3753
|
+
|
|
3754
|
+
<section class="intro" aria-label="About">
|
|
3755
|
+
${Line(introduction, '', 'About')}
|
|
3756
|
+
${Line(location, '🌐', 'Location')}
|
|
3757
|
+
${Line(pronouns, '', 'Pronouns')}
|
|
3758
|
+
</section>
|
|
3759
|
+
|
|
3760
|
+
<section class="buttonSection" aria-label="Actions" role="complementary">
|
|
3761
|
+
${addMeToYourFriendsDiv(subject, context)}
|
|
3762
|
+
</section>
|
|
3763
|
+
|
|
3764
|
+
<aside class="qrCodeSection" aria-label="Contact QR Code" role="complementary">
|
|
3765
|
+
${QRCodeCard(highlightColor, backgroundColor, subject)}
|
|
3766
|
+
</aside>
|
|
3767
|
+
</article>
|
|
3768
|
+
`;
|
|
3769
|
+
};
|
|
3770
|
+
const Line = (value, prefix = E, label = '') => value ? x `
|
|
3771
|
+
<div class="details" role="text" ${label ? `aria-label="${label}: ${value}"` : ''}>
|
|
3772
|
+
${prefix} ${value}
|
|
3773
|
+
</div>
|
|
3774
|
+
` : E;
|
|
3775
|
+
const Image = (src, alt) => src ? x `
|
|
3776
|
+
<img
|
|
3777
|
+
class="image"
|
|
3778
|
+
src=${src}
|
|
3779
|
+
alt="Profile photo of ${alt}"
|
|
3780
|
+
width="160"
|
|
3781
|
+
height="160"
|
|
3782
|
+
loading="eager"
|
|
3783
|
+
/>
|
|
3784
|
+
` : E;
|
|
3785
|
+
|
|
3786
|
+
;// ./src/CVCard.ts
|
|
3787
|
+
|
|
3788
|
+
|
|
3789
|
+
const CVCard = (cvData) => {
|
|
3790
|
+
const { rolesByType, skills, languages } = cvData;
|
|
3791
|
+
const futureRolesArr = rolesByType['FutureRole'] || [];
|
|
3792
|
+
const currentRolesArr = rolesByType['CurrentRole'] || [];
|
|
3793
|
+
const pastRolesArr = rolesByType['PastRole'] || [];
|
|
3794
|
+
const skillsArr = skills || [];
|
|
3795
|
+
const languagesArr = languages || [];
|
|
3796
|
+
const hasFutureRole = Array.isArray(futureRolesArr) && futureRolesArr.length > 0;
|
|
3797
|
+
const hasCurrentRole = Array.isArray(currentRolesArr) && currentRolesArr.length > 0;
|
|
3798
|
+
const hasPastRole = Array.isArray(pastRolesArr) && pastRolesArr.length > 0;
|
|
3799
|
+
const hasSkills = Array.isArray(skillsArr) && skillsArr.length > 0;
|
|
3800
|
+
const hasLanguages = Array.isArray(languagesArr) && languagesArr.length > 0;
|
|
3801
|
+
if (!(hasFutureRole || hasCurrentRole || hasPastRole || hasSkills || hasLanguages))
|
|
3802
|
+
return x ``;
|
|
3803
|
+
return x `
|
|
3804
|
+
<article class="cvCard" aria-label="Professional Experience" data-testid="curriculum-vitae">
|
|
3805
|
+
${hasFutureRole ? x `
|
|
3806
|
+
<section class="cvSection" aria-labelledby="cv-future-heading">
|
|
3807
|
+
<h3 id="cv-future-heading">Future Roles</h3>
|
|
3808
|
+
<ul role="list" aria-label="Upcoming professional roles">
|
|
3809
|
+
${renderRoles(futureRolesArr, true)}
|
|
3810
|
+
</ul>
|
|
3811
|
+
</section>
|
|
3812
|
+
` : ''}
|
|
3813
|
+
|
|
3814
|
+
${hasCurrentRole ? x `
|
|
3815
|
+
<section class="cvSection" aria-labelledby="cv-current-heading">
|
|
3816
|
+
<h3 id="cv-current-heading">Current Roles</h3>
|
|
3817
|
+
<ul role="list" aria-label="Current professional positions">
|
|
3818
|
+
${renderRoles(currentRolesArr, true)}
|
|
3819
|
+
</ul>
|
|
3820
|
+
</section>
|
|
3821
|
+
` : ''}
|
|
3822
|
+
|
|
3823
|
+
${hasPastRole ? x `
|
|
3824
|
+
<section class="cvSection" aria-labelledby="cv-past-heading">
|
|
3825
|
+
<h3 id="cv-past-heading">Past Roles</h3>
|
|
3826
|
+
<ul role="list" aria-label="Previous work experience">
|
|
3827
|
+
${renderRoles(pastRolesArr, true)}
|
|
3828
|
+
</ul>
|
|
3829
|
+
</section>
|
|
3830
|
+
` : ''}
|
|
3831
|
+
|
|
3832
|
+
${hasSkills ? x `
|
|
3833
|
+
<section class="cvSection" aria-labelledby="cv-skills-heading">
|
|
3834
|
+
<h3 id="cv-skills-heading">Skills</h3>
|
|
3835
|
+
<ul role="list" aria-label="Professional skills and competencies">
|
|
3836
|
+
${renderSkills(skillsArr, true)}
|
|
3837
|
+
</ul>
|
|
3838
|
+
</section>
|
|
3839
|
+
` : ''}
|
|
3840
|
+
|
|
3841
|
+
${hasLanguages ? x `
|
|
3842
|
+
<section class="cvSection" aria-labelledby="cv-languages-heading">
|
|
3843
|
+
<h3 id="cv-languages-heading">Languages</h3>
|
|
3844
|
+
<ul role="list" aria-label="Known languages">
|
|
3845
|
+
${renderLanguages(languagesArr, true)}
|
|
3846
|
+
</ul>
|
|
3847
|
+
</section>
|
|
3848
|
+
` : ''}
|
|
3849
|
+
</article>
|
|
3850
|
+
`;
|
|
3851
|
+
};
|
|
3852
|
+
function renderRole(role, asList = false) {
|
|
3853
|
+
if (!role)
|
|
3854
|
+
return x ``;
|
|
3855
|
+
return asList
|
|
3856
|
+
? x `
|
|
3857
|
+
<li class="cvRole" role="listitem">
|
|
3858
|
+
<strong class="cvOrg" aria-label="Organization">${role.orgName}</strong>
|
|
3859
|
+
<span aria-label="Role title">${strToUpperCase(role.roleText)}</span>
|
|
3860
|
+
<time aria-label="Employment period">${role.dates}</time>
|
|
3861
|
+
</li>`
|
|
3862
|
+
: x ``;
|
|
3863
|
+
}
|
|
3864
|
+
function renderRoles(roles, asList = false) {
|
|
3865
|
+
if (!roles || !roles.length || !roles[0])
|
|
3866
|
+
return x ``;
|
|
3867
|
+
return x `${renderRole(roles[0], asList)}${roles.length > 1 ? renderRoles(roles.slice(1), asList) : x ``}`;
|
|
3868
|
+
}
|
|
3869
|
+
function renderSkill(skill, asList = false) {
|
|
3870
|
+
if (!skill)
|
|
3871
|
+
return x ``;
|
|
3872
|
+
return asList
|
|
3873
|
+
? x `<li class="cvSkill">${strToUpperCase(skill)}</li>`
|
|
3874
|
+
: x ``;
|
|
3875
|
+
}
|
|
3876
|
+
function renderSkills(skills, asList = false) {
|
|
3877
|
+
if (!skills || !skills.length || !skills[0])
|
|
3878
|
+
return x ``;
|
|
3879
|
+
return x `${renderSkill(skills[0], asList)}${skills.length > 1 ? renderSkills(skills.slice(1), asList) : x ``}`;
|
|
3880
|
+
}
|
|
3881
|
+
function renderLan(language, asList = false) {
|
|
3882
|
+
if (!language)
|
|
3883
|
+
return x ``;
|
|
3884
|
+
return asList
|
|
3885
|
+
? x `<li class="cvLanguage">${language}</li>`
|
|
3886
|
+
: x ``;
|
|
3887
|
+
}
|
|
3888
|
+
function renderLanguages(languages, asList = false) {
|
|
3889
|
+
if (!languages || !languages.length || !languages[0])
|
|
3890
|
+
return x ``;
|
|
3891
|
+
return x `${renderLan(languages[0], asList)}${languages.length > 1 ? renderLanguages(languages.slice(1), asList) : x ``}`;
|
|
3892
|
+
}
|
|
3893
|
+
function strToUpperCase(str) {
|
|
3894
|
+
if (str && str[0] > '') {
|
|
3895
|
+
const strCase = str.split(' ');
|
|
3896
|
+
for (let i = 0; i < strCase.length; i++) {
|
|
3897
|
+
strCase[i] = strCase[i].charAt(0).toUpperCase() +
|
|
3898
|
+
strCase[i].substring(1);
|
|
3899
|
+
}
|
|
3900
|
+
return strCase.join(' ');
|
|
3901
|
+
}
|
|
3902
|
+
return '';
|
|
3903
|
+
}
|
|
3904
|
+
|
|
3905
|
+
;// ./src/SocialCard.ts
|
|
3906
|
+
|
|
3907
|
+
|
|
3908
|
+
const SocialCard = (SocialData) => {
|
|
3909
|
+
const { accounts } = SocialData;
|
|
3910
|
+
if (accounts.length) {
|
|
3911
|
+
return x `
|
|
3912
|
+
<section
|
|
3913
|
+
class="socialCard"
|
|
3914
|
+
aria-labelledby="social-card-title"
|
|
3915
|
+
role="region"
|
|
3916
|
+
data-testid="social-media"
|
|
3917
|
+
>
|
|
3918
|
+
<header class="socialHeader">
|
|
3919
|
+
<h3 id="social-card-title">Follow me on</h3>
|
|
3920
|
+
</header>
|
|
3921
|
+
<nav aria-label="Social media profiles">
|
|
3922
|
+
<ul class="socialList" role="list">
|
|
3923
|
+
${accounts.map(account => renderAccount(account))}
|
|
3924
|
+
</ul>
|
|
3925
|
+
</nav>
|
|
3926
|
+
</section>
|
|
3927
|
+
`;
|
|
3928
|
+
}
|
|
3929
|
+
function renderAccount(account) {
|
|
3930
|
+
return account.homepage && account.name && account.icon
|
|
3931
|
+
? x `
|
|
3932
|
+
<li class="socialItem" role="listitem">
|
|
3933
|
+
<a
|
|
3934
|
+
href="${account.homepage}"
|
|
3935
|
+
target="_blank"
|
|
3936
|
+
rel="noopener noreferrer"
|
|
3937
|
+
aria-label="Visit ${account.name} profile (opens in new tab)"
|
|
3938
|
+
style="display: flex; align-items: center; gap: 0.5em; text-decoration: none;"
|
|
3939
|
+
>
|
|
3940
|
+
<img
|
|
3941
|
+
class="socialIcon"
|
|
3942
|
+
src="${account.icon}"
|
|
3943
|
+
alt="${account.name} icon"
|
|
3944
|
+
width="40"
|
|
3945
|
+
height="40"
|
|
3946
|
+
loading="lazy"
|
|
3947
|
+
/>
|
|
3948
|
+
<span>${account.name}</span>
|
|
3949
|
+
</a>
|
|
3950
|
+
</li>
|
|
3951
|
+
`
|
|
3952
|
+
: x ``;
|
|
3953
|
+
}
|
|
3954
|
+
};
|
|
3955
|
+
|
|
3956
|
+
;// ./src/StuffCard.ts
|
|
3957
|
+
|
|
3958
|
+
|
|
3959
|
+
|
|
3960
|
+
const dom = document;
|
|
3961
|
+
const StuffCard = (profileBasics, context, subject, stuffData) => {
|
|
3962
|
+
const { stuff } = stuffData;
|
|
3963
|
+
return x `
|
|
3964
|
+
<section
|
|
3965
|
+
class="stuffCard"
|
|
3966
|
+
aria-labelledby="stuff-card-title"
|
|
3967
|
+
role="region"
|
|
3968
|
+
data-testid="stuff"
|
|
3969
|
+
>
|
|
3970
|
+
<header>
|
|
3971
|
+
<h3 id="stuff-card-title" class="sr-only">Shared Resources</h3>
|
|
3972
|
+
</header>
|
|
3973
|
+
<div role="table" aria-label="List of shared files and resources">
|
|
3974
|
+
<table class="stuffTable" data-testid="stuffTable">
|
|
3975
|
+
<caption class="sr-only">Files and resources shared by ${profileBasics.name}</caption>
|
|
3976
|
+
<tbody>
|
|
3977
|
+
${renderThings(stuff)}
|
|
3978
|
+
</tbody>
|
|
3979
|
+
</table>
|
|
3980
|
+
</div>
|
|
3981
|
+
</section>
|
|
3982
|
+
`;
|
|
3983
|
+
};
|
|
3984
|
+
function renderThingAsDOM(thing, dom) {
|
|
3985
|
+
const options = {};
|
|
3986
|
+
// widgets.personTR returns a DOM node, so we need to convert it to HTML string
|
|
3987
|
+
const row = external_UI_.widgets.personTR(dom, null, thing.instance, options);
|
|
3988
|
+
return row;
|
|
3989
|
+
}
|
|
3990
|
+
function renderThing(thing, dom) {
|
|
3991
|
+
return renderThingAsDOM(thing, dom);
|
|
3992
|
+
}
|
|
3993
|
+
function renderThings(things) {
|
|
3994
|
+
// console.log('Renderthings: ', things)
|
|
3995
|
+
if (things.length === 0)
|
|
3996
|
+
return x ``;
|
|
3997
|
+
return x `${renderThing(things[0], dom)}${things.length > 1 ? renderThings(things.slice(1)) : x ``}`;
|
|
3998
|
+
}
|
|
3999
|
+
|
|
4000
|
+
;// ./src/ProfileView.ts
|
|
4001
|
+
|
|
4002
|
+
|
|
4003
|
+
|
|
4004
|
+
|
|
4005
|
+
|
|
4006
|
+
// 20210527
|
|
4007
|
+
// 20210527
|
|
4008
|
+
// 20210527
|
|
4009
|
+
|
|
4010
|
+
|
|
4011
|
+
|
|
4012
|
+
|
|
4013
|
+
// The edit button switches to the editor pane
|
|
4014
|
+
/*
|
|
4015
|
+
function renderEditButton (subject) {
|
|
4016
|
+
return
|
|
4017
|
+
authn.currentUser() && authn.currentUser().sameTerm(subject) ?
|
|
4018
|
+
html `<button type="button" class="ProfilePaneCVEditButton">
|
|
4019
|
+
<img src="${editButtonURI}">
|
|
4020
|
+
Edit</button>`
|
|
4021
|
+
: html``;
|
|
4022
|
+
}
|
|
4023
|
+
*/
|
|
4024
|
+
async function ProfileView(subject, context) {
|
|
4025
|
+
const profileBasics = presentProfile(subject, context.session.store);
|
|
4026
|
+
const rolesByType = presentCV(subject, context.session.store);
|
|
4027
|
+
const accounts = presentSocial(subject, context.session.store);
|
|
4028
|
+
const stuffData = await presentStuff(subject);
|
|
4029
|
+
return x `
|
|
4030
|
+
<main
|
|
4031
|
+
id="main-content"
|
|
4032
|
+
class="profile-grid"
|
|
4033
|
+
style="--profile-grid-bg: radial-gradient(circle, ${profileBasics.backgroundColor} 80%, ${profileBasics.highlightColor} 100%)"
|
|
4034
|
+
role="main"
|
|
4035
|
+
aria-label="Profile for ${profileBasics.name}"
|
|
4036
|
+
tabindex="-1"
|
|
4037
|
+
>
|
|
4038
|
+
<!-- Enhanced breadcrumb navigation -->
|
|
4039
|
+
<nav id="profile-nav" aria-label="Profile sections" class="visually-hidden">
|
|
4040
|
+
<ol>
|
|
4041
|
+
<li><a href="#profile-card-heading">Personal Information</a></li>
|
|
4042
|
+
${(() => {
|
|
4043
|
+
const cv = CVCard(rolesByType);
|
|
4044
|
+
return cv && cv.strings && cv.strings.join('').trim() !== ''
|
|
4045
|
+
? x `<li><a href="#cv-heading">Professional Experience</a></li>`
|
|
4046
|
+
: '';
|
|
4047
|
+
})()}
|
|
4048
|
+
${accounts.accounts && accounts.accounts.length > 0
|
|
4049
|
+
? x `<li><a href="#social-heading" id="social-accounts">Social Accounts</a></li>`
|
|
4050
|
+
: ''}
|
|
4051
|
+
<li><a href="#chat-heading" id="contact-section">Contact</a></li>
|
|
4052
|
+
</ol>
|
|
4053
|
+
</nav>
|
|
4054
|
+
|
|
4055
|
+
<article
|
|
4056
|
+
aria-labelledby="profile-card-heading"
|
|
4057
|
+
class="profileSection"
|
|
4058
|
+
role="region"
|
|
4059
|
+
tabindex="-1"
|
|
4060
|
+
>
|
|
4061
|
+
<header>
|
|
4062
|
+
<h2 id="profile-card-heading" tabindex="-1">${profileBasics.name}</h2>
|
|
4063
|
+
</header>
|
|
4064
|
+
${ProfileCard(profileBasics, context, subject)}
|
|
4065
|
+
</article>
|
|
4066
|
+
|
|
4067
|
+
${(() => {
|
|
4068
|
+
const cv = CVCard(rolesByType);
|
|
4069
|
+
return cv && cv.strings && cv.strings.join('').trim() !== '' ? x `
|
|
4070
|
+
<section
|
|
4071
|
+
aria-labelledby="cv-heading"
|
|
4072
|
+
class="profileSection"
|
|
4073
|
+
role="region"
|
|
4074
|
+
tabindex="-1"
|
|
4075
|
+
>
|
|
4076
|
+
<header>
|
|
4077
|
+
<h2 id="cv-heading" tabindex="-1">Professional & Education</h2>
|
|
4078
|
+
</header>
|
|
4079
|
+
<div role="complementary" aria-label="Career and education information">
|
|
4080
|
+
${cv}
|
|
4081
|
+
</div>
|
|
4082
|
+
</section>
|
|
4083
|
+
` : '';
|
|
4084
|
+
})()}
|
|
4085
|
+
|
|
4086
|
+
${accounts.accounts && accounts.accounts.length > 0 ? x `
|
|
4087
|
+
<aside
|
|
4088
|
+
aria-labelledby="social-heading"
|
|
4089
|
+
class="profileSection"
|
|
4090
|
+
role="complementary"
|
|
4091
|
+
tabindex="-1"
|
|
4092
|
+
>
|
|
4093
|
+
<header>
|
|
4094
|
+
<h2 id="social-heading" tabindex="-1">Social Accounts</h2>
|
|
4095
|
+
</header>
|
|
4096
|
+
<nav aria-label="Social media links">
|
|
4097
|
+
${SocialCard(accounts)}
|
|
4098
|
+
</nav>
|
|
4099
|
+
</aside>
|
|
4100
|
+
` : ''}
|
|
4101
|
+
|
|
4102
|
+
${stuffData.stuff && stuffData.stuff.length > 0 ? x `
|
|
4103
|
+
<section
|
|
4104
|
+
aria-labelledby="stuff-heading"
|
|
4105
|
+
class="profileSection"
|
|
4106
|
+
role="region"
|
|
4107
|
+
tabindex="-1"
|
|
4108
|
+
>
|
|
4109
|
+
<header>
|
|
4110
|
+
<h2 id="stuff-heading" tabindex="-1">Shared Items</h2>
|
|
4111
|
+
</header>
|
|
4112
|
+
<div role="complementary" aria-label="Shared files and resources">
|
|
4113
|
+
${StuffCard(profileBasics, context, subject, stuffData)}
|
|
4114
|
+
</div>
|
|
4115
|
+
</section>
|
|
4116
|
+
` : ''}
|
|
4117
|
+
|
|
4118
|
+
${(() => {
|
|
4119
|
+
const friends = FriendList(subject, context);
|
|
4120
|
+
return friends ? x `
|
|
4121
|
+
<aside
|
|
4122
|
+
aria-labelledby="friends-heading"
|
|
4123
|
+
class="profileSection"
|
|
4124
|
+
role="complementary"
|
|
4125
|
+
tabindex="-1"
|
|
4126
|
+
>
|
|
4127
|
+
<header>
|
|
4128
|
+
<h2 id="friends-heading" tabindex="-1">Friends</h2>
|
|
4129
|
+
</header>
|
|
4130
|
+
<div role="list" aria-label="Friend connections">
|
|
4131
|
+
${friends}
|
|
4132
|
+
</div>
|
|
4133
|
+
</aside>
|
|
4134
|
+
` : '';
|
|
4135
|
+
})()}
|
|
4136
|
+
|
|
4137
|
+
<section
|
|
4138
|
+
aria-labelledby="chat-heading"
|
|
4139
|
+
class="profileSection"
|
|
4140
|
+
role="region"
|
|
4141
|
+
tabindex="-1"
|
|
4142
|
+
>
|
|
4143
|
+
<header>
|
|
4144
|
+
<h2 id="chat-heading" tabindex="-1">Contact</h2>
|
|
4145
|
+
</header>
|
|
4146
|
+
<div role="complementary" aria-label="Communication options">
|
|
4147
|
+
${ChatWithMe(subject, context)}
|
|
4148
|
+
</div>
|
|
4149
|
+
</section>
|
|
4150
|
+
</main>
|
|
4151
|
+
`;
|
|
4152
|
+
}
|
|
4153
|
+
|
|
4154
|
+
;// ./src/editProfilePane/profile.dom.ts
|
|
4155
|
+
function paneDiv(context, subject, paneName) {
|
|
4156
|
+
const view = context.session.paneRegistry.byName(paneName);
|
|
4157
|
+
if (!view) {
|
|
4158
|
+
const warning = context.dom.createElement('div');
|
|
4159
|
+
warning.innerText = `Unable to load view: ${paneName}`;
|
|
4160
|
+
return warning;
|
|
4161
|
+
}
|
|
4162
|
+
const viewContainer = view.render(subject, context);
|
|
4163
|
+
// Handle different node types
|
|
4164
|
+
let container;
|
|
4165
|
+
if (viewContainer && typeof viewContainer.setAttribute === 'function') {
|
|
4166
|
+
// It's already an Element node
|
|
4167
|
+
container = viewContainer;
|
|
4168
|
+
}
|
|
4169
|
+
else if (viewContainer && viewContainer.nodeType === Node.TEXT_NODE) {
|
|
4170
|
+
// It's a Text node, wrap it in a div
|
|
4171
|
+
container = context.dom.createElement('div');
|
|
4172
|
+
container.appendChild(viewContainer);
|
|
4173
|
+
}
|
|
4174
|
+
else {
|
|
4175
|
+
// Fallback for other cases
|
|
4176
|
+
container = context.dom.createElement('div');
|
|
4177
|
+
container.innerText = `View render did not return a valid Node for: ${paneName}`;
|
|
4178
|
+
}
|
|
4179
|
+
container.setAttribute('style', 'border: 0.3em solid #444; border-radius: 0.5em');
|
|
4180
|
+
return container;
|
|
4181
|
+
}
|
|
4182
|
+
|
|
4183
|
+
;// ./src/editProfilePane/editProfile.view.ts
|
|
4184
|
+
/**
|
|
4185
|
+
* Profile Editing App Pane
|
|
4186
|
+
*
|
|
4187
|
+
* Unlike view panes, this is available any place whatever the real subject,
|
|
4188
|
+
* and allows the user to edit their own profile.
|
|
4189
|
+
*
|
|
4190
|
+
* Usage: paneRegistry.register('profile/profilePane')
|
|
4191
|
+
* or standalone script adding onto existing mashlib.
|
|
4192
|
+
*/
|
|
4193
|
+
|
|
4194
|
+
|
|
4195
|
+
|
|
4196
|
+
|
|
4197
|
+
const highlightColor = external_UI_.style.highlightColor || '#7C4DFF';
|
|
4198
|
+
const editProfileView = {
|
|
4199
|
+
global: true,
|
|
4200
|
+
icon: external_UI_.icons.iconBase + 'noun_492246.svg',
|
|
4201
|
+
name: 'editProfile',
|
|
4202
|
+
label: () => null, // don't use this in the normal solid-panes dispatching
|
|
4203
|
+
render: function (subject, context) {
|
|
4204
|
+
//console.log('@@@ render edit profile pane: subject, context', subject, context)
|
|
4205
|
+
const dom = context.dom;
|
|
4206
|
+
const store = context.session.store;
|
|
4207
|
+
function complainIfBad(ok, mess) {
|
|
4208
|
+
if (ok)
|
|
4209
|
+
return;
|
|
4210
|
+
div.appendChild(external_UI_.widgets.errorMessageBlock(dom, mess, '#fee'));
|
|
4211
|
+
}
|
|
4212
|
+
function renderProfileForm(div, subject) {
|
|
4213
|
+
const preferencesForm = (0,external_rdflib_.sym)('https://solidos.github.io/profile-pane/src/ontology/profileForm.ttl#this');
|
|
4214
|
+
const preferencesFormDoc = preferencesForm.doc();
|
|
4215
|
+
if (!store.holds(undefined, undefined, undefined, preferencesFormDoc)) {
|
|
4216
|
+
// If not loaded already
|
|
4217
|
+
(0,external_rdflib_.parse)(profileForm_namespaceObject, store, preferencesFormDoc.uri, 'text/turtle', () => null); // Load form directly
|
|
4218
|
+
}
|
|
4219
|
+
div.setAttribute('data-testid', 'profile-editor');
|
|
4220
|
+
// @@ div.append?
|
|
4221
|
+
external_UI_.widgets.appendForm(dom, div, {}, subject, preferencesForm, editableProfile, complainIfBad);
|
|
4222
|
+
} // renderProfileForm
|
|
4223
|
+
const div = dom.createElement('div');
|
|
4224
|
+
div.setAttribute('data-testid', 'profile-editor');
|
|
4225
|
+
let editableProfile;
|
|
4226
|
+
div.setAttribute('style', `border: 0.3em solid ${highlightColor}; border-radius: 0.5em; padding: 0.7em; margin-top:0.7em;`);
|
|
4227
|
+
const table = div.appendChild(dom.createElement('table'));
|
|
4228
|
+
// const top = table.appendChild(dom.createElement('tr'))
|
|
4229
|
+
const main = table.appendChild(dom.createElement('tr'));
|
|
4230
|
+
const bottom = table.appendChild(dom.createElement('tr'));
|
|
4231
|
+
const statusArea = bottom.appendChild(dom.createElement('div'));
|
|
4232
|
+
statusArea.setAttribute('style', 'padding: 0.7em;');
|
|
4233
|
+
function comment(str) {
|
|
4234
|
+
const p = main.appendChild(dom.createElement('p'));
|
|
4235
|
+
p.setAttribute('style', 'padding: 1em;');
|
|
4236
|
+
p.textContent = str;
|
|
4237
|
+
return p;
|
|
4238
|
+
}
|
|
4239
|
+
function heading(str) {
|
|
4240
|
+
const h = main.appendChild(dom.createElement('h3'));
|
|
4241
|
+
h.setAttribute('style', 'color:' + highlightColor + ';');
|
|
4242
|
+
h.textContent = str;
|
|
4243
|
+
return h;
|
|
4244
|
+
}
|
|
4245
|
+
const profileContext = {
|
|
4246
|
+
dom: dom,
|
|
4247
|
+
div: main,
|
|
4248
|
+
statusArea: statusArea,
|
|
4249
|
+
me: null
|
|
4250
|
+
};
|
|
4251
|
+
external_UI_.login.ensureLoadedProfile(profileContext)
|
|
4252
|
+
.then(theContext => {
|
|
4253
|
+
const me = theContext.me;
|
|
4254
|
+
heading('Edit your public profile');
|
|
4255
|
+
const profile = me.doc();
|
|
4256
|
+
if (!store.updater) {
|
|
4257
|
+
throw new Error('Store has no updater');
|
|
4258
|
+
}
|
|
4259
|
+
if (store.any(me, external_UI_.ns.solid('editableProfile'))) {
|
|
4260
|
+
editableProfile = store.any(me, external_UI_.ns.solid('editableProfile'));
|
|
4261
|
+
}
|
|
4262
|
+
else if (store.updater.editable(profile.uri, store)) {
|
|
4263
|
+
editableProfile = profile;
|
|
4264
|
+
}
|
|
4265
|
+
else {
|
|
4266
|
+
statusArea.appendChild(external_UI_.widgets.errorMessageBlock(dom, `⚠️ Your profile ${profile} is not editable, so we cannot do much here.`, 'straw'));
|
|
4267
|
+
return;
|
|
4268
|
+
}
|
|
4269
|
+
comment(`Everything you put here will be public.
|
|
4270
|
+
There will be other places to record private things.`);
|
|
4271
|
+
heading('Your contact information');
|
|
4272
|
+
main.appendChild(paneDiv(context, me, 'contact'));
|
|
4273
|
+
heading('People you know who have WebIDs');
|
|
4274
|
+
comment(`This is your public social network.
|
|
4275
|
+
Only put people here to whom you are happy to be publicly connected.
|
|
4276
|
+
(You can always keep private track of friends and family in your contacts.)`);
|
|
4277
|
+
// TODO: would be useful to explain what it means to "drag people"
|
|
4278
|
+
// what is it that is being dragged?
|
|
4279
|
+
// is there a way to search for people (or things to drag) on this page?
|
|
4280
|
+
if (editableProfile) {
|
|
4281
|
+
comment('Drag people onto the target below to add people.');
|
|
4282
|
+
}
|
|
4283
|
+
external_UI_.widgets.attachmentList(dom, me, main, {
|
|
4284
|
+
doc: profile,
|
|
4285
|
+
modify: !!editableProfile,
|
|
4286
|
+
predicate: external_UI_.ns.foaf('knows'),
|
|
4287
|
+
noun: 'friend'
|
|
4288
|
+
});
|
|
4289
|
+
heading('Communities you participate in');
|
|
4290
|
+
comment('These are organizations and projects (etc) whose stuff you share');
|
|
4291
|
+
// TODO: would be useful to explain what it means to "drag organizations"
|
|
4292
|
+
// what is it that is being dragged?
|
|
4293
|
+
// is there a way to search for people (or things to drag) on this page?
|
|
4294
|
+
// Also provide a way of using cut and paste
|
|
4295
|
+
if (editableProfile) {
|
|
4296
|
+
comment('Drag organizations onto the target below to add organizations.');
|
|
4297
|
+
}
|
|
4298
|
+
external_UI_.widgets.attachmentList(dom, me, main, {
|
|
4299
|
+
doc: profile,
|
|
4300
|
+
modify: !!editableProfile,
|
|
4301
|
+
predicate: external_UI_.ns.solid('community'),
|
|
4302
|
+
noun: 'community'
|
|
4303
|
+
});
|
|
4304
|
+
renderProfileForm(main, me);
|
|
4305
|
+
heading('Thank you for filling your profile.');
|
|
4306
|
+
}).catch(error => {
|
|
4307
|
+
statusArea.appendChild(external_UI_.widgets.errorMessageBlock(dom, error, '#fee'));
|
|
4308
|
+
});
|
|
4309
|
+
return div;
|
|
4310
|
+
}
|
|
4311
|
+
};
|
|
4312
|
+
/* harmony default export */ const editProfile_view = (editProfileView);
|
|
4313
|
+
|
|
4314
|
+
// EXTERNAL MODULE: ./node_modules/qrcode/lib/browser.js
|
|
4315
|
+
var browser = __webpack_require__(583);
|
|
4316
|
+
;// ./src/index.ts
|
|
4317
|
+
|
|
4318
|
+
|
|
4319
|
+
|
|
4320
|
+
|
|
4321
|
+
|
|
4322
|
+
async function loadExtendedProfile(store, subject) {
|
|
4323
|
+
const otherProfiles = store.each(subject, external_UI_.ns.rdfs('seeAlso'), null, subject.doc());
|
|
4324
|
+
if (otherProfiles.length > 0) {
|
|
4325
|
+
await store.fetcher.load(otherProfiles);
|
|
4326
|
+
}
|
|
4327
|
+
}
|
|
4328
|
+
const Pane = {
|
|
4329
|
+
global: false,
|
|
4330
|
+
icon: external_UI_.icons.iconBase + 'noun_15059.svg',
|
|
4331
|
+
name: 'profile',
|
|
4332
|
+
label: function (subject, context) {
|
|
4333
|
+
const t = context.session.store.findTypeURIs(subject);
|
|
4334
|
+
if (t[external_UI_.ns.vcard('Individual').uri] ||
|
|
4335
|
+
t[external_UI_.ns.foaf('Person').uri] ||
|
|
4336
|
+
t[external_UI_.ns.schema('Person').uri]) {
|
|
4337
|
+
return 'Profile';
|
|
4338
|
+
}
|
|
4339
|
+
return null;
|
|
4340
|
+
},
|
|
4341
|
+
editor: editProfile_view,
|
|
4342
|
+
render: (subject, context) => {
|
|
4343
|
+
const target = context.dom.createElement('div');
|
|
4344
|
+
const store = context.session.store;
|
|
4345
|
+
loadExtendedProfile(store, subject).then(async () => {
|
|
4346
|
+
B(await ProfileView(subject, context), target);
|
|
4347
|
+
const QRCodeEles = Array.from(target.getElementsByClassName('QRCode')); // was context.dom
|
|
4348
|
+
if (!QRCodeEles.length)
|
|
4349
|
+
return console.error('QRCode Ele missing');
|
|
4350
|
+
for (const QRCodeElement of QRCodeEles) {
|
|
4351
|
+
const value = QRCodeElement.getAttribute('data-value');
|
|
4352
|
+
if (!value)
|
|
4353
|
+
return console.error('QRCode data-value missing');
|
|
4354
|
+
const highlightColor = QRCodeElement.getAttribute('highlightColor') || '#000000';
|
|
4355
|
+
const backgroundColor = QRCodeElement.getAttribute('backgroundColor') || '#ffffff';
|
|
4356
|
+
// console.log(`@@ qrcodes2 colours highlightColor ${highlightColor}, backgroundColor ${backgroundColor}`)
|
|
4357
|
+
const options = {
|
|
4358
|
+
type: 'svg',
|
|
4359
|
+
color: {
|
|
4360
|
+
dark: highlightColor,
|
|
4361
|
+
light: backgroundColor
|
|
4362
|
+
}
|
|
4363
|
+
};
|
|
4364
|
+
browser.toString(value, options, function (error, svg) {
|
|
4365
|
+
if (error) {
|
|
4366
|
+
console.error('QRcode error!', error);
|
|
4367
|
+
}
|
|
4368
|
+
else {
|
|
4369
|
+
// console.log('QRcode success.', svg);
|
|
4370
|
+
QRCodeElement.innerHTML = svg;
|
|
4371
|
+
QRCodeElement.style.width = '80%';
|
|
4372
|
+
QRCodeElement.style.height = '80%';
|
|
4373
|
+
QRCodeElement.style.margin = '10%';
|
|
4374
|
+
}
|
|
4375
|
+
});
|
|
4376
|
+
}
|
|
4377
|
+
});
|
|
4378
|
+
return target;
|
|
4379
|
+
},
|
|
4380
|
+
};
|
|
4381
|
+
/* harmony default export */ const src = (Pane);
|
|
4382
|
+
|
|
4383
|
+
})();
|
|
4384
|
+
|
|
4385
|
+
__webpack_exports__ = __webpack_exports__["default"];
|
|
4386
|
+
/******/ return __webpack_exports__;
|
|
4387
|
+
/******/ })()
|
|
4388
|
+
;
|
|
4389
|
+
});
|
|
4390
|
+
//# sourceMappingURL=profile-pane.js.map
|