diff --git a/client/dom/files.js b/client/dom/files.js index a7de8ff6..d7f79d3d 100644 --- a/client/dom/files.js +++ b/client/dom/files.js @@ -4,7 +4,7 @@ const itype = require('itype'); const {promisify} = require('es6-promisify'); -const load = require('./load'); +const load = require('#dom/load'); const RESTful = require('./rest'); const Promises = {}; diff --git a/client/dom/index.js b/client/dom/index.js index 27a1a5c6..7dbd7a0e 100644 --- a/client/dom/index.js +++ b/client/dom/index.js @@ -21,7 +21,7 @@ const DOM = { const CurrentInfo = {}; DOM.Images = Images; -DOM.load = require('./load'); +DOM.load = require('#dom/load'); DOM.Files = require('./files'); DOM.RESTful = RESTful; DOM.IO = require('./io'); diff --git a/client/dom/io/send-request.js b/client/dom/io/send-request.js index c61544f1..94349f91 100644 --- a/client/dom/io/send-request.js +++ b/client/dom/io/send-request.js @@ -4,7 +4,7 @@ const {promisify} = require('es6-promisify'); const Images = require('../images.mjs'); -const load = require('../load'); +const load = require('#dom/load'); module.exports = promisify((params, callback) => { const p = params; @@ -46,5 +46,5 @@ function replaceHash(url) { * if we send ajax request - * no need in hash so we escape # */ - return url.replace(/#/g, '%23'); + return url.replace(/#/g, '%' + '23'); } diff --git a/client/dom/load.js b/client/dom/load.mjs similarity index 88% rename from client/dom/load.js rename to client/dom/load.mjs index d060a92c..02158a83 100644 --- a/client/dom/load.js +++ b/client/dom/load.mjs @@ -1,19 +1,16 @@ -'use strict'; +import itype from 'itype'; +import jonny from 'jonny'; +import Emitify from 'emitify'; +import exec from 'execon'; +import * as Images from './images.mjs'; -const itype = require('itype'); -const jonny = require('jonny'); -const Emitify = require('emitify'); -const exec = require('execon'); -const Images = require('./images.mjs'); - -module.exports.getIdBySrc = getIdBySrc; /** * Function gets id by src * @param src * * Example: http://domain.com/1.js -> 1_js */ -function getIdBySrc(src) { +export function getIdBySrc(src) { const isStr = itype.string(src); if (!isStr) @@ -37,7 +34,7 @@ function getIdBySrc(src) { * * @param params */ -module.exports.ajax = (params) => { +export const ajax = (params) => { const p = params; const isObject = itype.object(p.data); const isArray = itype.array(p.data); @@ -94,11 +91,11 @@ module.exports.ajax = (params) => { xhr.send(data); }; -module.exports.put = (url, body) => { +export const put = (url, body) => { const emitter = Emitify(); const xhr = new XMLHttpRequest(); - url = encodeURI(url).replace(/#/g, '%23'); + url = encodeURI(url).replace(/#/g, '#'); xhr.open('put', url, true); diff --git a/client/dom/upload-files.js b/client/dom/upload-files.js index a1206282..01d4a777 100644 --- a/client/dom/upload-files.js +++ b/client/dom/upload-files.js @@ -4,7 +4,7 @@ const {eachSeries} = require('execon'); const wraptile = require('wraptile'); -const load = require('./load'); +const load = require('#dom/load'); const Images = require('./images.mjs'); const {alert} = require('./dialog'); diff --git a/client/modules/cloud.js b/client/modules/cloud.js index 53a6d9e9..5df1a888 100644 --- a/client/modules/cloud.js +++ b/client/modules/cloud.js @@ -6,7 +6,7 @@ const exec = require('execon'); const currify = require('currify'); const load = require('load.js'); -const {ajax} = require('../dom/load'); +const {ajax} = require('#dom/load'); const Files = require('../dom/files'); const Images = require('../dom/images.mjs'); diff --git a/client/modules/menu/index.js b/client/modules/menu/index.js index facb385a..b8b04e11 100644 --- a/client/modules/menu/index.js +++ b/client/modules/menu/index.js @@ -7,7 +7,7 @@ const wrap = require('wraptile'); const createElement = require('@cloudcmd/create-element'); const {FS} = require('../../../common/cloudfunc.mjs'); -const {getIdBySrc} = require('../../dom/load'); +const {getIdBySrc} = require('#dom/load'); const RESTful = require('../../dom/rest'); const {config, Key} = CloudCmd; @@ -298,7 +298,7 @@ function download(type) { * no need in hash so we escape # * and all other characters, like "%" */ - const encodedPath = encodeURI(path).replace(/#/g, '%23'); + const encodedPath = encodeURI(path).replace(/#/g, '#'); const id = getIdBySrc(path); let src; diff --git a/client/sw/sw.mjs b/client/sw/sw.mjs index 30b8909c..5b5643a3 100644 --- a/client/sw/sw.mjs +++ b/client/sw/sw.mjs @@ -96,4 +96,3 @@ async function addToCache(request, response) { const cache = await caches.open(NAME); return cache.put(request, response); } - diff --git a/package.json b/package.json index 88425207..6634a015 100644 --- a/package.json +++ b/package.json @@ -219,7 +219,8 @@ "webpackbar": "^7.0.0" }, "imports": { - "#dom/events": "./client/dom/events/index.mjs" + "#dom/events": "./client/dom/events/index.mjs", + "#dom/load": "./client/dom/load.mjs" }, "engines": { "node": ">=22"