@garfish/utils
Advanced tools
Comparing version 0.1.13-beta.12 to 0.1.13
@@ -17,3 +17,4 @@ import { interfaces } from '@garfish/core'; | ||
declare function internFunc(internalizeString: any): string; | ||
declare function evalWithEnv(code: string, params: Record<string, any>): void; | ||
declare function evalWithEnv(code: string, params: Record<string, any>, context: any): void; | ||
declare function safeWrapper(callback: (...args: Array<any>) => any): void; | ||
declare function nextTick(cb: () => void): void; | ||
@@ -31,4 +32,4 @@ declare function assert(condition: any, msg?: string | Error): void; | ||
declare function setDocCurrentScript(target: any, code: string, define?: boolean, url?: string, async?: boolean): () => void; | ||
declare function __extends(d: any, b: any): void; | ||
declare function isFunction(what: unknown): what is Function; | ||
declare function _extends(d: any, b: any): void; | ||
declare function mapObject(obj: Record<PropertyKey, any>, fn: (key: PropertyKey, val: any) => any): {}; | ||
declare const hookObjectProperty: <T extends {}, K extends keyof T, P extends any[]>(obj: T, key: K, hookFunc: (origin: T[K], ...params: P) => T[K]) => (...params: P) => (strict?: boolean) => void; | ||
@@ -90,3 +91,5 @@ | ||
declare const __LOADER_FLAG__: unique symbol; | ||
declare const __GARFISH_FLAG__: unique symbol; | ||
declare const __MockHtml__ = "__garfishmockhtml__"; | ||
declare const __MockBody__ = "__garfishmockbody__"; | ||
@@ -113,2 +116,2 @@ declare const __MockHead__ = "__garfishmockhead__"; | ||
export { DOMApis, Node, StackFrame, StackTrace, Text, __ELEMENT_DELETE_TAG__, __GARFISH_FLAG__, __MockBody__, __MockHead__, __extends, assert, callTestCallback, computeErrorUrl, computeStackTraceFromStackProp, createAppContainer, createKey, deepMerge, def, error, evalWithEnv, filterAndWrapEventListener, findTarget, getRenderNode, hasOwn, hookObjectProperty, inBrowser, internFunc, isAbsolute, isCss, isFunction, isHtml, isJs, isObject, isPlainObject, isPrimitive, isPromise, makeMap, mimeType, nextTick, noop, objectToString, parseContentType, remove, setDocCurrentScript, sourceListTags, sourceNode, templateParse, toBoolean, transformUrl, unique, validURL, warn }; | ||
export { DOMApis, Node, StackFrame, StackTrace, Text, __ELEMENT_DELETE_TAG__, __GARFISH_FLAG__, __LOADER_FLAG__, __MockBody__, __MockHead__, __MockHtml__, _extends, assert, callTestCallback, computeErrorUrl, computeStackTraceFromStackProp, createAppContainer, createKey, deepMerge, def, error, evalWithEnv, filterAndWrapEventListener, findTarget, getRenderNode, hasOwn, hookObjectProperty, inBrowser, internFunc, isAbsolute, isCss, isHtml, isJs, isObject, isPlainObject, isPrimitive, isPromise, makeMap, mapObject, mimeType, nextTick, noop, objectToString, parseContentType, remove, safeWrapper, setDocCurrentScript, sourceListTags, sourceNode, templateParse, toBoolean, transformUrl, unique, validURL, warn }; |
@@ -14,5 +14,7 @@ var __defProp = Object.defineProperty; | ||
__GARFISH_FLAG__: () => __GARFISH_FLAG__, | ||
__LOADER_FLAG__: () => __LOADER_FLAG__, | ||
__MockBody__: () => __MockBody__, | ||
__MockHead__: () => __MockHead__, | ||
__extends: () => __extends, | ||
__MockHtml__: () => __MockHtml__, | ||
_extends: () => _extends, | ||
assert: () => assert, | ||
@@ -37,3 +39,2 @@ callTestCallback: () => callTestCallback, | ||
isCss: () => isCss, | ||
isFunction: () => isFunction, | ||
isHtml: () => isHtml, | ||
@@ -46,2 +47,3 @@ isJs: () => isJs, | ||
makeMap: () => makeMap, | ||
mapObject: () => mapObject, | ||
nextTick: () => nextTick, | ||
@@ -52,2 +54,3 @@ noop: () => noop, | ||
remove: () => remove, | ||
safeWrapper: () => safeWrapper, | ||
setDocCurrentScript: () => setDocCurrentScript, | ||
@@ -64,3 +67,3 @@ sourceListTags: () => sourceListTags, | ||
// ../../../node_modules/.pnpm/tsup@5.1.0_typescript@4.4.3/node_modules/tsup/assets/cjs_shims.js | ||
// ../../node_modules/.pnpm/tsup@5.2.1_typescript@4.4.3/node_modules/tsup/assets/cjs_shims.js | ||
var importMetaUrlShim = typeof document === "undefined" ? new (require("url")).URL("file:" + __filename).href : document.currentScript && document.currentScript.src || new URL("main.js", document.baseURI).href; | ||
@@ -157,13 +160,15 @@ | ||
} | ||
function evalWithEnv(code, params) { | ||
function evalWithEnv(code, params, context) { | ||
const keys = Object.keys(params); | ||
const nativeWindow = (0, eval)("window;"); | ||
const randomValKey = "__garfish__exec_temporary__"; | ||
const vales = keys.map((k) => `window.${randomValKey}.${k}`); | ||
const values = keys.map((k) => `window.${randomValKey}.${k}`); | ||
const contextKey = "__garfish__exec_temporary__context__"; | ||
try { | ||
nativeWindow[randomValKey] = params; | ||
nativeWindow[contextKey] = context; | ||
const evalInfo = [ | ||
`;(function(${keys.join(",")}){`, | ||
` | ||
}).call(${vales[0]},${vales.join(",")});` | ||
}).call(window.${contextKey},${values.join(",")});` | ||
]; | ||
@@ -176,4 +181,12 @@ const internalizeString = internFunc(evalInfo[0] + code + evalInfo[1]); | ||
delete nativeWindow[randomValKey]; | ||
delete nativeWindow[contextKey]; | ||
} | ||
} | ||
function safeWrapper(callback) { | ||
try { | ||
callback(); | ||
} catch (e) { | ||
(typeof process !== "undefined" && process.env && process.env.NODE_ENV ? process.env.NODE_ENV !== "production" : false) && warn(e); | ||
} | ||
} | ||
function nextTick(cb) { | ||
@@ -360,3 +373,3 @@ Promise.resolve().then(cb); | ||
} | ||
function __extends(d, b) { | ||
function _extends(d, b) { | ||
Object.setPrototypeOf(d, b); | ||
@@ -374,4 +387,10 @@ function fNOP() { | ||
} | ||
function isFunction(what) { | ||
return typeof what === "function"; | ||
function mapObject(obj, fn) { | ||
const destObject = {}; | ||
for (const key in obj) { | ||
if (obj.hasOwnProperty(key)) { | ||
destObject[key] = fn(key, obj[key]); | ||
} | ||
} | ||
return destObject; | ||
} | ||
@@ -386,3 +405,3 @@ var hookObjectProperty = (obj, key, hookFunc) => { | ||
let hooked = hookedUnsafe; | ||
if (isFunction(hooked)) { | ||
if (typeof hooked === "function") { | ||
hooked = function(...args) { | ||
@@ -392,3 +411,3 @@ try { | ||
} catch { | ||
return isFunction(origin) && origin.apply(this, args); | ||
return typeof origin === "function" && origin.apply(this, args); | ||
} | ||
@@ -564,3 +583,5 @@ }; | ||
// src/garfish.ts | ||
var __LOADER_FLAG__ = Symbol.for("__LOADER_FLAG__"); | ||
var __GARFISH_FLAG__ = Symbol.for("__GARFISH_FLAG__"); | ||
var __MockHtml__ = "__garfishmockhtml__"; | ||
var __MockBody__ = "__garfishmockbody__"; | ||
@@ -790,6 +811,6 @@ var __MockHead__ = "__garfishmockhead__"; | ||
function createAppContainer(name) { | ||
const htmlNode = document.createElement("div"); | ||
const appContainer = document.createElement("div"); | ||
const htmlNode = document.createElement("div"); | ||
appContainer.id = `garfish_app_for_${name || "unknow"}_${createKey()}`; | ||
htmlNode.setAttribute("__GarfishMockHtml__", ""); | ||
htmlNode.setAttribute(__MockHtml__, ""); | ||
appContainer.id = `garfish_app_for_${name}_${createKey()}`; | ||
appContainer.appendChild(htmlNode); | ||
@@ -894,5 +915,7 @@ return { | ||
__GARFISH_FLAG__, | ||
__LOADER_FLAG__, | ||
__MockBody__, | ||
__MockHead__, | ||
__extends, | ||
__MockHtml__, | ||
_extends, | ||
assert, | ||
@@ -917,3 +940,2 @@ callTestCallback, | ||
isCss, | ||
isFunction, | ||
isHtml, | ||
@@ -926,2 +948,3 @@ isJs, | ||
makeMap, | ||
mapObject, | ||
nextTick, | ||
@@ -932,2 +955,3 @@ noop, | ||
remove, | ||
safeWrapper, | ||
setDocCurrentScript, | ||
@@ -934,0 +958,0 @@ sourceListTags, |
{ | ||
"name": "@garfish/utils", | ||
"version": "0.1.13-beta.12", | ||
"version": "0.1.13", | ||
"description": "utils module.", | ||
@@ -21,3 +21,3 @@ "keywords": [ | ||
".": { | ||
"import": "./dist/index.mjs", | ||
"import": "./dist/esm/index.js", | ||
"require": "./dist/index.js" | ||
@@ -28,17 +28,7 @@ }, | ||
"main": "dist/index.js", | ||
"module": "dist/index.mjs", | ||
"module": "dist/esm/index.js", | ||
"types": "dist/index.d.ts", | ||
"buildOptions": { | ||
"name": "Utils", | ||
"devTemplate": "module", | ||
"formats": [ | ||
"esm-bundler", | ||
"esm-browser", | ||
"cjs", | ||
"umd" | ||
] | ||
"devDependencies": { | ||
"@garfish/core": "0.1.13" | ||
}, | ||
"dependencies": { | ||
"@garfish/core": "0.1.13-beta.12" | ||
}, | ||
"publishConfig": { | ||
@@ -45,0 +35,0 @@ "registry": "https://registry.npmjs.org", |
@@ -1,1 +0,1 @@ | ||
export { tsup } from '../../../tsup.config'; | ||
export { tsup } from '../../tsup.config'; |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
0
71092
1
8
1927
12
3
- Removed@garfish/core@0.1.13-beta.12
- Removed@garfish/core@0.1.13-beta.12(transitive)
- Removed@garfish/hooks@0.1.13-beta.12(transitive)
- Removed@garfish/loader@0.1.13-beta.12(transitive)
- Removedhimalaya@1.1.0(transitive)