solid-ui 2.4.28-6f763399 → 2.4.28-75c05c1d
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/dist/solid-ui.js +385 -405
- package/dist/solid-ui.js.map +1 -1
- package/dist/solid-ui.min.js +1 -1
- package/dist/solid-ui.min.js.map +1 -1
- package/lib/login/login.d.ts.map +1 -1
- package/lib/login/login.js +44 -59
- package/lib/login/login.js.map +1 -1
- package/lib/media/media-capture.d.ts +2 -2
- package/lib/media/media-capture.d.ts.map +1 -1
- package/lib/media/media-capture.js +11 -15
- package/lib/media/media-capture.js.map +1 -1
- package/lib/pad.d.ts +2 -2
- package/lib/pad.d.ts.map +1 -1
- package/lib/pad.js +15 -38
- package/lib/pad.js.map +1 -1
- package/lib/participation.d.ts +6 -6
- package/lib/participation.d.ts.map +1 -1
- package/lib/participation.js +24 -23
- package/lib/participation.js.map +1 -1
- package/lib/style.js +93 -85
- package/lib/style.js.map +1 -1
- package/lib/styleConstants.js +36 -0
- package/lib/styleConstants.js.map +1 -0
- package/lib/tabs.d.ts +0 -125
- package/lib/tabs.d.ts.map +1 -1
- package/lib/tabs.js +15 -8
- package/lib/tabs.js.map +1 -1
- package/lib/utils/keyHelpers/accessData.d.ts +0 -1
- package/lib/utils/keyHelpers/accessData.d.ts.map +1 -1
- package/lib/utils/keyHelpers/accessData.js +93 -135
- package/lib/utils/keyHelpers/accessData.js.map +1 -1
- package/lib/versionInfo.js +6 -6
- package/lib/versionInfo.js.map +1 -1
- package/lib/widgets/dragAndDrop.js +10 -18
- package/lib/widgets/dragAndDrop.js.map +1 -1
- package/lib/widgets/error.d.ts.map +1 -1
- package/lib/widgets/error.js +9 -2
- package/lib/widgets/error.js.map +1 -1
- package/lib/widgets/forms/autocomplete/autocompletePicker.d.ts.map +1 -1
- package/lib/widgets/forms/autocomplete/autocompletePicker.js +2 -1
- package/lib/widgets/forms/autocomplete/autocompletePicker.js.map +1 -1
- package/lib/widgets/forms/basic.d.ts.map +1 -1
- package/lib/widgets/forms/basic.js +5 -4
- package/lib/widgets/forms/basic.js.map +1 -1
- package/lib/widgets/forms/fieldParams.js +2 -2
- package/lib/widgets/forms/fieldParams.js.map +1 -1
- package/lib/widgets/forms.js +9 -8
- package/lib/widgets/forms.js.map +1 -1
- package/package.json +1 -1
|
@@ -8,7 +8,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
8
8
|
exports.getExistingPrivateKey = getExistingPrivateKey;
|
|
9
9
|
exports.getExistingPublicKey = getExistingPublicKey;
|
|
10
10
|
exports.getKeyIfExists = getKeyIfExists;
|
|
11
|
-
exports.pubKeyUrl = exports.privKeyUrl =
|
|
11
|
+
exports.pubKeyUrl = exports.privKeyUrl = void 0;
|
|
12
12
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
13
13
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
14
14
|
var debug = _interopRequireWildcard(require("../../debug"));
|
|
@@ -16,216 +16,174 @@ var _solidLogic = require("solid-logic");
|
|
|
16
16
|
var ns = _interopRequireWildcard(require("../../ns"));
|
|
17
17
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
18
18
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
19
|
-
|
|
19
|
+
/* export const getPodRoot = async (webId: NamedNode) => {
|
|
20
|
+
const webIdURL = new URL(webId.uri)
|
|
21
|
+
// find storages in webId document
|
|
22
|
+
await store.fetcher.load(webId.uri)
|
|
23
|
+
const storages = store.each(webId, ns.space('storage'), null, webId.doc())
|
|
24
|
+
var podRoot: NamedNode | undefined
|
|
25
|
+
if (!storages?.length) {
|
|
26
|
+
// find storage recursively in webId URL
|
|
27
|
+
let path = webIdURL.pathname
|
|
28
|
+
while (path.length) {
|
|
29
|
+
path = path.substring(0, path.lastIndexOf('/'))
|
|
30
|
+
podRoot = store.sym(webIdURL.origin + path + '/')
|
|
31
|
+
const res = await store.fetcher.webOperation('HEAD', podRoot.uri)
|
|
32
|
+
if (res.headers.get('link')?.includes(ns.space('Storage').value)) break
|
|
33
|
+
if (!path) debug.warn(`Current user storage not found for\n${webId}`)
|
|
34
|
+
}
|
|
35
|
+
} else {
|
|
36
|
+
// give preference to storage in webId root
|
|
37
|
+
podRoot = storages.find((storage) => webIdURL.origin === new URL(storage.value).origin) as NamedNode
|
|
38
|
+
if (!podRoot) podRoot = storages[0] as NamedNode
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return podRoot as NamedNode
|
|
42
|
+
} */
|
|
43
|
+
|
|
44
|
+
var pubKeyUrl = /*#__PURE__*/function () {
|
|
20
45
|
var _ref = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(webId) {
|
|
21
|
-
var
|
|
46
|
+
var _store$any, _parentSettings;
|
|
47
|
+
var parentSettings;
|
|
22
48
|
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
23
49
|
while (1) switch (_context.prev = _context.next) {
|
|
24
50
|
case 0:
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
storages = _solidLogic.store.each(webId, ns.space('storage'), null, webId.doc());
|
|
30
|
-
if (storages !== null && storages !== void 0 && storages.length) {
|
|
31
|
-
_context.next = 19;
|
|
32
|
-
break;
|
|
33
|
-
}
|
|
34
|
-
// find storage recursively in webId URL
|
|
35
|
-
path = webIdURL.pathname;
|
|
36
|
-
case 6:
|
|
37
|
-
if (!path.length) {
|
|
38
|
-
_context.next = 17;
|
|
39
|
-
break;
|
|
40
|
-
}
|
|
41
|
-
path = path.substring(0, path.lastIndexOf('/'));
|
|
42
|
-
podRoot = _solidLogic.store.sym(webIdURL.origin + path + '/');
|
|
43
|
-
_context.next = 11;
|
|
44
|
-
return _solidLogic.store.fetcher.webOperation('HEAD', podRoot.uri);
|
|
45
|
-
case 11:
|
|
46
|
-
res = _context.sent;
|
|
47
|
-
if (!((_res$headers$get = res.headers.get('link')) !== null && _res$headers$get !== void 0 && _res$headers$get.includes(ns.space('Storage').value))) {
|
|
48
|
-
_context.next = 14;
|
|
51
|
+
parentSettings = (_store$any = _solidLogic.store.any(webId, ns.space('preferencesFile'), null, webId.doc())) === null || _store$any === void 0 ? void 0 : _store$any.value;
|
|
52
|
+
parentSettings = (_parentSettings = parentSettings) === null || _parentSettings === void 0 ? void 0 : _parentSettings.split('/').slice(0, -2).join('/');
|
|
53
|
+
if (parentSettings) {
|
|
54
|
+
_context.next = 4;
|
|
49
55
|
break;
|
|
50
56
|
}
|
|
51
|
-
|
|
52
|
-
case
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
break;
|
|
56
|
-
case 17:
|
|
57
|
-
_context.next = 21;
|
|
58
|
-
break;
|
|
59
|
-
case 19:
|
|
60
|
-
// give preference to storage in webId root
|
|
61
|
-
podRoot = storages.find(function (storage) {
|
|
62
|
-
return webIdURL.origin === new URL(storage.value).origin;
|
|
63
|
-
});
|
|
64
|
-
if (!podRoot) podRoot = storages[0];
|
|
65
|
-
case 21:
|
|
66
|
-
return _context.abrupt("return", podRoot);
|
|
67
|
-
case 22:
|
|
57
|
+
throw new Error("prefererencesFile is expected to exist in ".concat(webId.doc));
|
|
58
|
+
case 4:
|
|
59
|
+
return _context.abrupt("return", "".concat(parentSettings, "/profile/keys/publicKey.ttl"));
|
|
60
|
+
case 5:
|
|
68
61
|
case "end":
|
|
69
62
|
return _context.stop();
|
|
70
63
|
}
|
|
71
64
|
}, _callee);
|
|
72
65
|
}));
|
|
73
|
-
return function
|
|
66
|
+
return function pubKeyUrl(_x) {
|
|
74
67
|
return _ref.apply(this, arguments);
|
|
75
68
|
};
|
|
76
69
|
}();
|
|
77
|
-
exports.getPodRoot = getPodRoot;
|
|
78
|
-
var pubKeyUrl = /*#__PURE__*/function () {
|
|
79
|
-
var _ref2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(webId) {
|
|
80
|
-
return _regenerator["default"].wrap(function _callee2$(_context2) {
|
|
81
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
82
|
-
case 0:
|
|
83
|
-
_context2.prev = 0;
|
|
84
|
-
_context2.next = 3;
|
|
85
|
-
return getPodRoot(webId);
|
|
86
|
-
case 3:
|
|
87
|
-
_context2.t0 = _context2.sent.value;
|
|
88
|
-
return _context2.abrupt("return", _context2.t0 + 'profile/keys/publicKey.ttl');
|
|
89
|
-
case 7:
|
|
90
|
-
_context2.prev = 7;
|
|
91
|
-
_context2.t1 = _context2["catch"](0);
|
|
92
|
-
throw new Error(_context2.t1);
|
|
93
|
-
case 10:
|
|
94
|
-
case "end":
|
|
95
|
-
return _context2.stop();
|
|
96
|
-
}
|
|
97
|
-
}, _callee2, null, [[0, 7]]);
|
|
98
|
-
}));
|
|
99
|
-
return function pubKeyUrl(_x2) {
|
|
100
|
-
return _ref2.apply(this, arguments);
|
|
101
|
-
};
|
|
102
|
-
}();
|
|
103
70
|
exports.pubKeyUrl = pubKeyUrl;
|
|
104
|
-
function getExistingPublicKey(
|
|
71
|
+
function getExistingPublicKey(_x2, _x3) {
|
|
105
72
|
return _getExistingPublicKey.apply(this, arguments);
|
|
106
73
|
}
|
|
107
74
|
function _getExistingPublicKey() {
|
|
108
|
-
_getExistingPublicKey = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function
|
|
109
|
-
return _regenerator["default"].wrap(function
|
|
110
|
-
while (1) switch (
|
|
75
|
+
_getExistingPublicKey = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(webId, publicKeyUrl) {
|
|
76
|
+
return _regenerator["default"].wrap(function _callee3$(_context3) {
|
|
77
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
111
78
|
case 0:
|
|
112
|
-
|
|
79
|
+
_context3.next = 2;
|
|
113
80
|
return getKeyIfExists(webId, publicKeyUrl, 'publicKey');
|
|
114
81
|
case 2:
|
|
115
|
-
return
|
|
82
|
+
return _context3.abrupt("return", _context3.sent);
|
|
116
83
|
case 3:
|
|
117
84
|
case "end":
|
|
118
|
-
return
|
|
85
|
+
return _context3.stop();
|
|
119
86
|
}
|
|
120
|
-
},
|
|
87
|
+
}, _callee3);
|
|
121
88
|
}));
|
|
122
89
|
return _getExistingPublicKey.apply(this, arguments);
|
|
123
90
|
}
|
|
124
91
|
var privKeyUrl = /*#__PURE__*/function () {
|
|
125
|
-
var
|
|
126
|
-
var _store$
|
|
127
|
-
var settings
|
|
128
|
-
return _regenerator["default"].wrap(function
|
|
129
|
-
while (1) switch (
|
|
92
|
+
var _ref2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(webId) {
|
|
93
|
+
var _store$any2, _settings;
|
|
94
|
+
var settings;
|
|
95
|
+
return _regenerator["default"].wrap(function _callee2$(_context2) {
|
|
96
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
130
97
|
case 0:
|
|
131
|
-
settings = (_store$
|
|
98
|
+
settings = (_store$any2 = _solidLogic.store.any(webId, ns.space('preferencesFile'), null, webId.doc())) === null || _store$any2 === void 0 ? void 0 : _store$any2.value;
|
|
132
99
|
settings = (_settings = settings) === null || _settings === void 0 ? void 0 : _settings.split('/').slice(0, -1).join('/');
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
return getPodRoot(webId);
|
|
136
|
-
case 5:
|
|
137
|
-
podRoot = _context3.sent;
|
|
138
|
-
if ((_settings2 = settings) !== null && _settings2 !== void 0 && _settings2.startsWith(podRoot.value)) {
|
|
139
|
-
_context3.next = 8;
|
|
100
|
+
if (settings) {
|
|
101
|
+
_context2.next = 4;
|
|
140
102
|
break;
|
|
141
103
|
}
|
|
142
|
-
throw new Error("
|
|
143
|
-
case
|
|
144
|
-
return
|
|
145
|
-
case
|
|
146
|
-
_context3.prev = 11;
|
|
147
|
-
_context3.t0 = _context3["catch"](2);
|
|
148
|
-
throw new Error(_context3.t0);
|
|
149
|
-
case 14:
|
|
104
|
+
throw new Error("prefererencesFile is expected to exist in ".concat(webId.doc));
|
|
105
|
+
case 4:
|
|
106
|
+
return _context2.abrupt("return", "".concat(settings, "/keys/privateKey.ttl"));
|
|
107
|
+
case 5:
|
|
150
108
|
case "end":
|
|
151
|
-
return
|
|
109
|
+
return _context2.stop();
|
|
152
110
|
}
|
|
153
|
-
},
|
|
111
|
+
}, _callee2);
|
|
154
112
|
}));
|
|
155
|
-
return function privKeyUrl(
|
|
156
|
-
return
|
|
113
|
+
return function privKeyUrl(_x4) {
|
|
114
|
+
return _ref2.apply(this, arguments);
|
|
157
115
|
};
|
|
158
116
|
}();
|
|
159
117
|
exports.privKeyUrl = privKeyUrl;
|
|
160
|
-
function getExistingPrivateKey(
|
|
118
|
+
function getExistingPrivateKey(_x5, _x6) {
|
|
161
119
|
return _getExistingPrivateKey.apply(this, arguments);
|
|
162
120
|
}
|
|
163
121
|
function _getExistingPrivateKey() {
|
|
164
|
-
_getExistingPrivateKey = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function
|
|
165
|
-
return _regenerator["default"].wrap(function
|
|
166
|
-
while (1) switch (
|
|
122
|
+
_getExistingPrivateKey = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4(webId, privateKeyUrl) {
|
|
123
|
+
return _regenerator["default"].wrap(function _callee4$(_context4) {
|
|
124
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
167
125
|
case 0:
|
|
168
|
-
|
|
126
|
+
_context4.next = 2;
|
|
169
127
|
return getKeyIfExists(webId, privateKeyUrl, 'privateKey');
|
|
170
128
|
case 2:
|
|
171
|
-
return
|
|
129
|
+
return _context4.abrupt("return", _context4.sent);
|
|
172
130
|
case 3:
|
|
173
131
|
case "end":
|
|
174
|
-
return
|
|
132
|
+
return _context4.stop();
|
|
175
133
|
}
|
|
176
|
-
},
|
|
134
|
+
}, _callee4);
|
|
177
135
|
}));
|
|
178
136
|
return _getExistingPrivateKey.apply(this, arguments);
|
|
179
137
|
}
|
|
180
|
-
function getKeyIfExists(_x8, _x9
|
|
138
|
+
function getKeyIfExists(_x7, _x8, _x9) {
|
|
181
139
|
return _getKeyIfExists.apply(this, arguments);
|
|
182
140
|
}
|
|
183
141
|
function _getKeyIfExists() {
|
|
184
|
-
_getKeyIfExists = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function
|
|
142
|
+
_getKeyIfExists = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee5(webId, keyUrl, keyType) {
|
|
185
143
|
var key;
|
|
186
|
-
return _regenerator["default"].wrap(function
|
|
187
|
-
while (1) switch (
|
|
144
|
+
return _regenerator["default"].wrap(function _callee5$(_context5) {
|
|
145
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
188
146
|
case 0:
|
|
189
|
-
|
|
190
|
-
|
|
147
|
+
_context5.prev = 0;
|
|
148
|
+
_context5.next = 3;
|
|
191
149
|
return _solidLogic.store.fetcher.load(keyUrl);
|
|
192
150
|
case 3:
|
|
193
151
|
key = _solidLogic.store.any(webId, ns.solid(keyType)); // store.sym(CERT + keyType))
|
|
194
|
-
return
|
|
152
|
+
return _context5.abrupt("return", key === null || key === void 0 ? void 0 : key.value);
|
|
195
153
|
case 7:
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
if (!(
|
|
199
|
-
|
|
154
|
+
_context5.prev = 7;
|
|
155
|
+
_context5.t0 = _context5["catch"](0);
|
|
156
|
+
if (!(_context5.t0.response.status === 404)) {
|
|
157
|
+
_context5.next = 24;
|
|
200
158
|
break;
|
|
201
159
|
}
|
|
202
160
|
debug.log('createIfNotExists: doc does NOT exist, will create... ' + keyUrl);
|
|
203
|
-
|
|
204
|
-
|
|
161
|
+
_context5.prev = 11;
|
|
162
|
+
_context5.next = 14;
|
|
205
163
|
return _solidLogic.store.fetcher.webOperation('PUT', keyUrl, {
|
|
206
164
|
data: '',
|
|
207
165
|
contentType: 'text/turtle'
|
|
208
166
|
});
|
|
209
167
|
case 14:
|
|
210
|
-
|
|
168
|
+
_context5.next = 20;
|
|
211
169
|
break;
|
|
212
170
|
case 16:
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
debug.log('createIfNotExists doc FAILED: ' + keyUrl + ': ' +
|
|
216
|
-
throw
|
|
171
|
+
_context5.prev = 16;
|
|
172
|
+
_context5.t1 = _context5["catch"](11);
|
|
173
|
+
debug.log('createIfNotExists doc FAILED: ' + keyUrl + ': ' + _context5.t1);
|
|
174
|
+
throw _context5.t1;
|
|
217
175
|
case 20:
|
|
218
176
|
delete _solidLogic.store.fetcher.requested[keyUrl]; // delete cached 404 error
|
|
219
177
|
// debug.log('createIfNotExists doc created ok ' + doc)
|
|
220
|
-
return
|
|
178
|
+
return _context5.abrupt("return", undefined);
|
|
221
179
|
case 24:
|
|
222
|
-
debug.log('createIfNotExists doc FAILED: ' + keyUrl + ': ' +
|
|
223
|
-
throw
|
|
180
|
+
debug.log('createIfNotExists doc FAILED: ' + keyUrl + ': ' + _context5.t0);
|
|
181
|
+
throw _context5.t0;
|
|
224
182
|
case 26:
|
|
225
183
|
case "end":
|
|
226
|
-
return
|
|
184
|
+
return _context5.stop();
|
|
227
185
|
}
|
|
228
|
-
},
|
|
186
|
+
}, _callee5, null, [[0, 7], [11, 16]]);
|
|
229
187
|
}));
|
|
230
188
|
return _getKeyIfExists.apply(this, arguments);
|
|
231
189
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accessData.js","names":["debug","_interopRequireWildcard","require","_solidLogic","ns","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","_typeof","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","getPodRoot","_ref","_asyncToGenerator2","_regenerator","mark","_callee","webId","webIdURL","storages","podRoot","path","_res$headers$get","res","wrap","_callee$","_context","prev","next","URL","uri","store","fetcher","load","each","space","doc","length","pathname","substring","lastIndexOf","sym","origin","webOperation","sent","headers","includes","value","abrupt","warn","concat","find","storage","stop","_x","apply","arguments","exports","pubKeyUrl","_ref2","_callee2","_callee2$","_context2","t0","t1","Error","_x2","getExistingPublicKey","_x3","_x4","_getExistingPublicKey","_callee4","publicKeyUrl","_callee4$","_context4","getKeyIfExists","privKeyUrl","_ref3","_callee3","_store$any","_settings","settings","_settings2","_callee3$","_context3","any","split","slice","join","startsWith","_x5","getExistingPrivateKey","_x6","_x7","_getExistingPrivateKey","_callee5","privateKeyUrl","_callee5$","_context5","_x8","_x9","_x10","_getKeyIfExists","_callee6","keyUrl","keyType","_callee6$","_context6","solid","response","status","log","data","contentType","requested","undefined"],"sources":["../../../src/utils/keyHelpers/accessData.ts"],"sourcesContent":["import * as debug from '../../debug'\nimport { store } from 'solid-logic'\nimport * as ns from '../../ns'\nimport { NamedNode } from 'rdflib'\n\nexport const getPodRoot = async (webId: NamedNode) => {\n const webIdURL = new URL(webId.uri)\n // find storages in webId document\n await store.fetcher.load(webId.uri)\n const storages = store.each(webId, ns.space('storage'), null, webId.doc())\n var podRoot: NamedNode | undefined\n if (!storages?.length) {\n // find storage recursively in webId URL\n let path = webIdURL.pathname\n while (path.length) {\n path = path.substring(0, path.lastIndexOf('/'))\n podRoot = store.sym(webIdURL.origin + path + '/')\n const res = await store.fetcher.webOperation('HEAD', podRoot.uri)\n if (res.headers.get('link')?.includes(ns.space('Storage').value)) break\n if (!path) debug.warn(`Current user storage not found for\\n${webId}`)\n }\n } else {\n // give preference to storage in webId root\n podRoot = storages.find((storage) => webIdURL.origin === new URL(storage.value).origin) as NamedNode\n if (!podRoot) podRoot = storages[0] as NamedNode\n }\n return podRoot as NamedNode\n}\n\nexport const pubKeyUrl = async (webId: NamedNode) => {\n try {\n return (await getPodRoot(webId)).value + 'profile/keys/publicKey.ttl'\n } catch (err) { throw new Error(err) }\n}\n\nexport async function getExistingPublicKey (webId: NamedNode, publicKeyUrl: string) {\n // find publickey\n return await getKeyIfExists(webId, publicKeyUrl, 'publicKey')\n}\n\nexport const privKeyUrl = async (webId: NamedNode) => {\n let settings = store.any(webId, ns.space('preferencesFile'), null, webId.doc())?.value\n settings = settings?.split('/').slice(0, -1).join('/')\n try {\n const podRoot = await getPodRoot(webId)\n if (!settings?.startsWith(podRoot.value)) throw new Error(`/settings/ is expected to be in ${podRoot.value}`)\n return `${settings}/keys/privateKey.ttl`\n } catch (err) { throw new Error(err) }\n}\n\nexport async function getExistingPrivateKey (webId: NamedNode, privateKeyUrl: string) {\n // find privateKey\n return await getKeyIfExists(webId, privateKeyUrl, 'privateKey')\n}\n\ntype KeyType = 'publicKey' | 'privateKey'\n\nexport async function getKeyIfExists (webId: NamedNode, keyUrl: string, keyType: KeyType) {\n try {\n await store.fetcher.load(keyUrl)\n const key = store.any(webId, ns.solid(keyType)) // store.sym(CERT + keyType))\n return key?.value // as NamedNode\n } catch (err) {\n if (err.response.status === 404) {\n debug.log(\n 'createIfNotExists: doc does NOT exist, will create... ' + keyUrl\n )\n try {\n await store.fetcher.webOperation('PUT', keyUrl, {\n data: '',\n contentType: 'text/turtle'\n })\n } catch (err) {\n debug.log('createIfNotExists doc FAILED: ' + keyUrl + ': ' + err)\n throw err\n }\n delete store.fetcher.requested[keyUrl] // delete cached 404 error\n // debug.log('createIfNotExists doc created ok ' + doc)\n return undefined // response\n } else {\n debug.log('createIfNotExists doc FAILED: ' + keyUrl + ': ' + err)\n throw err\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAAA,IAAAA,KAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,EAAA,GAAAH,uBAAA,CAAAC,OAAA;AAA8B,SAAAG,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,yBAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAL,wBAAAS,GAAA,EAAAJ,WAAA,SAAAA,WAAA,IAAAI,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAAA,QAAAA,GAAA,aAAAE,OAAA,CAAAF,GAAA,yBAAAA,GAAA,uCAAAA,GAAA,UAAAG,KAAA,GAAAR,wBAAA,CAAAC,WAAA,OAAAO,KAAA,IAAAA,KAAA,CAAAC,GAAA,CAAAJ,GAAA,YAAAG,KAAA,CAAAE,GAAA,CAAAL,GAAA,SAAAM,MAAA,WAAAC,qBAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,GAAA,IAAAX,GAAA,QAAAW,GAAA,kBAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAd,GAAA,EAAAW,GAAA,SAAAI,IAAA,GAAAR,qBAAA,GAAAC,MAAA,CAAAE,wBAAA,CAAAV,GAAA,EAAAW,GAAA,cAAAI,IAAA,KAAAA,IAAA,CAAAV,GAAA,IAAAU,IAAA,CAAAC,GA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EAAA,GAAA2C,SAAA;UAEF3H,KAAK,CAAC+H,GAAG,CAAC,gCAAgC,GAAGP,MAAM,GAAG,IAAI,GAAAG,SAAA,CAAA3C,EAAM,CAAC;UAAA,MAAA2C,SAAA,CAAA3C,EAAA;QAAA;UAGnE,OAAOjC,iBAAK,CAACC,OAAO,CAACkF,SAAS,CAACV,MAAM,CAAC,EAAC;UACvC;UAAA,OAAAG,SAAA,CAAA3D,MAAA,WACOmE,SAAS;QAAA;UAEhBnI,KAAK,CAAC+H,GAAG,CAAC,gCAAgC,GAAGP,MAAM,GAAG,IAAI,GAAAG,SAAA,CAAA5C,EAAM,CAAC;UAAA,MAAA4C,SAAA,CAAA5C,EAAA;QAAA;QAAA;UAAA,OAAA4C,SAAA,CAAAtD,IAAA;MAAA;IAAA,GAAAkD,QAAA;EAAA,CAItE;EAAA,OAAAD,eAAA,CAAA/C,KAAA,OAAAC,SAAA;AAAA"}
|
|
1
|
+
{"version":3,"file":"accessData.js","names":["debug","_interopRequireWildcard","require","_solidLogic","ns","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","_typeof","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","pubKeyUrl","_ref","_asyncToGenerator2","_regenerator","mark","_callee","webId","_store$any","_parentSettings","parentSettings","wrap","_callee$","_context","prev","next","store","any","space","doc","value","split","slice","join","Error","concat","abrupt","stop","_x","apply","arguments","exports","getExistingPublicKey","_x2","_x3","_getExistingPublicKey","_callee3","publicKeyUrl","_callee3$","_context3","getKeyIfExists","sent","privKeyUrl","_ref2","_callee2","_store$any2","_settings","settings","_callee2$","_context2","_x4","getExistingPrivateKey","_x5","_x6","_getExistingPrivateKey","_callee4","privateKeyUrl","_callee4$","_context4","_x7","_x8","_x9","_getKeyIfExists","_callee5","keyUrl","keyType","_callee5$","_context5","fetcher","load","solid","t0","response","status","log","webOperation","data","contentType","t1","requested","undefined"],"sources":["../../../src/utils/keyHelpers/accessData.ts"],"sourcesContent":["import * as debug from '../../debug'\nimport { store } from 'solid-logic'\nimport * as ns from '../../ns'\nimport { NamedNode } from 'rdflib'\n\n/* export const getPodRoot = async (webId: NamedNode) => {\n const webIdURL = new URL(webId.uri)\n // find storages in webId document\n await store.fetcher.load(webId.uri)\n const storages = store.each(webId, ns.space('storage'), null, webId.doc())\n var podRoot: NamedNode | undefined\n if (!storages?.length) {\n // find storage recursively in webId URL\n let path = webIdURL.pathname\n while (path.length) {\n path = path.substring(0, path.lastIndexOf('/'))\n podRoot = store.sym(webIdURL.origin + path + '/')\n const res = await store.fetcher.webOperation('HEAD', podRoot.uri)\n if (res.headers.get('link')?.includes(ns.space('Storage').value)) break\n if (!path) debug.warn(`Current user storage not found for\\n${webId}`)\n }\n } else {\n // give preference to storage in webId root\n podRoot = storages.find((storage) => webIdURL.origin === new URL(storage.value).origin) as NamedNode\n if (!podRoot) podRoot = storages[0] as NamedNode\n }\n\n return podRoot as NamedNode\n} */\n\nexport const pubKeyUrl = async (webId: NamedNode) => {\n let parentSettings = store.any(webId, ns.space('preferencesFile'), null, webId.doc())?.value\n parentSettings = parentSettings?.split('/').slice(0, -2).join('/')\n if (!parentSettings) throw new Error(`prefererencesFile is expected to exist in ${webId.doc}`)\n return `${parentSettings}/profile/keys/publicKey.ttl`\n /* try {\n return (await getPodRoot(webId)).value + 'profile/keys/publicKey.ttl'\n } catch (err) { throw new Error(err) } */\n}\n\nexport async function getExistingPublicKey (webId: NamedNode, publicKeyUrl: string) {\n // find publickey\n return await getKeyIfExists(webId, publicKeyUrl, 'publicKey')\n}\n\nexport const privKeyUrl = async (webId: NamedNode) => {\n let settings = store.any(webId, ns.space('preferencesFile'), null, webId.doc())?.value\n settings = settings?.split('/').slice(0, -1).join('/')\n if (!settings) throw new Error(`prefererencesFile is expected to exist in ${webId.doc}`)\n return `${settings}/keys/privateKey.ttl`\n /* try {\n const podRoot = await getPodRoot(webId)\n if (!settings?.startsWith(podRoot.value)) throw new Error(`/settings/ is expected to be in ${podRoot.value}`)\n return `${settings}/keys/privateKey.ttl`\n } catch (err) { throw new Error(err) } */\n}\n\nexport async function getExistingPrivateKey (webId: NamedNode, privateKeyUrl: string) {\n // find privateKey\n return await getKeyIfExists(webId, privateKeyUrl, 'privateKey')\n}\n\ntype KeyType = 'publicKey' | 'privateKey'\n\nexport async function getKeyIfExists (webId: NamedNode, keyUrl: string, keyType: KeyType) {\n try {\n await store.fetcher.load(keyUrl)\n const key = store.any(webId, ns.solid(keyType)) // store.sym(CERT + keyType))\n return key?.value // as NamedNode\n } catch (err) {\n if (err.response.status === 404) {\n debug.log(\n 'createIfNotExists: doc does NOT exist, will create... ' + keyUrl\n )\n try {\n await store.fetcher.webOperation('PUT', keyUrl, {\n data: '',\n contentType: 'text/turtle'\n })\n } catch (err) {\n debug.log('createIfNotExists doc FAILED: ' + keyUrl + ': ' + err)\n throw err\n }\n delete store.fetcher.requested[keyUrl] // delete cached 404 error\n // debug.log('createIfNotExists doc created ok ' + doc)\n return undefined // response\n } else {\n debug.log('createIfNotExists doc FAILED: ' + keyUrl + ': ' + err)\n throw err\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAAA,IAAAA,KAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,EAAA,GAAAH,uBAAA,CAAAC,OAAA;AAA8B,SAAAG,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,yBAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAL,wBAAAS,GAAA,EAAAJ,WAAA,SAAAA,WAAA,IAAAI,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAAA,QAAAA,GAAA,aAAAE,OAAA,CAAAF,GAAA,yBAAAA,GAAA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,KAAA,OAAAC,SAAA;AAAA"}
|
package/lib/versionInfo.js
CHANGED
|
@@ -5,22 +5,22 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.versionInfo = void 0;
|
|
7
7
|
var versionInfo = {
|
|
8
|
-
buildTime: '2023-
|
|
9
|
-
commit: '
|
|
8
|
+
buildTime: '2023-08-16T08:00:14Z',
|
|
9
|
+
commit: '75c05c1d830611799317b095311e66247d5b2a91',
|
|
10
10
|
npmInfo: {
|
|
11
11
|
'solid-ui': '2.4.28',
|
|
12
12
|
npm: '8.19.4',
|
|
13
|
-
node: '16.20.
|
|
13
|
+
node: '16.20.1',
|
|
14
14
|
v8: '9.4.146.26-node.26',
|
|
15
15
|
uv: '1.43.0',
|
|
16
16
|
zlib: '1.2.11',
|
|
17
17
|
brotli: '1.0.9',
|
|
18
|
-
ares: '1.19.
|
|
18
|
+
ares: '1.19.1',
|
|
19
19
|
modules: '93',
|
|
20
20
|
nghttp2: '1.47.0',
|
|
21
21
|
napi: '8',
|
|
22
|
-
llhttp: '6.0.
|
|
23
|
-
openssl: '1.1.
|
|
22
|
+
llhttp: '6.0.11',
|
|
23
|
+
openssl: '1.1.1u+quic',
|
|
24
24
|
cldr: '41.0',
|
|
25
25
|
icu: '71.1',
|
|
26
26
|
tz: '2022f',
|
package/lib/versionInfo.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"versionInfo.js","names":["versionInfo","buildTime","commit","npmInfo","npm","node","v8","uv","zlib","brotli","ares","modules","nghttp2","napi","llhttp","openssl","cldr","icu","tz","unicode","ngtcp2","nghttp3","exports"],"sources":["../src/versionInfo.ts"],"sourcesContent":["export const versionInfo = {\n buildTime: '2023-
|
|
1
|
+
{"version":3,"file":"versionInfo.js","names":["versionInfo","buildTime","commit","npmInfo","npm","node","v8","uv","zlib","brotli","ares","modules","nghttp2","napi","llhttp","openssl","cldr","icu","tz","unicode","ngtcp2","nghttp3","exports"],"sources":["../src/versionInfo.ts"],"sourcesContent":["export const versionInfo = {\n buildTime: '2023-08-16T08:00:14Z',\n commit: '75c05c1d830611799317b095311e66247d5b2a91',\n npmInfo:\n{\n 'solid-ui': '2.4.28',\n npm: '8.19.4',\n node: '16.20.1',\n v8: '9.4.146.26-node.26',\n uv: '1.43.0',\n zlib: '1.2.11',\n brotli: '1.0.9',\n ares: '1.19.1',\n modules: '93',\n nghttp2: '1.47.0',\n napi: '8',\n llhttp: '6.0.11',\n openssl: '1.1.1u+quic',\n cldr: '41.0',\n icu: '71.1',\n tz: '2022f',\n unicode: '14.0',\n ngtcp2: '0.8.1',\n nghttp3: '0.7.0'\n}\n}\n"],"mappings":";;;;;;AAAO,IAAMA,WAAW,GAAG;EACzBC,SAAS,EAAE,sBAAsB;EACjCC,MAAM,EAAE,0CAA0C;EAClDC,OAAO,EACT;IACE,UAAU,EAAE,QAAQ;IACpBC,GAAG,EAAE,QAAQ;IACbC,IAAI,EAAE,SAAS;IACfC,EAAE,EAAE,oBAAoB;IACxBC,EAAE,EAAE,QAAQ;IACZC,IAAI,EAAE,QAAQ;IACdC,MAAM,EAAE,OAAO;IACfC,IAAI,EAAE,QAAQ;IACdC,OAAO,EAAE,IAAI;IACbC,OAAO,EAAE,QAAQ;IACjBC,IAAI,EAAE,GAAG;IACTC,MAAM,EAAE,QAAQ;IAChBC,OAAO,EAAE,aAAa;IACtBC,IAAI,EAAE,MAAM;IACZC,GAAG,EAAE,MAAM;IACXC,EAAE,EAAE,OAAO;IACXC,OAAO,EAAE,MAAM;IACfC,MAAM,EAAE,OAAO;IACfC,OAAO,EAAE;EACX;AACA,CAAC;AAAAC,OAAA,CAAAtB,WAAA,GAAAA,WAAA"}
|
|
@@ -9,16 +9,17 @@ exports.makeDropTarget = makeDropTarget;
|
|
|
9
9
|
exports.uploadFiles = uploadFiles;
|
|
10
10
|
var debug = _interopRequireWildcard(require("../debug"));
|
|
11
11
|
var mime = _interopRequireWildcard(require("mime-types"));
|
|
12
|
+
var style = _interopRequireWildcard(require("../style"));
|
|
12
13
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
13
14
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
14
15
|
/* Drag and drop common functionality
|
|
15
16
|
*
|
|
16
17
|
* It is easy to make something draggable, or to make it a drag target!
|
|
17
|
-
* Just call the functions below.
|
|
18
|
-
* represent one thing which has a
|
|
18
|
+
* Just call the functions below. In a solid world, any part of the UI which
|
|
19
|
+
* represent one thing which has a URI, should be made draggable using makeDraggable
|
|
19
20
|
* Any list of things should typically allow you to drag new members of the list
|
|
20
21
|
* onto it.
|
|
21
|
-
* The file upload function uploadFiles is provided as often
|
|
22
|
+
* The file upload function uploadFiles is provided as often as someone drags a file from the computer
|
|
22
23
|
* desktop, you may want to upload it into the pod.
|
|
23
24
|
*/
|
|
24
25
|
|
|
@@ -26,22 +27,16 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
26
27
|
|
|
27
28
|
function makeDropTarget(ele, droppedURIHandler, droppedFileHandler) {
|
|
28
29
|
var dragoverListener = function dragoverListener(e) {
|
|
29
|
-
e.preventDefault(); //
|
|
30
|
+
e.preventDefault(); // Need else drop does not work [sic]
|
|
30
31
|
e.dataTransfer.dropEffect = 'copy';
|
|
31
32
|
};
|
|
32
33
|
var dragenterListener = function dragenterListener(e) {
|
|
33
34
|
debug.log('dragenter event dropEffect: ' + e.dataTransfer.dropEffect);
|
|
34
|
-
if (this.
|
|
35
|
+
if (this.localStyle) {
|
|
35
36
|
// necessary not sure when
|
|
36
37
|
if (!this.savedStyle) {
|
|
37
|
-
this.savedStyle =
|
|
38
|
-
this.savedStyle.border = this.style.border;
|
|
39
|
-
this.savedStyle.backgroundColor = this.style.backgroundColor;
|
|
40
|
-
this.savedStyle.borderRadius = this.style.borderRadius;
|
|
38
|
+
this.savedStyle = style.dragEvent;
|
|
41
39
|
}
|
|
42
|
-
this.style.backgroundColor = '#ccc';
|
|
43
|
-
this.style.border = '0.25em dashed black';
|
|
44
|
-
this.style.borderRadius = '0.3em';
|
|
45
40
|
}
|
|
46
41
|
e.dataTransfer.dropEffect = 'link';
|
|
47
42
|
debug.log('dragenter event dropEffect 2: ' + e.dataTransfer.dropEffect);
|
|
@@ -49,12 +44,9 @@ function makeDropTarget(ele, droppedURIHandler, droppedFileHandler) {
|
|
|
49
44
|
var dragleaveListener = function dragleaveListener(e) {
|
|
50
45
|
debug.log('dragleave event dropEffect: ' + e.dataTransfer.dropEffect);
|
|
51
46
|
if (this.savedStyle) {
|
|
52
|
-
this.
|
|
53
|
-
this.style.backgroundColor = this.savedStyle.backgroundColor;
|
|
54
|
-
this.style.borderRadius = this.savedStyle.borderRadius;
|
|
47
|
+
this.localStyle = this.savedStyle;
|
|
55
48
|
} else {
|
|
56
|
-
this.
|
|
57
|
-
this.style.border = '0em solid black';
|
|
49
|
+
this.localStyle = style.dropEvent;
|
|
58
50
|
}
|
|
59
51
|
};
|
|
60
52
|
var dropListener = function dropListener(e) {
|
|
@@ -93,7 +85,7 @@ function makeDropTarget(ele, droppedURIHandler, droppedFileHandler) {
|
|
|
93
85
|
if (uris) {
|
|
94
86
|
droppedURIHandler(uris);
|
|
95
87
|
}
|
|
96
|
-
this.
|
|
88
|
+
this.localStyle = style.restoreStyle; // restore style
|
|
97
89
|
return false;
|
|
98
90
|
}; // dropListener
|
|
99
91
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dragAndDrop.js","names":["debug","_interopRequireWildcard","require","mime","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","_typeof","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","makeDropTarget","ele","droppedURIHandler","droppedFileHandler","dragoverListener","e","preventDefault","dataTransfer","dropEffect","dragenterListener","log","style","savedStyle","border","backgroundColor","borderRadius","dragleaveListener","dropListener","types","join","uris","text","t","length","type","getData","split","files","i","f","name","size","lastModifiedDate","toLocaleDateString","slice","addTargetListeners","addEventListener","makeDraggable","tr","setAttribute","fontWeight","setData","uri","outerHTML","stopPropagation","uploadFiles","fetcher","fileBase","imageBase","successHandler","reader","FileReader","onload","theFile","data","target","result","suffix","byteLength","contentType","lookup","msg","alert","Error","extension","endsWith","folderName","startsWith","destURI","encodeURIComponent","webOperation","then","_response","error","readAsArrayBuffer"],"sources":["../../src/widgets/dragAndDrop.js"],"sourcesContent":["/* Drag and drop common functionality\n *\n * It is easy to make something draggable, or to make it a drag target!\n * Just call the functions below. In a solid world, any part of the UI which\n * represent one thing which has a UR, should be made draggable using makeDraggable\n * Any list of things should typically allow you to drag new members of the list\n * onto it.\n * The file upload function uploadFiles is provided as often of someone drags a file from the computer\n * desktop, you may want to upload it into the pod.\n */\nimport * as debug from '../debug'\nimport * as mime from 'mime-types'\n\n/* global FileReader alert */\n\nexport function makeDropTarget (ele, droppedURIHandler, droppedFileHandler) {\n const dragoverListener = function (e) {\n e.preventDefault() // Neeed else drop does not work [sic]\n e.dataTransfer.dropEffect = 'copy'\n }\n\n const dragenterListener = function (e) {\n debug.log('dragenter event dropEffect: ' + e.dataTransfer.dropEffect)\n if (this.style) {\n // necessary not sure when\n if (!this.savedStyle) {\n this.savedStyle = {}\n this.savedStyle.border = this.style.border\n this.savedStyle.backgroundColor = this.style.backgroundColor\n this.savedStyle.borderRadius = this.style.borderRadius\n }\n this.style.backgroundColor = '#ccc'\n this.style.border = '0.25em dashed black'\n this.style.borderRadius = '0.3em'\n }\n\n e.dataTransfer.dropEffect = 'link'\n debug.log('dragenter event dropEffect 2: ' + e.dataTransfer.dropEffect)\n }\n const dragleaveListener = function (e) {\n debug.log('dragleave event dropEffect: ' + e.dataTransfer.dropEffect)\n if (this.savedStyle) {\n this.style.border = this.savedStyle.border\n this.style.backgroundColor = this.savedStyle.backgroundColor\n this.style.borderRadius = this.savedStyle.borderRadius\n } else {\n this.style.backgroundColor = 'white'\n this.style.border = '0em solid black'\n }\n }\n\n const dropListener = function (e) {\n if (e.preventDefault) e.preventDefault() // stops the browser from redirecting off to the text.\n debug.log('Drop event. dropEffect: ' + e.dataTransfer.dropEffect)\n debug.log(\n 'Drop event. types: ' +\n (e.dataTransfer.types ? e.dataTransfer.types.join(', ') : 'NOPE')\n )\n\n let uris = null\n let text\n if (e.dataTransfer.types) {\n for (let t = 0; t < e.dataTransfer.types.length; t++) {\n const type = e.dataTransfer.types[t]\n if (type === 'text/uri-list') {\n uris = e.dataTransfer.getData(type).split('\\n') // @ ignore those starting with #\n debug.log('Dropped text/uri-list: ' + uris)\n } else if (type === 'text/plain') {\n text = e.dataTransfer.getData(type)\n } else if (type === 'Files' && droppedFileHandler) {\n const files = e.dataTransfer.files // FileList object.\n for (let i = 0; files[i]; i++) {\n const f = files[i]\n debug.log(\n 'Filename: ' +\n f.name +\n ', type: ' +\n (f.type || 'n/a') +\n ' size: ' +\n f.size +\n ' bytes, last modified: ' +\n (f.lastModifiedDate\n ? f.lastModifiedDate.toLocaleDateString()\n : 'n/a')\n )\n }\n droppedFileHandler(files)\n }\n }\n if (uris === null && text && text.slice(0, 4) === 'http') {\n uris = text\n debug.log(\"Waring: Poor man's drop: using text for URI\") // chrome disables text/uri-list??\n }\n } else {\n // ... however, if we're IE, we don't have the .types property, so we'll just get the Text value\n uris = [e.dataTransfer.getData('Text')]\n debug.log('WARNING non-standard drop event: ' + uris[0])\n }\n debug.log('Dropped URI list (2): ' + uris)\n if (uris) {\n droppedURIHandler(uris)\n }\n this.style.backgroundColor = 'white' // restore style\n return false\n } // dropListener\n\n const addTargetListeners = function (ele) {\n if (!ele) {\n debug.log('@@@ addTargetListeners: ele ' + ele)\n }\n ele.addEventListener('dragover', dragoverListener)\n ele.addEventListener('dragenter', dragenterListener)\n ele.addEventListener('dragleave', dragleaveListener)\n ele.addEventListener('drop', dropListener)\n }\n addTargetListeners(ele, droppedURIHandler)\n} // listen for dropped URIs\n\n// Make an HTML element draggable as a URI-identified thing\n//\n// Possibly later set the drag image too?\n//\nexport function makeDraggable (tr, obj) {\n tr.setAttribute('draggable', 'true') // Stop the image being dragged instead - just the TR\n\n tr.addEventListener(\n 'dragstart',\n function (e) {\n tr.style.fontWeight = 'bold'\n e.dataTransfer.setData('text/uri-list', obj.uri)\n e.dataTransfer.setData('text/plain', obj.uri)\n e.dataTransfer.setData('text/html', tr.outerHTML)\n debug.log(\n 'Dragstart: ' + tr + ' -> ' + obj + 'de: ' + e.dataTransfer.dropEffect\n )\n },\n false\n )\n\n tr.addEventListener(\n 'drag',\n function (e) {\n e.preventDefault()\n e.stopPropagation()\n // debug.log('Drag: dropEffect: ' + e.dataTransfer.dropEffect)\n },\n false\n )\n\n tr.addEventListener(\n 'dragend',\n function (e) {\n tr.style.fontWeight = 'normal'\n debug.log('Dragend dropeffect: ' + e.dataTransfer.dropEffect)\n debug.log('Dragend: ' + tr + ' -> ' + obj)\n },\n false\n )\n}\n\n/** uploadFiles\n**\n** Generic uploader of local files to the web\n** typically called from dropped file handler\n**\n** @param {Fetcher} fetcher instance of class Fetcher as in kb.fetcher\n** @param {Array<File>} files Array of file objects\n** @param {String} fileBase URI of folder in which to put files (except images) (no trailing slash)\n** @param {String } imageBase URI of folder in which to put images\n** @param successHandler function(file, uploadedURI) Called after EACH success upload\n** With file object an final URI as params\n*/\n\nexport function uploadFiles (fetcher, files, fileBase, imageBase, successHandler) {\n for (let i = 0; files[i]; i++) {\n const f = files[i]\n debug.log(\n ' dropped: Filename: ' +\n f.name +\n ', type: ' +\n (f.type || 'n/a') +\n ' size: ' +\n f.size +\n ' bytes, last modified: ' +\n (f.lastModifiedDate ? f.lastModifiedDate.toLocaleDateString() : 'n/a')\n ) // See e.g. https://www.html5rocks.com/en/tutorials/file/dndfiles/\n\n // @@ Add: progress bar(s)\n const reader = new FileReader()\n reader.onload = (function (theFile) {\n return function (e) {\n const data = e.target.result\n let suffix = ''\n debug.log(' File read byteLength : ' + data.byteLength)\n let contentType = theFile.type\n if (!theFile.type || theFile.type === '') {\n // Not known by browser\n contentType = mime.lookup(theFile.name)\n if (!contentType) {\n const msg =\n 'Filename needs to have an extension which gives a type we know: ' +\n theFile.name\n debug.log(msg)\n alert(msg)\n throw new Error(msg)\n }\n } else {\n const extension = mime.extension(theFile.type)\n // Note not simple: eg .mp3 => audio/mpeg; .mpga => audio/mpeg; audio/mp3 => .mp3\n if (extension && extension !== 'false' && !theFile.name.endsWith('.' + extension) && // Not already has preferred extension? and ...\n theFile.type !== mime.lookup(theFile.name)) { // the mime type of this ext is not the right one?\n suffix = '_.' + extension\n // console.log('MIME TYPE MISMATCH: ' + mime.lookup(theFile.name) + ': adding extension: ' + suffix)\n }\n }\n const folderName = theFile.type.startsWith('image/')\n ? imageBase || fileBase\n : fileBase\n const destURI =\n folderName +\n (folderName.endsWith('/') ? '' : '/') +\n encodeURIComponent(theFile.name) +\n suffix\n\n fetcher\n .webOperation('PUT', destURI, {\n data,\n contentType\n })\n .then(\n _response => {\n debug.log(' Upload: put OK: ' + destURI)\n successHandler(theFile, destURI)\n },\n error => {\n const msg = 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AMqB,OAAO,GACXF,UAAU,IACTA,UAAU,CAACD,QAAQ,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,GAAG,CAAC,GACrCI,kBAAkB,CAAChB,OAAO,CAACvB,IAAI,CAAC,GAChC2B,MAAM;QAERX,OAAO,CACJwB,YAAY,CAAC,KAAK,EAAEF,OAAO,EAAE;UAC5Bd,IAAI,EAAJA,IAAI;UACJK,WAAW,EAAXA;QACF,CAAC,CAAC,CACDY,IAAI,CACH,UAAAC,SAAS,EAAI;UACXlG,KAAK,CAACoC,GAAG,CAAC,mBAAmB,GAAG0D,OAAO,CAAC;UACxCnB,cAAc,CAACI,OAAO,EAAEe,OAAO,CAAC;QAClC,CAAC,EACD,UAAAK,KAAK,EAAI;UACP,IAAMZ,GAAG,GAAG,gBAAgB,GAAGO,OAAO,GAAG,WAAW,GAAGK,KAAK;UAC5DnG,KAAK,CAACoC,GAAG,CAACmD,GAAG,CAAC;UACdC,KAAK,CAACD,GAAG,CAAC;UACV,MAAM,IAAIE,KAAK,CAACF,GAAG,CAAC;QACtB,CAAC,CACF;MACL,CAAC;IACH,CAAC,CAAEhC,CAAC,CAAC;IACLqB,MAAM,CAACwB,iBAAiB,CAAC7C,CAAC,CAAC;EAC7B;AACF"}
|
|
1
|
+
{"version":3,"file":"dragAndDrop.js","names":["debug","_interopRequireWildcard","require","mime","style","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","_typeof","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","makeDropTarget","ele","droppedURIHandler","droppedFileHandler","dragoverListener","e","preventDefault","dataTransfer","dropEffect","dragenterListener","log","localStyle","savedStyle","dragEvent","dragleaveListener","dropEvent","dropListener","types","join","uris","text","t","length","type","getData","split","files","i","f","name","size","lastModifiedDate","toLocaleDateString","slice","restoreStyle","addTargetListeners","addEventListener","makeDraggable","tr","setAttribute","fontWeight","setData","uri","outerHTML","stopPropagation","uploadFiles","fetcher","fileBase","imageBase","successHandler","reader","FileReader","onload","theFile","data","target","result","suffix","byteLength","contentType","lookup","msg","alert","Error","extension","endsWith","folderName","startsWith","destURI","encodeURIComponent","webOperation","then","_response","error","readAsArrayBuffer"],"sources":["../../src/widgets/dragAndDrop.js"],"sourcesContent":["/* Drag and drop common functionality\n *\n * It is easy to make something draggable, or to make it a drag target!\n * Just call the functions below. In a solid world, any part of the UI which\n * represent one thing which has a URI, should be made draggable using makeDraggable\n * Any list of things should typically allow you to drag new members of the list\n * onto it.\n * The file upload function uploadFiles is provided as often as someone drags a file from the computer\n * desktop, you may want to upload it into the pod.\n */\nimport * as debug from '../debug'\nimport * as mime from 'mime-types'\nimport * as style from '../style'\n\n/* global FileReader alert */\n\nexport function makeDropTarget (ele, droppedURIHandler, droppedFileHandler) {\n const dragoverListener = function (e) {\n e.preventDefault() // Need else drop does not work [sic]\n e.dataTransfer.dropEffect = 'copy'\n }\n\n const dragenterListener = function (e) {\n debug.log('dragenter event dropEffect: ' + e.dataTransfer.dropEffect)\n if (this.localStyle) {\n // necessary not sure when\n if (!this.savedStyle) {\n this.savedStyle = style.dragEvent\n }\n }\n\n e.dataTransfer.dropEffect = 'link'\n debug.log('dragenter event dropEffect 2: ' + e.dataTransfer.dropEffect)\n }\n const dragleaveListener = function (e) {\n debug.log('dragleave event dropEffect: ' + e.dataTransfer.dropEffect)\n if (this.savedStyle) {\n this.localStyle = this.savedStyle\n } else {\n this.localStyle = style.dropEvent\n }\n }\n\n const dropListener = function (e) {\n if (e.preventDefault) e.preventDefault() // stops the browser from redirecting off to the text.\n debug.log('Drop event. dropEffect: ' + e.dataTransfer.dropEffect)\n debug.log(\n 'Drop event. types: ' +\n (e.dataTransfer.types ? e.dataTransfer.types.join(', ') : 'NOPE')\n )\n\n let uris = null\n let text\n if (e.dataTransfer.types) {\n for (let t = 0; t < e.dataTransfer.types.length; t++) {\n const type = e.dataTransfer.types[t]\n if (type === 'text/uri-list') {\n uris = e.dataTransfer.getData(type).split('\\n') // @ ignore those starting with #\n debug.log('Dropped text/uri-list: ' + uris)\n } else if (type === 'text/plain') {\n text = e.dataTransfer.getData(type)\n } else if (type === 'Files' && droppedFileHandler) {\n const files = e.dataTransfer.files // FileList object.\n for (let i = 0; files[i]; i++) {\n const f = files[i]\n debug.log(\n 'Filename: ' +\n f.name +\n ', type: ' +\n (f.type || 'n/a') +\n ' size: ' +\n f.size +\n ' bytes, last modified: ' +\n (f.lastModifiedDate\n ? f.lastModifiedDate.toLocaleDateString()\n : 'n/a')\n )\n }\n droppedFileHandler(files)\n }\n }\n if (uris === null && text && text.slice(0, 4) === 'http') {\n uris = text\n debug.log(\"Waring: Poor man's drop: using text for URI\") // chrome disables text/uri-list??\n }\n } else {\n // ... however, if we're IE, we don't have the .types property, so we'll just get the Text value\n uris = [e.dataTransfer.getData('Text')]\n debug.log('WARNING non-standard drop event: ' + uris[0])\n }\n debug.log('Dropped URI list (2): ' + uris)\n if (uris) {\n droppedURIHandler(uris)\n }\n this.localStyle = style.restoreStyle // restore style\n return false\n } // dropListener\n\n const addTargetListeners = function (ele) {\n if (!ele) {\n debug.log('@@@ addTargetListeners: ele ' + ele)\n }\n ele.addEventListener('dragover', dragoverListener)\n ele.addEventListener('dragenter', dragenterListener)\n ele.addEventListener('dragleave', dragleaveListener)\n ele.addEventListener('drop', dropListener)\n }\n addTargetListeners(ele, droppedURIHandler)\n} // listen for dropped URIs\n\n// Make an HTML element draggable as a URI-identified thing\n//\n// Possibly later set the drag image too?\n//\nexport function makeDraggable (tr, obj) {\n tr.setAttribute('draggable', 'true') // Stop the image being dragged instead - just the TR\n\n tr.addEventListener(\n 'dragstart',\n function (e) {\n tr.style.fontWeight = 'bold'\n e.dataTransfer.setData('text/uri-list', obj.uri)\n e.dataTransfer.setData('text/plain', obj.uri)\n e.dataTransfer.setData('text/html', tr.outerHTML)\n debug.log(\n 'Dragstart: ' + tr + ' -> ' + obj + 'de: ' + e.dataTransfer.dropEffect\n )\n },\n false\n )\n\n tr.addEventListener(\n 'drag',\n function (e) {\n e.preventDefault()\n e.stopPropagation()\n // debug.log('Drag: dropEffect: ' + e.dataTransfer.dropEffect)\n },\n false\n )\n\n tr.addEventListener(\n 'dragend',\n function (e) {\n tr.style.fontWeight = 'normal'\n debug.log('Dragend dropeffect: ' + e.dataTransfer.dropEffect)\n debug.log('Dragend: ' + tr + ' -> ' + obj)\n },\n false\n )\n}\n\n/** uploadFiles\n**\n** Generic uploader of local files to the web\n** typically called from dropped file handler\n**\n** @param {Fetcher} fetcher instance of class Fetcher as in kb.fetcher\n** @param {Array<File>} files Array of file objects\n** @param {String} fileBase URI of folder in which to put files (except images) (no trailing slash)\n** @param {String } imageBase URI of folder in which to put images\n** @param successHandler function(file, uploadedURI) Called after EACH success upload\n** With file object an final URI as params\n*/\n\nexport function uploadFiles (fetcher, files, fileBase, imageBase, successHandler) {\n for (let i = 0; files[i]; i++) {\n const f = files[i]\n debug.log(\n ' dropped: Filename: ' +\n f.name +\n ', type: ' +\n (f.type || 'n/a') +\n ' size: ' +\n f.size +\n ' bytes, last modified: ' +\n (f.lastModifiedDate ? f.lastModifiedDate.toLocaleDateString() : 'n/a')\n ) // See e.g. https://www.html5rocks.com/en/tutorials/file/dndfiles/\n\n // @@ Add: progress bar(s)\n const reader = new FileReader()\n reader.onload = (function (theFile) {\n return function (e) {\n const data = e.target.result\n let suffix = ''\n debug.log(' File read byteLength : ' + data.byteLength)\n let contentType = theFile.type\n if (!theFile.type || theFile.type === '') {\n // Not known by browser\n contentType = mime.lookup(theFile.name)\n if (!contentType) {\n const msg =\n 'Filename needs to have an extension which gives a type we know: ' +\n theFile.name\n debug.log(msg)\n alert(msg)\n throw new Error(msg)\n }\n } else {\n const extension = mime.extension(theFile.type)\n // Note not simple: eg .mp3 => audio/mpeg; .mpga => audio/mpeg; audio/mp3 => .mp3\n if (extension && extension !== 'false' && !theFile.name.endsWith('.' + extension) && // Not already has preferred extension? and ...\n theFile.type !== mime.lookup(theFile.name)) { // the mime type of this ext is not the right one?\n suffix = '_.' + extension\n // console.log('MIME TYPE MISMATCH: ' + mime.lookup(theFile.name) + ': adding extension: ' + suffix)\n }\n }\n const folderName = theFile.type.startsWith('image/')\n ? imageBase || fileBase\n : fileBase\n const destURI =\n folderName +\n (folderName.endsWith('/') ? '' : '/') +\n encodeURIComponent(theFile.name) +\n suffix\n\n fetcher\n .webOperation('PUT', destURI, {\n data,\n contentType\n })\n .then(\n _response => {\n debug.log(' Upload: put OK: ' + destURI)\n successHandler(theFile, destURI)\n },\n error => {\n const msg = ' Upload: FAIL ' + destURI + ', Error: ' + error\n debug.log(msg)\n alert(msg)\n throw new Error(msg)\n }\n )\n }\n })(f)\n reader.readAsArrayBuffer(f)\n }\n}\n"],"mappings":";;;;;;;;;AAUA,IAAAA,KAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,IAAA,GAAAF,uBAAA,CAAAC,OAAA;AACA,IAAAE,KAAA,GAAAH,uBAAA,CAAAC,OAAA;AAAiC,SAAAG,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,yBAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAL,wBAAAS,GAAA,EAAAJ,WAAA,SAAAA,WAAA,IAAAI,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAAA,QAAAA,GAAA,aAAAE,OAAA,CAAAF,GAAA,yBAAAA,GAAA,uCAAAA,GAAA,UAAAG,KAAA,GAAAR,wBAAA,CAAAC,WAAA,OAAAO,KAAA,IAAAA,KAAA,CAAAC,GAAA,CAAAJ,GAAA,YAAAG,KAAA,CAAAE,GAAA,CAAAL,GAAA,SAAAM,MAAA,WAAAC,qBAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,GA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AAO,CACJwB,YAAY,CAAC,KAAK,EAAEF,OAAO,EAAE;UAC5Bd,IAAI,EAAJA,IAAI;UACJK,WAAW,EAAXA;QACF,CAAC,CAAC,CACDY,IAAI,CACH,UAAAC,SAAS,EAAI;UACXnG,KAAK,CAACqC,GAAG,CAAC,mBAAmB,GAAG0D,OAAO,CAAC;UACxCnB,cAAc,CAACI,OAAO,EAAEe,OAAO,CAAC;QAClC,CAAC,EACD,UAAAK,KAAK,EAAI;UACP,IAAMZ,GAAG,GAAG,gBAAgB,GAAGO,OAAO,GAAG,WAAW,GAAGK,KAAK;UAC5DpG,KAAK,CAACqC,GAAG,CAACmD,GAAG,CAAC;UACdC,KAAK,CAACD,GAAG,CAAC;UACV,MAAM,IAAIE,KAAK,CAACF,GAAG,CAAC;QACtB,CAAC,CACF;MACL,CAAC;IACH,CAAC,CAAEjC,CAAC,CAAC;IACLsB,MAAM,CAACwB,iBAAiB,CAAC9C,CAAC,CAAC;EAC7B;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../src/widgets/error.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../src/widgets/error.ts"],"names":[],"mappings":"AAiBA,wBAAgB,iBAAiB,CAAE,GAAG,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,GAAG,KAAK,EAAE,eAAe,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,KAAK,GAAG,cAAc,CAoBjI"}
|
package/lib/widgets/error.js
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
3
5
|
Object.defineProperty(exports, "__esModule", {
|
|
4
6
|
value: true
|
|
5
7
|
});
|
|
6
8
|
exports.errorMessageBlock = errorMessageBlock;
|
|
7
9
|
var _widgets = require("../widgets");
|
|
10
|
+
var style = _interopRequireWildcard(require("../style"));
|
|
11
|
+
var _styleConstants = _interopRequireDefault(require("../styleConstants"));
|
|
12
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
13
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
8
14
|
/**
|
|
9
15
|
* Create an error message block
|
|
10
16
|
* @param dom The DOM on which dom.createElement will be called
|
|
@@ -33,8 +39,9 @@ function errorMessageBlock(dom, err, backgroundColor, err2) {
|
|
|
33
39
|
}
|
|
34
40
|
div.appendChild((0, _widgets.cancelButton)(dom, function () {
|
|
35
41
|
if (div.parentNode) div.parentNode.removeChild(div);
|
|
36
|
-
})).style =
|
|
37
|
-
div.setAttribute('style',
|
|
42
|
+
})).style = style.errorCancelButton;
|
|
43
|
+
div.setAttribute('style', style.errorMessageBlockStyle);
|
|
44
|
+
div.style.backgroundColor = backgroundColor || _styleConstants["default"].defaultErrorBackgroundColor;
|
|
38
45
|
return div;
|
|
39
46
|
}
|
|
40
47
|
//# sourceMappingURL=error.js.map
|