mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-18 00:47:01 +00:00
feature: client: sw: register: migrate to ESM
This commit is contained in:
parent
5a16b018c5
commit
6b049d954b
7 changed files with 12 additions and 24 deletions
|
|
@ -10,7 +10,7 @@ import {addSlashToEnd} from 'format-io';
|
|||
import pascalCase from 'just-pascal-case';
|
||||
import currify from 'currify';
|
||||
import * as Images from './dom/images.mjs';
|
||||
import {unregisterSW} from './sw/register.js';
|
||||
import {unregisterSW} from './sw/register.mjs';
|
||||
import {getJsonFromFileTable} from './get-json-from-file-table.mjs';
|
||||
import {Key} from './key/index.mjs';
|
||||
import {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import process from 'node:process';
|
|||
import wraptile from 'wraptile';
|
||||
import load from 'load.js';
|
||||
import '../css/main.css';
|
||||
import {registerSW, listenSW} from './sw/register.js';
|
||||
import {registerSW, listenSW} from './sw/register.mjs';
|
||||
import {initSortPanel, sortPanel} from './sort.mjs';
|
||||
import Util from '../common/util.js';
|
||||
import * as CloudFunc from '../common/cloudfunc.mjs';
|
||||
|
|
|
|||
|
|
@ -8,4 +8,3 @@ export const getIndex = currify((array, item) => {
|
|||
|
||||
return index;
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -17,4 +17,3 @@ test('cloudcmd: client: listeners: getIndex: found', (t) => {
|
|||
t.equal(getIndex(array, 'world'), 1, 'should return index');
|
||||
t.end();
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -50,4 +50,3 @@ test('cloudcmd: client: listeners: getRange: one', (t) => {
|
|||
t.deepEqual(result, expected, 'should return range');
|
||||
t.end();
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -1,15 +1,10 @@
|
|||
'use strict';
|
||||
import {tryToCatch} from 'try-to-catch';
|
||||
|
||||
const {tryToCatch} = require('try-to-catch');
|
||||
|
||||
module.exports.registerSW = registerSW;
|
||||
module.exports.unregisterSW = unregisterSW;
|
||||
|
||||
module.exports.listenSW = (sw, ...args) => {
|
||||
export const listenSW = (sw, ...args) => {
|
||||
sw?.addEventListener(...args);
|
||||
};
|
||||
|
||||
async function registerSW(prefix) {
|
||||
export async function registerSW(prefix) {
|
||||
if (!navigator.serviceWorker)
|
||||
return;
|
||||
|
||||
|
|
@ -29,7 +24,7 @@ async function registerSW(prefix) {
|
|||
return sw;
|
||||
}
|
||||
|
||||
async function unregisterSW(prefix) {
|
||||
export async function unregisterSW(prefix) {
|
||||
const reg = await registerSW(prefix);
|
||||
reg?.unregister(prefix);
|
||||
}
|
||||
|
|
@ -1,16 +1,12 @@
|
|||
'use strict';
|
||||
|
||||
const autoGlobals = require('auto-globals');
|
||||
const tape = require('supertape');
|
||||
|
||||
const {stub} = require('@cloudcmd/stub');
|
||||
|
||||
const {tryCatch} = require('try-catch');
|
||||
const {
|
||||
import autoGlobals from 'auto-globals';
|
||||
import tape from 'supertape';
|
||||
import {stub} from '@cloudcmd/stub';
|
||||
import {tryCatch} from 'try-catch';
|
||||
import {
|
||||
listenSW,
|
||||
registerSW,
|
||||
unregisterSW,
|
||||
} = require('./register');
|
||||
} from './register.mjs';
|
||||
|
||||
const test = autoGlobals(tape);
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue