From 13f3b7693badb18daadec3fe9176acaaed1d3dfc Mon Sep 17 00:00:00 2001 From: Christian Robledo Date: Wed, 11 Sep 2024 19:00:27 -0600 Subject: [PATCH] refactor(native store): refactor native store and add session storage to node environment --- .gitignore | 3 +- dist/native-store/index.d.ts | 6 +- dist/native-store/index.d.ts.map | 2 +- dist/native-store/index.js | 61 +++++++++--- dist/native-store/index.js.map | 6 +- dist/native-store/index.mjs | 61 +++++++++--- dist/native-store/index.mjs.map | 6 +- dist/node/index.d.ts.map | 2 +- dist/node/index.js | 104 ++++++++++++++++++++ dist/node/index.js.map | 8 +- dist/node/index.mjs | 104 ++++++++++++++++++++ dist/node/index.mjs.map | 8 +- dist/node/utils/session-storage.d.ts | 22 +++++ dist/node/utils/session-storage.d.ts.map | 1 + dist/translate/index.d.ts | 14 +-- dist/translate/index.d.ts.map | 2 +- lib/native-store/index.ts | 66 ++++++++++--- lib/node/index.ts | 4 +- lib/node/utils/session-storage.ts | 117 +++++++++++++++++++++++ package-lock.json | 28 +++++- package.json | 2 +- test/native-storage_test.js | 88 +++++++++++++++++ 22 files changed, 644 insertions(+), 71 deletions(-) create mode 100644 dist/node/utils/session-storage.d.ts create mode 100644 dist/node/utils/session-storage.d.ts.map create mode 100644 lib/node/utils/session-storage.ts create mode 100644 test/native-storage_test.js diff --git a/.gitignore b/.gitignore index e14f1e4..3583744 100644 --- a/.gitignore +++ b/.gitignore @@ -68,4 +68,5 @@ typings/ yalc.lock .scratchpad -www \ No newline at end of file +www +.session-storage \ No newline at end of file diff --git a/dist/native-store/index.d.ts b/dist/native-store/index.d.ts index 77aaf1f..18a1851 100644 --- a/dist/native-store/index.d.ts +++ b/dist/native-store/index.d.ts @@ -1,3 +1,7 @@ +export declare enum StorageType { + Session = "session", + Local = "local" +} export interface NativeStorageInterface { state: Record; set(key: string, value: any): void; @@ -6,5 +10,5 @@ export interface NativeStorageInterface { load(): void; clear(): void; } -export declare function createNativeStore(key: string, definition?: Record, reuseIfExist?: boolean): NativeStorageInterface & T; +export declare function createNativeStore(key: string, definition?: Record, storageType?: StorageType, reuseIfExist?: boolean): NativeStorageInterface & T; //# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/dist/native-store/index.d.ts.map b/dist/native-store/index.d.ts.map index 3b1ef23..a020b70 100644 --- a/dist/native-store/index.d.ts.map +++ b/dist/native-store/index.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../lib/native-store/index.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,sBAAsB;IACrC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC3B,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,IAAI,CAAC;IACnC,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;IACtB,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,IAAI,IAAI,IAAI,CAAC;IACb,KAAK,IAAI,IAAI,CAAC;CACf;AAMD,wBAAgB,iBAAiB,CAAC,CAAC,EACjC,GAAG,EAAE,MAAM,EACX,UAAU,GAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM,EACpC,YAAY,UAAQ,GACnB,sBAAsB,GAAG,CAAC,CA6C5B"} \ No newline at end of file +{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../lib/native-store/index.ts"],"names":[],"mappings":"AAGA,oBAAY,WAAW;IACrB,OAAO,YAAY;IACnB,KAAK,UAAU;CAChB;AAED,MAAM,WAAW,sBAAsB;IACrC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC3B,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,IAAI,CAAC;IACnC,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;IACtB,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,IAAI,IAAI,IAAI,CAAC;IACb,KAAK,IAAI,IAAI,CAAC;CACf;AAaD,wBAAgB,iBAAiB,CAAC,CAAC,EACjC,GAAG,EAAE,MAAM,EACX,UAAU,GAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM,EACpC,WAAW,GAAE,WAA+B,EAC5C,YAAY,UAAQ,GACnB,sBAAsB,GAAG,CAAC,CAmE5B"} \ No newline at end of file diff --git a/dist/native-store/index.js b/dist/native-store/index.js index 67f8209..454c5dc 100644 --- a/dist/native-store/index.js +++ b/dist/native-store/index.js @@ -20,12 +20,27 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru // lib/native-store/index.ts var native_store_exports = {}; __export(native_store_exports, { + StorageType: () => StorageType, createNativeStore: () => createNativeStore }); module.exports = __toCommonJS(native_store_exports); -var nativeStore = sessionStorage || localStorage; +var import_valyrian = require("valyrian.js"); +var StorageType = /* @__PURE__ */ ((StorageType2) => { + StorageType2["Session"] = "session"; + StorageType2["Local"] = "local"; + return StorageType2; +})(StorageType || {}); var ids = /* @__PURE__ */ new Set(); -function createNativeStore(key, definition = {}, reuseIfExist = false) { +function getStorage(storageType) { + if (import_valyrian.isNodeJs && typeof localStorage === "undefined") { + throw new Error( + `localStorage and sessionStorage are not available in Node.js, to use it in your project, you need to "import "valyrian.js/node"` + ); + } + return storageType === "session" /* Session */ ? sessionStorage : localStorage; +} +function createNativeStore(key, definition = {}, storageType = "local" /* Local */, reuseIfExist = false) { + const nativeStore = getStorage(storageType); if (ids.has(key)) { if (reuseIfExist) { console.warn(`Store with key ${key} already exists and will be reused`); @@ -34,34 +49,52 @@ function createNativeStore(key, definition = {}, reuseIfExist = false) { } } ids.add(key); + const id = key; const Store = { state: {}, set(key2, value) { - this.state[key2] = value; - nativeStore.setItem(key2, JSON.stringify(this.state)); + try { + this.state[key2] = value; + nativeStore.setItem(id, JSON.stringify(this.state)); + } catch (e) { + console.error("Error setting item in storage:", e); + } }, get(key2) { - if (!this.state) { + if (Object.keys(this.state).length === 0) { this.load(); } return this.state[key2]; }, delete(key2) { - Reflect.deleteProperty(this.state, key2); - nativeStore.setItem(key2, JSON.stringify(this.state)); + try { + Reflect.deleteProperty(this.state, key2); + nativeStore.setItem(id, JSON.stringify(this.state)); + } catch (e) { + console.error("Error deleting item in storage:", e); + } }, load() { - const state = nativeStore.getItem(key); - if (!state) { + try { + const state = nativeStore.getItem(id); + if (!state) { + this.state = {}; + nativeStore.setItem(id, JSON.stringify(this.state)); + return; + } + this.state = JSON.parse(state); + } catch (e) { + console.error("Error loading state from storage:", e); this.state = {}; - nativeStore.setItem(key, JSON.stringify(this.state)); - return; } - this.state = JSON.parse(state); }, clear() { - this.state = {}; - nativeStore.removeItem(key); + try { + this.state = {}; + nativeStore.removeItem(id); + } catch (e) { + console.error("Error clearing storage:", e); + } }, ...definition }; diff --git a/dist/native-store/index.js.map b/dist/native-store/index.js.map index eac268d..ed72063 100644 --- a/dist/native-store/index.js.map +++ b/dist/native-store/index.js.map @@ -1,7 +1,7 @@ { "version": 3, "sources": ["../../lib/native-store/index.ts"], - "sourcesContent": ["export interface NativeStorageInterface {\n state: Record;\n set(key: string, value: any): void;\n get(key: string): any;\n delete(key: string): void;\n load(): void;\n clear(): void;\n}\n\nconst nativeStore = sessionStorage || localStorage;\n\nconst ids = new Set();\n\nexport function createNativeStore(\n key: string,\n definition: Record = {},\n reuseIfExist = false\n): NativeStorageInterface & T {\n if (ids.has(key)) {\n if (reuseIfExist) {\n // eslint-disable-next-line no-console\n console.warn(`Store with key ${key} already exists and will be reused`);\n } else {\n throw new Error(`Store with key ${key} already exists`);\n }\n }\n ids.add(key);\n const Store: NativeStorageInterface = {\n state: {},\n set(key, value) {\n this.state[key] = value;\n nativeStore.setItem(key, JSON.stringify(this.state));\n },\n get(key) {\n if (!this.state) {\n this.load();\n }\n return this.state[key];\n },\n delete(key) {\n Reflect.deleteProperty(this.state, key);\n nativeStore.setItem(key, JSON.stringify(this.state));\n },\n load() {\n const state = nativeStore.getItem(key);\n if (!state) {\n this.state = {};\n nativeStore.setItem(key, JSON.stringify(this.state));\n return;\n }\n this.state = JSON.parse(state);\n },\n clear() {\n this.state = {};\n nativeStore.removeItem(key);\n },\n ...definition\n };\n\n Store.load();\n\n return Store as NativeStorageInterface & T;\n}\n"], - "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AASA,IAAM,cAAc,kBAAkB;AAEtC,IAAM,MAAM,oBAAI,IAAY;AAErB,SAAS,kBACd,KACA,aAAkC,CAAC,GACnC,eAAe,OACa;AAC5B,MAAI,IAAI,IAAI,GAAG,GAAG;AAChB,QAAI,cAAc;AAEhB,cAAQ,KAAK,kBAAkB,GAAG,oCAAoC;AAAA,IACxE,OAAO;AACL,YAAM,IAAI,MAAM,kBAAkB,GAAG,iBAAiB;AAAA,IACxD;AAAA,EACF;AACA,MAAI,IAAI,GAAG;AACX,QAAM,QAAgC;AAAA,IACpC,OAAO,CAAC;AAAA,IACR,IAAIA,MAAK,OAAO;AACd,WAAK,MAAMA,IAAG,IAAI;AAClB,kBAAY,QAAQA,MAAK,KAAK,UAAU,KAAK,KAAK,CAAC;AAAA,IACrD;AAAA,IACA,IAAIA,MAAK;AACP,UAAI,CAAC,KAAK,OAAO;AACf,aAAK,KAAK;AAAA,MACZ;AACA,aAAO,KAAK,MAAMA,IAAG;AAAA,IACvB;AAAA,IACA,OAAOA,MAAK;AACV,cAAQ,eAAe,KAAK,OAAOA,IAAG;AACtC,kBAAY,QAAQA,MAAK,KAAK,UAAU,KAAK,KAAK,CAAC;AAAA,IACrD;AAAA,IACA,OAAO;AACL,YAAM,QAAQ,YAAY,QAAQ,GAAG;AACrC,UAAI,CAAC,OAAO;AACV,aAAK,QAAQ,CAAC;AACd,oBAAY,QAAQ,KAAK,KAAK,UAAU,KAAK,KAAK,CAAC;AACnD;AAAA,MACF;AACA,WAAK,QAAQ,KAAK,MAAM,KAAK;AAAA,IAC/B;AAAA,IACA,QAAQ;AACN,WAAK,QAAQ,CAAC;AACd,kBAAY,WAAW,GAAG;AAAA,IAC5B;AAAA,IACA,GAAG;AAAA,EACL;AAEA,QAAM,KAAK;AAEX,SAAO;AACT;", - "names": ["key"] + "sourcesContent": ["import { isNodeJs } from \"valyrian.js\";\n\n/* eslint-disable no-console */\nexport enum StorageType {\n Session = \"session\",\n Local = \"local\"\n}\n\nexport interface NativeStorageInterface {\n state: Record;\n set(key: string, value: any): void;\n get(key: string): any;\n delete(key: string): void;\n load(): void;\n clear(): void;\n}\n\nconst ids = new Set();\n\nfunction getStorage(storageType: StorageType) {\n if (isNodeJs && typeof localStorage === \"undefined\") {\n throw new Error(\n `localStorage and sessionStorage are not available in Node.js, to use it in your project, you need to \"import \"valyrian.js/node\"`\n );\n }\n return storageType === StorageType.Session ? sessionStorage : localStorage;\n}\n\nexport function createNativeStore(\n key: string,\n definition: Record = {},\n storageType: StorageType = StorageType.Local,\n reuseIfExist = false\n): NativeStorageInterface & T {\n const nativeStore = getStorage(storageType);\n\n if (ids.has(key)) {\n if (reuseIfExist) {\n // eslint-disable-next-line no-console\n console.warn(`Store with key ${key} already exists and will be reused`);\n } else {\n throw new Error(`Store with key ${key} already exists`);\n }\n }\n ids.add(key);\n\n const id = key;\n\n const Store: NativeStorageInterface = {\n state: {},\n set(key, value) {\n try {\n this.state[key] = value;\n nativeStore.setItem(id, JSON.stringify(this.state));\n } catch (e) {\n console.error(\"Error setting item in storage:\", e);\n }\n },\n get(key) {\n if (Object.keys(this.state).length === 0) {\n this.load();\n }\n return this.state[key];\n },\n delete(key) {\n try {\n Reflect.deleteProperty(this.state, key);\n nativeStore.setItem(id, JSON.stringify(this.state));\n } catch (e) {\n console.error(\"Error deleting item in storage:\", e);\n }\n },\n load() {\n try {\n const state = nativeStore.getItem(id);\n if (!state) {\n this.state = {};\n nativeStore.setItem(id, JSON.stringify(this.state));\n return;\n }\n this.state = JSON.parse(state);\n } catch (e) {\n console.error(\"Error loading state from storage:\", e);\n this.state = {};\n }\n },\n clear() {\n try {\n this.state = {};\n nativeStore.removeItem(id);\n } catch (e) {\n console.error(\"Error clearing storage:\", e);\n }\n },\n ...definition\n };\n\n Store.load();\n\n return Store as NativeStorageInterface & T;\n}\n"], + "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAyB;AAGlB,IAAK,cAAL,kBAAKA,iBAAL;AACL,EAAAA,aAAA,aAAU;AACV,EAAAA,aAAA,WAAQ;AAFE,SAAAA;AAAA,GAAA;AAcZ,IAAM,MAAM,oBAAI,IAAY;AAE5B,SAAS,WAAW,aAA0B;AAC5C,MAAI,4BAAY,OAAO,iBAAiB,aAAa;AACnD,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACA,SAAO,gBAAgB,0BAAsB,iBAAiB;AAChE;AAEO,SAAS,kBACd,KACA,aAAkC,CAAC,GACnC,cAA2B,qBAC3B,eAAe,OACa;AAC5B,QAAM,cAAc,WAAW,WAAW;AAE1C,MAAI,IAAI,IAAI,GAAG,GAAG;AAChB,QAAI,cAAc;AAEhB,cAAQ,KAAK,kBAAkB,GAAG,oCAAoC;AAAA,IACxE,OAAO;AACL,YAAM,IAAI,MAAM,kBAAkB,GAAG,iBAAiB;AAAA,IACxD;AAAA,EACF;AACA,MAAI,IAAI,GAAG;AAEX,QAAM,KAAK;AAEX,QAAM,QAAgC;AAAA,IACpC,OAAO,CAAC;AAAA,IACR,IAAIC,MAAK,OAAO;AACd,UAAI;AACF,aAAK,MAAMA,IAAG,IAAI;AAClB,oBAAY,QAAQ,IAAI,KAAK,UAAU,KAAK,KAAK,CAAC;AAAA,MACpD,SAAS,GAAG;AACV,gBAAQ,MAAM,kCAAkC,CAAC;AAAA,MACnD;AAAA,IACF;AAAA,IACA,IAAIA,MAAK;AACP,UAAI,OAAO,KAAK,KAAK,KAAK,EAAE,WAAW,GAAG;AACxC,aAAK,KAAK;AAAA,MACZ;AACA,aAAO,KAAK,MAAMA,IAAG;AAAA,IACvB;AAAA,IACA,OAAOA,MAAK;AACV,UAAI;AACF,gBAAQ,eAAe,KAAK,OAAOA,IAAG;AACtC,oBAAY,QAAQ,IAAI,KAAK,UAAU,KAAK,KAAK,CAAC;AAAA,MACpD,SAAS,GAAG;AACV,gBAAQ,MAAM,mCAAmC,CAAC;AAAA,MACpD;AAAA,IACF;AAAA,IACA,OAAO;AACL,UAAI;AACF,cAAM,QAAQ,YAAY,QAAQ,EAAE;AACpC,YAAI,CAAC,OAAO;AACV,eAAK,QAAQ,CAAC;AACd,sBAAY,QAAQ,IAAI,KAAK,UAAU,KAAK,KAAK,CAAC;AAClD;AAAA,QACF;AACA,aAAK,QAAQ,KAAK,MAAM,KAAK;AAAA,MAC/B,SAAS,GAAG;AACV,gBAAQ,MAAM,qCAAqC,CAAC;AACpD,aAAK,QAAQ,CAAC;AAAA,MAChB;AAAA,IACF;AAAA,IACA,QAAQ;AACN,UAAI;AACF,aAAK,QAAQ,CAAC;AACd,oBAAY,WAAW,EAAE;AAAA,MAC3B,SAAS,GAAG;AACV,gBAAQ,MAAM,2BAA2B,CAAC;AAAA,MAC5C;AAAA,IACF;AAAA,IACA,GAAG;AAAA,EACL;AAEA,QAAM,KAAK;AAEX,SAAO;AACT;", + "names": ["StorageType", "key"] } diff --git a/dist/native-store/index.mjs b/dist/native-store/index.mjs index 70425a2..10b0d7e 100644 --- a/dist/native-store/index.mjs +++ b/dist/native-store/index.mjs @@ -1,7 +1,21 @@ // lib/native-store/index.ts -var nativeStore = sessionStorage || localStorage; +import { isNodeJs } from "valyrian.js"; +var StorageType = /* @__PURE__ */ ((StorageType2) => { + StorageType2["Session"] = "session"; + StorageType2["Local"] = "local"; + return StorageType2; +})(StorageType || {}); var ids = /* @__PURE__ */ new Set(); -function createNativeStore(key, definition = {}, reuseIfExist = false) { +function getStorage(storageType) { + if (isNodeJs && typeof localStorage === "undefined") { + throw new Error( + `localStorage and sessionStorage are not available in Node.js, to use it in your project, you need to "import "valyrian.js/node"` + ); + } + return storageType === "session" /* Session */ ? sessionStorage : localStorage; +} +function createNativeStore(key, definition = {}, storageType = "local" /* Local */, reuseIfExist = false) { + const nativeStore = getStorage(storageType); if (ids.has(key)) { if (reuseIfExist) { console.warn(`Store with key ${key} already exists and will be reused`); @@ -10,34 +24,52 @@ function createNativeStore(key, definition = {}, reuseIfExist = false) { } } ids.add(key); + const id = key; const Store = { state: {}, set(key2, value) { - this.state[key2] = value; - nativeStore.setItem(key2, JSON.stringify(this.state)); + try { + this.state[key2] = value; + nativeStore.setItem(id, JSON.stringify(this.state)); + } catch (e) { + console.error("Error setting item in storage:", e); + } }, get(key2) { - if (!this.state) { + if (Object.keys(this.state).length === 0) { this.load(); } return this.state[key2]; }, delete(key2) { - Reflect.deleteProperty(this.state, key2); - nativeStore.setItem(key2, JSON.stringify(this.state)); + try { + Reflect.deleteProperty(this.state, key2); + nativeStore.setItem(id, JSON.stringify(this.state)); + } catch (e) { + console.error("Error deleting item in storage:", e); + } }, load() { - const state = nativeStore.getItem(key); - if (!state) { + try { + const state = nativeStore.getItem(id); + if (!state) { + this.state = {}; + nativeStore.setItem(id, JSON.stringify(this.state)); + return; + } + this.state = JSON.parse(state); + } catch (e) { + console.error("Error loading state from storage:", e); this.state = {}; - nativeStore.setItem(key, JSON.stringify(this.state)); - return; } - this.state = JSON.parse(state); }, clear() { - this.state = {}; - nativeStore.removeItem(key); + try { + this.state = {}; + nativeStore.removeItem(id); + } catch (e) { + console.error("Error clearing storage:", e); + } }, ...definition }; @@ -45,5 +77,6 @@ function createNativeStore(key, definition = {}, reuseIfExist = false) { return Store; } export { + StorageType, createNativeStore }; diff --git a/dist/native-store/index.mjs.map b/dist/native-store/index.mjs.map index 97ed5cc..59b0b96 100644 --- a/dist/native-store/index.mjs.map +++ b/dist/native-store/index.mjs.map @@ -1,7 +1,7 @@ { "version": 3, "sources": ["../../lib/native-store/index.ts"], - "sourcesContent": ["export interface NativeStorageInterface {\n state: Record;\n set(key: string, value: any): void;\n get(key: string): any;\n delete(key: string): void;\n load(): void;\n clear(): void;\n}\n\nconst nativeStore = sessionStorage || localStorage;\n\nconst ids = new Set();\n\nexport function createNativeStore(\n key: string,\n definition: Record = {},\n reuseIfExist = false\n): NativeStorageInterface & T {\n if (ids.has(key)) {\n if (reuseIfExist) {\n // eslint-disable-next-line no-console\n console.warn(`Store with key ${key} already exists and will be reused`);\n } else {\n throw new Error(`Store with key ${key} already exists`);\n }\n }\n ids.add(key);\n const Store: NativeStorageInterface = {\n state: {},\n set(key, value) {\n this.state[key] = value;\n nativeStore.setItem(key, JSON.stringify(this.state));\n },\n get(key) {\n if (!this.state) {\n this.load();\n }\n return this.state[key];\n },\n delete(key) {\n Reflect.deleteProperty(this.state, key);\n nativeStore.setItem(key, JSON.stringify(this.state));\n },\n load() {\n const state = nativeStore.getItem(key);\n if (!state) {\n this.state = {};\n nativeStore.setItem(key, JSON.stringify(this.state));\n return;\n }\n this.state = JSON.parse(state);\n },\n clear() {\n this.state = {};\n nativeStore.removeItem(key);\n },\n ...definition\n };\n\n Store.load();\n\n return Store as NativeStorageInterface & T;\n}\n"], - "mappings": ";AASA,IAAM,cAAc,kBAAkB;AAEtC,IAAM,MAAM,oBAAI,IAAY;AAErB,SAAS,kBACd,KACA,aAAkC,CAAC,GACnC,eAAe,OACa;AAC5B,MAAI,IAAI,IAAI,GAAG,GAAG;AAChB,QAAI,cAAc;AAEhB,cAAQ,KAAK,kBAAkB,GAAG,oCAAoC;AAAA,IACxE,OAAO;AACL,YAAM,IAAI,MAAM,kBAAkB,GAAG,iBAAiB;AAAA,IACxD;AAAA,EACF;AACA,MAAI,IAAI,GAAG;AACX,QAAM,QAAgC;AAAA,IACpC,OAAO,CAAC;AAAA,IACR,IAAIA,MAAK,OAAO;AACd,WAAK,MAAMA,IAAG,IAAI;AAClB,kBAAY,QAAQA,MAAK,KAAK,UAAU,KAAK,KAAK,CAAC;AAAA,IACrD;AAAA,IACA,IAAIA,MAAK;AACP,UAAI,CAAC,KAAK,OAAO;AACf,aAAK,KAAK;AAAA,MACZ;AACA,aAAO,KAAK,MAAMA,IAAG;AAAA,IACvB;AAAA,IACA,OAAOA,MAAK;AACV,cAAQ,eAAe,KAAK,OAAOA,IAAG;AACtC,kBAAY,QAAQA,MAAK,KAAK,UAAU,KAAK,KAAK,CAAC;AAAA,IACrD;AAAA,IACA,OAAO;AACL,YAAM,QAAQ,YAAY,QAAQ,GAAG;AACrC,UAAI,CAAC,OAAO;AACV,aAAK,QAAQ,CAAC;AACd,oBAAY,QAAQ,KAAK,KAAK,UAAU,KAAK,KAAK,CAAC;AACnD;AAAA,MACF;AACA,WAAK,QAAQ,KAAK,MAAM,KAAK;AAAA,IAC/B;AAAA,IACA,QAAQ;AACN,WAAK,QAAQ,CAAC;AACd,kBAAY,WAAW,GAAG;AAAA,IAC5B;AAAA,IACA,GAAG;AAAA,EACL;AAEA,QAAM,KAAK;AAEX,SAAO;AACT;", - "names": ["key"] + "sourcesContent": ["import { isNodeJs } from \"valyrian.js\";\n\n/* eslint-disable no-console */\nexport enum StorageType {\n Session = \"session\",\n Local = \"local\"\n}\n\nexport interface NativeStorageInterface {\n state: Record;\n set(key: string, value: any): void;\n get(key: string): any;\n delete(key: string): void;\n load(): void;\n clear(): void;\n}\n\nconst ids = new Set();\n\nfunction getStorage(storageType: StorageType) {\n if (isNodeJs && typeof localStorage === \"undefined\") {\n throw new Error(\n `localStorage and sessionStorage are not available in Node.js, to use it in your project, you need to \"import \"valyrian.js/node\"`\n );\n }\n return storageType === StorageType.Session ? sessionStorage : localStorage;\n}\n\nexport function createNativeStore(\n key: string,\n definition: Record = {},\n storageType: StorageType = StorageType.Local,\n reuseIfExist = false\n): NativeStorageInterface & T {\n const nativeStore = getStorage(storageType);\n\n if (ids.has(key)) {\n if (reuseIfExist) {\n // eslint-disable-next-line no-console\n console.warn(`Store with key ${key} already exists and will be reused`);\n } else {\n throw new Error(`Store with key ${key} already exists`);\n }\n }\n ids.add(key);\n\n const id = key;\n\n const Store: NativeStorageInterface = {\n state: {},\n set(key, value) {\n try {\n this.state[key] = value;\n nativeStore.setItem(id, JSON.stringify(this.state));\n } catch (e) {\n console.error(\"Error setting item in storage:\", e);\n }\n },\n get(key) {\n if (Object.keys(this.state).length === 0) {\n this.load();\n }\n return this.state[key];\n },\n delete(key) {\n try {\n Reflect.deleteProperty(this.state, key);\n nativeStore.setItem(id, JSON.stringify(this.state));\n } catch (e) {\n console.error(\"Error deleting item in storage:\", e);\n }\n },\n load() {\n try {\n const state = nativeStore.getItem(id);\n if (!state) {\n this.state = {};\n nativeStore.setItem(id, JSON.stringify(this.state));\n return;\n }\n this.state = JSON.parse(state);\n } catch (e) {\n console.error(\"Error loading state from storage:\", e);\n this.state = {};\n }\n },\n clear() {\n try {\n this.state = {};\n nativeStore.removeItem(id);\n } catch (e) {\n console.error(\"Error clearing storage:\", e);\n }\n },\n ...definition\n };\n\n Store.load();\n\n return Store as NativeStorageInterface & T;\n}\n"], + "mappings": ";AAAA,SAAS,gBAAgB;AAGlB,IAAK,cAAL,kBAAKA,iBAAL;AACL,EAAAA,aAAA,aAAU;AACV,EAAAA,aAAA,WAAQ;AAFE,SAAAA;AAAA,GAAA;AAcZ,IAAM,MAAM,oBAAI,IAAY;AAE5B,SAAS,WAAW,aAA0B;AAC5C,MAAI,YAAY,OAAO,iBAAiB,aAAa;AACnD,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACA,SAAO,gBAAgB,0BAAsB,iBAAiB;AAChE;AAEO,SAAS,kBACd,KACA,aAAkC,CAAC,GACnC,cAA2B,qBAC3B,eAAe,OACa;AAC5B,QAAM,cAAc,WAAW,WAAW;AAE1C,MAAI,IAAI,IAAI,GAAG,GAAG;AAChB,QAAI,cAAc;AAEhB,cAAQ,KAAK,kBAAkB,GAAG,oCAAoC;AAAA,IACxE,OAAO;AACL,YAAM,IAAI,MAAM,kBAAkB,GAAG,iBAAiB;AAAA,IACxD;AAAA,EACF;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ist/node/index.d.ts.map b/dist/node/index.d.ts.map index ff0801b..bf1fdf7 100644 --- a/dist/node/index.d.ts.map +++ b/dist/node/index.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../lib/node/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,SAAS,EAAE,gBAAgB,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAK3G,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,EAAE,EAAE,MAAM,YAAY,CAAC;AAKhC,iBAAS,MAAM,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,iBAK7B;AAED,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC"} \ No newline at end of file +{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../lib/node/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,SAAS,EAAE,gBAAgB,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAI3G,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,EAAE,EAAE,MAAM,YAAY,CAAC;AAQhC,iBAAS,MAAM,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,iBAK7B;AAED,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC"} \ No newline at end of file diff --git a/dist/node/index.js b/dist/node/index.js index b74ebbe..f8ee6dd 100644 --- a/dist/node/index.js +++ b/dist/node/index.js @@ -958,9 +958,113 @@ function sw(file, options = {}) { import_fs3.default.writeFileSync(file, contents, "utf8"); } +// lib/node/utils/session-storage.ts +var import_fs4 = __toESM(require("fs")); +var import_path2 = __toESM(require("path")); +var SessionStorage = class { + storage; + limit; + persist; + filePath; + directory = ".session-storage"; + constructor({ persist = false, filePath = "./sessionData.json" } = {}) { + this.storage = {}; + this.limit = 5 * 1024 * 1024; + this.persist = persist; + this.filePath = import_path2.default.resolve(this.directory, filePath); + if (!import_fs4.default.existsSync(this.directory)) { + import_fs4.default.mkdirSync(this.directory, { recursive: true }); + } + if (this.persist) { + this.loadFromFile(); + } + } + // Calculate total size in bytes of stored data + getStorageSize() { + return new TextEncoder().encode(JSON.stringify(this.storage)).length; + } + // Check if storage limit is exceeded + checkSizeLimit() { + const size = this.getStorageSize(); + if (size > this.limit) { + throw new DOMException("Storage limit exceeded", "QuotaExceededError"); + } + } + // Store value under the specified key + setItem(key, value) { + if (key === null || key === void 0) { + throw new TypeError("Failed to execute 'setItem' on 'Storage': 1 argument required, but only 0 present."); + } + if (value === null) { + value = "null"; + } else if (value === void 0) { + value = "undefined"; + } + this.storage[key] = String(value); + this.checkSizeLimit(); + if (this.persist) { + this.saveToFile(); + } + } + // Retrieve value stored under the specified key + getItem(key) { + if (key === null || key === void 0) { + throw new TypeError("Failed to execute 'getItem' on 'Storage': 1 argument required, but only 0 present."); + } + return this.storage[key] || null; + } + // Remove the value under the specified key + removeItem(key) { + if (key === null || key === void 0) { + throw new TypeError("Failed to execute 'removeItem' on 'Storage': 1 argument required, but only 0 present."); + } + delete this.storage[key]; + if (this.persist) { + this.saveToFile(); + } + } + // Clear all stored values + clear() { + this.storage = {}; + if (this.persist) { + this.saveToFile(); + } + } + // Return the number of stored items + get length() { + return Object.keys(this.storage).length; + } + // Return the key at the specified index + key(index) { + const keys = Object.keys(this.storage); + return keys[index] || null; + } + // Save data to a file (only if persistence is enabled) + saveToFile() { + try { + import_fs4.default.writeFileSync(this.filePath, JSON.stringify(this.storage), "utf-8"); + } catch (error) { + throw new Error(`Error saving data to file: ${error.message}`); + } + } + // Load data from a file (only if persistence is enabled) + loadFromFile() { + try { + if (import_fs4.default.existsSync(this.filePath)) { + const data = import_fs4.default.readFileSync(this.filePath, "utf-8"); + this.storage = JSON.parse(data || "{}"); + } + } catch (error) { + throw new Error(`Error loading data from file: ${error.message}`); + } + } +}; + // lib/node/index.ts global.FormData = import_form_data.default; global.document = document; +global.sessionStorage = new SessionStorage(); +global.localStorage = new SessionStorage(); function render(...args) { const Component = () => args; const result = (0, import_valyrian.mount)("div", Component); diff --git a/dist/node/index.js.map b/dist/node/index.js.map index 5799fe5..0417d0c 100644 --- a/dist/node/index.js.map +++ b/dist/node/index.js.map @@ -1,7 +1,7 @@ { "version": 3, - "sources": ["../../lib/node/index.ts", "../../lib/node/utils/tree-adapter.ts", "../../lib/node/utils/icons.ts", "../../lib/node/utils/inline.ts", "../../lib/node/utils/sw.ts"], - "sourcesContent": ["import { document, domToHtml, domToHyperscript, htmlToDom, htmlToHyperscript } from \"./utils/tree-adapter\";\nimport { mount, unmount } from \"valyrian.js\";\n\nimport FormData from \"form-data\";\n// import fetch from \"node-fetch\";\nimport { icons } from \"./utils/icons\";\nimport { inline } from \"./utils/inline\";\nimport { sw } from \"./utils/sw\";\n\nglobal.FormData = FormData as any;\nglobal.document = document as any;\n\nfunction render(...args: any[]) {\n const Component = () => args;\n const result = mount(\"div\", Component);\n unmount();\n return result;\n}\n\nexport { domToHtml, domToHyperscript, htmlToDom, htmlToHyperscript, inline, sw, icons, render };\n", "/* eslint-disable no-use-before-define */\n/* eslint-disable complexity */\ninterface ChildNodes extends Array {}\n\nexport class Node implements Node {\n // eslint-disable-next-line no-use-before-define\n childNodes: ChildNodes = [];\n baseURI: string = \"\";\n\n tag_name!: string;\n get nodeName(): string {\n return this.tag_name.toLowerCase();\n }\n set nodeName(name: string) {\n this.tag_name = name;\n }\n get tagName(): string {\n return this.tag_name;\n }\n set tagName(name: string) {\n this.tag_name = name;\n }\n\n node_type!: number;\n get nodeType(): number {\n return this.node_type;\n }\n set nodeType(type: number) {\n this.node_type = type;\n }\n\n node_value = \"\";\n attributes: Attr[] = [];\n set textContent(text) {\n this.node_value = String(text);\n }\n get textContent() {\n return this.node_value;\n }\n set nodeValue(text) {\n this.node_value = String(text);\n }\n get nodeValue() {\n return this.node_value;\n }\n\n // eslint-disable-next-line no-use-before-define\n parent_node: Node | null = null;\n get parentNode() {\n return this.parent_node;\n }\n set parentNode(node) {\n this.parent_node = node;\n }\n\n #dataset: Record = {};\n\n get dataset() {\n return this.#dataset;\n }\n\n set dataset(value) {\n this.#dataset = value;\n }\n\n constructor() {}\n\n appendChild(node: T): T {\n if (node) {\n node.parentNode && node.parentNode.removeChild(node as Node);\n this.childNodes.push(node);\n node.parentNode = this;\n }\n return node;\n }\n\n insertBefore(node: T, child: Node | null): T {\n if (node) {\n node.parentNode && node.parentNode.removeChild(node as Node);\n node.parentNode = this;\n if (child) {\n const idx = this.childNodes.indexOf(child);\n this.childNodes.splice(idx, 0, node);\n } else {\n this.childNodes.push(node);\n }\n }\n return node;\n }\n\n replaceChild(node: Node, child: T): T {\n if (node && child && child.parentNode === this) {\n this.insertBefore(node, child);\n child.parentNode && child.parentNode.removeChild(child);\n }\n return child;\n }\n removeChild(child: T): T {\n if (child && child.parentNode === this) {\n const idx = (this.childNodes as unknown as Node[]).indexOf(child);\n (this.childNodes as unknown as Node[]).splice(idx, 1);\n child.parentNode = null;\n }\n return child;\n }\n\n remove(): Node {\n return this.parentNode ? this.parentNode.removeChild(this) : this;\n }\n\n cloneNode(deep?: boolean | undefined): Node {\n if (this.nodeType === 3) {\n return new Text(this.nodeValue);\n }\n\n if (this.nodeType === 1) {\n const node = new Element();\n node.nodeType = this.nodeType;\n this.nodeName = this.nodeName;\n if (this.attributes) {\n for (let i = 0, l = this.attributes.length; i < l; i++) {\n node.setAttribute(this.attributes[i].nodeName, this.attributes[i].nodeValue);\n }\n }\n\n for (const key in this.dataset) {\n node.dataset[key] = this.dataset[key];\n }\n\n if (deep) {\n for (let i = 0, l = this.childNodes.length; i < l; i++) {\n node.appendChild(this.childNodes[i].cloneNode(deep));\n }\n }\n return node;\n }\n\n const node = new Node();\n node.nodeType = this.nodeType;\n node.nodeName = this.nodeName;\n return node;\n }\n\n setAttribute(name: string, value: any) {\n const attr = {\n nodeName: name,\n nodeValue: value\n };\n let idx = -1;\n for (let i = 0, l = this.attributes.length; i < l; i++) {\n if (this.attributes[i].nodeName === name) {\n idx = i;\n break;\n }\n }\n idx === -1 ? this.attributes.push(attr as Attr) : this.attributes.splice(idx, 1, attr as Attr);\n }\n\n getAttribute(name: string) {\n for (let i = 0, l = this.attributes.length; i < l; i++) {\n if (this.attributes[i].nodeName === name) {\n return this.attributes[i].nodeValue;\n }\n }\n }\n\n removeAttribute(name: string) {\n let idx = -1;\n for (let i = 0, l = this.attributes.length; i < l; i++) {\n if (this.attributes[i].nodeName === name) {\n idx = i;\n break;\n }\n }\n if (idx > -1) {\n this.attributes.splice(idx, 1);\n }\n }\n\n getElementById(id: string): Node | null {\n let elementFound;\n for (let i = 0, l = this.childNodes.length; i < l; i++) {\n if (this.childNodes[i].nodeType === 1) {\n if (this.childNodes[i].getAttribute(\"id\") === id) {\n elementFound = this.childNodes[i];\n break;\n }\n elementFound = this.childNodes[i].getElementById(id);\n if (elementFound) {\n break;\n }\n }\n }\n return elementFound || null;\n }\n\n // Not implemented\n // firstChild!: ChildNode | null;\n // isConnected!: boolean;\n // lastChild!: ChildNode | null;\n // nextSibling!: ChildNode | null;\n // ownerDocument!: Document | null;\n // parentElement!: HTMLElement | null;\n // previousSibling!: ChildNode | null;\n // compareDocumentPosition(other: Node): number {\n // throw new Error(\"Method not implemented.\");\n // }\n // contains(other: Node | null): boolean {\n // throw new Error(\"Method not implemented.\");\n // }\n // getRootNode(options?: GetRootNodeOptions | undefined): Node {\n // throw new Error(\"Method not implemented.\");\n // }\n // hasChildNodes(): boolean {\n // throw new Error(\"Method not implemented.\");\n // }\n // isDefaultNamespace(namespace: string | null): boolean {\n // throw new Error(\"Method not implemented.\");\n // }\n // isEqualNode(otherNode: Node | null): boolean {\n // throw new Error(\"Method not implemented.\");\n // }\n // isSameNode(otherNode: Node | null): boolean {\n // throw new Error(\"Method not implemented.\");\n // }\n // lookupNamespaceURI(prefix: string | null): string | null {\n // throw new Error(\"Method not implemented.\");\n // }\n // lookupPrefix(namespace: string | null): string | null {\n // throw new Error(\"Method not implemented.\");\n // }\n // normalize(): void {\n // throw new Error(\"Method not implemented.\");\n // }\n // ATTRIBUTE_NODE!: number;\n // CDATA_SECTION_NODE!: number;\n // COMMENT_NODE!: number;\n // DOCUMENT_FRAGMENT_NODE!: number;\n // DOCUMENT_NODE!: number;\n // DOCUMENT_POSITION_CONTAINED_BY!: number;\n // DOCUMENT_POSITION_CONTAINS!: number;\n // DOCUMENT_POSITION_DISCONNECTED!: number;\n // DOCUMENT_POSITION_FOLLOWING!: number;\n // DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC!: number;\n // DOCUMENT_POSITION_PRECEDING!: number;\n // DOCUMENT_TYPE_NODE!: number;\n // ELEMENT_NODE!: number;\n // ENTITY_NODE!: number;\n // ENTITY_REFERENCE_NODE!: number;\n // NOTATION_NODE!: number;\n // PROCESSING_INSTRUCTION_NODE!: number;\n // TEXT_NODE!: number;\n addEventListener(\n // eslint-disable-next-line no-unused-vars\n type: string,\n // eslint-disable-next-line no-unused-vars\n callback: EventListenerOrEventListenerObject | null,\n // eslint-disable-next-line no-unused-vars\n options?: boolean | AddEventListenerOptions | undefined\n ): void {\n // throw new Error(\"Method not implemented.\");\n }\n // dispatchEvent(event: Event): boolean {\n // throw new Error(\"Method not implemented.\");\n // }\n removeEventListener(\n // eslint-disable-next-line no-unused-vars\n type: string,\n // eslint-disable-next-line no-unused-vars\n callback: EventListenerOrEventListenerObject | null,\n // eslint-disable-next-line no-unused-vars\n options?: boolean | EventListenerOptions | undefined\n ): void {\n // throw new Error(\"Method not implemented.\");\n }\n}\n\nexport class Text extends Node {\n constructor(text: any) {\n super();\n this.nodeType = 3;\n this.nodeName = \"#text\";\n this.node_value = String(text);\n }\n}\n\nfunction updateElementStyles(element: Element, state: Record) {\n let str = \"\";\n for (const key in state) {\n const value = state[key];\n if (typeof value !== \"undefined\" && value !== null && String(value).length > 0) {\n str += `${key}: ${state[key]};`;\n }\n }\n if (str.length === 0) {\n element.removeAttribute(\"style\");\n } else {\n element.setAttribute(\"style\", str);\n }\n}\n\nexport class Element extends Node {\n constructor() {\n super();\n this.nodeType = 1;\n this.attributes = [];\n this.childNodes = [];\n }\n\n _style = new Proxy(\n {},\n {\n get: (state: Record, prop: string) => state[prop],\n set: (state: Record, prop: string, value: any) => {\n state[prop] = value;\n updateElementStyles(this, state);\n return true;\n },\n deleteProperty: (state: Record, prop: string) => {\n Reflect.deleteProperty(state, prop);\n updateElementStyles(this, state);\n return true;\n }\n }\n );\n\n get style() {\n return this._style as any;\n }\n\n set style(value: string) {\n if (typeof value === \"string\") {\n // should match pairs like \"color: red; font-size: 12px; background: url(http://example.com/image.png?s=1024x1024&w=is&k=20&c=ASa_AG8uP5Di7azXgJraSA6ME7fbLB0GX4YT_OzCARI=);\"\n const regex = /([^:\\s]+):\\s*((url\\([^)]+\\))|[^;]+(?=(;|$)))/g;\n let match;\n\n while ((match = regex.exec(value)) !== null) {\n this._style[match[1]] = match[2].trim();\n }\n\n return;\n }\n\n throw new Error(\"Cannot set style\");\n }\n\n get className(): string {\n return this.getAttribute(\"class\") || \"\";\n }\n\n set className(value: string | boolean) {\n if (value == null || value === false) {\n this.removeAttribute(\"class\");\n } else {\n this.setAttribute(\"class\", String(value));\n }\n }\n\n classList = {\n toggle: (item: any, force: any) => {\n if (item) {\n const classes = (this.className || \"\").split(\" \");\n const itemIndex = classes.indexOf(item);\n if (force && itemIndex === -1) {\n classes.push(item);\n }\n\n if (!force && itemIndex !== -1) {\n classes.splice(itemIndex, 1);\n }\n\n const final = classes.join(\" \").trim();\n if (final.length) {\n this.className = classes.join(\" \").trim();\n } else {\n this.className = false;\n }\n }\n }\n };\n\n get id(): string {\n return this.getAttribute(\"id\") || \"\";\n }\n\n set id(value: string | boolean) {\n if (value == null || value === false) {\n this.removeAttribute(\"id\");\n } else {\n this.setAttribute(\"id\", String(value));\n }\n }\n\n set textContent(text) {\n this.nodeValue = String(text);\n this.childNodes = this.nodeValue ? [new Text(this.nodeValue)] : [];\n }\n get textContent() {\n return this.nodeValue;\n }\n\n set innerText(text) {\n this.nodeValue = String(text);\n }\n\n get innerText() {\n return this.nodeValue;\n }\n\n get innerHTML() {\n let str = \"\";\n for (let i = 0, l = this.childNodes.length; i < l; i++) {\n // console.log(\"domToHtml\", this.childNodes[i], domToHtml(this.childNodes[i] as Element));\n str += domToHtml(this.childNodes[i] as Element);\n }\n return str;\n }\n\n set innerHTML(html) {\n this.textContent = \"\";\n const result = htmlToDom(html);\n if (result instanceof DocumentFragment) {\n for (let i = 0, l = result.childNodes.length; i < l; i++) {\n this.appendChild(result.childNodes[i]);\n }\n } else {\n this.appendChild(result);\n }\n }\n\n get outerHTML(): string {\n return domToHtml(this);\n }\n}\n\nexport class DocumentFragment extends Element {\n constructor() {\n super();\n this.nodeType = 11;\n this.nodeName = \"#document-fragment\";\n }\n}\n\nexport class Document extends Element {\n constructor() {\n super();\n this.nodeType = 9;\n this.nodeName = \"#document\";\n }\n\n createDocumentFragment(): DocumentFragment {\n return new DocumentFragment();\n }\n\n createElement(type: string) {\n const element = new Element();\n element.nodeName = type.toUpperCase();\n return element;\n }\n\n createElementNS(ns: string, type: string) {\n const element = this.createElement(type);\n element.baseURI = ns;\n return element;\n }\n\n createTextNode(text: any) {\n return new Text(text);\n }\n}\n\nconst selfClosingTags = [\n \"area\",\n \"base\",\n \"br\",\n \"col\",\n \"embed\",\n \"hr\",\n \"img\",\n \"input\",\n \"link\",\n \"meta\",\n \"param\",\n \"source\",\n \"track\",\n \"wbr\",\n \"!doctype\"\n];\n\nexport function domToHtml(dom: Element): string {\n if (dom.nodeType === 3) {\n return dom.textContent;\n }\n\n if (dom.nodeType === 1) {\n const name = dom.nodeName.toLowerCase();\n let str = \"<\" + name;\n for (let i = 0, l = dom.attributes.length; i < l; i++) {\n str += \" \" + dom.attributes[i].nodeName + '=\"' + dom.attributes[i].nodeValue + '\"';\n }\n\n if (selfClosingTags.indexOf(name) === -1) {\n str += \">\";\n if (dom.childNodes && dom.childNodes.length > 0) {\n for (let i = 0, l = dom.childNodes.length; i < l; i++) {\n const child = domToHtml(dom.childNodes[i] as Element);\n if (child) {\n str += child;\n }\n }\n }\n str += \"\";\n } else {\n str += \"/>\";\n }\n\n return str;\n }\n\n return \"\";\n}\n\nexport function domToHyperscript(childNodes: ChildNodes, depth = 1) {\n let spaces = \"\";\n for (let i = 0; i < depth; i++) {\n spaces += \" \";\n }\n\n return childNodes\n .map((item) => {\n if (item.nodeType === 10) {\n return `\\n${spaces}\"\"`;\n } else if (item.nodeType === 3) {\n return `\\n${spaces}\"${item.nodeValue}\"`;\n } else {\n let str = `\\n${spaces}v(\"${item.nodeName}\", `;\n\n if (item.attributes) {\n const attrs: Record = {};\n for (let i = 0, l = item.attributes.length; i < l; i++) {\n const attr = item.attributes[i];\n attrs[attr.nodeName] = attr.nodeValue;\n }\n str += JSON.stringify(attrs);\n } else {\n str += \"{}\";\n }\n\n str += \", [\";\n if (item.childNodes && item.childNodes.length > 0) {\n str += `${domToHyperscript(item.childNodes as unknown as Element[], depth + 1)}\\n${spaces}`;\n }\n\n str += `])`;\n return str;\n }\n })\n .join(\",\");\n}\n\ninterface ObjectIndexItem {\n tagName: string;\n startsAt: number;\n endsAt: number | null;\n contentStartsAt: number;\n contentEndsAt: number | null;\n attributes: { [key: string]: any };\n children: ObjectIndexItem[];\n nodeValue: string | null;\n}\n\ninterface ObjectIndexItemWithContent extends ObjectIndexItem {\n endsAt: number;\n contentEndsAt: number;\n children: ObjectIndexItemWithContent[];\n}\n\ninterface ObjectIndexList extends Array {}\n\nfunction findTexts(item: ObjectIndexItemWithContent, html: string) {\n const newChildren: ObjectIndexItemWithContent[] = [];\n\n // If the item has children\n if (item.children.length) {\n // Search for texts in the children.\n for (let i = 0; i < item.children.length; i++) {\n const child = item.children[i];\n const nextChild = item.children[i + 1];\n\n // If is the first child and the child startsAt is greater than the item contentStartsAt then\n // the content between the item contentStartsAt and the child startsAt is a text child of the item.\n if (i === 0 && child.startsAt > item.contentStartsAt) {\n const childContent = html.substring(item.contentStartsAt, child.startsAt);\n\n const childText: ObjectIndexItemWithContent = {\n tagName: \"#text\",\n startsAt: item.contentStartsAt,\n endsAt: item.contentStartsAt + childContent.length,\n contentStartsAt: item.contentStartsAt,\n contentEndsAt: item.contentStartsAt + childContent.length,\n attributes: {},\n children: [],\n nodeValue: childContent\n };\n\n newChildren.push(childText);\n }\n\n // Add the child to the newChildren array.\n newChildren.push(child);\n\n // If there is a next child and the child endsAt is less than the next child startsAt then\n // the content between the child endsAt and the next child startsAt is a text child of the item.\n if (nextChild && child.endsAt < nextChild.startsAt) {\n const childContent = html.substring(child.endsAt, nextChild.startsAt);\n\n const childText: ObjectIndexItemWithContent = {\n tagName: \"#text\",\n startsAt: child.endsAt,\n endsAt: child.endsAt + childContent.length,\n contentStartsAt: child.endsAt,\n contentEndsAt: child.endsAt + childContent.length,\n attributes: {},\n children: [],\n nodeValue: childContent\n };\n\n newChildren.push(childText);\n }\n\n // If there are no next child and the child endsAt is less than the item contentEndsAt then\n // the content between the child endsAt and the item contentEndsAt is a text child of the item.\n if (!nextChild && child.endsAt < item.contentEndsAt) {\n const childContent = html.substring(child.endsAt, item.contentEndsAt);\n\n const childText: ObjectIndexItemWithContent = {\n tagName: \"#text\",\n startsAt: child.endsAt,\n endsAt: child.endsAt + childContent.length,\n contentStartsAt: child.endsAt,\n contentEndsAt: item.contentEndsAt,\n attributes: {},\n children: [],\n nodeValue: childContent\n };\n\n newChildren.push(childText);\n }\n\n // Find texts in the child.\n findTexts(child, html);\n }\n }\n\n // If the item has no children then set the contents between the item contentStartsAt and the item contentEndsAt\n // as a text child of the item.\n if (!item.children.length) {\n const childContent = html.substring(item.contentStartsAt, item.contentEndsAt);\n\n if (childContent.length) {\n const childText: ObjectIndexItemWithContent = {\n tagName: \"#text\",\n startsAt: item.contentStartsAt,\n endsAt: item.contentEndsAt,\n contentStartsAt: item.contentStartsAt,\n contentEndsAt: item.contentEndsAt,\n attributes: {},\n children: [],\n nodeValue: childContent\n };\n\n newChildren.push(childText);\n }\n }\n\n item.children = newChildren;\n}\n\nfunction convertToDom(item: ObjectIndexItemWithContent): T {\n let node: T;\n\n if (item.tagName === \"#text\") {\n node = document.createTextNode(item.nodeValue as string) as unknown as T;\n } else {\n node = (item.tagName === \"#document-fragment\"\n ? document.createDocumentFragment()\n : document.createElement(item.tagName)) as unknown as T;\n\n for (const key in item.attributes) {\n node.setAttribute(key, item.attributes[key]);\n }\n\n for (let i = 0; i < item.children.length; i++) {\n const child = convertToDom(item.children[i]);\n node.appendChild(child);\n }\n }\n\n return node;\n}\n\n// eslint-disable-next-line sonarjs/cognitive-complexity\nfunction getObjectIndexTree(html: string): DocumentFragment {\n let item;\n const regex = RegExp(\"<([^>|^!]+)>\", \"g\");\n const items: ObjectIndexList = [];\n\n // Make the initial list of items.\n while ((item = regex.exec(html))) {\n // If is a closing tag\n if (item[0].startsWith(\" item.endsAt === null);\n if (lastOpenedItem) {\n lastOpenedItem.endsAt = item.index + item[0].length;\n lastOpenedItem.contentEndsAt = item.index;\n\n // Find the last opened item again, this will be the parent of the current item.\n const parent = [...items].reverse().find((item) => item.endsAt === null);\n if (parent) {\n // Find the index of the current item in the items array.\n const index = items.indexOf(lastOpenedItem);\n // Remove the last opened item from the items array.\n items.splice(index, 1);\n\n // Add the last opened item as a child of the parent.\n parent.children.push(lastOpenedItem);\n }\n }\n\n continue;\n }\n\n // If is an opening tag\n const element: ObjectIndexItem = {\n tagName: item[1].split(\" \")[0],\n startsAt: item.index,\n endsAt: null,\n contentStartsAt: item.index + item[0].length,\n contentEndsAt: null,\n attributes: {},\n children: [],\n nodeValue: null\n };\n\n // Find the attributes of the tag.\n let string = (item[1] || \"\").substring(element.tagName.length + 1).replace(/\\/$/g, \"\");\n const attributesWithValues = string.match(/\\S+=\"[^\"]+\"/g);\n\n if (attributesWithValues) {\n for (const attribute of attributesWithValues) {\n const [name, ...value] = attribute.trim().split(\"=\");\n string = string.replace(attribute, \"\");\n if (value) {\n element.attributes[name] = value.join(\"=\").replace(/(^\"|\"$)/g, \"\");\n }\n }\n }\n\n const attributesWithBooleanValues = string.match(/\\s\\S+=[^\"]+/g);\n if (attributesWithBooleanValues) {\n for (const attribute of attributesWithBooleanValues) {\n const [name, ...value] = attribute.trim().split(\"=\");\n string = string.replace(attribute, \"\");\n if (value) {\n element.attributes[name] = value.join(\"=\").replace(/(^\"|\"$)/g, \"\");\n }\n }\n }\n\n const attributesWithEmptyValues = string.match(/\\s?\\S+/g);\n if (attributesWithEmptyValues) {\n for (const attribute of attributesWithEmptyValues) {\n const name = attribute.trim();\n element.attributes[name] = true;\n }\n }\n\n // If the tag is self closing\n if (item[0].endsWith(\"/>\")) {\n element.endsAt = element.startsAt + item[0].length;\n element.contentStartsAt = element.contentEndsAt = element.endsAt;\n\n // Find the last opened item, this will be the parent of the current item.\n const parent = [...items].reverse().find((item) => item.endsAt === null);\n if (parent) {\n // Add the last opened item as a child of the parent.\n parent.children.push(element);\n continue;\n }\n }\n\n items.push(element);\n }\n\n const fragmentItem: ObjectIndexItemWithContent = {\n tagName: \"#document-fragment\",\n startsAt: 0,\n endsAt: html.length,\n contentStartsAt: 0,\n contentEndsAt: html.length,\n attributes: {},\n children: items as ObjectIndexItemWithContent[],\n nodeValue: null\n };\n\n findTexts(fragmentItem, html);\n\n return convertToDom(fragmentItem);\n}\n\n// First we create a tree of object indexes from the HTML string.\n// The resulting array is then reordered to match the order of the html string.\n// And to move the children to the correct position in its parents.\n// This resulting array is populated with a object node version of the object index.\n// If the final result have more than 1 node, then return a document fragment node.\n// If the final result have 1 node, then return the node.\n// eslint-disable-next-line complexity\nexport function htmlToDom(html: string): Element | Text | DocumentFragment {\n // Search for the opening and closing tags of the root element.\n // The opening tag could be in the middle of the string, so we need to\n // search for the first opening tag.\n const openingTag = html.match(/<[^>]+>/g);\n\n const document = new Document();\n\n // If the opening tag is not found, return a document fragment node with the html string as text content.\n if (!openingTag) {\n const documentFragment = document.createDocumentFragment();\n documentFragment.appendChild(document.createTextNode(html));\n return documentFragment;\n }\n\n const fragment = getObjectIndexTree(html);\n\n if (fragment.childNodes.length > 1) {\n return fragment;\n }\n\n return fragment.childNodes[0];\n}\n\nexport function htmlToHyperscript(html: string) {\n const domTree = htmlToDom(html);\n const hyperscript = domToHyperscript(domTree instanceof DocumentFragment ? domTree.childNodes : [domTree]);\n return `[${hyperscript}\\n]`;\n}\n\nexport const document = new Document();\n", "import fs from \"fs\";\nimport { htmlToHyperscript } from \"./tree-adapter\";\n\ninterface IconsOptions {\n iconsPath: string | null;\n linksViewPath: string | null;\n logging: boolean;\n\n // favicons options\n path: string;\n appName?: string;\n appDescription?: string;\n developerName?: string;\n developerURL?: string;\n dir?: \"auto\" | \"ltr\" | \"rtl\";\n lang?: string;\n background?: string;\n theme_color?: string;\n display?: \"browser\" | \"standalone\";\n orientation?: \"any\" | \"portrait\" | \"landscape\";\n start_url?: string;\n version?: string;\n icons: {\n android: boolean;\n appleIcon: boolean;\n appleStartup: boolean;\n coast: boolean;\n favicons: boolean;\n firefox: boolean;\n windows: boolean;\n yandex: boolean;\n };\n}\n\nexport async function icons(source: string, configuration?: IconsOptions) {\n const options = {\n ...icons.options,\n ...(configuration || {})\n };\n\n if (options.iconsPath) {\n options.iconsPath = options.iconsPath.replace(/\\/$/gi, \"\") + \"/\";\n }\n\n if (options.linksViewPath) {\n options.linksViewPath = options.linksViewPath.replace(/\\/$/gi, \"\") + \"/\";\n }\n\n const { favicons } = await import(\"favicons\");\n\n try {\n const response = await favicons(source, options);\n\n if (options.iconsPath) {\n for (const i in response.images) {\n fs.writeFileSync(options.iconsPath + response.images[i].name, response.images[i].contents);\n }\n\n for (const i in response.files) {\n fs.writeFileSync(options.iconsPath + response.files[i].name, response.files[i].contents);\n }\n }\n\n if (options.linksViewPath) {\n const html = `\n function Links(){\n return ${htmlToHyperscript(response.html.join(\"\"))};\n }\n \n Links.default = Links;\n module.exports = Links;\n `;\n\n fs.writeFileSync(`${options.linksViewPath}/links.js`, html);\n }\n } catch (err) {\n process.stdout.write((err as any).status + \"\\n\"); // HTTP error code (e.g. `200`) or `null`\n process.stdout.write((err as any).name + \"\\n\"); // Error name e.g. \"API Error\"\n process.stdout.write((err as any).message + \"\\n\"); // Error description e.g. \"An unknown error has occurred\"\n }\n}\n\nicons.options = {\n iconsPath: null,\n linksViewPath: null,\n\n // favicons options\n path: \"\",\n appName: null,\n appDescription: null,\n developerName: null,\n developerURL: null,\n dir: \"auto\",\n lang: \"en-US\",\n background: \"#fff\",\n theme_color: \"#fff\",\n display: \"standalone\",\n orientation: \"any\",\n start_url: \"/\",\n version: \"1.0\",\n logging: false,\n icons: {\n android: true,\n appleIcon: true,\n appleStartup: true,\n coast: false,\n favicons: true,\n firefox: false,\n windows: true,\n yandex: false // Create Yandex browser icon. `boolean`\n }\n} as unknown as IconsOptions;\n", "import * as tsc from \"tsc-prog\";\n\nimport CleanCSS from \"clean-css\";\nimport { PurgeCSS } from \"purgecss\";\nimport esbuild from \"esbuild\";\n/* eslint-disable sonarjs/cognitive-complexity */\nimport fs from \"fs\";\n\n// eslint-disable-next-line complexity\nexport async function inline(\n file: string | { raw: string; map?: string | null; file: string },\n options: Record = {}\n) {\n if (typeof file === \"string\") {\n const ext = file.split(\".\").pop();\n if (ext && /(js|cjs|jsx|mjs|ts|tsx)/.test(ext)) {\n if (/(ts|tsx)/.test(ext) && !options.noValidate) {\n const declarationDir = options.declarationDir;\n const emitDeclaration = !!declarationDir;\n\n const tscProgOptions = {\n basePath: process.cwd(), // always required, used for relative paths\n configFilePath: \"tsconfig.json\", // config to inherit from (optional)\n files: [file],\n include: [\"**/*.ts\", \"**/*.js\", \"**/*.tsx\", \"**/*.jsx\", \"**/*.mjs\"],\n exclude: [\"test*/**/*\", \"**/*.test.ts\", \"**/*.spec.ts\", \"dist/**\"],\n pretty: true,\n copyOtherToOutDir: false,\n clean: emitDeclaration ? [declarationDir] : [],\n ...(options.tsc || {}),\n compilerOptions: {\n rootDir: \"./\",\n outDir: \"dist\",\n noEmitOnError: true,\n noEmit: !emitDeclaration,\n declaration: emitDeclaration,\n declarationDir,\n emitDeclarationOnly: emitDeclaration,\n allowJs: true,\n esModuleInterop: true,\n inlineSourceMap: true,\n resolveJsonModule: true,\n removeComments: true,\n ...(options.tsc || {}).compilerOptions\n },\n jsxFactory: \"v\",\n jsxFragment: \"v.fragment\"\n };\n\n // eslint-disable-next-line no-console\n console.log(\"tsc\", tscProgOptions);\n\n tsc.build(tscProgOptions);\n }\n\n const esbuildOptions = {\n entryPoints: [file],\n bundle: \"bundle\" in options ? options.bundle : true,\n sourcemap: \"external\",\n write: false,\n minify: options.compact,\n outdir: \"out\",\n target: \"esnext\",\n jsxFactory: \"v\",\n jsxFragment: \"v.fragment\",\n loader: {\n \".js\": \"jsx\",\n \".cjs\": \"jsx\",\n \".mjs\": \"jsx\",\n \".ts\": \"tsx\"\n },\n ...(options.esbuild || {})\n };\n\n const result = await esbuild.build(esbuildOptions);\n if (result.outputFiles?.length !== 2) {\n throw new Error(result.errors.join(\"\\n\"));\n }\n\n if (options.compact) {\n const terser = await import(\"terser\");\n const result2 = await terser.minify(result.outputFiles[1].text, {\n sourceMap: {\n content: result.outputFiles[0].text.toString()\n },\n compress: {\n booleans_as_integers: false\n },\n output: {\n wrap_func_args: false\n },\n ecma: 2022,\n ...(options.terser || {})\n });\n\n if (!result2.code || !result2.map) {\n throw new Error(\"Unknown error\");\n }\n\n const mapBase64 = Buffer.from(result2.map.toString()).toString(\"base64\");\n const suffix = `//# sourceMappingURL=data:application/json;charset=utf-8;base64,${mapBase64}`;\n return { raw: result2.code, map: suffix, file };\n } else {\n const mapBase64 = Buffer.from(result.outputFiles[0].text.toString()).toString(\"base64\");\n const suffix = `//# sourceMappingURL=data:application/json;charset=utf-8;base64,${mapBase64}`;\n return { raw: result.outputFiles[1].text, map: suffix, file };\n }\n } else if (ext && /(css|scss|styl)/.test(ext)) {\n const result = await new CleanCSS({\n sourceMap: true,\n level: {\n 1: {\n roundingPrecision: \"all=3\"\n },\n 2: {\n restructureRules: true // controls rule restructuring; defaults to false\n }\n },\n ...(options.cleanCss || {})\n }).minify([file]);\n\n return { raw: result.styles, map: null, file };\n } else {\n return { raw: fs.readFileSync(file, \"utf8\"), map: null, file };\n }\n } else if (typeof file === \"object\" && \"raw\" in file) {\n return { map: null, ...file };\n }\n}\n\ninline.uncss = async function (\n renderedHtml: (string | Promise)[],\n css: string,\n options: Record = {}\n) {\n const html = await Promise.all(renderedHtml);\n\n const contents = html.map((item) => {\n return {\n raw: item,\n extension: \"html\"\n };\n });\n\n const purgecss = new PurgeCSS();\n\n const output = await purgecss.purge({\n fontFace: true,\n keyframes: true,\n variables: true,\n defaultExtractor: (content) => content.match(/[A-Za-z0-9-_/:@]*[A-Za-z0-9-_/:@/]+/g) || [],\n ...options,\n content: contents,\n css: [{ raw: css }]\n });\n\n const cleanCss = await new CleanCSS({\n sourceMap: false,\n level: {\n 1: {\n roundingPrecision: \"all=3\"\n },\n 2: {\n restructureRules: true // controls rule restructuring; defaults to false\n }\n },\n ...(options.cleanCss || {})\n }).minify(output[0].css);\n\n return cleanCss.styles;\n};\n", "import fs from \"fs\";\nimport path from \"path\";\n\nexport function sw(file: string, options = {}) {\n const swfiletemplate = path.resolve(__dirname, \"./node.sw.tpl\");\n const swTpl = fs.readFileSync(swfiletemplate, \"utf8\");\n const opt = Object.assign(\n {\n version: \"v1::\",\n name: \"Valyrian.js\",\n urls: [\"/\"],\n debug: false\n },\n options\n );\n let contents = swTpl\n .replace(\"v1::\", \"v\" + opt.version + \"::\")\n .replace(\"Valyrian.js\", opt.name)\n .replace(\"['/']\", '[\"' + opt.urls.join('\",\"') + '\"]');\n\n if (!opt.debug) {\n contents = contents.replace(\"console.log\", \"() => {}\");\n }\n\n fs.writeFileSync(file, contents, \"utf8\");\n}\n"], - "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACIO,IAAM,OAAN,MAAM,MAAqB;AAAA;AAAA,EAEhC,aAAyB,CAAC;AAAA,EAC1B,UAAkB;AAAA,EAElB;AAAA,EACA,IAAI,WAAmB;AACrB,WAAO,KAAK,SAAS,YAAY;AAAA,EACnC;AAAA,EACA,IAAI,SAAS,MAAc;AACzB,SAAK,WAAW;AAAA,EAClB;AAAA,EACA,IAAI,UAAkB;AACpB,WAAO,KAAK;AAAA,EACd;AAAA,EACA,IAAI,QAAQ,MAAc;AACxB,SAAK,WAAW;AAAA,EAClB;AAAA,EAEA;AAAA,EACA,IAAI,WAAmB;AACrB,WAAO,KAAK;AAAA,EACd;AAAA,EACA,IAAI,SAAS,MAAc;AACzB,SAAK,YAAY;AAAA,EACnB;AAAA,EAEA,aAAa;AAAA,EACb,aAAqB,CAAC;AAAA,EACtB,IAAI,YAAY,MAAM;AACpB,SAAK,aAAa,OAAO,IAAI;AAAA,EAC/B;AAAA,EACA,IAAI,cAAc;AAChB,WAAO,KAAK;AAAA,EACd;AAAA,EACA,IAAI,UAAU,MAAM;AAClB,SAAK,aAAa,OAAO,IAAI;AAAA,EAC/B;AAAA,EACA,IAAI,YAAY;AACd,WAAO,KAAK;AAAA,EACd;AAAA;AAAA,EAGA,cAA2B;AAAA,EAC3B,IAAI,aAAa;AACf,WAAO,KAAK;AAAA,EACd;AAAA,EACA,IAAI,WAAW,MAAM;AACnB,SAAK,cAAc;AAAA,EACrB;AAAA,EAEA,WAAyC,CAAC;AAAA,EAE1C,IAAI,UAAU;AACZ,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,IAAI,QAAQ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AE,KAAK,IAAI,CAAC;AAAA,EACpB,CAAC;AAED,QAAM,WAAW,MAAM,IAAI,iBAAAD,QAAS;AAAA,IAClC,WAAW;AAAA,IACX,OAAO;AAAA,MACL,GAAG;AAAA,QACD,mBAAmB;AAAA,MACrB;AAAA,MACA,GAAG;AAAA,QACD,kBAAkB;AAAA;AAAA,MACpB;AAAA,IACF;AAAA,IACA,GAAI,QAAQ,YAAY,CAAC;AAAA,EAC3B,CAAC,EAAE,OAAO,OAAO,CAAC,EAAE,GAAG;AAEvB,SAAO,SAAS;AAClB;;;AC1KA,IAAAE,aAAe;AACf,kBAAiB;AAEV,SAAS,GAAG,MAAc,UAAU,CAAC,GAAG;AAC7C,QAAM,iBAAiB,YAAAC,QAAK,QAAQ,WAAW,eAAe;AAC9D,QAAM,QAAQ,WAAAC,QAAG,aAAa,gBAAgB,MAAM;AACpD,QAAM,MAAM,OAAO;AAAA,IACjB;AAAA,MACE,SAAS;AAAA,MACT,MAAM;AAAA,MACN,MAAM,CAAC,GAAG;AAAA,MACV,OAAO;AAAA,IACT;AAAA,IACA;AAAA,EACF;AACA,MAAI,WAAW,MACZ,QAAQ,QAAQ,MAAM,IAAI,UAAU,IAAI,EACxC,QAAQ,eAAe,IAAI,IAAI,EAC/B,QAAQ,SAAS,OAAO,IAAI,KAAK,KAAK,KAAK,IAAI,IAAI;AAEtD,MAAI,CAAC,IAAI,OAAO;AACd,eAAW,SAAS,QAAQ,eAAe,UAAU;AAAA,EACvD;AAEA,aAAAA,QAAG,cAAc,MAAM,UAAU,MAAM;AACzC;;;AJhBA,OAAO,WAAW,iBAAAC;AAClB,OAAO,WAAW;AAElB,SAAS,UAAU,MAAa;AAC9B,QAAM,YAAY,MAAM;AACxB,QAAM,aAAS,uBAAM,OAAO,SAAS;AACrC,+BAAQ;AACR,SAAO;AACT;", - "names": ["node", "item", "document", "fs", "import_fs", "esbuild", "CleanCSS", "fs", "import_fs", "path", "fs", "FormData"] + "sources": ["../../lib/node/index.ts", "../../lib/node/utils/tree-adapter.ts", "../../lib/node/utils/icons.ts", "../../lib/node/utils/inline.ts", "../../lib/node/utils/sw.ts", "../../lib/node/utils/session-storage.ts"], + "sourcesContent": ["import { document, domToHtml, domToHyperscript, htmlToDom, htmlToHyperscript } from \"./utils/tree-adapter\";\nimport { mount, unmount } from \"valyrian.js\";\n\nimport FormData from \"form-data\";\nimport { icons } from \"./utils/icons\";\nimport { inline } from \"./utils/inline\";\nimport { sw } from \"./utils/sw\";\nimport { SessionStorage } from \"./utils/session-storage\";\n\nglobal.FormData = FormData as any;\nglobal.document = document as any;\nglobal.sessionStorage = new SessionStorage();\nglobal.localStorage = new SessionStorage();\n\nfunction render(...args: any[]) {\n const Component = () => args;\n const result = mount(\"div\", Component);\n unmount();\n return result;\n}\n\nexport { domToHtml, domToHyperscript, htmlToDom, htmlToHyperscript, inline, sw, icons, render };\n", "/* eslint-disable no-use-before-define */\n/* eslint-disable complexity */\ninterface ChildNodes extends Array {}\n\nexport class Node implements Node {\n // eslint-disable-next-line no-use-before-define\n childNodes: ChildNodes = [];\n baseURI: string = \"\";\n\n tag_name!: string;\n get nodeName(): string {\n return this.tag_name.toLowerCase();\n }\n set nodeName(name: string) {\n this.tag_name = name;\n }\n get tagName(): string {\n return this.tag_name;\n }\n set tagName(name: string) {\n this.tag_name = name;\n }\n\n node_type!: number;\n get nodeType(): number {\n return this.node_type;\n }\n set nodeType(type: number) {\n this.node_type = type;\n }\n\n node_value = \"\";\n attributes: Attr[] = [];\n set textContent(text) {\n this.node_value = String(text);\n }\n get textContent() {\n return this.node_value;\n }\n set nodeValue(text) {\n this.node_value = String(text);\n }\n get nodeValue() {\n return this.node_value;\n }\n\n // eslint-disable-next-line no-use-before-define\n parent_node: Node | null = null;\n get parentNode() {\n return this.parent_node;\n }\n set parentNode(node) {\n this.parent_node = node;\n }\n\n #dataset: Record = {};\n\n get dataset() {\n return this.#dataset;\n }\n\n set dataset(value) {\n this.#dataset = value;\n }\n\n constructor() {}\n\n appendChild(node: T): T {\n if (node) {\n node.parentNode && node.parentNode.removeChild(node as Node);\n this.childNodes.push(node);\n node.parentNode = this;\n }\n return node;\n }\n\n insertBefore(node: T, child: Node | null): T {\n if (node) {\n node.parentNode && node.parentNode.removeChild(node as Node);\n node.parentNode = this;\n if (child) {\n const idx = this.childNodes.indexOf(child);\n this.childNodes.splice(idx, 0, node);\n } else {\n this.childNodes.push(node);\n }\n }\n return node;\n }\n\n replaceChild(node: Node, child: T): T {\n if (node && child && child.parentNode === this) {\n this.insertBefore(node, child);\n child.parentNode && child.parentNode.removeChild(child);\n }\n return child;\n }\n removeChild(child: T): T {\n if (child && child.parentNode === this) {\n const idx = (this.childNodes as unknown as Node[]).indexOf(child);\n (this.childNodes as unknown as Node[]).splice(idx, 1);\n child.parentNode = null;\n }\n return child;\n }\n\n remove(): Node {\n return this.parentNode ? this.parentNode.removeChild(this) : this;\n }\n\n cloneNode(deep?: boolean | undefined): Node {\n if (this.nodeType === 3) {\n return new Text(this.nodeValue);\n }\n\n if (this.nodeType === 1) {\n const node = new Element();\n node.nodeType = this.nodeType;\n this.nodeName = this.nodeName;\n if (this.attributes) {\n for (let i = 0, l = this.attributes.length; i < l; i++) {\n node.setAttribute(this.attributes[i].nodeName, this.attributes[i].nodeValue);\n }\n }\n\n for (const key in this.dataset) {\n node.dataset[key] = this.dataset[key];\n }\n\n if (deep) {\n for (let i = 0, l = this.childNodes.length; i < l; i++) {\n node.appendChild(this.childNodes[i].cloneNode(deep));\n }\n }\n return node;\n }\n\n const node = new Node();\n node.nodeType = this.nodeType;\n node.nodeName = this.nodeName;\n return node;\n }\n\n setAttribute(name: string, value: any) {\n const attr = {\n nodeName: name,\n nodeValue: value\n };\n let idx = -1;\n for (let i = 0, l = this.attributes.length; i < l; i++) {\n if (this.attributes[i].nodeName === name) {\n idx = i;\n break;\n }\n }\n idx === -1 ? this.attributes.push(attr as Attr) : this.attributes.splice(idx, 1, attr as Attr);\n }\n\n getAttribute(name: string) {\n for (let i = 0, l = this.attributes.length; i < l; i++) {\n if (this.attributes[i].nodeName === name) {\n return this.attributes[i].nodeValue;\n }\n }\n }\n\n removeAttribute(name: string) {\n let idx = -1;\n for (let i = 0, l = this.attributes.length; i < l; i++) {\n if (this.attributes[i].nodeName === name) {\n idx = i;\n break;\n }\n }\n if (idx > -1) {\n this.attributes.splice(idx, 1);\n }\n }\n\n getElementById(id: string): Node | null {\n let elementFound;\n for (let i = 0, l = this.childNodes.length; i < l; i++) {\n if (this.childNodes[i].nodeType === 1) {\n if (this.childNodes[i].getAttribute(\"id\") === id) {\n elementFound = this.childNodes[i];\n break;\n }\n elementFound = this.childNodes[i].getElementById(id);\n if (elementFound) {\n break;\n }\n }\n }\n return elementFound || null;\n }\n\n // Not implemented\n // firstChild!: ChildNode | null;\n // isConnected!: boolean;\n // lastChild!: ChildNode | null;\n // nextSibling!: ChildNode | null;\n // ownerDocument!: Document | null;\n // parentElement!: HTMLElement | null;\n // previousSibling!: ChildNode | null;\n // compareDocumentPosition(other: Node): number {\n // throw new Error(\"Method not implemented.\");\n // }\n // contains(other: Node | null): boolean {\n // throw new Error(\"Method not implemented.\");\n // }\n // getRootNode(options?: GetRootNodeOptions | undefined): Node {\n // throw new Error(\"Method not implemented.\");\n // }\n // hasChildNodes(): boolean {\n // throw new Error(\"Method not implemented.\");\n // }\n // isDefaultNamespace(namespace: string | null): boolean {\n // throw new Error(\"Method not implemented.\");\n // }\n // isEqualNode(otherNode: Node | null): boolean {\n // throw new Error(\"Method not implemented.\");\n // }\n // isSameNode(otherNode: Node | null): boolean {\n // throw new Error(\"Method not implemented.\");\n // }\n // lookupNamespaceURI(prefix: string | null): string | null {\n // throw new Error(\"Method not implemented.\");\n // }\n // lookupPrefix(namespace: string | null): string | null {\n // throw new Error(\"Method not implemented.\");\n // }\n // normalize(): void {\n // throw new Error(\"Method not implemented.\");\n // }\n // ATTRIBUTE_NODE!: number;\n // CDATA_SECTION_NODE!: number;\n // COMMENT_NODE!: number;\n // DOCUMENT_FRAGMENT_NODE!: number;\n // DOCUMENT_NODE!: number;\n // DOCUMENT_POSITION_CONTAINED_BY!: number;\n // DOCUMENT_POSITION_CONTAINS!: number;\n // DOCUMENT_POSITION_DISCONNECTED!: number;\n // DOCUMENT_POSITION_FOLLOWING!: number;\n // DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC!: number;\n // DOCUMENT_POSITION_PRECEDING!: number;\n // DOCUMENT_TYPE_NODE!: number;\n // ELEMENT_NODE!: number;\n // ENTITY_NODE!: number;\n // ENTITY_REFERENCE_NODE!: number;\n // NOTATION_NODE!: number;\n // PROCESSING_INSTRUCTION_NODE!: number;\n // TEXT_NODE!: number;\n addEventListener(\n // eslint-disable-next-line no-unused-vars\n type: string,\n // eslint-disable-next-line no-unused-vars\n callback: EventListenerOrEventListenerObject | null,\n // eslint-disable-next-line no-unused-vars\n options?: boolean | AddEventListenerOptions | undefined\n ): void {\n // throw new Error(\"Method not implemented.\");\n }\n // dispatchEvent(event: Event): boolean {\n // throw new Error(\"Method not implemented.\");\n // }\n removeEventListener(\n // eslint-disable-next-line no-unused-vars\n type: string,\n // eslint-disable-next-line no-unused-vars\n callback: EventListenerOrEventListenerObject | null,\n // eslint-disable-next-line no-unused-vars\n options?: boolean | EventListenerOptions | undefined\n ): void {\n // throw new Error(\"Method not implemented.\");\n }\n}\n\nexport class Text extends Node {\n constructor(text: any) {\n super();\n this.nodeType = 3;\n this.nodeName = \"#text\";\n this.node_value = String(text);\n }\n}\n\nfunction updateElementStyles(element: Element, state: Record) {\n let str = \"\";\n for (const key in state) {\n const value = state[key];\n if (typeof value !== \"undefined\" && value !== null && String(value).length > 0) {\n str += `${key}: ${state[key]};`;\n }\n }\n if (str.length === 0) {\n element.removeAttribute(\"style\");\n } else {\n element.setAttribute(\"style\", str);\n }\n}\n\nexport class Element extends Node {\n constructor() {\n super();\n this.nodeType = 1;\n this.attributes = [];\n this.childNodes = [];\n }\n\n _style = new Proxy(\n {},\n {\n get: (state: Record, prop: string) => state[prop],\n set: (state: Record, prop: string, value: any) => {\n state[prop] = value;\n updateElementStyles(this, state);\n return true;\n },\n deleteProperty: (state: Record, prop: string) => {\n Reflect.deleteProperty(state, prop);\n updateElementStyles(this, state);\n return true;\n }\n }\n );\n\n get style() {\n return this._style as any;\n }\n\n set style(value: string) {\n if (typeof value === \"string\") {\n // should match pairs like \"color: red; font-size: 12px; background: url(http://example.com/image.png?s=1024x1024&w=is&k=20&c=ASa_AG8uP5Di7azXgJraSA6ME7fbLB0GX4YT_OzCARI=);\"\n const regex = /([^:\\s]+):\\s*((url\\([^)]+\\))|[^;]+(?=(;|$)))/g;\n let match;\n\n while ((match = regex.exec(value)) !== null) {\n this._style[match[1]] = match[2].trim();\n }\n\n return;\n }\n\n throw new Error(\"Cannot set style\");\n }\n\n get className(): string {\n return this.getAttribute(\"class\") || \"\";\n }\n\n set className(value: string | boolean) {\n if (value == null || value === false) {\n this.removeAttribute(\"class\");\n } else {\n this.setAttribute(\"class\", String(value));\n }\n }\n\n classList = {\n toggle: (item: any, force: any) => {\n if (item) {\n const classes = (this.className || \"\").split(\" \");\n const itemIndex = classes.indexOf(item);\n if (force && itemIndex === -1) {\n classes.push(item);\n }\n\n if (!force && itemIndex !== -1) {\n classes.splice(itemIndex, 1);\n }\n\n const final = classes.join(\" \").trim();\n if (final.length) {\n this.className = classes.join(\" \").trim();\n } else {\n this.className = false;\n }\n }\n }\n };\n\n get id(): string {\n return this.getAttribute(\"id\") || \"\";\n }\n\n set id(value: string | boolean) {\n if (value == null || value === false) {\n this.removeAttribute(\"id\");\n } else {\n this.setAttribute(\"id\", String(value));\n }\n }\n\n set textContent(text) {\n this.nodeValue = String(text);\n this.childNodes = this.nodeValue ? [new Text(this.nodeValue)] : [];\n }\n get textContent() {\n return this.nodeValue;\n }\n\n set innerText(text) {\n this.nodeValue = String(text);\n }\n\n get innerText() {\n return this.nodeValue;\n }\n\n get innerHTML() {\n let str = \"\";\n for (let i = 0, l = this.childNodes.length; i < l; i++) {\n // console.log(\"domToHtml\", this.childNodes[i], domToHtml(this.childNodes[i] as Element));\n str += domToHtml(this.childNodes[i] as Element);\n }\n return str;\n }\n\n set innerHTML(html) {\n this.textContent = \"\";\n const result = htmlToDom(html);\n if (result instanceof DocumentFragment) {\n for (let i = 0, l = result.childNodes.length; i < l; i++) {\n this.appendChild(result.childNodes[i]);\n }\n } else {\n this.appendChild(result);\n }\n }\n\n get outerHTML(): string {\n return domToHtml(this);\n }\n}\n\nexport class DocumentFragment extends Element {\n constructor() {\n super();\n this.nodeType = 11;\n this.nodeName = \"#document-fragment\";\n }\n}\n\nexport class Document extends Element {\n constructor() {\n super();\n this.nodeType = 9;\n this.nodeName = \"#document\";\n }\n\n createDocumentFragment(): DocumentFragment {\n return new DocumentFragment();\n }\n\n createElement(type: string) {\n const element = new Element();\n element.nodeName = type.toUpperCase();\n return element;\n }\n\n createElementNS(ns: string, type: string) {\n const element = this.createElement(type);\n element.baseURI = ns;\n return element;\n }\n\n createTextNode(text: any) {\n return new Text(text);\n }\n}\n\nconst selfClosingTags = [\n \"area\",\n \"base\",\n \"br\",\n \"col\",\n \"embed\",\n \"hr\",\n \"img\",\n \"input\",\n \"link\",\n \"meta\",\n \"param\",\n \"source\",\n \"track\",\n \"wbr\",\n \"!doctype\"\n];\n\nexport function domToHtml(dom: Element): string {\n if (dom.nodeType === 3) {\n return dom.textContent;\n }\n\n if (dom.nodeType === 1) {\n const name = dom.nodeName.toLowerCase();\n let str = \"<\" + name;\n for (let i = 0, l = dom.attributes.length; i < l; i++) {\n str += \" \" + dom.attributes[i].nodeName + '=\"' + dom.attributes[i].nodeValue + '\"';\n }\n\n if (selfClosingTags.indexOf(name) === -1) {\n str += \">\";\n if (dom.childNodes && dom.childNodes.length > 0) {\n for (let i = 0, l = dom.childNodes.length; i < l; i++) {\n const child = domToHtml(dom.childNodes[i] as Element);\n if (child) {\n str += child;\n }\n }\n }\n str += \"\";\n } else {\n str += \"/>\";\n }\n\n return str;\n }\n\n return \"\";\n}\n\nexport function domToHyperscript(childNodes: ChildNodes, depth = 1) {\n let spaces = \"\";\n for (let i = 0; i < depth; i++) {\n spaces += \" \";\n }\n\n return childNodes\n .map((item) => {\n if (item.nodeType === 10) {\n return `\\n${spaces}\"\"`;\n } else if (item.nodeType === 3) {\n return `\\n${spaces}\"${item.nodeValue}\"`;\n } else {\n let str = `\\n${spaces}v(\"${item.nodeName}\", `;\n\n if (item.attributes) {\n const attrs: Record = {};\n for (let i = 0, l = item.attributes.length; i < l; i++) {\n const attr = item.attributes[i];\n attrs[attr.nodeName] = attr.nodeValue;\n }\n str += JSON.stringify(attrs);\n } else {\n str += \"{}\";\n }\n\n str += \", [\";\n if (item.childNodes && item.childNodes.length > 0) {\n str += `${domToHyperscript(item.childNodes as unknown as Element[], depth + 1)}\\n${spaces}`;\n }\n\n str += `])`;\n return str;\n }\n })\n .join(\",\");\n}\n\ninterface ObjectIndexItem {\n tagName: string;\n startsAt: number;\n endsAt: number | null;\n contentStartsAt: number;\n contentEndsAt: number | null;\n attributes: { [key: string]: any };\n children: ObjectIndexItem[];\n nodeValue: string | null;\n}\n\ninterface ObjectIndexItemWithContent extends ObjectIndexItem {\n endsAt: number;\n contentEndsAt: number;\n children: ObjectIndexItemWithContent[];\n}\n\ninterface ObjectIndexList extends Array {}\n\nfunction findTexts(item: ObjectIndexItemWithContent, html: string) {\n const newChildren: ObjectIndexItemWithContent[] = [];\n\n // If the item has children\n if (item.children.length) {\n // Search for texts in the children.\n for (let i = 0; i < item.children.length; i++) {\n const child = item.children[i];\n const nextChild = item.children[i + 1];\n\n // If is the first child and the child startsAt is greater than the item contentStartsAt then\n // the content between the item contentStartsAt and the child startsAt is a text child of the item.\n if (i === 0 && child.startsAt > item.contentStartsAt) {\n const childContent = html.substring(item.contentStartsAt, child.startsAt);\n\n const childText: ObjectIndexItemWithContent = {\n tagName: \"#text\",\n startsAt: item.contentStartsAt,\n endsAt: item.contentStartsAt + childContent.length,\n contentStartsAt: item.contentStartsAt,\n contentEndsAt: item.contentStartsAt + childContent.length,\n attributes: {},\n children: [],\n nodeValue: childContent\n };\n\n newChildren.push(childText);\n }\n\n // Add the child to the newChildren array.\n newChildren.push(child);\n\n // If there is a next child and the child endsAt is less than the next child startsAt then\n // the content between the child endsAt and the next child startsAt is a text child of the item.\n if (nextChild && child.endsAt < nextChild.startsAt) {\n const childContent = html.substring(child.endsAt, nextChild.startsAt);\n\n const childText: ObjectIndexItemWithContent = {\n tagName: \"#text\",\n startsAt: child.endsAt,\n endsAt: child.endsAt + childContent.length,\n contentStartsAt: child.endsAt,\n contentEndsAt: child.endsAt + childContent.length,\n attributes: {},\n children: [],\n nodeValue: childContent\n };\n\n newChildren.push(childText);\n }\n\n // If there are no next child and the child endsAt is less than the item contentEndsAt then\n // the content between the child endsAt and the item contentEndsAt is a text child of the item.\n if (!nextChild && child.endsAt < item.contentEndsAt) {\n const childContent = html.substring(child.endsAt, item.contentEndsAt);\n\n const childText: ObjectIndexItemWithContent = {\n tagName: \"#text\",\n startsAt: child.endsAt,\n endsAt: child.endsAt + childContent.length,\n contentStartsAt: child.endsAt,\n contentEndsAt: item.contentEndsAt,\n attributes: {},\n children: [],\n nodeValue: childContent\n };\n\n newChildren.push(childText);\n }\n\n // Find texts in the child.\n findTexts(child, html);\n }\n }\n\n // If the item has no children then set the contents between the item contentStartsAt and the item contentEndsAt\n // as a text child of the item.\n if (!item.children.length) {\n const childContent = html.substring(item.contentStartsAt, item.contentEndsAt);\n\n if (childContent.length) {\n const childText: ObjectIndexItemWithContent = {\n tagName: \"#text\",\n startsAt: item.contentStartsAt,\n endsAt: item.contentEndsAt,\n contentStartsAt: item.contentStartsAt,\n contentEndsAt: item.contentEndsAt,\n attributes: {},\n children: [],\n nodeValue: childContent\n };\n\n newChildren.push(childText);\n }\n }\n\n item.children = newChildren;\n}\n\nfunction convertToDom(item: ObjectIndexItemWithContent): T {\n let node: T;\n\n if (item.tagName === \"#text\") {\n node = document.createTextNode(item.nodeValue as string) as unknown as T;\n } else {\n node = (item.tagName === \"#document-fragment\"\n ? document.createDocumentFragment()\n : document.createElement(item.tagName)) as unknown as T;\n\n for (const key in item.attributes) {\n node.setAttribute(key, item.attributes[key]);\n }\n\n for (let i = 0; i < item.children.length; i++) {\n const child = convertToDom(item.children[i]);\n node.appendChild(child);\n }\n }\n\n return node;\n}\n\n// eslint-disable-next-line sonarjs/cognitive-complexity\nfunction getObjectIndexTree(html: string): DocumentFragment {\n let item;\n const regex = RegExp(\"<([^>|^!]+)>\", \"g\");\n const items: ObjectIndexList = [];\n\n // Make the initial list of items.\n while ((item = regex.exec(html))) {\n // If is a closing tag\n if (item[0].startsWith(\" item.endsAt === null);\n if (lastOpenedItem) {\n lastOpenedItem.endsAt = item.index + item[0].length;\n lastOpenedItem.contentEndsAt = item.index;\n\n // Find the last opened item again, this will be the parent of the current item.\n const parent = [...items].reverse().find((item) => item.endsAt === null);\n if (parent) {\n // Find the index of the current item in the items array.\n const index = items.indexOf(lastOpenedItem);\n // Remove the last opened item from the items array.\n items.splice(index, 1);\n\n // Add the last opened item as a child of the parent.\n parent.children.push(lastOpenedItem);\n }\n }\n\n continue;\n }\n\n // If is an opening tag\n const element: ObjectIndexItem = {\n tagName: item[1].split(\" \")[0],\n startsAt: item.index,\n endsAt: null,\n contentStartsAt: item.index + item[0].length,\n contentEndsAt: null,\n attributes: {},\n children: [],\n nodeValue: null\n };\n\n // Find the attributes of the tag.\n let string = (item[1] || \"\").substring(element.tagName.length + 1).replace(/\\/$/g, \"\");\n const attributesWithValues = string.match(/\\S+=\"[^\"]+\"/g);\n\n if (attributesWithValues) {\n for (const attribute of attributesWithValues) {\n const [name, ...value] = attribute.trim().split(\"=\");\n string = string.replace(attribute, \"\");\n if (value) {\n element.attributes[name] = value.join(\"=\").replace(/(^\"|\"$)/g, \"\");\n }\n }\n }\n\n const attributesWithBooleanValues = string.match(/\\s\\S+=[^\"]+/g);\n if (attributesWithBooleanValues) {\n for (const attribute of attributesWithBooleanValues) {\n const [name, ...value] = attribute.trim().split(\"=\");\n string = string.replace(attribute, \"\");\n if (value) {\n element.attributes[name] = value.join(\"=\").replace(/(^\"|\"$)/g, \"\");\n }\n }\n }\n\n const attributesWithEmptyValues = string.match(/\\s?\\S+/g);\n if (attributesWithEmptyValues) {\n for (const attribute of attributesWithEmptyValues) {\n const name = attribute.trim();\n element.attributes[name] = true;\n }\n }\n\n // If the tag is self closing\n if (item[0].endsWith(\"/>\")) {\n element.endsAt = element.startsAt + item[0].length;\n element.contentStartsAt = element.contentEndsAt = element.endsAt;\n\n // Find the last opened item, this will be the parent of the current item.\n const parent = [...items].reverse().find((item) => item.endsAt === null);\n if (parent) {\n // Add the last opened item as a child of the parent.\n parent.children.push(element);\n continue;\n }\n }\n\n items.push(element);\n }\n\n const fragmentItem: ObjectIndexItemWithContent = {\n tagName: \"#document-fragment\",\n startsAt: 0,\n endsAt: html.length,\n contentStartsAt: 0,\n contentEndsAt: html.length,\n attributes: {},\n children: items as ObjectIndexItemWithContent[],\n nodeValue: null\n };\n\n findTexts(fragmentItem, html);\n\n return convertToDom(fragmentItem);\n}\n\n// First we create a tree of object indexes from the HTML string.\n// The resulting array is then reordered to match the order of the html string.\n// And to move the children to the correct position in its parents.\n// This resulting array is populated with a object node version of the object index.\n// If the final result have more than 1 node, then return a document fragment node.\n// If the final result have 1 node, then return the node.\n// eslint-disable-next-line complexity\nexport function htmlToDom(html: string): Element | Text | DocumentFragment {\n // Search for the opening and closing tags of the root element.\n // The opening tag could be in the middle of the string, so we need to\n // search for the first opening tag.\n const openingTag = html.match(/<[^>]+>/g);\n\n const document = new Document();\n\n // If the opening tag is not found, return a document fragment node with the html string as text content.\n if (!openingTag) {\n const documentFragment = document.createDocumentFragment();\n documentFragment.appendChild(document.createTextNode(html));\n return documentFragment;\n }\n\n const fragment = getObjectIndexTree(html);\n\n if (fragment.childNodes.length > 1) {\n return fragment;\n }\n\n return fragment.childNodes[0];\n}\n\nexport function htmlToHyperscript(html: string) {\n const domTree = htmlToDom(html);\n const hyperscript = domToHyperscript(domTree instanceof DocumentFragment ? domTree.childNodes : [domTree]);\n return `[${hyperscript}\\n]`;\n}\n\nexport const document = new Document();\n", "import fs from \"fs\";\nimport { htmlToHyperscript } from \"./tree-adapter\";\n\ninterface IconsOptions {\n iconsPath: string | null;\n linksViewPath: string | null;\n logging: boolean;\n\n // favicons options\n path: string;\n appName?: string;\n appDescription?: string;\n developerName?: string;\n developerURL?: string;\n dir?: \"auto\" | \"ltr\" | \"rtl\";\n lang?: string;\n background?: string;\n theme_color?: string;\n display?: \"browser\" | \"standalone\";\n orientation?: \"any\" | \"portrait\" | \"landscape\";\n start_url?: string;\n version?: string;\n icons: {\n android: boolean;\n appleIcon: boolean;\n appleStartup: boolean;\n coast: boolean;\n favicons: boolean;\n firefox: boolean;\n windows: boolean;\n yandex: boolean;\n };\n}\n\nexport async function icons(source: string, configuration?: IconsOptions) {\n const options = {\n ...icons.options,\n ...(configuration || {})\n };\n\n if (options.iconsPath) {\n options.iconsPath = options.iconsPath.replace(/\\/$/gi, \"\") + \"/\";\n }\n\n if (options.linksViewPath) {\n options.linksViewPath = options.linksViewPath.replace(/\\/$/gi, \"\") + \"/\";\n }\n\n const { favicons } = await import(\"favicons\");\n\n try {\n const response = await favicons(source, options);\n\n if (options.iconsPath) {\n for (const i in response.images) {\n fs.writeFileSync(options.iconsPath + response.images[i].name, response.images[i].contents);\n }\n\n for (const i in response.files) {\n fs.writeFileSync(options.iconsPath + response.files[i].name, response.files[i].contents);\n }\n }\n\n if (options.linksViewPath) {\n const html = `\n function Links(){\n return ${htmlToHyperscript(response.html.join(\"\"))};\n }\n \n Links.default = Links;\n module.exports = Links;\n `;\n\n fs.writeFileSync(`${options.linksViewPath}/links.js`, html);\n }\n } catch (err) {\n process.stdout.write((err as any).status + \"\\n\"); // HTTP error code (e.g. `200`) or `null`\n process.stdout.write((err as any).name + \"\\n\"); // Error name e.g. \"API Error\"\n process.stdout.write((err as any).message + \"\\n\"); // Error description e.g. \"An unknown error has occurred\"\n }\n}\n\nicons.options = {\n iconsPath: null,\n linksViewPath: null,\n\n // favicons options\n path: \"\",\n appName: null,\n appDescription: null,\n developerName: null,\n developerURL: null,\n dir: \"auto\",\n lang: \"en-US\",\n background: \"#fff\",\n theme_color: \"#fff\",\n display: \"standalone\",\n orientation: \"any\",\n start_url: \"/\",\n version: \"1.0\",\n logging: false,\n icons: {\n android: true,\n appleIcon: true,\n appleStartup: true,\n coast: false,\n favicons: true,\n firefox: false,\n windows: true,\n yandex: false // Create Yandex browser icon. `boolean`\n }\n} as unknown as IconsOptions;\n", "import * as tsc from \"tsc-prog\";\n\nimport CleanCSS from \"clean-css\";\nimport { PurgeCSS } from \"purgecss\";\nimport esbuild from \"esbuild\";\n/* eslint-disable sonarjs/cognitive-complexity */\nimport fs from \"fs\";\n\n// eslint-disable-next-line complexity\nexport async function inline(\n file: string | { raw: string; map?: string | null; file: string },\n options: Record = {}\n) {\n if (typeof file === \"string\") {\n const ext = file.split(\".\").pop();\n if (ext && /(js|cjs|jsx|mjs|ts|tsx)/.test(ext)) {\n if (/(ts|tsx)/.test(ext) && !options.noValidate) {\n const declarationDir = options.declarationDir;\n const emitDeclaration = !!declarationDir;\n\n const tscProgOptions = {\n basePath: process.cwd(), // always required, used for relative paths\n configFilePath: \"tsconfig.json\", // config to inherit from (optional)\n files: [file],\n include: [\"**/*.ts\", \"**/*.js\", \"**/*.tsx\", \"**/*.jsx\", \"**/*.mjs\"],\n exclude: [\"test*/**/*\", \"**/*.test.ts\", \"**/*.spec.ts\", \"dist/**\"],\n pretty: true,\n copyOtherToOutDir: false,\n clean: emitDeclaration ? [declarationDir] : [],\n ...(options.tsc || {}),\n compilerOptions: {\n rootDir: \"./\",\n outDir: \"dist\",\n noEmitOnError: true,\n noEmit: !emitDeclaration,\n declaration: emitDeclaration,\n declarationDir,\n emitDeclarationOnly: emitDeclaration,\n allowJs: true,\n esModuleInterop: true,\n inlineSourceMap: true,\n resolveJsonModule: true,\n removeComments: true,\n ...(options.tsc || {}).compilerOptions\n },\n jsxFactory: \"v\",\n jsxFragment: \"v.fragment\"\n };\n\n // eslint-disable-next-line no-console\n console.log(\"tsc\", tscProgOptions);\n\n tsc.build(tscProgOptions);\n }\n\n const esbuildOptions = {\n entryPoints: [file],\n bundle: \"bundle\" in options ? options.bundle : true,\n sourcemap: \"external\",\n write: false,\n minify: options.compact,\n outdir: \"out\",\n target: \"esnext\",\n jsxFactory: \"v\",\n jsxFragment: \"v.fragment\",\n loader: {\n \".js\": \"jsx\",\n \".cjs\": \"jsx\",\n \".mjs\": \"jsx\",\n \".ts\": \"tsx\"\n },\n ...(options.esbuild || {})\n };\n\n const result = await esbuild.build(esbuildOptions);\n if (result.outputFiles?.length !== 2) {\n throw new Error(result.errors.join(\"\\n\"));\n }\n\n if (options.compact) {\n const terser = await import(\"terser\");\n const result2 = await terser.minify(result.outputFiles[1].text, {\n sourceMap: {\n content: result.outputFiles[0].text.toString()\n },\n compress: {\n booleans_as_integers: false\n },\n output: {\n wrap_func_args: false\n },\n ecma: 2022,\n ...(options.terser || {})\n });\n\n if (!result2.code || !result2.map) {\n throw new Error(\"Unknown error\");\n }\n\n const mapBase64 = Buffer.from(result2.map.toString()).toString(\"base64\");\n const suffix = `//# sourceMappingURL=data:application/json;charset=utf-8;base64,${mapBase64}`;\n return { raw: result2.code, map: suffix, file };\n } else {\n const mapBase64 = Buffer.from(result.outputFiles[0].text.toString()).toString(\"base64\");\n const suffix = `//# sourceMappingURL=data:application/json;charset=utf-8;base64,${mapBase64}`;\n return { raw: result.outputFiles[1].text, map: suffix, file };\n }\n } else if (ext && /(css|scss|styl)/.test(ext)) {\n const result = await new CleanCSS({\n sourceMap: true,\n level: {\n 1: {\n roundingPrecision: \"all=3\"\n },\n 2: {\n restructureRules: true // controls rule restructuring; defaults to false\n }\n },\n ...(options.cleanCss || {})\n }).minify([file]);\n\n return { raw: result.styles, map: null, file };\n } else {\n return { raw: fs.readFileSync(file, \"utf8\"), map: null, file };\n }\n } else if (typeof file === \"object\" && \"raw\" in file) {\n return { map: null, ...file };\n }\n}\n\ninline.uncss = async function (\n renderedHtml: (string | Promise)[],\n css: string,\n options: Record = {}\n) {\n const html = await Promise.all(renderedHtml);\n\n const contents = html.map((item) => {\n return {\n raw: item,\n extension: \"html\"\n };\n });\n\n const purgecss = new PurgeCSS();\n\n const output = await purgecss.purge({\n fontFace: true,\n keyframes: true,\n variables: true,\n defaultExtractor: (content) => content.match(/[A-Za-z0-9-_/:@]*[A-Za-z0-9-_/:@/]+/g) || [],\n ...options,\n content: contents,\n css: [{ raw: css }]\n });\n\n const cleanCss = await new CleanCSS({\n sourceMap: false,\n level: {\n 1: {\n roundingPrecision: \"all=3\"\n },\n 2: {\n restructureRules: true // controls rule restructuring; defaults to false\n }\n },\n ...(options.cleanCss || {})\n }).minify(output[0].css);\n\n return cleanCss.styles;\n};\n", "import fs from \"fs\";\nimport path from \"path\";\n\nexport function sw(file: string, options = {}) {\n const swfiletemplate = path.resolve(__dirname, \"./node.sw.tpl\");\n const swTpl = fs.readFileSync(swfiletemplate, \"utf8\");\n const opt = Object.assign(\n {\n version: \"v1::\",\n name: \"Valyrian.js\",\n urls: [\"/\"],\n debug: false\n },\n options\n );\n let contents = swTpl\n .replace(\"v1::\", \"v\" + opt.version + \"::\")\n .replace(\"Valyrian.js\", opt.name)\n .replace(\"['/']\", '[\"' + opt.urls.join('\",\"') + '\"]');\n\n if (!opt.debug) {\n contents = contents.replace(\"console.log\", \"() => {}\");\n }\n\n fs.writeFileSync(file, contents, \"utf8\");\n}\n", "import fs from \"fs\";\nimport path from \"path\";\n\nexport class SessionStorage {\n private storage: { [key: string]: string };\n private limit: number;\n private persist: boolean;\n private filePath: string;\n private directory: string = \".session-storage\";\n\n constructor({ persist = false, filePath = \"./sessionData.json\" }: { persist?: boolean; filePath?: string } = {}) {\n this.storage = {};\n this.limit = 5 * 1024 * 1024; // 5MB storage limit\n this.persist = persist;\n this.filePath = path.resolve(this.directory, filePath);\n\n if (!fs.existsSync(this.directory)) {\n fs.mkdirSync(this.directory, { recursive: true });\n }\n\n // Load data from file if persistence is enabled\n if (this.persist) {\n this.loadFromFile();\n }\n }\n\n // Calculate total size in bytes of stored data\n private getStorageSize(): number {\n return new TextEncoder().encode(JSON.stringify(this.storage)).length;\n }\n\n // Check if storage limit is exceeded\n private checkSizeLimit(): void {\n const size = this.getStorageSize();\n if (size > this.limit) {\n throw new DOMException(\"Storage limit exceeded\", \"QuotaExceededError\");\n }\n }\n\n // Store value under the specified key\n setItem(key: string | null | undefined, value: string | null | undefined): void {\n if (key === null || key === undefined) {\n throw new TypeError(\"Failed to execute 'setItem' on 'Storage': 1 argument required, but only 0 present.\");\n }\n\n if (value === null) {\n value = \"null\"; // Convert null to \"null\"\n } else if (value === undefined) {\n value = \"undefined\"; // Convert undefined to \"undefined\"\n }\n\n this.storage[key] = String(value); // Store as string\n this.checkSizeLimit(); // Check storage limit\n if (this.persist) {\n this.saveToFile(); // Save to file if persistence is enabled\n }\n }\n\n // Retrieve value stored under the specified key\n getItem(key: string | null | undefined): string | null {\n if (key === null || key === undefined) {\n throw new TypeError(\"Failed to execute 'getItem' on 'Storage': 1 argument required, but only 0 present.\");\n }\n return this.storage[key] || null; // Return null if key doesn't exist\n }\n\n // Remove the value under the specified key\n removeItem(key: string | null | undefined): void {\n if (key === null || key === undefined) {\n throw new TypeError(\"Failed to execute 'removeItem' on 'Storage': 1 argument required, but only 0 present.\");\n }\n delete this.storage[key];\n if (this.persist) {\n this.saveToFile(); // Save to file if persistence is enabled\n }\n }\n\n // Clear all stored values\n clear(): void {\n this.storage = {};\n if (this.persist) {\n this.saveToFile(); // Save to file if persistence is enabled\n }\n }\n\n // Return the number of stored items\n get length(): number {\n return Object.keys(this.storage).length;\n }\n\n // Return the key at the specified index\n key(index: number): string | null {\n const keys = Object.keys(this.storage);\n return keys[index] || null;\n }\n\n // Save data to a file (only if persistence is enabled)\n private saveToFile(): void {\n try {\n fs.writeFileSync(this.filePath, JSON.stringify(this.storage), \"utf-8\");\n } catch (error) {\n throw new Error(`Error saving data to file: ${(error as any).message}`);\n }\n }\n\n // Load data from a file (only if persistence is enabled)\n private loadFromFile(): void {\n try {\n if (fs.existsSync(this.filePath)) {\n const data = fs.readFileSync(this.filePath, \"utf-8\");\n this.storage = JSON.parse(data || \"{}\");\n }\n } catch (error) {\n throw new Error(`Error loading data from file: ${(error as any).message}`);\n }\n }\n}\n"], + "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACIO,IAAM,OAAN,MAAM,MAAqB;AAAA;AAAA,EAEhC,aAAyB,CAAC;AAAA,EAC1B,UAAkB;AAAA,EAElB;AAAA,EACA,IAAI,WAAmB;AACrB,WAAO,KAAK,SAAS,YAAY;AAAA,EACnC;AAAA,EACA,IAAI,SAAS,MAAc;AACzB,SAAK,WAAW;AAAA,EAClB;AAAA,EACA,IAAI,UAAkB;AACpB,WAAO,KAAK;AAAA,EACd;AAAA,EACA,IAAI,QAAQ,MAAc;AACxB,SAAK,WAAW;AAAA,EAClB;AAAA,EAEA;AAAA,EACA,IAAI,WAAmB;AACrB,WAAO,KAAK;AAAA,EACd;AAAA,EACA,IAAI,SAAS,MAAc;AACzB,SAAK,YAAY;AAAA,EACnB;AAAA,EAEA,aAAa;AAAA,EACb,aAAqB,CAAC;AAAA,EACtB,IAAI,YAAY,MAAM;AACpB,SAAK,aAAa,OAAO,IAAI;AAAA,EAC/B;AAAA,EACA,IAAI,cAAc;AAChB,WAAO,KAAK;AAAA,EACd;AAAA,EACA,IAAI,UAAU,MAAM;AAClB,SAAK,aAAa,OAAO,IAAI;AAAA,EAC/B;AAAA,EACA,IAAI,YAAY;AACd,WAAO,KAAK;AAAA,EACd;AAAA;AAAA,EAGA,cAA2B;AAAA,EAC3B,IAAI,aAAa;AACf,WAAO,KAAK;AAAA,EACd;AAAA,EACA,IAAI,WAAW,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s", "import_fs", "esbuild", "CleanCSS", "fs", "import_fs", "path", "fs", "import_fs", "import_path", "path", "fs", "FormData"] } diff --git a/dist/node/index.mjs b/dist/node/index.mjs index f8c3d70..d05099e 100644 --- a/dist/node/index.mjs +++ b/dist/node/index.mjs @@ -915,9 +915,113 @@ function sw(file, options = {}) { fs3.writeFileSync(file, contents, "utf8"); } +// lib/node/utils/session-storage.ts +import fs4 from "fs"; +import path2 from "path"; +var SessionStorage = class { + storage; + limit; + persist; + filePath; + directory = ".session-storage"; + constructor({ persist = false, filePath = "./sessionData.json" } = {}) { + this.storage = {}; + this.limit = 5 * 1024 * 1024; + this.persist = persist; + this.filePath = path2.resolve(this.directory, filePath); + if (!fs4.existsSync(this.directory)) { + fs4.mkdirSync(this.directory, { recursive: true }); + } + if (this.persist) { + this.loadFromFile(); + } + } + // Calculate total size in bytes of stored data + getStorageSize() { + return new TextEncoder().encode(JSON.stringify(this.storage)).length; + } + // Check if storage limit is exceeded + checkSizeLimit() { + const size = this.getStorageSize(); + if (size > this.limit) { + throw new DOMException("Storage limit exceeded", "QuotaExceededError"); + } + } + // Store value under the specified key + setItem(key, value) { + if (key === null || key === void 0) { + throw new TypeError("Failed to execute 'setItem' on 'Storage': 1 argument required, but only 0 present."); + } + if (value === null) { + value = "null"; + } else if (value === void 0) { + value = "undefined"; + } + this.storage[key] = String(value); + this.checkSizeLimit(); + if (this.persist) { + this.saveToFile(); + } + } + // Retrieve value stored under the specified key + getItem(key) { + if (key === null || key === void 0) { + throw new TypeError("Failed to execute 'getItem' on 'Storage': 1 argument required, but only 0 present."); + } + return this.storage[key] || null; + } + // Remove the value under the specified key + removeItem(key) { + if (key === null || key === void 0) { + throw new TypeError("Failed to execute 'removeItem' on 'Storage': 1 argument required, but only 0 present."); + } + delete this.storage[key]; + if (this.persist) { + this.saveToFile(); + } + } + // Clear all stored values + clear() { + this.storage = {}; + if (this.persist) { + this.saveToFile(); + } + } + // Return the number of stored items + get length() { + return Object.keys(this.storage).length; + } + // Return the key at the specified index + key(index) { + const keys = Object.keys(this.storage); + return keys[index] || null; + } + // Save data to a file (only if persistence is enabled) + saveToFile() { + try { + fs4.writeFileSync(this.filePath, JSON.stringify(this.storage), "utf-8"); + } catch (error) { + throw new Error(`Error saving data to file: ${error.message}`); + } + } + // Load data from a file (only if persistence is enabled) + loadFromFile() { + try { + if (fs4.existsSync(this.filePath)) { + const data = fs4.readFileSync(this.filePath, "utf-8"); + this.storage = JSON.parse(data || "{}"); + } + } catch (error) { + throw new Error(`Error loading data from file: ${error.message}`); + } + } +}; + // lib/node/index.ts global.FormData = FormData; global.document = document; +global.sessionStorage = new SessionStorage(); +global.localStorage = new SessionStorage(); function render(...args) { const Component = () => args; const result = mount("div", Component); diff --git a/dist/node/index.mjs.map b/dist/node/index.mjs.map index c9e45ab..c81304f 100644 --- a/dist/node/index.mjs.map +++ b/dist/node/index.mjs.map @@ -1,7 +1,7 @@ { "version": 3, - "sources": ["../../lib/node/utils/tree-adapter.ts", "../../lib/node/index.ts", "../../lib/node/utils/icons.ts", "../../lib/node/utils/inline.ts", "../../lib/node/utils/sw.ts"], - "sourcesContent": ["/* eslint-disable no-use-before-define */\n/* eslint-disable complexity */\ninterface ChildNodes extends Array {}\n\nexport class Node implements Node {\n // eslint-disable-next-line no-use-before-define\n childNodes: ChildNodes = [];\n baseURI: string = \"\";\n\n tag_name!: string;\n get nodeName(): string {\n return this.tag_name.toLowerCase();\n }\n set nodeName(name: string) {\n this.tag_name = name;\n }\n get tagName(): string {\n return this.tag_name;\n }\n set tagName(name: string) {\n this.tag_name = name;\n }\n\n node_type!: number;\n get nodeType(): number {\n return this.node_type;\n }\n set nodeType(type: number) {\n this.node_type = type;\n }\n\n node_value = \"\";\n attributes: Attr[] = [];\n set textContent(text) {\n this.node_value = String(text);\n }\n get textContent() {\n return this.node_value;\n }\n set nodeValue(text) {\n this.node_value = String(text);\n }\n get nodeValue() {\n return this.node_value;\n }\n\n // eslint-disable-next-line no-use-before-define\n parent_node: Node | null = null;\n get parentNode() {\n return this.parent_node;\n }\n set parentNode(node) {\n this.parent_node = node;\n }\n\n #dataset: Record = {};\n\n get dataset() {\n return this.#dataset;\n }\n\n set dataset(value) {\n this.#dataset = value;\n }\n\n constructor() {}\n\n appendChild(node: T): T {\n if (node) {\n node.parentNode && node.parentNode.removeChild(node as Node);\n this.childNodes.push(node);\n node.parentNode = this;\n }\n return node;\n }\n\n insertBefore(node: T, child: Node | null): T {\n if (node) {\n node.parentNode && node.parentNode.removeChild(node as Node);\n node.parentNode = this;\n if (child) {\n const idx = this.childNodes.indexOf(child);\n this.childNodes.splice(idx, 0, node);\n } else {\n this.childNodes.push(node);\n }\n }\n return node;\n }\n\n replaceChild(node: Node, child: T): T {\n if (node && child && child.parentNode === this) {\n this.insertBefore(node, child);\n child.parentNode && child.parentNode.removeChild(child);\n }\n return child;\n }\n removeChild(child: T): T {\n if (child && child.parentNode === this) {\n const idx = (this.childNodes as unknown as Node[]).indexOf(child);\n (this.childNodes as unknown as Node[]).splice(idx, 1);\n child.parentNode = null;\n }\n return child;\n }\n\n remove(): Node {\n return this.parentNode ? this.parentNode.removeChild(this) : this;\n }\n\n cloneNode(deep?: boolean | undefined): Node {\n if (this.nodeType === 3) {\n return new Text(this.nodeValue);\n }\n\n if (this.nodeType === 1) {\n const node = new Element();\n node.nodeType = this.nodeType;\n this.nodeName = this.nodeName;\n if (this.attributes) {\n for (let i = 0, l = this.attributes.length; i < l; i++) {\n node.setAttribute(this.attributes[i].nodeName, this.attributes[i].nodeValue);\n }\n }\n\n for (const key in this.dataset) {\n node.dataset[key] = this.dataset[key];\n }\n\n if (deep) {\n for (let i = 0, l = this.childNodes.length; i < l; i++) {\n node.appendChild(this.childNodes[i].cloneNode(deep));\n }\n }\n return node;\n }\n\n const node = new Node();\n node.nodeType = this.nodeType;\n node.nodeName = this.nodeName;\n return node;\n }\n\n setAttribute(name: string, value: any) {\n const attr = {\n nodeName: name,\n nodeValue: value\n };\n let idx = -1;\n for (let i = 0, l = this.attributes.length; i < l; i++) {\n if (this.attributes[i].nodeName === name) {\n idx = i;\n break;\n }\n }\n idx === -1 ? this.attributes.push(attr as Attr) : this.attributes.splice(idx, 1, attr as Attr);\n }\n\n getAttribute(name: string) {\n for (let i = 0, l = this.attributes.length; i < l; i++) {\n if (this.attributes[i].nodeName === name) {\n return this.attributes[i].nodeValue;\n }\n }\n }\n\n removeAttribute(name: string) {\n let idx = -1;\n for (let i = 0, l = this.attributes.length; i < l; i++) {\n if (this.attributes[i].nodeName === name) {\n idx = i;\n break;\n }\n }\n if (idx > -1) {\n this.attributes.splice(idx, 1);\n }\n }\n\n getElementById(id: string): Node | null {\n let elementFound;\n for (let i = 0, l = this.childNodes.length; i < l; i++) {\n if (this.childNodes[i].nodeType === 1) {\n if (this.childNodes[i].getAttribute(\"id\") === id) {\n elementFound = this.childNodes[i];\n break;\n }\n elementFound = this.childNodes[i].getElementById(id);\n if (elementFound) {\n break;\n }\n }\n }\n return elementFound || null;\n }\n\n // Not implemented\n // firstChild!: ChildNode | null;\n // isConnected!: boolean;\n // lastChild!: ChildNode | null;\n // nextSibling!: ChildNode | null;\n // ownerDocument!: Document | null;\n // parentElement!: HTMLElement | null;\n // previousSibling!: ChildNode | null;\n // compareDocumentPosition(other: Node): number {\n // throw new Error(\"Method not implemented.\");\n // }\n // contains(other: Node | null): boolean {\n // throw new Error(\"Method not implemented.\");\n // }\n // getRootNode(options?: GetRootNodeOptions | undefined): Node {\n // throw new Error(\"Method not implemented.\");\n // }\n // hasChildNodes(): boolean {\n // throw new Error(\"Method not implemented.\");\n // }\n // isDefaultNamespace(namespace: string | null): boolean {\n // throw new Error(\"Method not implemented.\");\n // }\n // isEqualNode(otherNode: Node | null): boolean {\n // throw new Error(\"Method not implemented.\");\n // }\n // isSameNode(otherNode: Node | null): boolean {\n // throw new Error(\"Method not implemented.\");\n // }\n // lookupNamespaceURI(prefix: string | null): string | null {\n // throw new Error(\"Method not implemented.\");\n // }\n // lookupPrefix(namespace: string | null): string | null {\n // throw new Error(\"Method not implemented.\");\n // }\n // normalize(): void {\n // throw new Error(\"Method not implemented.\");\n // }\n // ATTRIBUTE_NODE!: number;\n // CDATA_SECTION_NODE!: number;\n // COMMENT_NODE!: number;\n // DOCUMENT_FRAGMENT_NODE!: number;\n // DOCUMENT_NODE!: number;\n // DOCUMENT_POSITION_CONTAINED_BY!: number;\n // DOCUMENT_POSITION_CONTAINS!: number;\n // DOCUMENT_POSITION_DISCONNECTED!: number;\n // DOCUMENT_POSITION_FOLLOWING!: number;\n // DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC!: number;\n // DOCUMENT_POSITION_PRECEDING!: number;\n // DOCUMENT_TYPE_NODE!: number;\n // ELEMENT_NODE!: number;\n // ENTITY_NODE!: number;\n // ENTITY_REFERENCE_NODE!: number;\n // NOTATION_NODE!: number;\n // PROCESSING_INSTRUCTION_NODE!: number;\n // TEXT_NODE!: number;\n addEventListener(\n // eslint-disable-next-line no-unused-vars\n type: string,\n // eslint-disable-next-line no-unused-vars\n callback: EventListenerOrEventListenerObject | null,\n // eslint-disable-next-line no-unused-vars\n options?: boolean | AddEventListenerOptions | undefined\n ): void {\n // throw new Error(\"Method not implemented.\");\n }\n // dispatchEvent(event: Event): boolean {\n // throw new Error(\"Method not implemented.\");\n // }\n removeEventListener(\n // eslint-disable-next-line no-unused-vars\n type: string,\n // eslint-disable-next-line no-unused-vars\n callback: EventListenerOrEventListenerObject | null,\n // eslint-disable-next-line no-unused-vars\n options?: boolean | EventListenerOptions | undefined\n ): void {\n // throw new Error(\"Method not implemented.\");\n }\n}\n\nexport class Text extends Node {\n constructor(text: any) {\n super();\n this.nodeType = 3;\n this.nodeName = \"#text\";\n this.node_value = String(text);\n }\n}\n\nfunction updateElementStyles(element: Element, state: Record) {\n let str = \"\";\n for (const key in state) {\n const value = state[key];\n if (typeof value !== \"undefined\" && value !== null && String(value).length > 0) {\n str += `${key}: ${state[key]};`;\n }\n }\n if (str.length === 0) {\n element.removeAttribute(\"style\");\n } else {\n element.setAttribute(\"style\", str);\n }\n}\n\nexport class Element extends Node {\n constructor() {\n super();\n this.nodeType = 1;\n this.attributes = [];\n this.childNodes = [];\n }\n\n _style = new Proxy(\n {},\n {\n get: (state: Record, prop: string) => state[prop],\n set: (state: Record, prop: string, value: any) => {\n state[prop] = value;\n updateElementStyles(this, state);\n return true;\n },\n deleteProperty: (state: Record, prop: string) => {\n Reflect.deleteProperty(state, prop);\n updateElementStyles(this, state);\n return true;\n }\n }\n );\n\n get style() {\n return this._style as any;\n }\n\n set style(value: string) {\n if (typeof value === \"string\") {\n // should match pairs like \"color: red; font-size: 12px; background: url(http://example.com/image.png?s=1024x1024&w=is&k=20&c=ASa_AG8uP5Di7azXgJraSA6ME7fbLB0GX4YT_OzCARI=);\"\n const regex = /([^:\\s]+):\\s*((url\\([^)]+\\))|[^;]+(?=(;|$)))/g;\n let match;\n\n while ((match = regex.exec(value)) !== null) {\n this._style[match[1]] = match[2].trim();\n }\n\n return;\n }\n\n throw new Error(\"Cannot set style\");\n }\n\n get className(): string {\n return this.getAttribute(\"class\") || \"\";\n }\n\n set className(value: string | boolean) {\n if (value == null || value === false) {\n this.removeAttribute(\"class\");\n } else {\n this.setAttribute(\"class\", String(value));\n }\n }\n\n classList = {\n toggle: (item: any, force: any) => {\n if (item) {\n const classes = (this.className || \"\").split(\" \");\n const itemIndex = classes.indexOf(item);\n if (force && itemIndex === -1) {\n classes.push(item);\n }\n\n if (!force && itemIndex !== -1) {\n classes.splice(itemIndex, 1);\n }\n\n const final = classes.join(\" \").trim();\n if (final.length) {\n this.className = classes.join(\" \").trim();\n } else {\n this.className = false;\n }\n }\n }\n };\n\n get id(): string {\n return this.getAttribute(\"id\") || \"\";\n }\n\n set id(value: string | boolean) {\n if (value == null || value === false) {\n this.removeAttribute(\"id\");\n } else {\n this.setAttribute(\"id\", String(value));\n }\n }\n\n set textContent(text) {\n this.nodeValue = String(text);\n this.childNodes = this.nodeValue ? [new Text(this.nodeValue)] : [];\n }\n get textContent() {\n return this.nodeValue;\n }\n\n set innerText(text) {\n this.nodeValue = String(text);\n }\n\n get innerText() {\n return this.nodeValue;\n }\n\n get innerHTML() {\n let str = \"\";\n for (let i = 0, l = this.childNodes.length; i < l; i++) {\n // console.log(\"domToHtml\", this.childNodes[i], domToHtml(this.childNodes[i] as Element));\n str += domToHtml(this.childNodes[i] as Element);\n }\n return str;\n }\n\n set innerHTML(html) {\n this.textContent = \"\";\n const result = htmlToDom(html);\n if (result instanceof DocumentFragment) {\n for (let i = 0, l = result.childNodes.length; i < l; i++) {\n this.appendChild(result.childNodes[i]);\n }\n } else {\n this.appendChild(result);\n }\n }\n\n get outerHTML(): string {\n return domToHtml(this);\n }\n}\n\nexport class DocumentFragment extends Element {\n constructor() {\n super();\n this.nodeType = 11;\n this.nodeName = \"#document-fragment\";\n }\n}\n\nexport class Document extends Element {\n constructor() {\n super();\n this.nodeType = 9;\n this.nodeName = \"#document\";\n }\n\n createDocumentFragment(): DocumentFragment {\n return new DocumentFragment();\n }\n\n createElement(type: string) {\n const element = new Element();\n element.nodeName = type.toUpperCase();\n return element;\n }\n\n createElementNS(ns: string, type: string) {\n const element = this.createElement(type);\n element.baseURI = ns;\n return element;\n }\n\n createTextNode(text: any) {\n return new Text(text);\n }\n}\n\nconst selfClosingTags = [\n \"area\",\n \"base\",\n \"br\",\n \"col\",\n \"embed\",\n \"hr\",\n \"img\",\n \"input\",\n \"link\",\n \"meta\",\n \"param\",\n \"source\",\n \"track\",\n \"wbr\",\n \"!doctype\"\n];\n\nexport function domToHtml(dom: Element): string {\n if (dom.nodeType === 3) {\n return dom.textContent;\n }\n\n if (dom.nodeType === 1) {\n const name = dom.nodeName.toLowerCase();\n let str = \"<\" + name;\n for (let i = 0, l = dom.attributes.length; i < l; i++) {\n str += \" \" + dom.attributes[i].nodeName + '=\"' + dom.attributes[i].nodeValue + '\"';\n }\n\n if (selfClosingTags.indexOf(name) === -1) {\n str += \">\";\n if (dom.childNodes && dom.childNodes.length > 0) {\n for (let i = 0, l = dom.childNodes.length; i < l; i++) {\n const child = domToHtml(dom.childNodes[i] as Element);\n if (child) {\n str += child;\n }\n }\n }\n str += \"\";\n } else {\n str += \"/>\";\n }\n\n return str;\n }\n\n return \"\";\n}\n\nexport function domToHyperscript(childNodes: ChildNodes, depth = 1) {\n let spaces = \"\";\n for (let i = 0; i < depth; i++) {\n spaces += \" \";\n }\n\n return childNodes\n .map((item) => {\n if (item.nodeType === 10) {\n return `\\n${spaces}\"\"`;\n } else if (item.nodeType === 3) {\n return `\\n${spaces}\"${item.nodeValue}\"`;\n } else {\n let str = `\\n${spaces}v(\"${item.nodeName}\", `;\n\n if (item.attributes) {\n const attrs: Record = {};\n for (let i = 0, l = item.attributes.length; i < l; i++) {\n const attr = item.attributes[i];\n attrs[attr.nodeName] = attr.nodeValue;\n }\n str += JSON.stringify(attrs);\n } else {\n str += \"{}\";\n }\n\n str += \", [\";\n if (item.childNodes && item.childNodes.length > 0) {\n str += `${domToHyperscript(item.childNodes as unknown as Element[], depth + 1)}\\n${spaces}`;\n }\n\n str += `])`;\n return str;\n }\n })\n .join(\",\");\n}\n\ninterface ObjectIndexItem {\n tagName: string;\n startsAt: number;\n endsAt: number | null;\n contentStartsAt: number;\n contentEndsAt: number | null;\n attributes: { [key: string]: any };\n children: ObjectIndexItem[];\n nodeValue: string | null;\n}\n\ninterface ObjectIndexItemWithContent extends ObjectIndexItem {\n endsAt: number;\n contentEndsAt: number;\n children: ObjectIndexItemWithContent[];\n}\n\ninterface ObjectIndexList extends Array {}\n\nfunction findTexts(item: ObjectIndexItemWithContent, html: string) {\n const newChildren: ObjectIndexItemWithContent[] = [];\n\n // If the item has children\n if (item.children.length) {\n // Search for texts in the children.\n for (let i = 0; i < item.children.length; i++) {\n const child = item.children[i];\n const nextChild = item.children[i + 1];\n\n // If is the first child and the child startsAt is greater than the item contentStartsAt then\n // the content between the item contentStartsAt and the child startsAt is a text child of the item.\n if (i === 0 && child.startsAt > item.contentStartsAt) {\n const childContent = html.substring(item.contentStartsAt, child.startsAt);\n\n const childText: ObjectIndexItemWithContent = {\n tagName: \"#text\",\n startsAt: item.contentStartsAt,\n endsAt: item.contentStartsAt + childContent.length,\n contentStartsAt: item.contentStartsAt,\n contentEndsAt: item.contentStartsAt + childContent.length,\n attributes: {},\n children: [],\n nodeValue: childContent\n };\n\n newChildren.push(childText);\n }\n\n // Add the child to the newChildren array.\n newChildren.push(child);\n\n // If there is a next child and the child endsAt is less than the next child startsAt then\n // the content between the child endsAt and the next child startsAt is a text child of the item.\n if (nextChild && child.endsAt < nextChild.startsAt) {\n const childContent = html.substring(child.endsAt, nextChild.startsAt);\n\n const childText: ObjectIndexItemWithContent = {\n tagName: \"#text\",\n startsAt: child.endsAt,\n endsAt: child.endsAt + childContent.length,\n contentStartsAt: child.endsAt,\n contentEndsAt: child.endsAt + childContent.length,\n attributes: {},\n children: [],\n nodeValue: childContent\n };\n\n newChildren.push(childText);\n }\n\n // If there are no next child and the child endsAt is less than the item contentEndsAt then\n // the content between the child endsAt and the item contentEndsAt is a text child of the item.\n if (!nextChild && child.endsAt < item.contentEndsAt) {\n const childContent = html.substring(child.endsAt, item.contentEndsAt);\n\n const childText: ObjectIndexItemWithContent = {\n tagName: \"#text\",\n startsAt: child.endsAt,\n endsAt: child.endsAt + childContent.length,\n contentStartsAt: child.endsAt,\n contentEndsAt: item.contentEndsAt,\n attributes: {},\n children: [],\n nodeValue: childContent\n };\n\n newChildren.push(childText);\n }\n\n // Find texts in the child.\n findTexts(child, html);\n }\n }\n\n // If the item has no children then set the contents between the item contentStartsAt and the item contentEndsAt\n // as a text child of the item.\n if (!item.children.length) {\n const childContent = html.substring(item.contentStartsAt, item.contentEndsAt);\n\n if (childContent.length) {\n const childText: ObjectIndexItemWithContent = {\n tagName: \"#text\",\n startsAt: item.contentStartsAt,\n endsAt: item.contentEndsAt,\n contentStartsAt: item.contentStartsAt,\n contentEndsAt: item.contentEndsAt,\n attributes: {},\n children: [],\n nodeValue: childContent\n };\n\n newChildren.push(childText);\n }\n }\n\n item.children = newChildren;\n}\n\nfunction convertToDom(item: ObjectIndexItemWithContent): T {\n let node: T;\n\n if (item.tagName === \"#text\") {\n node = document.createTextNode(item.nodeValue as string) as unknown as T;\n } else {\n node = (item.tagName === \"#document-fragment\"\n ? document.createDocumentFragment()\n : document.createElement(item.tagName)) as unknown as T;\n\n for (const key in item.attributes) {\n node.setAttribute(key, item.attributes[key]);\n }\n\n for (let i = 0; i < item.children.length; i++) {\n const child = convertToDom(item.children[i]);\n node.appendChild(child);\n }\n }\n\n return node;\n}\n\n// eslint-disable-next-line sonarjs/cognitive-complexity\nfunction getObjectIndexTree(html: string): DocumentFragment {\n let item;\n const regex = RegExp(\"<([^>|^!]+)>\", \"g\");\n const items: ObjectIndexList = [];\n\n // Make the initial list of items.\n while ((item = regex.exec(html))) {\n // If is a closing tag\n if (item[0].startsWith(\" item.endsAt === null);\n if (lastOpenedItem) {\n lastOpenedItem.endsAt = item.index + item[0].length;\n lastOpenedItem.contentEndsAt = item.index;\n\n // Find the last opened item again, this will be the parent of the current item.\n const parent = [...items].reverse().find((item) => item.endsAt === null);\n if (parent) {\n // Find the index of the current item in the items array.\n const index = items.indexOf(lastOpenedItem);\n // Remove the last opened item from the items array.\n items.splice(index, 1);\n\n // Add the last opened item as a child of the parent.\n parent.children.push(lastOpenedItem);\n }\n }\n\n continue;\n }\n\n // If is an opening tag\n const element: ObjectIndexItem = {\n tagName: item[1].split(\" \")[0],\n startsAt: item.index,\n endsAt: null,\n contentStartsAt: item.index + item[0].length,\n contentEndsAt: null,\n attributes: {},\n children: [],\n nodeValue: null\n };\n\n // Find the attributes of the tag.\n let string = (item[1] || \"\").substring(element.tagName.length + 1).replace(/\\/$/g, \"\");\n const attributesWithValues = string.match(/\\S+=\"[^\"]+\"/g);\n\n if (attributesWithValues) {\n for (const attribute of attributesWithValues) {\n const [name, ...value] = attribute.trim().split(\"=\");\n string = string.replace(attribute, \"\");\n if (value) {\n element.attributes[name] = value.join(\"=\").replace(/(^\"|\"$)/g, \"\");\n }\n }\n }\n\n const attributesWithBooleanValues = string.match(/\\s\\S+=[^\"]+/g);\n if (attributesWithBooleanValues) {\n for (const attribute of attributesWithBooleanValues) {\n const [name, ...value] = attribute.trim().split(\"=\");\n string = string.replace(attribute, \"\");\n if (value) {\n element.attributes[name] = value.join(\"=\").replace(/(^\"|\"$)/g, \"\");\n }\n }\n }\n\n const attributesWithEmptyValues = string.match(/\\s?\\S+/g);\n if (attributesWithEmptyValues) {\n for (const attribute of attributesWithEmptyValues) {\n const name = attribute.trim();\n element.attributes[name] = true;\n }\n }\n\n // If the tag is self closing\n if (item[0].endsWith(\"/>\")) {\n element.endsAt = element.startsAt + item[0].length;\n element.contentStartsAt = element.contentEndsAt = element.endsAt;\n\n // Find the last opened item, this will be the parent of the current item.\n const parent = [...items].reverse().find((item) => item.endsAt === null);\n if (parent) {\n // Add the last opened item as a child of the parent.\n parent.children.push(element);\n continue;\n }\n }\n\n items.push(element);\n }\n\n const fragmentItem: ObjectIndexItemWithContent = {\n tagName: \"#document-fragment\",\n startsAt: 0,\n endsAt: html.length,\n contentStartsAt: 0,\n contentEndsAt: html.length,\n attributes: {},\n children: items as ObjectIndexItemWithContent[],\n nodeValue: null\n };\n\n findTexts(fragmentItem, html);\n\n return convertToDom(fragmentItem);\n}\n\n// First we create a tree of object indexes from the HTML string.\n// The resulting array is then reordered to match the order of the html string.\n// And to move the children to the correct position in its parents.\n// This resulting array is populated with a object node version of the object index.\n// If the final result have more than 1 node, then return a document fragment node.\n// If the final result have 1 node, then return the node.\n// eslint-disable-next-line complexity\nexport function htmlToDom(html: string): Element | Text | DocumentFragment {\n // Search for the opening and closing tags of the root element.\n // The opening tag could be in the middle of the string, so we need to\n // search for the first opening tag.\n const openingTag = html.match(/<[^>]+>/g);\n\n const document = new Document();\n\n // If the opening tag is not found, return a document fragment node with the html string as text content.\n if (!openingTag) {\n const documentFragment = document.createDocumentFragment();\n documentFragment.appendChild(document.createTextNode(html));\n return documentFragment;\n }\n\n const fragment = getObjectIndexTree(html);\n\n if (fragment.childNodes.length > 1) {\n return fragment;\n }\n\n return fragment.childNodes[0];\n}\n\nexport function htmlToHyperscript(html: string) {\n const domTree = htmlToDom(html);\n const hyperscript = domToHyperscript(domTree instanceof DocumentFragment ? domTree.childNodes : [domTree]);\n return `[${hyperscript}\\n]`;\n}\n\nexport const document = new Document();\n", "import { document, domToHtml, domToHyperscript, htmlToDom, htmlToHyperscript } from \"./utils/tree-adapter\";\nimport { mount, unmount } from \"valyrian.js\";\n\nimport FormData from \"form-data\";\n// import fetch from \"node-fetch\";\nimport { icons } from \"./utils/icons\";\nimport { inline } from \"./utils/inline\";\nimport { sw } from \"./utils/sw\";\n\nglobal.FormData = FormData as any;\nglobal.document = document as any;\n\nfunction render(...args: any[]) {\n const Component = () => args;\n const result = mount(\"div\", Component);\n unmount();\n return result;\n}\n\nexport { domToHtml, domToHyperscript, htmlToDom, htmlToHyperscript, inline, sw, icons, render };\n", "import fs from \"fs\";\nimport { htmlToHyperscript } from \"./tree-adapter\";\n\ninterface IconsOptions {\n iconsPath: string | null;\n linksViewPath: string | null;\n logging: boolean;\n\n // favicons options\n path: string;\n appName?: string;\n appDescription?: string;\n developerName?: string;\n developerURL?: string;\n dir?: \"auto\" | \"ltr\" | \"rtl\";\n lang?: string;\n background?: string;\n theme_color?: string;\n display?: \"browser\" | \"standalone\";\n orientation?: \"any\" | \"portrait\" | \"landscape\";\n start_url?: string;\n version?: string;\n icons: {\n android: boolean;\n appleIcon: boolean;\n appleStartup: boolean;\n coast: boolean;\n favicons: boolean;\n firefox: boolean;\n windows: boolean;\n yandex: boolean;\n };\n}\n\nexport async function icons(source: string, configuration?: IconsOptions) {\n const options = {\n ...icons.options,\n ...(configuration || {})\n };\n\n if (options.iconsPath) {\n options.iconsPath = options.iconsPath.replace(/\\/$/gi, \"\") + \"/\";\n }\n\n if (options.linksViewPath) {\n options.linksViewPath = options.linksViewPath.replace(/\\/$/gi, \"\") + \"/\";\n }\n\n const { favicons } = await import(\"favicons\");\n\n try {\n const response = await favicons(source, options);\n\n if (options.iconsPath) {\n for (const i in response.images) {\n fs.writeFileSync(options.iconsPath + response.images[i].name, response.images[i].contents);\n }\n\n for (const i in response.files) {\n fs.writeFileSync(options.iconsPath + response.files[i].name, response.files[i].contents);\n }\n }\n\n if (options.linksViewPath) {\n const html = `\n function Links(){\n return ${htmlToHyperscript(response.html.join(\"\"))};\n }\n \n Links.default = Links;\n module.exports = Links;\n `;\n\n fs.writeFileSync(`${options.linksViewPath}/links.js`, html);\n }\n } catch (err) {\n process.stdout.write((err as any).status + \"\\n\"); // HTTP error code (e.g. `200`) or `null`\n process.stdout.write((err as any).name + \"\\n\"); // Error name e.g. \"API Error\"\n process.stdout.write((err as any).message + \"\\n\"); // Error description e.g. \"An unknown error has occurred\"\n }\n}\n\nicons.options = {\n iconsPath: null,\n linksViewPath: null,\n\n // favicons options\n path: \"\",\n appName: null,\n appDescription: null,\n developerName: null,\n developerURL: null,\n dir: \"auto\",\n lang: \"en-US\",\n background: \"#fff\",\n theme_color: \"#fff\",\n display: \"standalone\",\n orientation: \"any\",\n start_url: \"/\",\n version: \"1.0\",\n logging: false,\n icons: {\n android: true,\n appleIcon: true,\n appleStartup: true,\n coast: false,\n favicons: true,\n firefox: false,\n windows: true,\n yandex: false // Create Yandex browser icon. `boolean`\n }\n} as unknown as IconsOptions;\n", "import * as tsc from \"tsc-prog\";\n\nimport CleanCSS from \"clean-css\";\nimport { PurgeCSS } from \"purgecss\";\nimport esbuild from \"esbuild\";\n/* eslint-disable sonarjs/cognitive-complexity */\nimport fs from \"fs\";\n\n// eslint-disable-next-line complexity\nexport async function inline(\n file: string | { raw: string; map?: string | null; file: string },\n options: Record = {}\n) {\n if (typeof file === \"string\") {\n const ext = file.split(\".\").pop();\n if (ext && /(js|cjs|jsx|mjs|ts|tsx)/.test(ext)) {\n if (/(ts|tsx)/.test(ext) && !options.noValidate) {\n const declarationDir = options.declarationDir;\n const emitDeclaration = !!declarationDir;\n\n const tscProgOptions = {\n basePath: process.cwd(), // always required, used for relative paths\n configFilePath: \"tsconfig.json\", // config to inherit from (optional)\n files: [file],\n include: [\"**/*.ts\", \"**/*.js\", \"**/*.tsx\", \"**/*.jsx\", \"**/*.mjs\"],\n exclude: [\"test*/**/*\", \"**/*.test.ts\", \"**/*.spec.ts\", \"dist/**\"],\n pretty: true,\n copyOtherToOutDir: false,\n clean: emitDeclaration ? [declarationDir] : [],\n ...(options.tsc || {}),\n compilerOptions: {\n rootDir: \"./\",\n outDir: \"dist\",\n noEmitOnError: true,\n noEmit: !emitDeclaration,\n declaration: emitDeclaration,\n declarationDir,\n emitDeclarationOnly: emitDeclaration,\n allowJs: true,\n esModuleInterop: true,\n inlineSourceMap: true,\n resolveJsonModule: true,\n removeComments: true,\n ...(options.tsc || {}).compilerOptions\n },\n jsxFactory: \"v\",\n jsxFragment: \"v.fragment\"\n };\n\n // eslint-disable-next-line no-console\n console.log(\"tsc\", tscProgOptions);\n\n tsc.build(tscProgOptions);\n }\n\n const esbuildOptions = {\n entryPoints: [file],\n bundle: \"bundle\" in options ? options.bundle : true,\n sourcemap: \"external\",\n write: false,\n minify: options.compact,\n outdir: \"out\",\n target: \"esnext\",\n jsxFactory: \"v\",\n jsxFragment: \"v.fragment\",\n loader: {\n \".js\": \"jsx\",\n \".cjs\": \"jsx\",\n \".mjs\": \"jsx\",\n \".ts\": \"tsx\"\n },\n ...(options.esbuild || {})\n };\n\n const result = await esbuild.build(esbuildOptions);\n if (result.outputFiles?.length !== 2) {\n throw new Error(result.errors.join(\"\\n\"));\n }\n\n if (options.compact) {\n const terser = await import(\"terser\");\n const result2 = await terser.minify(result.outputFiles[1].text, {\n sourceMap: {\n content: result.outputFiles[0].text.toString()\n },\n compress: {\n booleans_as_integers: false\n },\n output: {\n wrap_func_args: false\n },\n ecma: 2022,\n ...(options.terser || {})\n });\n\n if (!result2.code || !result2.map) {\n throw new Error(\"Unknown error\");\n }\n\n const mapBase64 = Buffer.from(result2.map.toString()).toString(\"base64\");\n const suffix = `//# sourceMappingURL=data:application/json;charset=utf-8;base64,${mapBase64}`;\n return { raw: result2.code, map: suffix, file };\n } else {\n const mapBase64 = Buffer.from(result.outputFiles[0].text.toString()).toString(\"base64\");\n const suffix = `//# sourceMappingURL=data:application/json;charset=utf-8;base64,${mapBase64}`;\n return { raw: result.outputFiles[1].text, map: suffix, file };\n }\n } else if (ext && /(css|scss|styl)/.test(ext)) {\n const result = await new CleanCSS({\n sourceMap: true,\n level: {\n 1: {\n roundingPrecision: \"all=3\"\n },\n 2: {\n restructureRules: true // controls rule restructuring; defaults to false\n }\n },\n ...(options.cleanCss || {})\n }).minify([file]);\n\n return { raw: result.styles, map: null, file };\n } else {\n return { raw: fs.readFileSync(file, \"utf8\"), map: null, file };\n }\n } else if (typeof file === \"object\" && \"raw\" in file) {\n return { map: null, ...file };\n }\n}\n\ninline.uncss = async function (\n renderedHtml: (string | Promise)[],\n css: string,\n options: Record = {}\n) {\n const html = await Promise.all(renderedHtml);\n\n const contents = html.map((item) => {\n return {\n raw: item,\n extension: \"html\"\n };\n });\n\n const purgecss = new PurgeCSS();\n\n const output = await purgecss.purge({\n fontFace: true,\n keyframes: true,\n variables: true,\n defaultExtractor: (content) => content.match(/[A-Za-z0-9-_/:@]*[A-Za-z0-9-_/:@/]+/g) || [],\n ...options,\n content: contents,\n css: [{ raw: css }]\n });\n\n const cleanCss = await new CleanCSS({\n sourceMap: false,\n level: {\n 1: {\n roundingPrecision: \"all=3\"\n },\n 2: {\n restructureRules: true // controls rule restructuring; defaults to false\n }\n },\n ...(options.cleanCss || {})\n }).minify(output[0].css);\n\n return cleanCss.styles;\n};\n", "import fs from \"fs\";\nimport path from \"path\";\n\nexport function sw(file: string, options = {}) {\n const swfiletemplate = path.resolve(__dirname, \"./node.sw.tpl\");\n const swTpl = fs.readFileSync(swfiletemplate, \"utf8\");\n const opt = Object.assign(\n {\n version: \"v1::\",\n name: \"Valyrian.js\",\n urls: [\"/\"],\n debug: false\n },\n options\n );\n let contents = swTpl\n .replace(\"v1::\", \"v\" + opt.version + \"::\")\n .replace(\"Valyrian.js\", opt.name)\n .replace(\"['/']\", '[\"' + opt.urls.join('\",\"') + '\"]');\n\n if (!opt.debug) {\n contents = contents.replace(\"console.log\", \"() => {}\");\n }\n\n fs.writeFileSync(file, contents, \"utf8\");\n}\n"], - "mappings": ";AAIO,IAAM,OAAN,MAAM,MAAqB;AAAA;AAAA,EAEhC,aAAyB,CAAC;AAAA,EAC1B,UAAkB;AAAA,EAElB;AAAA,EACA,IAAI,WAAmB;AACrB,WAAO,KAAK,SAAS,YAAY;AAAA,EACnC;AAAA,EACA,IAAI,SAAS,MAAc;AACzB,SAAK,WAAW;AAAA,EAClB;AAAA,EACA,IAAI,UAAkB;AACpB,WAAO,KAAK;AAAA,EACd;AAAA,EACA,IAAI,QAAQ,MAAc;AACxB,SAAK,WAAW;AAAA,EAClB;AAAA,EAEA;AAAA,EACA,IAAI,WAAmB;AACrB,WAAO,KAAK;AAAA,EACd;AAAA,EACA,IAAI,SAAS,MAAc;AACzB,SAAK,YAAY;AAAA,EACnB;AAAA,EAEA,aAAa;AAAA,EACb,aAAqB,CAAC;AAAA,EACtB,IAAI,YAAY,MAAM;AACpB,SAAK,aAAa,OAAO,IAAI;AAAA,EAC/B;AAAA,EACA,IAAI,cAAc;AAChB,WAAO,KAAK;AAAA,EACd;AAAA,EACA,IAAI,UAAU,MAAM;AAClB,SAAK,aAAa,OAAO,IAAI;AAAA,EAC/B;AAAA,EACA,IAAI,YAAY;AACd,WAAO,KAAK;AAAA,EACd;AAAA;AAAA,EAGA,cAA2B;AAAA,EAC3B,IAAI,aAAa;AACf,WAAO,KAAK;AAAA,EACd;AAAA,EACA,IAAI,WAAW,MAAM;AACnB,SAAK,cAAc;AAAA,EACrB;AAAA,EAEA,WAAyC,CAAC;AAAA,EAE1C,IAAI,UAAU;AACZ,WAAO,KAAK;AAAA,EACd;AAA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,CAAC,EAAE,KAAK,IAAI,CAAC;AAAA,EACpB,CAAC;AAED,QAAM,WAAW,MAAM,IAAI,SAAS;AAAA,IAClC,WAAW;AAAA,IACX,OAAO;AAAA,MACL,GAAG;AAAA,QACD,mBAAmB;AAAA,MACrB;AAAA,MACA,GAAG;AAAA,QACD,kBAAkB;AAAA;AAAA,MACpB;AAAA,IACF;AAAA,IACA,GAAI,QAAQ,YAAY,CAAC;AAAA,EAC3B,CAAC,EAAE,OAAO,OAAO,CAAC,EAAE,GAAG;AAEvB,SAAO,SAAS;AAClB;;;AC1KA,OAAOC,SAAQ;AACf,OAAO,UAAU;AAEV,SAAS,GAAG,MAAc,UAAU,CAAC,GAAG;AAC7C,QAAM,iBAAiB,KAAK,QAAQ,WAAW,eAAe;AAC9D,QAAM,QAAQA,IAAG,aAAa,gBAAgB,MAAM;AACpD,QAAM,MAAM,OAAO;AAAA,IACjB;AAAA,MACE,SAAS;AAAA,MACT,MAAM;AAAA,MACN,MAAM,CAAC,GAAG;AAAA,MACV,OAAO;AAAA,IACT;AAAA,IACA;AAAA,EACF;AACA,MAAI,WAAW,MACZ,QAAQ,QAAQ,MAAM,IAAI,UAAU,IAAI,EACxC,QAAQ,eAAe,IAAI,IAAI,EAC/B,QAAQ,SAAS,OAAO,IAAI,KAAK,KAAK,KAAK,IAAI,IAAI;AAEtD,MAAI,CAAC,IAAI,OAAO;AACd,eAAW,SAAS,QAAQ,eAAe,UAAU;AAAA,EACvD;AAEA,EAAAA,IAAG,cAAc,MAAM,UAAU,MAAM;AACzC;;;AHhBA,OAAO,WAAW;AAClB,OAAO,WAAW;AAElB,SAAS,UAAU,MAAa;AAC9B,QAAM,YAAY,MAAM;AACxB,QAAM,SAAS,MAAM,OAAO,SAAS;AACrC,UAAQ;AACR,SAAO;AACT;", - "names": ["node", "item", "document", "fs", "fs"] + "sources": ["../../lib/node/utils/tree-adapter.ts", "../../lib/node/index.ts", "../../lib/node/utils/icons.ts", "../../lib/node/utils/inline.ts", "../../lib/node/utils/sw.ts", "../../lib/node/utils/session-storage.ts"], + "sourcesContent": ["/* eslint-disable no-use-before-define */\n/* eslint-disable complexity */\ninterface ChildNodes extends Array {}\n\nexport class Node implements Node {\n // eslint-disable-next-line no-use-before-define\n childNodes: ChildNodes = [];\n baseURI: string = \"\";\n\n tag_name!: string;\n get nodeName(): string {\n return this.tag_name.toLowerCase();\n }\n set nodeName(name: string) {\n this.tag_name = name;\n }\n get tagName(): string {\n return this.tag_name;\n }\n set tagName(name: string) {\n this.tag_name = name;\n }\n\n node_type!: number;\n get nodeType(): number {\n return this.node_type;\n }\n set nodeType(type: number) {\n this.node_type = type;\n }\n\n node_value = \"\";\n attributes: Attr[] = [];\n set textContent(text) {\n this.node_value = String(text);\n }\n get textContent() {\n return this.node_value;\n }\n set nodeValue(text) {\n this.node_value = String(text);\n }\n get nodeValue() {\n return this.node_value;\n }\n\n // eslint-disable-next-line no-use-before-define\n parent_node: Node | null = null;\n get parentNode() {\n return this.parent_node;\n }\n set parentNode(node) {\n this.parent_node = node;\n }\n\n #dataset: Record = {};\n\n get dataset() {\n return this.#dataset;\n }\n\n set dataset(value) {\n this.#dataset = value;\n }\n\n constructor() {}\n\n appendChild(node: T): T {\n if (node) {\n node.parentNode && node.parentNode.removeChild(node as Node);\n this.childNodes.push(node);\n node.parentNode = this;\n }\n return node;\n }\n\n insertBefore(node: T, child: Node | null): T {\n if (node) {\n node.parentNode && node.parentNode.removeChild(node as Node);\n node.parentNode = this;\n if (child) {\n const idx = this.childNodes.indexOf(child);\n this.childNodes.splice(idx, 0, node);\n } else {\n this.childNodes.push(node);\n }\n }\n return node;\n }\n\n replaceChild(node: Node, child: T): T {\n if (node && child && child.parentNode === this) {\n this.insertBefore(node, child);\n child.parentNode && child.parentNode.removeChild(child);\n }\n return child;\n }\n removeChild(child: T): T {\n if (child && child.parentNode === this) {\n const idx = (this.childNodes as unknown as Node[]).indexOf(child);\n (this.childNodes as unknown as Node[]).splice(idx, 1);\n child.parentNode = null;\n }\n return child;\n }\n\n remove(): Node {\n return this.parentNode ? this.parentNode.removeChild(this) : this;\n }\n\n cloneNode(deep?: boolean | undefined): Node {\n if (this.nodeType === 3) {\n return new Text(this.nodeValue);\n }\n\n if (this.nodeType === 1) {\n const node = new Element();\n node.nodeType = this.nodeType;\n this.nodeName = this.nodeName;\n if (this.attributes) {\n for (let i = 0, l = this.attributes.length; i < l; i++) {\n node.setAttribute(this.attributes[i].nodeName, this.attributes[i].nodeValue);\n }\n }\n\n for (const key in this.dataset) {\n node.dataset[key] = this.dataset[key];\n }\n\n if (deep) {\n for (let i = 0, l = this.childNodes.length; i < l; i++) {\n node.appendChild(this.childNodes[i].cloneNode(deep));\n }\n }\n return node;\n }\n\n const node = new Node();\n node.nodeType = this.nodeType;\n node.nodeName = this.nodeName;\n return node;\n }\n\n setAttribute(name: string, value: any) {\n const attr = {\n nodeName: name,\n nodeValue: value\n };\n let idx = -1;\n for (let i = 0, l = this.attributes.length; i < l; i++) {\n if (this.attributes[i].nodeName === name) {\n idx = i;\n break;\n }\n }\n idx === -1 ? this.attributes.push(attr as Attr) : this.attributes.splice(idx, 1, attr as Attr);\n }\n\n getAttribute(name: string) {\n for (let i = 0, l = this.attributes.length; i < l; i++) {\n if (this.attributes[i].nodeName === name) {\n return this.attributes[i].nodeValue;\n }\n }\n }\n\n removeAttribute(name: string) {\n let idx = -1;\n for (let i = 0, l = this.attributes.length; i < l; i++) {\n if (this.attributes[i].nodeName === name) {\n idx = i;\n break;\n }\n }\n if (idx > -1) {\n this.attributes.splice(idx, 1);\n }\n }\n\n getElementById(id: string): Node | null {\n let elementFound;\n for (let i = 0, l = this.childNodes.length; i < l; i++) {\n if (this.childNodes[i].nodeType === 1) {\n if (this.childNodes[i].getAttribute(\"id\") === id) {\n elementFound = this.childNodes[i];\n break;\n }\n elementFound = this.childNodes[i].getElementById(id);\n if (elementFound) {\n break;\n }\n }\n }\n return elementFound || null;\n }\n\n // Not implemented\n // firstChild!: ChildNode | null;\n // isConnected!: boolean;\n // lastChild!: ChildNode | null;\n // nextSibling!: ChildNode | null;\n // ownerDocument!: Document | null;\n // parentElement!: HTMLElement | null;\n // previousSibling!: ChildNode | null;\n // compareDocumentPosition(other: Node): number {\n // throw new Error(\"Method not implemented.\");\n // }\n // contains(other: Node | null): boolean {\n // throw new Error(\"Method not implemented.\");\n // }\n // getRootNode(options?: GetRootNodeOptions | undefined): Node {\n // throw new Error(\"Method not implemented.\");\n // }\n // hasChildNodes(): boolean {\n // throw new Error(\"Method not implemented.\");\n // }\n // isDefaultNamespace(namespace: string | null): boolean {\n // throw new Error(\"Method not implemented.\");\n // }\n // isEqualNode(otherNode: Node | null): boolean {\n // throw new Error(\"Method not implemented.\");\n // }\n // isSameNode(otherNode: Node | null): boolean {\n // throw new Error(\"Method not implemented.\");\n // }\n // lookupNamespaceURI(prefix: string | null): string | null {\n // throw new Error(\"Method not implemented.\");\n // }\n // lookupPrefix(namespace: string | null): string | null {\n // throw new Error(\"Method not implemented.\");\n // }\n // normalize(): void {\n // throw new Error(\"Method not implemented.\");\n // }\n // ATTRIBUTE_NODE!: number;\n // CDATA_SECTION_NODE!: number;\n // COMMENT_NODE!: number;\n // DOCUMENT_FRAGMENT_NODE!: number;\n // DOCUMENT_NODE!: number;\n // DOCUMENT_POSITION_CONTAINED_BY!: number;\n // DOCUMENT_POSITION_CONTAINS!: number;\n // DOCUMENT_POSITION_DISCONNECTED!: number;\n // DOCUMENT_POSITION_FOLLOWING!: number;\n // DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC!: number;\n // DOCUMENT_POSITION_PRECEDING!: number;\n // DOCUMENT_TYPE_NODE!: number;\n // ELEMENT_NODE!: number;\n // ENTITY_NODE!: number;\n // ENTITY_REFERENCE_NODE!: number;\n // NOTATION_NODE!: number;\n // PROCESSING_INSTRUCTION_NODE!: number;\n // TEXT_NODE!: number;\n addEventListener(\n // eslint-disable-next-line no-unused-vars\n type: string,\n // eslint-disable-next-line no-unused-vars\n callback: EventListenerOrEventListenerObject | null,\n // eslint-disable-next-line no-unused-vars\n options?: boolean | AddEventListenerOptions | undefined\n ): void {\n // throw new Error(\"Method not implemented.\");\n }\n // dispatchEvent(event: Event): boolean {\n // throw new Error(\"Method not implemented.\");\n // }\n removeEventListener(\n // eslint-disable-next-line no-unused-vars\n type: string,\n // eslint-disable-next-line no-unused-vars\n callback: EventListenerOrEventListenerObject | null,\n // eslint-disable-next-line no-unused-vars\n options?: boolean | EventListenerOptions | undefined\n ): void {\n // throw new Error(\"Method not implemented.\");\n }\n}\n\nexport class Text extends Node {\n constructor(text: any) {\n super();\n this.nodeType = 3;\n this.nodeName = \"#text\";\n this.node_value = String(text);\n }\n}\n\nfunction updateElementStyles(element: Element, state: Record) {\n let str = \"\";\n for (const key in state) {\n const value = state[key];\n if (typeof value !== \"undefined\" && value !== null && String(value).length > 0) {\n str += `${key}: ${state[key]};`;\n }\n }\n if (str.length === 0) {\n element.removeAttribute(\"style\");\n } else {\n element.setAttribute(\"style\", str);\n }\n}\n\nexport class Element extends Node {\n constructor() {\n super();\n this.nodeType = 1;\n this.attributes = [];\n this.childNodes = [];\n }\n\n _style = new Proxy(\n {},\n {\n get: (state: Record, prop: string) => state[prop],\n set: (state: Record, prop: string, value: any) => {\n state[prop] = value;\n updateElementStyles(this, state);\n return true;\n },\n deleteProperty: (state: Record, prop: string) => {\n Reflect.deleteProperty(state, prop);\n updateElementStyles(this, state);\n return true;\n }\n }\n );\n\n get style() {\n return this._style as any;\n }\n\n set style(value: string) {\n if (typeof value === \"string\") {\n // should match pairs like \"color: red; font-size: 12px; background: url(http://example.com/image.png?s=1024x1024&w=is&k=20&c=ASa_AG8uP5Di7azXgJraSA6ME7fbLB0GX4YT_OzCARI=);\"\n const regex = /([^:\\s]+):\\s*((url\\([^)]+\\))|[^;]+(?=(;|$)))/g;\n let match;\n\n while ((match = regex.exec(value)) !== null) {\n this._style[match[1]] = match[2].trim();\n }\n\n return;\n }\n\n throw new Error(\"Cannot set style\");\n }\n\n get className(): string {\n return this.getAttribute(\"class\") || \"\";\n }\n\n set className(value: string | boolean) {\n if (value == null || value === false) {\n this.removeAttribute(\"class\");\n } else {\n this.setAttribute(\"class\", String(value));\n }\n }\n\n classList = {\n toggle: (item: any, force: any) => {\n if (item) {\n const classes = (this.className || \"\").split(\" \");\n const itemIndex = classes.indexOf(item);\n if (force && itemIndex === -1) {\n classes.push(item);\n }\n\n if (!force && itemIndex !== -1) {\n classes.splice(itemIndex, 1);\n }\n\n const final = classes.join(\" \").trim();\n if (final.length) {\n this.className = classes.join(\" \").trim();\n } else {\n this.className = false;\n }\n }\n }\n };\n\n get id(): string {\n return this.getAttribute(\"id\") || \"\";\n }\n\n set id(value: string | boolean) {\n if (value == null || value === false) {\n this.removeAttribute(\"id\");\n } else {\n this.setAttribute(\"id\", String(value));\n }\n }\n\n set textContent(text) {\n this.nodeValue = String(text);\n this.childNodes = this.nodeValue ? [new Text(this.nodeValue)] : [];\n }\n get textContent() {\n return this.nodeValue;\n }\n\n set innerText(text) {\n this.nodeValue = String(text);\n }\n\n get innerText() {\n return this.nodeValue;\n }\n\n get innerHTML() {\n let str = \"\";\n for (let i = 0, l = this.childNodes.length; i < l; i++) {\n // console.log(\"domToHtml\", this.childNodes[i], domToHtml(this.childNodes[i] as Element));\n str += domToHtml(this.childNodes[i] as Element);\n }\n return str;\n }\n\n set innerHTML(html) {\n this.textContent = \"\";\n const result = htmlToDom(html);\n if (result instanceof DocumentFragment) {\n for (let i = 0, l = result.childNodes.length; i < l; i++) {\n this.appendChild(result.childNodes[i]);\n }\n } else {\n this.appendChild(result);\n }\n }\n\n get outerHTML(): string {\n return domToHtml(this);\n }\n}\n\nexport class DocumentFragment extends Element {\n constructor() {\n super();\n this.nodeType = 11;\n this.nodeName = \"#document-fragment\";\n }\n}\n\nexport class Document extends Element {\n constructor() {\n super();\n this.nodeType = 9;\n this.nodeName = \"#document\";\n }\n\n createDocumentFragment(): DocumentFragment {\n return new DocumentFragment();\n }\n\n createElement(type: string) {\n const element = new Element();\n element.nodeName = type.toUpperCase();\n return element;\n }\n\n createElementNS(ns: string, type: string) {\n const element = this.createElement(type);\n element.baseURI = ns;\n return element;\n }\n\n createTextNode(text: any) {\n return new Text(text);\n }\n}\n\nconst selfClosingTags = [\n \"area\",\n \"base\",\n \"br\",\n \"col\",\n \"embed\",\n \"hr\",\n \"img\",\n \"input\",\n \"link\",\n \"meta\",\n \"param\",\n \"source\",\n \"track\",\n \"wbr\",\n \"!doctype\"\n];\n\nexport function domToHtml(dom: Element): string {\n if (dom.nodeType === 3) {\n return dom.textContent;\n }\n\n if (dom.nodeType === 1) {\n const name = dom.nodeName.toLowerCase();\n let str = \"<\" + name;\n for (let i = 0, l = dom.attributes.length; i < l; i++) {\n str += \" \" + dom.attributes[i].nodeName + '=\"' + dom.attributes[i].nodeValue + '\"';\n }\n\n if (selfClosingTags.indexOf(name) === -1) {\n str += \">\";\n if (dom.childNodes && dom.childNodes.length > 0) {\n for (let i = 0, l = dom.childNodes.length; i < l; i++) {\n const child = domToHtml(dom.childNodes[i] as Element);\n if (child) {\n str += child;\n }\n }\n }\n str += \"\";\n } else {\n str += \"/>\";\n }\n\n return str;\n }\n\n return \"\";\n}\n\nexport function domToHyperscript(childNodes: ChildNodes, depth = 1) {\n let spaces = \"\";\n for (let i = 0; i < depth; i++) {\n spaces += \" \";\n }\n\n return childNodes\n .map((item) => {\n if (item.nodeType === 10) {\n return `\\n${spaces}\"\"`;\n } else if (item.nodeType === 3) {\n return `\\n${spaces}\"${item.nodeValue}\"`;\n } else {\n let str = `\\n${spaces}v(\"${item.nodeName}\", `;\n\n if (item.attributes) {\n const attrs: Record = {};\n for (let i = 0, l = item.attributes.length; i < l; i++) {\n const attr = item.attributes[i];\n attrs[attr.nodeName] = attr.nodeValue;\n }\n str += JSON.stringify(attrs);\n } else {\n str += \"{}\";\n }\n\n str += \", [\";\n if (item.childNodes && item.childNodes.length > 0) {\n str += `${domToHyperscript(item.childNodes as unknown as Element[], depth + 1)}\\n${spaces}`;\n }\n\n str += `])`;\n return str;\n }\n })\n .join(\",\");\n}\n\ninterface ObjectIndexItem {\n tagName: string;\n startsAt: number;\n endsAt: number | null;\n contentStartsAt: number;\n contentEndsAt: number | null;\n attributes: { [key: string]: any };\n children: ObjectIndexItem[];\n nodeValue: string | null;\n}\n\ninterface ObjectIndexItemWithContent extends ObjectIndexItem {\n endsAt: number;\n contentEndsAt: number;\n children: ObjectIndexItemWithContent[];\n}\n\ninterface ObjectIndexList extends Array {}\n\nfunction findTexts(item: ObjectIndexItemWithContent, html: string) {\n const newChildren: ObjectIndexItemWithContent[] = [];\n\n // If the item has children\n if (item.children.length) {\n // Search for texts in the children.\n for (let i = 0; i < item.children.length; i++) {\n const child = item.children[i];\n const nextChild = item.children[i + 1];\n\n // If is the first child and the child startsAt is greater than the item contentStartsAt then\n // the content between the item contentStartsAt and the child startsAt is a text child of the item.\n if (i === 0 && child.startsAt > item.contentStartsAt) {\n const childContent = html.substring(item.contentStartsAt, child.startsAt);\n\n const childText: ObjectIndexItemWithContent = {\n tagName: \"#text\",\n startsAt: item.contentStartsAt,\n endsAt: item.contentStartsAt + childContent.length,\n contentStartsAt: item.contentStartsAt,\n contentEndsAt: item.contentStartsAt + childContent.length,\n attributes: {},\n children: [],\n nodeValue: childContent\n };\n\n newChildren.push(childText);\n }\n\n // Add the child to the newChildren array.\n newChildren.push(child);\n\n // If there is a next child and the child endsAt is less than the next child startsAt then\n // the content between the child endsAt and the next child startsAt is a text child of the item.\n if (nextChild && child.endsAt < nextChild.startsAt) {\n const childContent = html.substring(child.endsAt, nextChild.startsAt);\n\n const childText: ObjectIndexItemWithContent = {\n tagName: \"#text\",\n startsAt: child.endsAt,\n endsAt: child.endsAt + childContent.length,\n contentStartsAt: child.endsAt,\n contentEndsAt: child.endsAt + childContent.length,\n attributes: {},\n children: [],\n nodeValue: childContent\n };\n\n newChildren.push(childText);\n }\n\n // If there are no next child and the child endsAt is less than the item contentEndsAt then\n // the content between the child endsAt and the item contentEndsAt is a text child of the item.\n if (!nextChild && child.endsAt < item.contentEndsAt) {\n const childContent = html.substring(child.endsAt, item.contentEndsAt);\n\n const childText: ObjectIndexItemWithContent = {\n tagName: \"#text\",\n startsAt: child.endsAt,\n endsAt: child.endsAt + childContent.length,\n contentStartsAt: child.endsAt,\n contentEndsAt: item.contentEndsAt,\n attributes: {},\n children: [],\n nodeValue: childContent\n };\n\n newChildren.push(childText);\n }\n\n // Find texts in the child.\n findTexts(child, html);\n }\n }\n\n // If the item has no children then set the contents between the item contentStartsAt and the item contentEndsAt\n // as a text child of the item.\n if (!item.children.length) {\n const childContent = html.substring(item.contentStartsAt, item.contentEndsAt);\n\n if (childContent.length) {\n const childText: ObjectIndexItemWithContent = {\n tagName: \"#text\",\n startsAt: item.contentStartsAt,\n endsAt: item.contentEndsAt,\n contentStartsAt: item.contentStartsAt,\n contentEndsAt: item.contentEndsAt,\n attributes: {},\n children: [],\n nodeValue: childContent\n };\n\n newChildren.push(childText);\n }\n }\n\n item.children = newChildren;\n}\n\nfunction convertToDom(item: ObjectIndexItemWithContent): T {\n let node: T;\n\n if (item.tagName === \"#text\") {\n node = document.createTextNode(item.nodeValue as string) as unknown as T;\n } else {\n node = (item.tagName === \"#document-fragment\"\n ? document.createDocumentFragment()\n : document.createElement(item.tagName)) as unknown as T;\n\n for (const key in item.attributes) {\n node.setAttribute(key, item.attributes[key]);\n }\n\n for (let i = 0; i < item.children.length; i++) {\n const child = convertToDom(item.children[i]);\n node.appendChild(child);\n }\n }\n\n return node;\n}\n\n// eslint-disable-next-line sonarjs/cognitive-complexity\nfunction getObjectIndexTree(html: string): DocumentFragment {\n let item;\n const regex = RegExp(\"<([^>|^!]+)>\", \"g\");\n const items: ObjectIndexList = [];\n\n // Make the initial list of items.\n while ((item = regex.exec(html))) {\n // If is a closing tag\n if (item[0].startsWith(\" item.endsAt === null);\n if (lastOpenedItem) {\n lastOpenedItem.endsAt = item.index + item[0].length;\n lastOpenedItem.contentEndsAt = item.index;\n\n // Find the last opened item again, this will be the parent of the current item.\n const parent = [...items].reverse().find((item) => item.endsAt === null);\n if (parent) {\n // Find the index of the current item in the items array.\n const index = items.indexOf(lastOpenedItem);\n // Remove the last opened item from the items array.\n items.splice(index, 1);\n\n // Add the last opened item as a child of the parent.\n parent.children.push(lastOpenedItem);\n }\n }\n\n continue;\n }\n\n // If is an opening tag\n const element: ObjectIndexItem = {\n tagName: item[1].split(\" \")[0],\n startsAt: item.index,\n endsAt: null,\n contentStartsAt: item.index + item[0].length,\n contentEndsAt: null,\n attributes: {},\n children: [],\n nodeValue: null\n };\n\n // Find the attributes of the tag.\n let string = (item[1] || \"\").substring(element.tagName.length + 1).replace(/\\/$/g, \"\");\n const attributesWithValues = string.match(/\\S+=\"[^\"]+\"/g);\n\n if (attributesWithValues) {\n for (const attribute of attributesWithValues) {\n const [name, ...value] = attribute.trim().split(\"=\");\n string = string.replace(attribute, \"\");\n if (value) {\n element.attributes[name] = value.join(\"=\").replace(/(^\"|\"$)/g, \"\");\n }\n }\n }\n\n const attributesWithBooleanValues = string.match(/\\s\\S+=[^\"]+/g);\n if (attributesWithBooleanValues) {\n for (const attribute of attributesWithBooleanValues) {\n const [name, ...value] = attribute.trim().split(\"=\");\n string = string.replace(attribute, \"\");\n if (value) {\n element.attributes[name] = value.join(\"=\").replace(/(^\"|\"$)/g, \"\");\n }\n }\n }\n\n const attributesWithEmptyValues = string.match(/\\s?\\S+/g);\n if (attributesWithEmptyValues) {\n for (const attribute of attributesWithEmptyValues) {\n const name = attribute.trim();\n element.attributes[name] = true;\n }\n }\n\n // If the tag is self closing\n if (item[0].endsWith(\"/>\")) {\n element.endsAt = element.startsAt + item[0].length;\n element.contentStartsAt = element.contentEndsAt = element.endsAt;\n\n // Find the last opened item, this will be the parent of the current item.\n const parent = [...items].reverse().find((item) => item.endsAt === null);\n if (parent) {\n // Add the last opened item as a child of the parent.\n parent.children.push(element);\n continue;\n }\n }\n\n items.push(element);\n }\n\n const fragmentItem: ObjectIndexItemWithContent = {\n tagName: \"#document-fragment\",\n startsAt: 0,\n endsAt: html.length,\n contentStartsAt: 0,\n contentEndsAt: html.length,\n attributes: {},\n children: items as ObjectIndexItemWithContent[],\n nodeValue: null\n };\n\n findTexts(fragmentItem, html);\n\n return convertToDom(fragmentItem);\n}\n\n// First we create a tree of object indexes from the HTML string.\n// The resulting array is then reordered to match the order of the html string.\n// And to move the children to the correct position in its parents.\n// This resulting array is populated with a object node version of the object index.\n// If the final result have more than 1 node, then return a document fragment node.\n// If the final result have 1 node, then return the node.\n// eslint-disable-next-line complexity\nexport function htmlToDom(html: string): Element | Text | DocumentFragment {\n // Search for the opening and closing tags of the root element.\n // The opening tag could be in the middle of the string, so we need to\n // search for the first opening tag.\n const openingTag = html.match(/<[^>]+>/g);\n\n const document = new Document();\n\n // If the opening tag is not found, return a document fragment node with the html string as text content.\n if (!openingTag) {\n const documentFragment = document.createDocumentFragment();\n documentFragment.appendChild(document.createTextNode(html));\n return documentFragment;\n }\n\n const fragment = getObjectIndexTree(html);\n\n if (fragment.childNodes.length > 1) {\n return fragment;\n }\n\n return fragment.childNodes[0];\n}\n\nexport function htmlToHyperscript(html: string) {\n const domTree = htmlToDom(html);\n const hyperscript = domToHyperscript(domTree instanceof DocumentFragment ? domTree.childNodes : [domTree]);\n return `[${hyperscript}\\n]`;\n}\n\nexport const document = new Document();\n", "import { document, domToHtml, domToHyperscript, htmlToDom, htmlToHyperscript } from \"./utils/tree-adapter\";\nimport { mount, unmount } from \"valyrian.js\";\n\nimport FormData from \"form-data\";\nimport { icons } from \"./utils/icons\";\nimport { inline } from \"./utils/inline\";\nimport { sw } from \"./utils/sw\";\nimport { SessionStorage } from \"./utils/session-storage\";\n\nglobal.FormData = FormData as any;\nglobal.document = document as any;\nglobal.sessionStorage = new SessionStorage();\nglobal.localStorage = new SessionStorage();\n\nfunction render(...args: any[]) {\n const Component = () => args;\n const result = mount(\"div\", Component);\n unmount();\n return result;\n}\n\nexport { domToHtml, domToHyperscript, htmlToDom, htmlToHyperscript, inline, sw, icons, render };\n", "import fs from \"fs\";\nimport { htmlToHyperscript } from \"./tree-adapter\";\n\ninterface IconsOptions {\n iconsPath: string | null;\n linksViewPath: string | null;\n logging: boolean;\n\n // favicons options\n path: string;\n appName?: string;\n appDescription?: string;\n developerName?: string;\n developerURL?: string;\n dir?: \"auto\" | \"ltr\" | \"rtl\";\n lang?: string;\n background?: string;\n theme_color?: string;\n display?: \"browser\" | \"standalone\";\n orientation?: \"any\" | \"portrait\" | \"landscape\";\n start_url?: string;\n version?: string;\n icons: {\n android: boolean;\n appleIcon: boolean;\n appleStartup: boolean;\n coast: boolean;\n favicons: boolean;\n firefox: boolean;\n windows: boolean;\n yandex: boolean;\n };\n}\n\nexport async function icons(source: string, configuration?: IconsOptions) {\n const options = {\n ...icons.options,\n ...(configuration || {})\n };\n\n if (options.iconsPath) {\n options.iconsPath = options.iconsPath.replace(/\\/$/gi, \"\") + \"/\";\n }\n\n if (options.linksViewPath) {\n options.linksViewPath = options.linksViewPath.replace(/\\/$/gi, \"\") + \"/\";\n }\n\n const { favicons } = await import(\"favicons\");\n\n try {\n const response = await favicons(source, options);\n\n if (options.iconsPath) {\n for (const i in response.images) {\n fs.writeFileSync(options.iconsPath + response.images[i].name, response.images[i].contents);\n }\n\n for (const i in response.files) {\n fs.writeFileSync(options.iconsPath + response.files[i].name, response.files[i].contents);\n }\n }\n\n if (options.linksViewPath) {\n const html = `\n function Links(){\n return ${htmlToHyperscript(response.html.join(\"\"))};\n }\n \n Links.default = Links;\n module.exports = Links;\n `;\n\n fs.writeFileSync(`${options.linksViewPath}/links.js`, html);\n }\n } catch (err) {\n process.stdout.write((err as any).status + \"\\n\"); // HTTP error code (e.g. `200`) or `null`\n process.stdout.write((err as any).name + \"\\n\"); // Error name e.g. \"API Error\"\n process.stdout.write((err as any).message + \"\\n\"); // Error description e.g. \"An unknown error has occurred\"\n }\n}\n\nicons.options = {\n iconsPath: null,\n linksViewPath: null,\n\n // favicons options\n path: \"\",\n appName: null,\n appDescription: null,\n developerName: null,\n developerURL: null,\n dir: \"auto\",\n lang: \"en-US\",\n background: \"#fff\",\n theme_color: \"#fff\",\n display: \"standalone\",\n orientation: \"any\",\n start_url: \"/\",\n version: \"1.0\",\n logging: false,\n icons: {\n android: true,\n appleIcon: true,\n appleStartup: true,\n coast: false,\n favicons: true,\n firefox: false,\n windows: true,\n yandex: false // Create Yandex browser icon. `boolean`\n }\n} as unknown as IconsOptions;\n", "import * as tsc from \"tsc-prog\";\n\nimport CleanCSS from \"clean-css\";\nimport { PurgeCSS } from \"purgecss\";\nimport esbuild from \"esbuild\";\n/* eslint-disable sonarjs/cognitive-complexity */\nimport fs from \"fs\";\n\n// eslint-disable-next-line complexity\nexport async function inline(\n file: string | { raw: string; map?: string | null; file: string },\n options: Record = {}\n) {\n if (typeof file === \"string\") {\n const ext = file.split(\".\").pop();\n if (ext && /(js|cjs|jsx|mjs|ts|tsx)/.test(ext)) {\n if (/(ts|tsx)/.test(ext) && !options.noValidate) {\n const declarationDir = options.declarationDir;\n const emitDeclaration = !!declarationDir;\n\n const tscProgOptions = {\n basePath: process.cwd(), // always required, used for relative paths\n configFilePath: \"tsconfig.json\", // config to inherit from (optional)\n files: [file],\n include: [\"**/*.ts\", \"**/*.js\", \"**/*.tsx\", \"**/*.jsx\", \"**/*.mjs\"],\n exclude: [\"test*/**/*\", \"**/*.test.ts\", \"**/*.spec.ts\", \"dist/**\"],\n pretty: true,\n copyOtherToOutDir: false,\n clean: emitDeclaration ? [declarationDir] : [],\n ...(options.tsc || {}),\n compilerOptions: {\n rootDir: \"./\",\n outDir: \"dist\",\n noEmitOnError: true,\n noEmit: !emitDeclaration,\n declaration: emitDeclaration,\n declarationDir,\n emitDeclarationOnly: emitDeclaration,\n allowJs: true,\n esModuleInterop: true,\n inlineSourceMap: true,\n resolveJsonModule: true,\n removeComments: true,\n ...(options.tsc || {}).compilerOptions\n },\n jsxFactory: \"v\",\n jsxFragment: \"v.fragment\"\n };\n\n // eslint-disable-next-line no-console\n console.log(\"tsc\", tscProgOptions);\n\n tsc.build(tscProgOptions);\n }\n\n const esbuildOptions = {\n entryPoints: [file],\n bundle: \"bundle\" in options ? options.bundle : true,\n sourcemap: \"external\",\n write: false,\n minify: options.compact,\n outdir: \"out\",\n target: \"esnext\",\n jsxFactory: \"v\",\n jsxFragment: \"v.fragment\",\n loader: {\n \".js\": \"jsx\",\n \".cjs\": \"jsx\",\n \".mjs\": \"jsx\",\n \".ts\": \"tsx\"\n },\n ...(options.esbuild || {})\n };\n\n const result = await esbuild.build(esbuildOptions);\n if (result.outputFiles?.length !== 2) {\n throw new Error(result.errors.join(\"\\n\"));\n }\n\n if (options.compact) {\n const terser = await import(\"terser\");\n const result2 = await terser.minify(result.outputFiles[1].text, {\n sourceMap: {\n content: result.outputFiles[0].text.toString()\n },\n compress: {\n booleans_as_integers: false\n },\n output: {\n wrap_func_args: false\n },\n ecma: 2022,\n ...(options.terser || {})\n });\n\n if (!result2.code || !result2.map) {\n throw new Error(\"Unknown error\");\n }\n\n const mapBase64 = Buffer.from(result2.map.toString()).toString(\"base64\");\n const suffix = `//# sourceMappingURL=data:application/json;charset=utf-8;base64,${mapBase64}`;\n return { raw: result2.code, map: suffix, file };\n } else {\n const mapBase64 = Buffer.from(result.outputFiles[0].text.toString()).toString(\"base64\");\n const suffix = `//# sourceMappingURL=data:application/json;charset=utf-8;base64,${mapBase64}`;\n return { raw: result.outputFiles[1].text, map: suffix, file };\n }\n } else if (ext && /(css|scss|styl)/.test(ext)) {\n const result = await new CleanCSS({\n sourceMap: true,\n level: {\n 1: {\n roundingPrecision: \"all=3\"\n },\n 2: {\n restructureRules: true // controls rule restructuring; defaults to false\n }\n },\n ...(options.cleanCss || {})\n }).minify([file]);\n\n return { raw: result.styles, map: null, file };\n } else {\n return { raw: fs.readFileSync(file, \"utf8\"), map: null, file };\n }\n } else if (typeof file === \"object\" && \"raw\" in file) {\n return { map: null, ...file };\n }\n}\n\ninline.uncss = async function (\n renderedHtml: (string | Promise)[],\n css: string,\n options: Record = {}\n) {\n const html = await Promise.all(renderedHtml);\n\n const contents = html.map((item) => {\n return {\n raw: item,\n extension: \"html\"\n };\n });\n\n const purgecss = new PurgeCSS();\n\n const output = await purgecss.purge({\n fontFace: true,\n keyframes: true,\n variables: true,\n defaultExtractor: (content) => content.match(/[A-Za-z0-9-_/:@]*[A-Za-z0-9-_/:@/]+/g) || [],\n ...options,\n content: contents,\n css: [{ raw: css }]\n });\n\n const cleanCss = await new CleanCSS({\n sourceMap: false,\n level: {\n 1: {\n roundingPrecision: \"all=3\"\n },\n 2: {\n restructureRules: true // controls rule restructuring; defaults to false\n }\n },\n ...(options.cleanCss || {})\n }).minify(output[0].css);\n\n return cleanCss.styles;\n};\n", "import fs from \"fs\";\nimport path from \"path\";\n\nexport function sw(file: string, options = {}) {\n const swfiletemplate = path.resolve(__dirname, \"./node.sw.tpl\");\n const swTpl = fs.readFileSync(swfiletemplate, \"utf8\");\n const opt = Object.assign(\n {\n version: \"v1::\",\n name: \"Valyrian.js\",\n urls: [\"/\"],\n debug: false\n },\n options\n );\n let contents = swTpl\n .replace(\"v1::\", \"v\" + opt.version + \"::\")\n .replace(\"Valyrian.js\", opt.name)\n .replace(\"['/']\", '[\"' + opt.urls.join('\",\"') + '\"]');\n\n if (!opt.debug) {\n contents = contents.replace(\"console.log\", \"() => {}\");\n }\n\n fs.writeFileSync(file, contents, \"utf8\");\n}\n", "import fs from \"fs\";\nimport path from \"path\";\n\nexport class SessionStorage {\n private storage: { [key: string]: string };\n private limit: number;\n private persist: boolean;\n private filePath: string;\n private directory: string = \".session-storage\";\n\n constructor({ persist = false, filePath = \"./sessionData.json\" }: { persist?: boolean; filePath?: string } = {}) {\n this.storage = {};\n this.limit = 5 * 1024 * 1024; // 5MB storage limit\n this.persist = persist;\n this.filePath = path.resolve(this.directory, filePath);\n\n if (!fs.existsSync(this.directory)) {\n fs.mkdirSync(this.directory, { recursive: true });\n }\n\n // Load data from file if persistence is enabled\n if (this.persist) {\n this.loadFromFile();\n }\n }\n\n // Calculate total size in bytes of stored data\n private getStorageSize(): number {\n return new TextEncoder().encode(JSON.stringify(this.storage)).length;\n }\n\n // Check if storage limit is exceeded\n private checkSizeLimit(): void {\n const size = this.getStorageSize();\n if (size > this.limit) {\n throw new DOMException(\"Storage limit exceeded\", \"QuotaExceededError\");\n }\n }\n\n // Store value under the specified key\n setItem(key: string | null | undefined, value: string | null | undefined): void {\n if (key === null || key === undefined) {\n throw new TypeError(\"Failed to execute 'setItem' on 'Storage': 1 argument required, but only 0 present.\");\n }\n\n if (value === null) {\n value = \"null\"; // Convert null to \"null\"\n } else if (value === undefined) {\n value = \"undefined\"; // Convert undefined to \"undefined\"\n }\n\n this.storage[key] = String(value); // Store as string\n this.checkSizeLimit(); // Check storage limit\n if (this.persist) {\n this.saveToFile(); // Save to file if persistence is enabled\n }\n }\n\n // Retrieve value stored under the specified key\n getItem(key: string | null | undefined): string | null {\n if (key === null || key === undefined) {\n throw new TypeError(\"Failed to execute 'getItem' on 'Storage': 1 argument required, but only 0 present.\");\n }\n return this.storage[key] || null; // Return null if key doesn't exist\n }\n\n // Remove the value under the specified key\n removeItem(key: string | null | undefined): void {\n if (key === null || key === undefined) {\n throw new TypeError(\"Failed to execute 'removeItem' on 'Storage': 1 argument required, but only 0 present.\");\n }\n delete this.storage[key];\n if (this.persist) {\n this.saveToFile(); // Save to file if persistence is enabled\n }\n }\n\n // Clear all stored values\n clear(): void {\n this.storage = {};\n if (this.persist) {\n this.saveToFile(); // Save to file if persistence is enabled\n }\n }\n\n // Return the number of stored items\n get length(): number {\n return Object.keys(this.storage).length;\n }\n\n // Return the key at the specified index\n key(index: number): string | null {\n const keys = Object.keys(this.storage);\n return keys[index] || null;\n }\n\n // Save data to a file (only if persistence is enabled)\n private saveToFile(): void {\n try {\n fs.writeFileSync(this.filePath, JSON.stringify(this.storage), \"utf-8\");\n } catch (error) {\n throw new Error(`Error saving data to file: ${(error as any).message}`);\n }\n }\n\n // Load data from a file (only if persistence is enabled)\n private loadFromFile(): void {\n try {\n if (fs.existsSync(this.filePath)) {\n const data = fs.readFileSync(this.filePath, \"utf-8\");\n this.storage = JSON.parse(data || \"{}\");\n }\n } catch (error) {\n throw new Error(`Error loading data from file: ${(error as any).message}`);\n }\n }\n}\n"], + "mappings": ";AAIO,IAAM,OAAN,MAAM,MAAqB;AAAA;AAAA,EAEhC,aAAyB,CAAC;AAAA,EAC1B,UAAkB;AAAA,EAElB;AAAA,EACA,IAAI,WAAmB;AACrB,WAAO,KAAK,SAAS,YAAY;AAAA,EACnC;AAAA,EACA,IAAI,SAAS,MAAc;AACzB,SAAK,WAAW;AAAA,EAClB;AAAA,EACA,IAAI,UAAkB;AACpB,WAAO,KAAK;AAAA,EACd;AAAA,EACA,IAAI,QAAQ,MAAc;AACxB,SAAK,WAAW;AAAA,EAClB;AAAA,EAEA;AAAA,EACA,IAAI,WAAmB;AACrB,WAAO,KAAK;AAAA,EACd;AAAA,EACA,IAAI,SAAS,MAAc;AACzB,SAAK,YAAY;AAAA,EACnB;AAAA,EAEA,aAAa;AAAA,EACb,aAAqB,CAAC;AAAA,EACtB,IAAI,YAAY,MAAM;AACpB,SAAK,aAAa,OAAO,IAAI;AAAA,EAC/B;AAAA,EACA,IAAI,cAAc;AAChB,WAAO,KAAK;AAAA,EACd;AAAA,EACA,IAAI,UAAU,MAAM;AAClB,SAAK,aAAa,OAAO,IAAI;AAAA,EAC/B;AAAA,EACA,IAAI,YAAY;AACd,WAAO,KAAK;AAAA,EACd;AAAA;AAAA,EAGA,cAA2B;AAAA,EAC3B,IAAI,aAAa;AACf,WAAO,KAAK;AAAA,EACd;AAAA,EACA,IAAI,WAAW,MAAM;AACnB,SAAK,cAAc;AAAA,EACrB;AAAA,EAEA,WAAyC,CAAC;AAAA,EAE1C,IAAI,UAAU;AACZ,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,IAAI,QAAQ,OAAO;AACjB,SAAK,WAAW;AAAA,EACl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I,KAAK,SAAS;AAChB,WAAK,WAAW;AAAA,IAClB;AAAA,EACF;AAAA;AAAA,EAGA,IAAI,SAAiB;AACnB,WAAO,OAAO,KAAK,KAAK,OAAO,EAAE;AAAA,EACnC;AAAA;AAAA,EAGA,IAAI,OAA8B;AAChC,UAAM,OAAO,OAAO,KAAK,KAAK,OAAO;AACrC,WAAO,KAAK,KAAK,KAAK;AAAA,EACxB;AAAA;AAAA,EAGQ,aAAmB;AACzB,QAAI;AACF,MAAAA,IAAG,cAAc,KAAK,UAAU,KAAK,UAAU,KAAK,OAAO,GAAG,OAAO;AAAA,IACvE,SAAS,OAAO;AACd,YAAM,IAAI,MAAM,8BAA+B,MAAc,OAAO,EAAE;AAAA,IACxE;AAAA,EACF;AAAA;AAAA,EAGQ,eAAqB;AAC3B,QAAI;AACF,UAAIA,IAAG,WAAW,KAAK,QAAQ,GAAG;AAChC,cAAM,OAAOA,IAAG,aAAa,KAAK,UAAU,OAAO;AACnD,aAAK,UAAU,KAAK,MAAM,QAAQ,IAAI;AAAA,MACxC;AAAA,IACF,SAAS,OAAO;AACd,YAAM,IAAI,MAAM,iCAAkC,MAAc,OAAO,EAAE;AAAA,IAC3E;AAAA,EACF;AACF;;;AJ3GA,OAAO,WAAW;AAClB,OAAO,WAAW;AAClB,OAAO,iBAAiB,IAAI,eAAe;AAC3C,OAAO,eAAe,IAAI,eAAe;AAEzC,SAAS,UAAU,MAAa;AAC9B,QAAM,YAAY,MAAM;AACxB,QAAM,SAAS,MAAM,OAAO,SAAS;AACrC,UAAQ;AACR,SAAO;AACT;", + "names": ["node", "item", "document", "fs", "fs", "fs", "path"] } diff --git a/dist/node/utils/session-storage.d.ts b/dist/node/utils/session-storage.d.ts new file mode 100644 index 0000000..ed3db1d --- /dev/null +++ b/dist/node/utils/session-storage.d.ts @@ -0,0 +1,22 @@ +export declare class SessionStorage { + private storage; + private limit; + private persist; + private filePath; + private directory; + constructor({ persist, filePath }?: { + persist?: boolean; + filePath?: string; + }); + private getStorageSize; + private checkSizeLimit; + setItem(key: string | null | undefined, value: string | null | undefined): void; + getItem(key: string | null | undefined): string | null; + removeItem(key: string | null | undefined): void; + clear(): void; + get length(): number; + key(index: number): string | null; + private saveToFile; + private loadFromFile; +} +//# sourceMappingURL=session-storage.d.ts.map \ No newline at end of file diff --git a/dist/node/utils/session-storage.d.ts.map b/dist/node/utils/session-storage.d.ts.map new file mode 100644 index 0000000..6a9cd30 --- /dev/null +++ b/dist/node/utils/session-storage.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"session-storage.d.ts","sourceRoot":"","sources":["../../../lib/node/utils/session-storage.ts"],"names":[],"mappings":"AAGA,qBAAa,cAAc;IACzB,OAAO,CAAC,OAAO,CAA4B;IAC3C,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,OAAO,CAAU;IACzB,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,SAAS,CAA8B;gBAEnC,EAAE,OAAe,EAAE,QAA+B,EAAE,GAAE;QAAE,OAAO,CAAC,EAAE,OAAO,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAO;IAiB/G,OAAO,CAAC,cAAc;IAKtB,OAAO,CAAC,cAAc;IAQtB,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,IAAI;IAmB/E,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI;IAQtD,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,IAAI;IAWhD,KAAK,IAAI,IAAI;IAQb,IAAI,MAAM,IAAI,MAAM,CAEnB;IAGD,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IAMjC,OAAO,CAAC,UAAU;IASlB,OAAO,CAAC,YAAY;CAUrB"} \ No newline at end of file diff --git a/dist/translate/index.d.ts b/dist/translate/index.d.ts index adaac36..4cc5904 100644 --- a/dist/translate/index.d.ts +++ b/dist/translate/index.d.ts @@ -1,19 +1,19 @@ -interface TInterface { - (path: string, params?: Record): string; -} -export declare function setTranslations(defaultTranslation: Record, newTranslations: Record>): TInterface; +export declare function t(path: string, params?: Record): string; +export declare function setTranslations(defaultTranslation: Record, newTranslations: Record>): void; +export declare function getTranslations(): Record>; export declare function setLang(newLang: string): void; +export declare function getLang(): string; export declare class NumberFormatter { #private; get value(): number; + private constructor(); set(newValue: number | string, shiftDecimal?: boolean): this; private clean; - format(digits?: number): string; + format(digits?: number, options?: Intl.NumberFormatOptions, customLocale?: Intl.LocalesArgument): string; fromDecimalPlaces(decimalPlaces: number): this; toDecimalPlaces(decimalPlaces: number): this; getDecimalPlaces(): number; - shiftDecimal(): this; + shiftDecimalPlaces(): this; static create(value?: number | string, shiftDecimal?: boolean): NumberFormatter; } -export {}; //# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/dist/translate/index.d.ts.map b/dist/translate/index.d.ts.map index be16917..4f1928e 100644 --- a/dist/translate/index.d.ts.map +++ b/dist/translate/index.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../lib/translate/index.ts"],"names":[],"mappings":"AAMA,UAAU,UAAU;IAClB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAAC;CACzD;AAsBD,wBAAgB,eAAe,CAC7B,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACvC,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,GACnD,UAAU,CAaZ;AAED,wBAAgB,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAmB7C;AAED,qBAAa,eAAe;;IAG1B,IAAI,KAAK,IAAI,MAA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,CAAC,aAAa,EAAE,MAAM;IAQvC,eAAe,CAAC,aAAa,EAAE,MAAM;IAOrC,gBAAgB,IAAI,MAAM;IAU1B,kBAAkB;IAIlB,MAAM,CAAC,MAAM,CAAC,KAAK,GAAE,MAAM,GAAG,MAAU,EAAE,YAAY,UAAQ,GAAG,eAAe;CAIjF"} \ No newline at end of file diff --git a/lib/native-store/index.ts b/lib/native-store/index.ts index 7592bea..9043e43 100644 --- a/lib/native-store/index.ts +++ b/lib/native-store/index.ts @@ -1,3 +1,11 @@ +import { isNodeJs } from "valyrian.js"; + +/* eslint-disable no-console */ +export enum StorageType { + Session = "session", + Local = "local" +} + export interface NativeStorageInterface { state: Record; set(key: string, value: any): void; @@ -7,15 +15,25 @@ export interface NativeStorageInterface { clear(): void; } -const nativeStore = sessionStorage || localStorage; - const ids = new Set(); +function getStorage(storageType: StorageType) { + if (isNodeJs && typeof localStorage === "undefined") { + throw new Error( + `localStorage and sessionStorage are not available in Node.js, to use it in your project, you need to "import "valyrian.js/node"` + ); + } + return storageType === StorageType.Session ? sessionStorage : localStorage; +} + export function createNativeStore( key: string, definition: Record = {}, + storageType: StorageType = StorageType.Local, reuseIfExist = false ): NativeStorageInterface & T { + const nativeStore = getStorage(storageType); + if (ids.has(key)) { if (reuseIfExist) { // eslint-disable-next-line no-console @@ -25,34 +43,54 @@ export function createNativeStore( } } ids.add(key); + + const id = key; + const Store: NativeStorageInterface = { state: {}, set(key, value) { - this.state[key] = value; - nativeStore.setItem(key, JSON.stringify(this.state)); + try { + this.state[key] = value; + nativeStore.setItem(id, JSON.stringify(this.state)); + } catch (e) { + console.error("Error setting item in storage:", e); + } }, get(key) { - if (!this.state) { + if (Object.keys(this.state).length === 0) { this.load(); } return this.state[key]; }, delete(key) { - Reflect.deleteProperty(this.state, key); - nativeStore.setItem(key, JSON.stringify(this.state)); + try { + Reflect.deleteProperty(this.state, key); + nativeStore.setItem(id, JSON.stringify(this.state)); + } catch (e) { + console.error("Error deleting item in storage:", e); + } }, load() { - const state = nativeStore.getItem(key); - if (!state) { + try { + const state = nativeStore.getItem(id); + if (!state) { + this.state = {}; + nativeStore.setItem(id, JSON.stringify(this.state)); + return; + } + this.state = JSON.parse(state); + } catch (e) { + console.error("Error loading state from storage:", e); this.state = {}; - nativeStore.setItem(key, JSON.stringify(this.state)); - return; } - this.state = JSON.parse(state); }, clear() { - this.state = {}; - nativeStore.removeItem(key); + try { + this.state = {}; + nativeStore.removeItem(id); + } catch (e) { + console.error("Error clearing storage:", e); + } }, ...definition }; diff --git a/lib/node/index.ts b/lib/node/index.ts index 9e6372f..5348592 100644 --- a/lib/node/index.ts +++ b/lib/node/index.ts @@ -2,13 +2,15 @@ import { document, domToHtml, domToHyperscript, htmlToDom, htmlToHyperscript } f import { mount, unmount } from "valyrian.js"; import FormData from "form-data"; -// import fetch from "node-fetch"; import { icons } from "./utils/icons"; import { inline } from "./utils/inline"; import { sw } from "./utils/sw"; +import { SessionStorage } from "./utils/session-storage"; global.FormData = FormData as any; global.document = document as any; +global.sessionStorage = new SessionStorage(); +global.localStorage = new SessionStorage(); function render(...args: any[]) { const Component = () => args; diff --git a/lib/node/utils/session-storage.ts b/lib/node/utils/session-storage.ts new file mode 100644 index 0000000..a4e4746 --- /dev/null +++ b/lib/node/utils/session-storage.ts @@ -0,0 +1,117 @@ +import fs from "fs"; +import path from "path"; + +export class SessionStorage { + private storage: { [key: string]: string }; + private limit: number; + private persist: boolean; + private filePath: string; + private directory: string = ".session-storage"; + + constructor({ persist = false, filePath = "./sessionData.json" }: { persist?: boolean; filePath?: string } = {}) { + this.storage = {}; + this.limit = 5 * 1024 * 1024; // 5MB storage limit + this.persist = persist; + this.filePath = path.resolve(this.directory, filePath); + + if (!fs.existsSync(this.directory)) { + fs.mkdirSync(this.directory, { recursive: true }); + } + + // Load data from file if persistence is enabled + if (this.persist) { + this.loadFromFile(); + } + } + + // Calculate total size in bytes of stored data + private getStorageSize(): number { + return new TextEncoder().encode(JSON.stringify(this.storage)).length; + } + + // Check if storage limit is exceeded + private checkSizeLimit(): void { + const size = this.getStorageSize(); + if (size > this.limit) { + throw new DOMException("Storage limit exceeded", "QuotaExceededError"); + } + } + + // Store value under the specified key + setItem(key: string | null | undefined, value: string | null | undefined): void { + if (key === null || key === undefined) { + throw new TypeError("Failed to execute 'setItem' on 'Storage': 1 argument required, but only 0 present."); + } + + if (value === null) { + value = "null"; // Convert null to "null" + } else if (value === undefined) { + value = "undefined"; // Convert undefined to "undefined" + } + + this.storage[key] = String(value); // Store as string + this.checkSizeLimit(); // Check storage limit + if (this.persist) { + this.saveToFile(); // Save to file if persistence is enabled + } + } + + // Retrieve value stored under the specified key + getItem(key: string | null | undefined): string | null { + if (key === null || key === undefined) { + throw new TypeError("Failed to execute 'getItem' on 'Storage': 1 argument required, but only 0 present."); + } + return this.storage[key] || null; // Return null if key doesn't exist + } + + // Remove the value under the specified key + removeItem(key: string | null | undefined): void { + if (key === null || key === undefined) { + throw new TypeError("Failed to execute 'removeItem' on 'Storage': 1 argument required, but only 0 present."); + } + delete this.storage[key]; + if (this.persist) { + this.saveToFile(); // Save to file if persistence is enabled + } + } + + // Clear all stored values + clear(): void { + this.storage = {}; + if (this.persist) { + this.saveToFile(); // Save to file if persistence is enabled + } + } + + // Return the number of stored items + get length(): number { + return Object.keys(this.storage).length; + } + + // Return the key at the specified index + key(index: number): string | null { + const keys = Object.keys(this.storage); + return keys[index] || null; + } + + // Save data to a file (only if persistence is enabled) + private saveToFile(): void { + try { + fs.writeFileSync(this.filePath, JSON.stringify(this.storage), "utf-8"); + } catch (error) { + throw new Error(`Error saving data to file: ${(error as any).message}`); + } + } + + // Load data from a file (only if persistence is enabled) + private loadFromFile(): void { + try { + if (fs.existsSync(this.filePath)) { + const data = fs.readFileSync(this.filePath, "utf-8"); + this.storage = JSON.parse(data || "{}"); + } + } catch (error) { + throw new Error(`Error loading data from file: ${(error as any).message}`); + } + } +} diff --git a/package-lock.json b/package-lock.json index 13e2576..d1a0720 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19,7 +19,8 @@ "ts-node": "^10.9.1", "tsc-prog": "^2.3.0", "tslib": "^2.6.2", - "typescript": "^5.2.2" + "typescript": "^5.2.2", + "valyrian.js": "^7.2.12" }, "devDependencies": { "@release-it/conventional-changelog": "^7.0.2", @@ -14252,6 +14253,31 @@ "spdx-expression-parse": "^3.0.0" } }, + "node_modules/valyrian.js": { + "version": "7.2.12", + "resolved": "https://registry.npmjs.org/valyrian.js/-/valyrian.js-7.2.12.tgz", + "integrity": "sha512-Ww8kcj9QaLBgQ/giX7+uto814z0+PWb++AzkOKdcVH3Hqj44MqPiEQv7gZK1Xg1thLUsqxPOVygCG+2x5TFYpw==", + "license": "Apache-2.0", + "dependencies": { + "clean-css": "^5.3.2", + "esbuild": "^0.19.3", + "favicons": "^7.1.4", + "form-data": "^4.0.0", + "purgecss": "^5.0.0", + "remark": "^15.0.1", + "terser": "^5.20.0", + "ts-node": "^10.9.1", + "tsc-prog": "^2.3.0", + "tslib": "^2.6.2", + "typescript": "^5.2.2" + }, + "engines": { + "node": ">=18.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/Masquerade-Circus" + } + }, "node_modules/vary": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", diff --git a/package.json b/package.json index c8e10f7..01836b7 100644 --- a/package.json +++ b/package.json @@ -213,4 +213,4 @@ ] } } -} \ No newline at end of file +} diff --git a/test/native-storage_test.js b/test/native-storage_test.js new file mode 100644 index 0000000..df0e491 --- /dev/null +++ b/test/native-storage_test.js @@ -0,0 +1,88 @@ +import { describe, it, beforeEach } from "mocha"; +import { expect } from "expect"; +import "valyrian.js/node"; +import { createNativeStore, StorageType } from "valyrian.js/native-store"; + +describe("NativeStore Tests", () => { + beforeEach(() => { + localStorage.clear(); + sessionStorage.clear(); + }); + + it("should create a store using localStorage with an empty state", () => { + const store = createNativeStore("testLocal", {}, StorageType.Local); + expect(store.state).toEqual({}); + }); + + it("should create a store using sessionStorage with an empty state", () => { + const store = createNativeStore("testSession", {}, StorageType.Session); + expect(store.state).toEqual({}); + }); + + it("should reuse an existing store if reuseIfExist is true", () => { + const store1 = createNativeStore("reuseTest", {}, StorageType.Local); + store1.set("key", "value"); + + const store2 = createNativeStore("reuseTest", {}, StorageType.Local, true); + expect(store2.get("key")).toEqual("value"); + }); + + it("should throw an error if a store with the same key exists and reuseIfExist is false", () => { + createNativeStore("testDuplicate", {}, StorageType.Local); + expect(() => createNativeStore("testDuplicate", {}, StorageType.Local, false)).toThrowError(); + }); + + it("should store a value in localStorage", () => { + const store = createNativeStore("testLocalStorage", {}, StorageType.Local); + store.set("key1", "value1"); + expect(localStorage.getItem("testLocalStorage")).toEqual(JSON.stringify({ key1: "value1" })); + }); + + it("should store a value in sessionStorage", () => { + const store = createNativeStore("testSessionStorage", {}, StorageType.Session); + store.set("key1", "value1"); + expect(sessionStorage.getItem("testSessionStorage")).toEqual(JSON.stringify({ key1: "value1" })); + }); + + it("should retrieve a value from localStorage", () => { + const store = createNativeStore("testRetrieveLocal", {}, StorageType.Local); + store.set("key", "value"); + const retrieved = store.get("key"); + expect(retrieved).toEqual("value"); + }); + + it("should retrieve a value from sessionStorage", () => { + const store = createNativeStore("testRetrieveSession", {}, StorageType.Session); + store.set("key", "value"); + const retrieved = store.get("key"); + expect(retrieved).toEqual("value"); + }); + + it("should delete a value from localStorage", () => { + const store = createNativeStore("testDeleteLocal", {}, StorageType.Local); + store.set("key", "value"); + store.delete("key"); + expect(localStorage.getItem("testDeleteLocal")).toEqual(JSON.stringify({})); + }); + + it("should delete a value from sessionStorage", () => { + const store = createNativeStore("testDeleteSession", {}, StorageType.Session); + store.set("key", "value"); + store.delete("key"); + expect(sessionStorage.getItem("testDeleteSession")).toEqual(JSON.stringify({})); + }); + + it("should clear the store in localStorage", () => { + const store = createNativeStore("testClearLocal", {}, StorageType.Local); + store.set("key", "value"); + store.clear(); + expect(localStorage.getItem("testClearLocal")).toEqual(null); + }); + + it("should clear the store in sessionStorage", () => { + const store = createNativeStore("testClearSession", {}, StorageType.Session); + store.set("key", "value"); + store.clear(); + expect(sessionStorage.getItem("testClearSession")).toEqual(null); + }); +});