@bbn/bbn 2.0.221 → 2.0.223
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/bbn.js +17 -1
- package/dist/bbn.js.map +1 -1
- package/dist/bbn.sw.js +18 -0
- package/dist/bbn.sw.js.map +1 -0
- package/dist/com.js +0 -1
- package/dist/db.d.ts +7 -3
- package/dist/db.js +149 -76
- package/dist/dt/classes/date.d.ts +1 -1
- package/dist/dt/classes/date.js +1 -1
- package/dist/dt/classes/dateTime.d.ts +1 -1
- package/dist/dt/classes/dateTime.js +1 -1
- package/dist/dt/classes/dt.d.ts +1 -1
- package/dist/dt/classes/dt.js +1 -1
- package/dist/dt/classes/duration.d.ts +1 -1
- package/dist/dt/classes/duration.js +1 -1
- package/dist/dt/classes/monthDay.d.ts +1 -1
- package/dist/dt/classes/monthDay.js +1 -1
- package/dist/dt/classes/time.d.ts +1 -1
- package/dist/dt/classes/time.js +1 -1
- package/dist/dt/classes/yearMonth.d.ts +1 -1
- package/dist/dt/classes/yearMonth.js +1 -1
- package/dist/dt/classes/zoned.d.ts +1 -1
- package/dist/dt/classes/zoned.js +1 -1
- package/dist/dt/functions/fromJsDate.d.ts +1 -1
- package/dist/dt/functions/fromJsDate.js +1 -1
- package/dist/dt/functions/parse.js +1 -1
- package/dist/dt/vars/types.d.ts +1 -1
- package/dist/dt.js +1 -1
- package/dist/fn/init.js +21 -21
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/package.json +17 -10
package/dist/com.js
CHANGED
|
@@ -53,7 +53,6 @@ const fetchRequest = (method, url, config = {}, aborter) => {
|
|
|
53
53
|
const hasBody = methodsWithBody.includes(method.toUpperCase());
|
|
54
54
|
if (config.data != null && hasBody) {
|
|
55
55
|
// You can get fancier here (JSON, FormData, etc.)
|
|
56
|
-
bbn.fn.log('DATA', config.data);
|
|
57
56
|
if (typeof config.data === 'object' && !(config.data instanceof FormData)) {
|
|
58
57
|
fetchConfig.headers.set('Content-Type', 'application/json');
|
|
59
58
|
fetchConfig.body = JSON.stringify(config.data);
|
package/dist/db.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ type WhereObject = Record<string, unknown> | null;
|
|
|
16
16
|
type OrderClause = unknown;
|
|
17
17
|
interface IDbApi {
|
|
18
18
|
lastError(): unknown;
|
|
19
|
+
close(): void;
|
|
19
20
|
insert(table: string, data: Record<string, unknown> | Record<string, unknown>[]): Promise<number>;
|
|
20
21
|
update(table: string, data: Record<string, unknown>, where: WhereObject, replace?: boolean): Promise<number>;
|
|
21
22
|
delete(table: string, where: Record<string, unknown>): Promise<number>;
|
|
@@ -31,12 +32,15 @@ interface DbManager {
|
|
|
31
32
|
_connections: Record<string, IDBDatabase>;
|
|
32
33
|
_stores: Record<string, unknown>;
|
|
33
34
|
ok: boolean;
|
|
34
|
-
open(name: string): Promise<IDbApi>;
|
|
35
|
-
add(database: string, name: string, structure: DbStructure): Promise<
|
|
35
|
+
open(name: string, version?: number): Promise<IDbApi>;
|
|
36
|
+
add(database: string, name: string, structure: DbStructure): Promise<boolean>;
|
|
37
|
+
openRaw(name: string, version?: number): Promise<IDBDatabase>;
|
|
36
38
|
remove(database: string, name: string): Promise<void>;
|
|
37
39
|
updateStructure(storeName: string, structure: DbStructure, database: IDBDatabase): void;
|
|
38
|
-
|
|
40
|
+
importStructure(database: string, structure: Record<string, DbStructure>): Promise<void>;
|
|
41
|
+
reopenWithUpgrade(name: string): Promise<IDbApi>;
|
|
39
42
|
getExistingVersion(name: string): Promise<number>;
|
|
43
|
+
close(database: string): void;
|
|
40
44
|
}
|
|
41
45
|
declare const db: DbManager;
|
|
42
46
|
export default db;
|
package/dist/db.js
CHANGED
|
@@ -82,12 +82,22 @@ class DbObject {
|
|
|
82
82
|
this.lastErr = null;
|
|
83
83
|
this.dbName = dbName;
|
|
84
84
|
}
|
|
85
|
-
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
return
|
|
85
|
+
hasMissingStores(database, conn) {
|
|
86
|
+
const structures = db._structures[database] || {};
|
|
87
|
+
return Object.keys(structures).some(storeName => !conn.objectStoreNames.contains(storeName));
|
|
88
|
+
}
|
|
89
|
+
getConnection() {
|
|
90
|
+
return __awaiter(this, arguments, void 0, function* (database = '') {
|
|
91
|
+
let conn = db._connections[database || this.dbName];
|
|
92
|
+
if (!conn) {
|
|
93
|
+
const tmp = yield db.open(database || this.dbName);
|
|
94
|
+
if (!db._connections[database || this.dbName]) {
|
|
95
|
+
throw new Error(_('The database %s is not open', this.dbName));
|
|
96
|
+
}
|
|
97
|
+
conn = db._connections[database || this.dbName];
|
|
98
|
+
}
|
|
99
|
+
return conn;
|
|
100
|
+
});
|
|
91
101
|
}
|
|
92
102
|
get structure() {
|
|
93
103
|
const structure = db._structures[this.dbName];
|
|
@@ -97,27 +107,43 @@ class DbObject {
|
|
|
97
107
|
return structure;
|
|
98
108
|
}
|
|
99
109
|
getStore(table, mode) {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
this.
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
111
|
+
const connection = yield this.getConnection();
|
|
112
|
+
if (!this.structure[table]) {
|
|
113
|
+
throw new Error(_('Table %s is not defined in database structure %s', table, this.dbName));
|
|
114
|
+
}
|
|
115
|
+
if (!connection.objectStoreNames.contains(table)) {
|
|
116
|
+
throw new Error(_('Table %s does not exist in database %s. Schema upgrade required.', table, this.dbName));
|
|
117
|
+
}
|
|
118
|
+
const tx = connection.transaction([table], mode);
|
|
119
|
+
tx.onabort = () => {
|
|
120
|
+
this.lastErr = tx.error;
|
|
121
|
+
log(tx.error);
|
|
122
|
+
};
|
|
123
|
+
tx.onerror = () => {
|
|
124
|
+
this.lastErr = tx.error;
|
|
125
|
+
log(tx.error);
|
|
126
|
+
};
|
|
127
|
+
return [tx, tx.objectStore(table)];
|
|
128
|
+
});
|
|
110
129
|
}
|
|
111
130
|
lastError() {
|
|
112
131
|
return this.lastErr;
|
|
113
132
|
}
|
|
133
|
+
close() {
|
|
134
|
+
const conn = db._connections[this.dbName];
|
|
135
|
+
if (conn) {
|
|
136
|
+
conn.close();
|
|
137
|
+
delete db._connections[this.dbName];
|
|
138
|
+
}
|
|
139
|
+
}
|
|
114
140
|
insert(table, data) {
|
|
115
141
|
return __awaiter(this, void 0, void 0, function* () {
|
|
116
142
|
const rows = Array.isArray(data) ? data : [data];
|
|
117
143
|
if (!rows.length) {
|
|
118
144
|
return 0;
|
|
119
145
|
}
|
|
120
|
-
const [tx, store] = this.getStore(table, 'readwrite');
|
|
146
|
+
const [tx, store] = yield this.getStore(table, 'readwrite');
|
|
121
147
|
let inserted = 0;
|
|
122
148
|
for (const row of rows) {
|
|
123
149
|
const req = store.put(row);
|
|
@@ -144,7 +170,7 @@ class DbObject {
|
|
|
144
170
|
if (Array.isArray(primary)) {
|
|
145
171
|
throw new Error(_('Composite primary keys are not supported by this update implementation'));
|
|
146
172
|
}
|
|
147
|
-
const [tx, store] = this.getStore(table, 'readwrite');
|
|
173
|
+
const [tx, store] = yield this.getStore(table, 'readwrite');
|
|
148
174
|
let updated = 0;
|
|
149
175
|
for (const row of rows) {
|
|
150
176
|
const nextRow = extend({}, replace ? { [primary]: row[primary] } : row, data);
|
|
@@ -174,7 +200,7 @@ class DbObject {
|
|
|
174
200
|
if (!(primary in where)) {
|
|
175
201
|
throw new Error(_('No primary key in the filter'));
|
|
176
202
|
}
|
|
177
|
-
const [tx, store] = this.getStore(table, 'readwrite');
|
|
203
|
+
const [tx, store] = yield this.getStore(table, 'readwrite');
|
|
178
204
|
store.delete(where[primary]);
|
|
179
205
|
yield transactionDone(tx);
|
|
180
206
|
return 1;
|
|
@@ -196,7 +222,7 @@ class DbObject {
|
|
|
196
222
|
selectAll(table_1) {
|
|
197
223
|
return __awaiter(this, arguments, void 0, function* (table, fields = [], where = null, order = null, start = 0, limit = null) {
|
|
198
224
|
void order;
|
|
199
|
-
const [tx, store] = this.getStore(table, 'readonly');
|
|
225
|
+
const [tx, store] = yield this.getStore(table, 'readonly');
|
|
200
226
|
const structure = this.structure[table];
|
|
201
227
|
const primary = getPrimaryKey(structure);
|
|
202
228
|
const results = [];
|
|
@@ -241,7 +267,7 @@ class DbObject {
|
|
|
241
267
|
}
|
|
242
268
|
const matches = !where || !((_b = (_a = globalThis.bbn) === null || _a === void 0 ? void 0 : _a.fn) === null || _b === void 0 ? void 0 : _b.search)
|
|
243
269
|
? true
|
|
244
|
-
:
|
|
270
|
+
: 0 === globalThis.bbn.fn.search([cursor.value], where);
|
|
245
271
|
if (matches) {
|
|
246
272
|
if (i >= start) {
|
|
247
273
|
const transformed = transformResult(cursor.value, fields);
|
|
@@ -277,11 +303,15 @@ class DbObject {
|
|
|
277
303
|
}
|
|
278
304
|
copyTable(target_1, table_1) {
|
|
279
305
|
return __awaiter(this, arguments, void 0, function* (target, table, fields = [], where = null, order = null, start = 0, limit = null) {
|
|
280
|
-
if (!this.
|
|
306
|
+
if (!this.structure[table]) {
|
|
307
|
+
throw new Error(_('Source table %s does not exist in structure', table));
|
|
308
|
+
}
|
|
309
|
+
let connection = yield this.getConnection();
|
|
310
|
+
if (!connection.objectStoreNames.contains(target)) {
|
|
281
311
|
yield db.add(this.dbName, target, this.structure[table]);
|
|
282
|
-
yield
|
|
312
|
+
connection = yield this.getConnection();
|
|
283
313
|
}
|
|
284
|
-
if (!
|
|
314
|
+
if (!connection.objectStoreNames.contains(target)) {
|
|
285
315
|
throw new Error(_('The target table %s does not exist', target));
|
|
286
316
|
}
|
|
287
317
|
const rows = yield this.selectAll(table, fields, where, order, start, limit);
|
|
@@ -303,6 +333,13 @@ const db = {
|
|
|
303
333
|
_connections: {},
|
|
304
334
|
_stores: {},
|
|
305
335
|
ok: idb !== undefined,
|
|
336
|
+
close(database) {
|
|
337
|
+
const conn = this._connections[database];
|
|
338
|
+
if (conn) {
|
|
339
|
+
conn.close();
|
|
340
|
+
delete this._connections[database];
|
|
341
|
+
}
|
|
342
|
+
},
|
|
306
343
|
updateStructure(storeName, structure, database) {
|
|
307
344
|
const primary = getPrimaryKey(structure);
|
|
308
345
|
if (!database.objectStoreNames.contains(storeName)) {
|
|
@@ -316,6 +353,20 @@ const db = {
|
|
|
316
353
|
});
|
|
317
354
|
}
|
|
318
355
|
},
|
|
356
|
+
importStructure(database, structure) {
|
|
357
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
358
|
+
if (!this._structures[database]) {
|
|
359
|
+
this._structures[database] = {};
|
|
360
|
+
}
|
|
361
|
+
for (const storeName in structure) {
|
|
362
|
+
if (!this._structures[database].hasOwnProperty(storeName)) {
|
|
363
|
+
this._structures[database][storeName] = structure[storeName];
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
yield this.reopenWithUpgrade(database);
|
|
367
|
+
this.close(database);
|
|
368
|
+
});
|
|
369
|
+
},
|
|
319
370
|
getExistingVersion(name) {
|
|
320
371
|
return __awaiter(this, void 0, void 0, function* () {
|
|
321
372
|
const live = this._connections[name];
|
|
@@ -348,37 +399,19 @@ const db = {
|
|
|
348
399
|
},
|
|
349
400
|
reopenWithUpgrade(name) {
|
|
350
401
|
return __awaiter(this, void 0, void 0, function* () {
|
|
402
|
+
if (!this._structures[name]) {
|
|
403
|
+
throw new Error(_('Impossible to find a structure for the database %s', name));
|
|
404
|
+
}
|
|
351
405
|
const existingVersion = yield this.getExistingVersion(name);
|
|
352
406
|
const nextVersion = existingVersion + 1;
|
|
407
|
+
log(_('Going from version %s to version %s for database %s', existingVersion, nextVersion, name));
|
|
353
408
|
if (this._connections[name]) {
|
|
354
|
-
this.
|
|
355
|
-
delete this._connections[name];
|
|
409
|
+
this.close(name);
|
|
356
410
|
}
|
|
357
|
-
return
|
|
358
|
-
if (!idb) {
|
|
359
|
-
reject(new Error(_('IndexedDB is not available')));
|
|
360
|
-
return;
|
|
361
|
-
}
|
|
362
|
-
const req = idb.open(name, nextVersion);
|
|
363
|
-
req.onupgradeneeded = () => {
|
|
364
|
-
const database = req.result;
|
|
365
|
-
const dbStructure = this._structures[name] || {};
|
|
366
|
-
iterate(dbStructure, (structure, storeName) => {
|
|
367
|
-
if (!database.objectStoreNames.contains(storeName)) {
|
|
368
|
-
this.updateStructure(storeName, structure, database);
|
|
369
|
-
}
|
|
370
|
-
});
|
|
371
|
-
};
|
|
372
|
-
req.onsuccess = () => {
|
|
373
|
-
this._connections[name] = req.result;
|
|
374
|
-
resolve(req.result);
|
|
375
|
-
};
|
|
376
|
-
req.onerror = () => reject(req.error);
|
|
377
|
-
req.onblocked = () => reject(req.error || new Error(_('IndexedDB upgrade blocked')));
|
|
378
|
-
});
|
|
411
|
+
return yield this.open(name, nextVersion);
|
|
379
412
|
});
|
|
380
413
|
},
|
|
381
|
-
open(database) {
|
|
414
|
+
open(database, version) {
|
|
382
415
|
return __awaiter(this, void 0, void 0, function* () {
|
|
383
416
|
if (!idb) {
|
|
384
417
|
throw new Error(_('IndexedDB is not available'));
|
|
@@ -390,7 +423,7 @@ const db = {
|
|
|
390
423
|
return new DbObject(database);
|
|
391
424
|
}
|
|
392
425
|
yield new Promise((resolve, reject) => {
|
|
393
|
-
const req = idb.open(database);
|
|
426
|
+
const req = version ? idb.open(database, version) : idb.open(database);
|
|
394
427
|
req.onupgradeneeded = () => {
|
|
395
428
|
const db = req.result;
|
|
396
429
|
const dbStructure = this._structures[database] || {};
|
|
@@ -405,6 +438,9 @@ const db = {
|
|
|
405
438
|
resolve(req.result);
|
|
406
439
|
};
|
|
407
440
|
req.onerror = () => reject(req.error);
|
|
441
|
+
req.onblocked = (event) => {
|
|
442
|
+
reject(_('open: Upgrade blocked for database %s. Please close other connections to proceed.', database));
|
|
443
|
+
};
|
|
408
444
|
});
|
|
409
445
|
return new DbObject(database);
|
|
410
446
|
});
|
|
@@ -419,42 +455,79 @@ const db = {
|
|
|
419
455
|
this._structures[database] = {};
|
|
420
456
|
}
|
|
421
457
|
this._structures[database][name] = structure;
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
if (
|
|
425
|
-
yield this.
|
|
458
|
+
const hadConn = !!this._connections[database];
|
|
459
|
+
let conn;
|
|
460
|
+
if (!hadConn) {
|
|
461
|
+
yield this.open(database);
|
|
426
462
|
}
|
|
463
|
+
conn = this._connections[database];
|
|
464
|
+
// DB exists already: open temporarily and check if store exists
|
|
465
|
+
const hasStore = conn.objectStoreNames.contains(name);
|
|
466
|
+
if (!hasStore) {
|
|
467
|
+
const tmp = yield this.reopenWithUpgrade(database);
|
|
468
|
+
if (!this._connections[database]) {
|
|
469
|
+
throw new Error(_('The database %s is not open after upgrade', database));
|
|
470
|
+
}
|
|
471
|
+
conn = this._connections[database];
|
|
472
|
+
}
|
|
473
|
+
if (!hadConn) {
|
|
474
|
+
this.close(database);
|
|
475
|
+
}
|
|
476
|
+
return true;
|
|
477
|
+
});
|
|
478
|
+
},
|
|
479
|
+
openRaw(name, version) {
|
|
480
|
+
return new Promise((resolve, reject) => {
|
|
481
|
+
if (!idb) {
|
|
482
|
+
reject(new Error(_('IndexedDB is not available')));
|
|
483
|
+
return;
|
|
484
|
+
}
|
|
485
|
+
const req = version ? idb.open(name, version) : idb.open(name);
|
|
486
|
+
req.onsuccess = () => resolve(req.result);
|
|
487
|
+
req.onerror = () => reject(req.error);
|
|
488
|
+
req.onblocked = () => reject(new Error(_('IndexedDB open blocked for database %s', name)));
|
|
427
489
|
});
|
|
428
490
|
},
|
|
429
491
|
remove(database, name) {
|
|
430
492
|
return __awaiter(this, void 0, void 0, function* () {
|
|
431
|
-
|
|
432
|
-
(
|
|
433
|
-
const conn = this._connections[database];
|
|
434
|
-
if (!conn) {
|
|
493
|
+
const currentStructure = this._structures[database];
|
|
494
|
+
if (!(currentStructure === null || currentStructure === void 0 ? void 0 : currentStructure[name])) {
|
|
435
495
|
return;
|
|
436
496
|
}
|
|
437
|
-
const
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
if (!
|
|
442
|
-
reject(new Error(_('IndexedDB is not available')));
|
|
497
|
+
const old = currentStructure[name];
|
|
498
|
+
delete currentStructure[name];
|
|
499
|
+
try {
|
|
500
|
+
const conn = this._connections[database];
|
|
501
|
+
if (!conn) {
|
|
443
502
|
return;
|
|
444
503
|
}
|
|
445
|
-
const
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
if (
|
|
449
|
-
|
|
504
|
+
const nextVersion = conn.version + 1;
|
|
505
|
+
this.close(database);
|
|
506
|
+
yield new Promise((resolve, reject) => {
|
|
507
|
+
if (!idb) {
|
|
508
|
+
reject(new Error(_('IndexedDB is not available')));
|
|
509
|
+
return;
|
|
450
510
|
}
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
511
|
+
const req = idb.open(database, nextVersion);
|
|
512
|
+
req.onupgradeneeded = () => {
|
|
513
|
+
const dbInstance = req.result;
|
|
514
|
+
if (dbInstance.objectStoreNames.contains(name)) {
|
|
515
|
+
dbInstance.deleteObjectStore(name);
|
|
516
|
+
dbInstance.close();
|
|
517
|
+
}
|
|
518
|
+
};
|
|
519
|
+
req.onsuccess = () => {
|
|
520
|
+
req.result.close();
|
|
521
|
+
resolve();
|
|
522
|
+
};
|
|
523
|
+
req.onerror = () => reject(req.error);
|
|
524
|
+
req.onblocked = () => reject(new Error(_('Remove blocked for database %s', database)));
|
|
525
|
+
});
|
|
526
|
+
}
|
|
527
|
+
catch (e) {
|
|
528
|
+
currentStructure[name] = old;
|
|
529
|
+
throw e;
|
|
530
|
+
}
|
|
458
531
|
});
|
|
459
532
|
}
|
|
460
533
|
};
|
package/dist/dt/classes/date.js
CHANGED
package/dist/dt/classes/dt.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Temporal } from '
|
|
1
|
+
import { Temporal } from 'temporal-polyfill';
|
|
2
2
|
import { bbnDtTemporal } from '../vars/types.js';
|
|
3
3
|
import bbnDtDuration from './duration.js';
|
|
4
4
|
export declare abstract class bbnDt<TValue extends bbnDtTemporal> {
|
package/dist/dt/classes/dt.js
CHANGED
|
@@ -10,7 +10,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
10
10
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
11
|
};
|
|
12
12
|
var _bbnDt_value;
|
|
13
|
-
import { Temporal } from '
|
|
13
|
+
import { Temporal } from 'temporal-polyfill';
|
|
14
14
|
import { unitsCorrespondence, units, formatsMap } from '../vars/units.js';
|
|
15
15
|
import _ from '../../_.js';
|
|
16
16
|
import substr from '../../fn/string/substr.js';
|
|
@@ -10,7 +10,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
10
10
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
11
|
};
|
|
12
12
|
var _bbnDtDuration_instances, _bbnDtDuration_value, _bbnDtDuration_unit, _bbnDtDuration_getUnitValue;
|
|
13
|
-
import { Temporal } from '
|
|
13
|
+
import { Temporal } from 'temporal-polyfill';
|
|
14
14
|
import { units, unitsCorrespondence } from '../vars/units.js';
|
|
15
15
|
import getRow from '../../fn/object/getRow.js';
|
|
16
16
|
const DURATION_RELATIVE_TO = Temporal.ZonedDateTime.from('1970-01-01T00:00Z[UTC]');
|
package/dist/dt/classes/time.js
CHANGED
package/dist/dt/classes/zoned.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Temporal } from '
|
|
1
|
+
import { Temporal } from 'temporal-polyfill';
|
|
2
2
|
import buildLocaleFromIntl from './buildLocaleFromIntl.js';
|
|
3
3
|
import bbnDtZoned from '../classes/zoned.js';
|
|
4
4
|
import bbnDtDateTime from '../classes/dateTime.js';
|
package/dist/dt/vars/types.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Temporal } from '
|
|
1
|
+
import { Temporal } from 'temporal-polyfill';
|
|
2
2
|
export type bbnDtTemporal = Temporal.PlainDateTime | Temporal.PlainDate | Temporal.PlainTime | Temporal.PlainYearMonth | Temporal.PlainMonthDay | Temporal.ZonedDateTime;
|
package/dist/dt.js
CHANGED
package/dist/fn/init.js
CHANGED
|
@@ -81,7 +81,7 @@ export default function init(cfg, force) {
|
|
|
81
81
|
if (bbn.var.colors) {
|
|
82
82
|
addColors(bbn.var.colors);
|
|
83
83
|
}
|
|
84
|
-
|
|
84
|
+
document.addEventListener("visibilitychange", () => {
|
|
85
85
|
if (document.hidden) {
|
|
86
86
|
bbn.env.isVisible = false;
|
|
87
87
|
}
|
|
@@ -89,7 +89,7 @@ export default function init(cfg, force) {
|
|
|
89
89
|
bbn.env.isVisible = true;
|
|
90
90
|
}
|
|
91
91
|
});
|
|
92
|
-
|
|
92
|
+
document.addEventListener("focus", (e) => {
|
|
93
93
|
if (e.target instanceof HTMLElement &&
|
|
94
94
|
!e.target.classList.contains("bbn-no")) {
|
|
95
95
|
bbn.env.focused = e.target;
|
|
@@ -97,7 +97,7 @@ export default function init(cfg, force) {
|
|
|
97
97
|
bbn.env.isFocused = true;
|
|
98
98
|
bbn.env.last_focus = timestamp();
|
|
99
99
|
});
|
|
100
|
-
|
|
100
|
+
document.addEventListener("blur", (e) => {
|
|
101
101
|
if (e.target instanceof HTMLElement &&
|
|
102
102
|
!e.target.classList.contains("bbn-no")) {
|
|
103
103
|
bbn.env.focused = e.target;
|
|
@@ -105,29 +105,29 @@ export default function init(cfg, force) {
|
|
|
105
105
|
bbn.env.isFocused = false;
|
|
106
106
|
bbn.env.last_focus = timestamp();
|
|
107
107
|
});
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
108
|
+
document.addEventListener("click", onActivity);
|
|
109
|
+
document.addEventListener("keydown", onActivity);
|
|
110
|
+
document.addEventListener("focusin", onFocus);
|
|
111
|
+
document.addEventListener("focusout", onFocus);
|
|
112
|
+
window.addEventListener("hashchange", () => {
|
|
113
113
|
bbn.env.hashChanged = new Date().getTime();
|
|
114
114
|
}, false);
|
|
115
|
-
|
|
115
|
+
window.addEventListener("resize", () => {
|
|
116
116
|
resize();
|
|
117
117
|
});
|
|
118
|
-
|
|
118
|
+
window.addEventListener("orientationchange", () => {
|
|
119
119
|
resize();
|
|
120
120
|
});
|
|
121
121
|
resize();
|
|
122
122
|
if (isMobile()) {
|
|
123
|
-
|
|
123
|
+
document.body.classList.add("bbn-mobile");
|
|
124
124
|
if (isTabletDevice()) {
|
|
125
|
-
|
|
125
|
+
document.body.classList.add("bbn-tablet");
|
|
126
126
|
}
|
|
127
127
|
}
|
|
128
|
-
if (
|
|
129
|
-
|
|
130
|
-
let h =
|
|
128
|
+
if (window.history) {
|
|
129
|
+
window.onpopstate = function (e) {
|
|
130
|
+
let h = window.history;
|
|
131
131
|
if (!bbn.env.historyDisabled && h) {
|
|
132
132
|
//e.preventDefault();
|
|
133
133
|
if (bbn.fn.defaultHistoryFunction(h.state)) {
|
|
@@ -143,17 +143,17 @@ export default function init(cfg, force) {
|
|
|
143
143
|
}
|
|
144
144
|
};
|
|
145
145
|
}
|
|
146
|
-
|
|
146
|
+
window.addEventListener('online', () => {
|
|
147
147
|
bbn.env.online = true;
|
|
148
148
|
});
|
|
149
|
-
|
|
149
|
+
window.addEventListener('offline', () => {
|
|
150
150
|
bbn.env.online = false;
|
|
151
151
|
});
|
|
152
152
|
bbn.env.isInit = true;
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
153
|
+
document.dispatchEvent(new Event("bbninit"));
|
|
154
|
+
}
|
|
155
|
+
if (bbn.env.logging) {
|
|
156
|
+
log("Logging in bbn is enabled");
|
|
157
157
|
}
|
|
158
158
|
}
|
|
159
159
|
}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED