3.2.0 • Published 6 months ago

@hcfy/utils v3.2.0

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

@hcfy/utils

开发划词翻译时用到的一些工具函数。

工具函数的运行环境

工具函数根据代码可用环境分为了以下几类:

类别说明运行所需环境
@hcfy/utils支持在所有 JavaScript 运行环境中使用。
@hcfy/utils/dom需要有 DOM 环境才能运行的工具函数。DOM 环境
@hcfy/utils/react-hooksReact HooksDOM 环境、React 运行时
@hcfy/utils/browser-extension可以在所有扩展程序环境中运行的工具函数。同时兼容 Manifest V2 与 V3。内容脚本可用的 Manifest V2 chrome.* API 且 callback 形式
@hcfy/utils/browser-extension-no-content可以在除了内容脚本的其它扩展程序环境中运行的工具函数。同时兼容 Manifest V2 与 V3。全部 Manifest V2 chrome.* API 且 callback 形式

以下是暂时还没有工具函数的几个类别:

类别说明运行所需环境
@hcfy/utils/browser-extension-dom可以在拥有 DOM 环境的扩展程序环境中使用。同时兼容 Manifest V2 与 V3。内容脚本可用的 Manifest V2 chrome.* API 且 callback 形式、DOM 环境
@hcfy/utils/browser-extension-dom-no-content可以在拥有 DOM 环境的、除了内容脚本的其它扩展程序环境中运行的工具函数。同时兼容 Manifest V2 与 V3。全部 Manifest V2 chrome.* API 且 callback 形式、DOM 环境
@hcfy/utils/browser-extension-v3可以在所有扩展程序环境中运行的工具函数。只兼容 Manifest V3。内容脚本可用的 Manifest V3 chrome.* API
@hcfy/utils/browser-extension-v3-no-content可以在除了内容脚本的其它扩展程序环境中运行的工具函数。只兼容 Manifest V3。全部 Manifest V3 chrome.* API
@hcfy/utils/browser-extension-v3-dom可以在拥有 DOM 环境的扩展程序环境中使用。只兼容 Manifest V3。内容脚本可用的 Manifest V3 chrome.* API、DOM 环境
@hcfy/utils/browser-extension-v3-dom-no-content可以在拥有 DOM 环境的、除了内容脚本的其它扩展程序环境中运行的工具函数。只兼容 Manifest V3。全部 Manifest V3 chrome.* API、DOM 环境
@hcfy/utils/browser-extension-v3-service-worker只能在 Manifest V3 的背景脚本(service worker)里使用全部 Manifest V3 chrome.* API、service worker 环境

解释一下运行环境:

  • DOM 环境:可以用 document.querySelector() 这种 DOM API。
  • Node.js 环境:可以用 Node.js 的内置模块。
  • Electron 环境:可以用 Electron 的内置模块。
  • 内容脚本可用的 Manifest V2 chrome.* API 且 callback 形式:内容脚本才能用的那一少部分 chrome.* API,且这些 API 是 Manifest V2 里有的并使用 callback 方式调用。这意味着这些工具函数能同时兼容 Manifest V2 与 V3。
  • 全部 Manifest V2 chrome.* API 且 callback 形式:全部 chrome.* API,且这些 API 是 Manifest V2 里有的并使用 callback 方式调用。这意味着这些工具函数能同时兼容 Manifest V2 与 V3。
  • 内容脚本可用的 Manifest V3 chrome.* API:内容脚本才能用的那一少部分 chrome.* API,且这些 API 可以是 Manifest V3 里新加的。这意味着这些工具函数只兼容 Manifest V3,所以可以直接使用 promise 方式调用 chrome.* API。
  • 全部 Manifest V3 chrome.* API:全部 chrome.* API,且这些 API 可以是 Manifest V3 里新加的。这意味着这些工具函数只兼容 Manifest V3,所以可以直接使用 promise 方式调用 chrome.* API。
  • service worker 环境:能用 service worker 独有的 API,比如 self.addEventListener('install', ...)
3.2.0

6 months ago

3.1.0

7 months ago

1.7.0

10 months ago

3.0.0

8 months ago

1.6.0

10 months ago

2.3.0

9 months ago

2.2.0

9 months ago

2.4.0

8 months ago

2.3.1

9 months ago

2.1.0

9 months ago

2.0.1

10 months ago

2.0.0

10 months ago

1.4.0

1 year ago

1.3.0

1 year ago

1.2.0

1 year ago

1.1.0

1 year ago

1.0.0

1 year ago