@garfish/utils
Advanced tools
Comparing version 0.0.30 to 0.0.31
@@ -20,2 +20,3 @@ export interface Text { | ||
isPrefetchJsLinkNode(node: Node): boolean; | ||
isRemoteModule(node: Node): boolean; | ||
removeElement(el: Element): void; | ||
@@ -22,0 +23,0 @@ createElement(node: Node): SVGElement | HTMLElement; |
@@ -96,2 +96,3 @@ 'use strict'; | ||
const keys = Object.keys(params); | ||
const nativeWindow = (0, eval)('window;'); | ||
// No random value can be used, otherwise it cannot be reused as a constant string | ||
@@ -101,3 +102,3 @@ const randomValKey = '__garfish__exec_temporary__'; | ||
try { | ||
window[randomValKey] = params; | ||
nativeWindow[randomValKey] = params; | ||
const evalInfo = [ | ||
@@ -115,3 +116,3 @@ `;(function(${keys.join(',')}){`, | ||
finally { | ||
delete window[randomValKey]; | ||
delete nativeWindow[randomValKey]; | ||
} | ||
@@ -437,7 +438,7 @@ } | ||
'link', | ||
'style', | ||
'script', | ||
'img', | ||
'script', | ||
'video', | ||
'audio', | ||
'style', | ||
]; | ||
@@ -580,2 +581,22 @@ const sourceNode = makeMap(sourceListTags); | ||
}, | ||
isRemoteModule(node) { | ||
if (!this.isNode(node) || node.tagName !== 'meta') | ||
return false; | ||
let hasNameAttr, hasSrcAttr; | ||
for (const { key, value } of node.attributes) { | ||
if (key === 'name') { | ||
hasNameAttr = true; | ||
if (value !== 'garfish-remote-module') { | ||
return false; | ||
} | ||
} | ||
else if (key === 'src') { | ||
hasSrcAttr = true; | ||
if (typeof value === 'undefined' || value === '') { | ||
return false; | ||
} | ||
} | ||
} | ||
return Boolean(hasNameAttr && hasSrcAttr); | ||
}, | ||
removeElement(el) { | ||
@@ -582,0 +603,0 @@ const parentNode = el && el.parentNode; |
@@ -91,2 +91,3 @@ 'use strict'; | ||
const keys = Object.keys(params); | ||
const nativeWindow = (0, eval)('window;'); | ||
// No random value can be used, otherwise it cannot be reused as a constant string | ||
@@ -96,3 +97,3 @@ const randomValKey = '__garfish__exec_temporary__'; | ||
try { | ||
window[randomValKey] = params; | ||
nativeWindow[randomValKey] = params; | ||
const evalInfo = [ | ||
@@ -110,3 +111,3 @@ `;(function(${keys.join(',')}){`, | ||
finally { | ||
delete window[randomValKey]; | ||
delete nativeWindow[randomValKey]; | ||
} | ||
@@ -429,7 +430,7 @@ } | ||
'link', | ||
'style', | ||
'script', | ||
'img', | ||
'script', | ||
'video', | ||
'audio', | ||
'style', | ||
]; | ||
@@ -572,2 +573,22 @@ const sourceNode = makeMap(sourceListTags); | ||
}, | ||
isRemoteModule(node) { | ||
if (!this.isNode(node) || node.tagName !== 'meta') | ||
return false; | ||
let hasNameAttr, hasSrcAttr; | ||
for (const { key, value } of node.attributes) { | ||
if (key === 'name') { | ||
hasNameAttr = true; | ||
if (value !== 'garfish-remote-module') { | ||
return false; | ||
} | ||
} | ||
else if (key === 'src') { | ||
hasSrcAttr = true; | ||
if (typeof value === 'undefined' || value === '') { | ||
return false; | ||
} | ||
} | ||
} | ||
return Boolean(hasNameAttr && hasSrcAttr); | ||
}, | ||
removeElement(el) { | ||
@@ -574,0 +595,0 @@ const parentNode = el && el.parentNode; |
@@ -26,3 +26,3 @@ export declare const objectToString: () => string; | ||
export declare function transformUrl(resolvePath: string, curPath: string): string; | ||
export declare function findTarget(el: Element | ShadowRoot | Document, selectors: Array<string>): Document | Element | ShadowRoot; | ||
export declare function findTarget(el: Element | ShadowRoot | Document, selectors: Array<string>): Element | ShadowRoot | Document; | ||
export declare function setDocCurrentScript(target: any, code: string, define?: boolean, url?: string, async?: boolean): () => void; |
@@ -92,2 +92,3 @@ const objectToString = Object.prototype.toString; | ||
const keys = Object.keys(params); | ||
const nativeWindow = (0, eval)('window;'); | ||
// No random value can be used, otherwise it cannot be reused as a constant string | ||
@@ -97,3 +98,3 @@ const randomValKey = '__garfish__exec_temporary__'; | ||
try { | ||
window[randomValKey] = params; | ||
nativeWindow[randomValKey] = params; | ||
const evalInfo = [ | ||
@@ -111,3 +112,3 @@ `;(function(${keys.join(',')}){`, | ||
finally { | ||
delete window[randomValKey]; | ||
delete nativeWindow[randomValKey]; | ||
} | ||
@@ -433,7 +434,7 @@ } | ||
'link', | ||
'style', | ||
'script', | ||
'img', | ||
'script', | ||
'video', | ||
'audio', | ||
'style', | ||
]; | ||
@@ -576,2 +577,22 @@ const sourceNode = makeMap(sourceListTags); | ||
}, | ||
isRemoteModule(node) { | ||
if (!this.isNode(node) || node.tagName !== 'meta') | ||
return false; | ||
let hasNameAttr, hasSrcAttr; | ||
for (const { key, value } of node.attributes) { | ||
if (key === 'name') { | ||
hasNameAttr = true; | ||
if (value !== 'garfish-remote-module') { | ||
return false; | ||
} | ||
} | ||
else if (key === 'src') { | ||
hasSrcAttr = true; | ||
if (typeof value === 'undefined' || value === '') { | ||
return false; | ||
} | ||
} | ||
} | ||
return Boolean(hasNameAttr && hasSrcAttr); | ||
}, | ||
removeElement(el) { | ||
@@ -578,0 +599,0 @@ const parentNode = el && el.parentNode; |
@@ -92,2 +92,3 @@ const objectToString = Object.prototype.toString; | ||
const keys = Object.keys(params); | ||
const nativeWindow = (0, eval)('window;'); | ||
// No random value can be used, otherwise it cannot be reused as a constant string | ||
@@ -97,3 +98,3 @@ const randomValKey = '__garfish__exec_temporary__'; | ||
try { | ||
window[randomValKey] = params; | ||
nativeWindow[randomValKey] = params; | ||
const evalInfo = [ | ||
@@ -111,3 +112,3 @@ `;(function(${keys.join(',')}){`, | ||
finally { | ||
delete window[randomValKey]; | ||
delete nativeWindow[randomValKey]; | ||
} | ||
@@ -433,7 +434,7 @@ } | ||
'link', | ||
'style', | ||
'script', | ||
'img', | ||
'script', | ||
'video', | ||
'audio', | ||
'style', | ||
]; | ||
@@ -576,2 +577,22 @@ const sourceNode = makeMap(sourceListTags); | ||
}, | ||
isRemoteModule(node) { | ||
if (!this.isNode(node) || node.tagName !== 'meta') | ||
return false; | ||
let hasNameAttr, hasSrcAttr; | ||
for (const { key, value } of node.attributes) { | ||
if (key === 'name') { | ||
hasNameAttr = true; | ||
if (value !== 'garfish-remote-module') { | ||
return false; | ||
} | ||
} | ||
else if (key === 'src') { | ||
hasSrcAttr = true; | ||
if (typeof value === 'undefined' || value === '') { | ||
return false; | ||
} | ||
} | ||
} | ||
return Boolean(hasNameAttr && hasSrcAttr); | ||
}, | ||
removeElement(el) { | ||
@@ -578,0 +599,0 @@ const parentNode = el && el.parentNode; |
@@ -98,2 +98,3 @@ (function (global, factory) { | ||
const keys = Object.keys(params); | ||
const nativeWindow = (0, eval)('window;'); | ||
// No random value can be used, otherwise it cannot be reused as a constant string | ||
@@ -103,3 +104,3 @@ const randomValKey = '__garfish__exec_temporary__'; | ||
try { | ||
window[randomValKey] = params; | ||
nativeWindow[randomValKey] = params; | ||
const evalInfo = [ | ||
@@ -117,3 +118,3 @@ `;(function(${keys.join(',')}){`, | ||
finally { | ||
delete window[randomValKey]; | ||
delete nativeWindow[randomValKey]; | ||
} | ||
@@ -439,7 +440,7 @@ } | ||
'link', | ||
'style', | ||
'script', | ||
'img', | ||
'script', | ||
'video', | ||
'audio', | ||
'style', | ||
]; | ||
@@ -582,2 +583,22 @@ const sourceNode = makeMap(sourceListTags); | ||
}, | ||
isRemoteModule(node) { | ||
if (!this.isNode(node) || node.tagName !== 'meta') | ||
return false; | ||
let hasNameAttr, hasSrcAttr; | ||
for (const { key, value } of node.attributes) { | ||
if (key === 'name') { | ||
hasNameAttr = true; | ||
if (value !== 'garfish-remote-module') { | ||
return false; | ||
} | ||
} | ||
else if (key === 'src') { | ||
hasSrcAttr = true; | ||
if (typeof value === 'undefined' || value === '') { | ||
return false; | ||
} | ||
} | ||
} | ||
return Boolean(hasNameAttr && hasSrcAttr); | ||
}, | ||
removeElement(el) { | ||
@@ -584,0 +605,0 @@ const parentNode = el && el.parentNode; |
{ | ||
"name": "@garfish/utils", | ||
"version": "0.0.30", | ||
"version": "0.0.31", | ||
"description": "utils module.", | ||
@@ -40,3 +40,3 @@ "keywords": [ | ||
}, | ||
"gitHead": "ff9e4aceb22b2a1de4bdf2de8e9bb96998c1dabd" | ||
"gitHead": "4a882c7f2734d085689d423f5e0c51d9a0eccbba" | ||
} |
@@ -7,6 +7,6 @@ # `@garfish/utils` | ||
``` | ||
import @garfish/utils from '@garfish/utils'; | ||
```js | ||
import { isObject } from '@garfish/utils'; | ||
// TODO: DEMONSTRATE API | ||
``` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
206066
4559