@design-edito/tools 0.0.27 → 0.0.29
Sign up to get free protection for your applications and to get access to all the features.
- package/chunks/{chunk-LCBMRJKP.js → chunk-EFFU6KXJ.js} +1 -1
- package/chunks/{chunk-CF6GPH7Z.js → chunk-LCLAV6Q2.js} +1 -1
- package/index.js +2 -4
- package/package.json +1 -1
- package/utils/agnostic/array-random-pick/index.d.ts +3 -1
- package/utils/agnostic/array-random-pick/index.js +1 -1
- package/utils/agnostic/clientside-html-sanitizer/index.js +1 -1
- package/utils/agnostic/{detect-runtime → crossenv}/index.d.ts +2 -1
- package/utils/agnostic/crossenv/index.js +1 -0
- package/utils/agnostic/selector-to-element/index.js +1 -1
- package/utils/agnostic/str-to-nodes/index.js +1 -1
- package/chunks/chunk-AFA3GSXO.js +0 -1
- package/utils/agnostic/detect-runtime/index.js +0 -1
- package/utils/agnostic/get-document/index.d.ts +0 -1
- package/utils/agnostic/get-document/index.js +0 -1
@@ -1 +1 @@
|
|
1
|
-
import{
|
1
|
+
import{c as N}from"./chunk-LCLAV6Q2.js";var E={depth:20};async function z(d,o=E){let l=(o.documentObj??await N()).createElement("div"),{inputFreeTransform:a}=o;return l.innerHTML=a!==void 0?a(d):d,y(l,o)?.innerHTML??""}function y(d,o=E){let{tagName:e,attributes:l,childNodes:a}=d,{allowedTags:g=[],allowedAttributes:b={},forbiddenTags:m=[],forbiddenAttributes:A={},depth:w=20,verbose:s=!1}=o;if(w<=0)return console.warn("Max depth reached"),null;let f=e.toLowerCase().trim();if(m.includes("*")||m.includes(f))return s===!0&&console.warn(e,"tag is forbidden"),null;if(!(g.includes("*")||g.includes(f)))return s===!0&&console.warn(e,"tag is not allowed"),null;let p=document.createElement(e);Array.from(l).filter(({name:t,value:i})=>{let I=A["*"]??[],O=A[f]??[];if([...I,...O].some(({attributeName:r,attributeValues:u})=>typeof r=="string"&&r!=="*"&&t!==r||typeof r!="string"&&!r.test(t)?!1:u===void 0||u.includes("*")?(s===!0&&console.warn(t,"attribute on",e,"tag is forbidden"),!0):u.some(n=>typeof n=="string"&&i===n||typeof n!="string"&&n.test(i)?(s===!0&&console.warn(i,"value for",t,"attribute on",e,"tag is forbidden. Rule:",n),!0):!1)))return!1;let F=b["*"]??[],P=b[f]??[],x=[...F,...P],c=[e,"has no allowed attributes"];return x.some(({attributeName:r,attributeValues:u})=>typeof r=="string"&&r!=="*"&&t!==r?(c=[t,"attribute on",e,"tag is not allowed"],!1):typeof r!="string"&&!r.test(t)?(c=[t,"attribute on",e,"tag is not allowed"],!1):u===void 0||u.includes("*")?!0:u.some(n=>typeof n=="string"&&i===n||typeof n!="string"&&n.test(i)?!0:(c=[i,"value for",t,"attribute on",e,"tag is not allowed"],!1)))?!0:(s===!0&&console.warn(...c),!1)}).forEach(({name:t,value:i})=>{p.setAttribute(t,i)});let h=Array.from(a).map(t=>t.nodeType===Node.ELEMENT_NODE?y(t,{...o,depth:w-1}):t.nodeType===Node.TEXT_NODE||o.keepComments===!0&&t.nodeType===Node.COMMENT_NODE?t:null).filter(t=>t!==null);return p.replaceChildren(...h),p}export{E as a,z as b,y as c};
|
@@ -1 +1 @@
|
|
1
|
-
var
|
1
|
+
var t=(e=>(e.NODE="Node.js",e.BROWSER="Browser",e.DENO="Deno",e.REACT_NATIVE="React Native",e.ELECTRON="Electron",e.CLOUDFLARE="Cloudflare Workers",e.AWS_LAMBDA="AWS Lambda",e))(t||{});function o(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"?"Node.js":typeof window<"u"&&typeof window.document<"u"?"Browser":typeof Deno<"u"?"Deno":typeof process<"u"&&typeof navigator.userAgent=="string"&&/ReactNative/.test(navigator.userAgent)?"React Native":typeof process<"u"&&typeof process.versions<"u"&&typeof process.version.electron<"u"?"Electron":typeof self<"u"&&typeof self.addEventListener=="function"&&typeof Headers<"u"?"Cloudflare Workers":typeof AWS<"u"&&typeof AWS.Lambda<"u"?"AWS Lambda":null}async function u(){let n=o();return["Browser","Electron"].includes(n)?window.document:new(await import("jsdom")).JSDOM().window.document}export{t as a,o as b,u as c};
|
package/index.js
CHANGED
@@ -6,12 +6,11 @@ import * as cast from './utils/agnostic/cast/index.js'
|
|
6
6
|
import * as charcodeString from './utils/agnostic/charcode-string/index.js'
|
7
7
|
import * as clamp from './utils/agnostic/clamp/index.js'
|
8
8
|
import * as clientsideHtmlSanitizer from './utils/agnostic/clientside-html-sanitizer/index.js'
|
9
|
-
import * as
|
9
|
+
import * as crossenv from './utils/agnostic/crossenv/index.js'
|
10
10
|
import * as findDuplicatesInArray from './utils/agnostic/find-duplicates-in-array/index.js'
|
11
11
|
import * as flattenGetters from './utils/agnostic/flatten-getters/index.js'
|
12
12
|
import * as generateHtmlPlaceholders from './utils/agnostic/generate-html-placeholders/index.js'
|
13
13
|
import * as generateNiceColor from './utils/agnostic/generate-nice-color/index.js'
|
14
|
-
import * as getDocument from './utils/agnostic/get-document/index.js'
|
15
14
|
import * as insertNode from './utils/agnostic/insert-node/index.js'
|
16
15
|
import * as interpolate from './utils/agnostic/interpolate/index.js'
|
17
16
|
import * as isArrayOf from './utils/agnostic/is-array-of/index.js'
|
@@ -49,12 +48,11 @@ export { cast }
|
|
49
48
|
export { charcodeString }
|
50
49
|
export { clamp }
|
51
50
|
export { clientsideHtmlSanitizer }
|
52
|
-
export {
|
51
|
+
export { crossenv }
|
53
52
|
export { findDuplicatesInArray }
|
54
53
|
export { flattenGetters }
|
55
54
|
export { generateHtmlPlaceholders }
|
56
55
|
export { generateNiceColor }
|
57
|
-
export { getDocument }
|
58
56
|
export { insertNode }
|
59
57
|
export { interpolate }
|
60
58
|
export { isArrayOf }
|
package/package.json
CHANGED
@@ -1 +1 @@
|
|
1
|
-
function
|
1
|
+
var f=Symbol();function a(t,e=[]){let r=[...t].filter(l=>!e.includes(l)),o=r.length;if(o===0)return f;let n=Math.floor(Math.random()*o);return r[n]}export{a as default,f as errorSybol};
|
@@ -1 +1 @@
|
|
1
|
-
import{a,b,c}from"../../../chunks/chunk-
|
1
|
+
import{a,b,c}from"../../../chunks/chunk-EFFU6KXJ.js";import"../../../chunks/chunk-LCLAV6Q2.js";export{b as default,a as defaultOptions,c as sanitizeElement};
|
@@ -7,4 +7,5 @@ export declare enum RuntimeName {
|
|
7
7
|
CLOUDFLARE = "Cloudflare Workers",
|
8
8
|
AWS_LAMBDA = "AWS Lambda"
|
9
9
|
}
|
10
|
-
export
|
10
|
+
export declare function detectRuntime(): RuntimeName | null;
|
11
|
+
export declare function getDocument(): Promise<Document>;
|
@@ -0,0 +1 @@
|
|
1
|
+
import{a,b,c}from"../../../chunks/chunk-LCLAV6Q2.js";export{a as RuntimeName,b as detectRuntime,c as getDocument};
|
@@ -1 +1 @@
|
|
1
|
-
import{
|
1
|
+
import{c as o}from"../../../chunks/chunk-LCLAV6Q2.js";async function x(e,m){let i=m??await o(),l=/^[A-Za-z]+/,d=/#[A-Za-z]+[\w\-\:]*/,r=/\.[A-Za-z]+[\w\-]*/,u=/\[[A-Za-z]+[\w\-]*(="[\w\-]+")?\]/,a=e.match(l)??[],n=e.match(d)??[],p=e.match(r)??[],g=e.match(u)??[],h=a[a.length-1]??"div",s=n[n.length-1]??null,f=p.map(t=>t.replace(/^\./,"")),A=g.map(t=>t.replace(/^\[/,"").replace(/\]$/,"").split("=")),c=i.createElement(h);return s!==null&&(c.id=s),c.classList.add(...f),A.forEach(([t,w=""])=>{t!==void 0&&c.setAttribute(t,w)}),c}export{x as default};
|
@@ -1 +1 @@
|
|
1
|
-
import{b as i}from"../../../chunks/chunk-
|
1
|
+
import{b as i}from"../../../chunks/chunk-EFFU6KXJ.js";import{c as o}from"../../../chunks/chunk-LCLAV6Q2.js";async function a(n,e){let s=e?.documentObj??await o(),r=e?.sanitize!==void 0?await i(n,e.sanitize):n,t=s.createElement("div");return t.innerHTML=r,Array.from(t.childNodes).filter(d=>[Node.ELEMENT_NODE,Node.TEXT_NODE].includes(d.nodeType))}export{a as default};
|
package/chunks/chunk-AFA3GSXO.js
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
import{b as n}from"./chunk-CF6GPH7Z.js";async function o(){let t=n();return["Browser","Electron"].includes(t)?window.document:new(await import("jsdom")).JSDOM().window.document}export{o as a};
|
@@ -1 +0,0 @@
|
|
1
|
-
import{a,b}from"../../../chunks/chunk-CF6GPH7Z.js";export{a as RuntimeName,b as default};
|
@@ -1 +0,0 @@
|
|
1
|
-
export default function getDocument(): Promise<Document>;
|
@@ -1 +0,0 @@
|
|
1
|
-
import{a}from"../../../chunks/chunk-AFA3GSXO.js";import"../../../chunks/chunk-CF6GPH7Z.js";export{a as default};
|