npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@hyext/builder-webview

v1.0.1

Published

> TODO: description

Downloads

77

Readme

builder-webview

初始化

  • 新建一个项目目录如 my-project
  • 将游戏引擎导出的文件复制到 my-project 目录内, 如 game-files
  • 进入 my-project 目录, 执行 npm init -y 初始化项目
  • 添加 @hyext/cli 依赖: npm i @hyext/cli -D
  • 生成配置: npx @hyext/cli init -b @hyext/builder-webview

配置

builder-webview 的配置在 project.config.jsonbuilder.config 中配置:

// 具体内容请查看 src/typings.ts
export interface BuilderConfig {}

其中 buildConfig 的类型为:

// 具体内容请查看 src/typings.ts
export interface BuildConfig {}

开发, 测试, 发布

在虎牙直播APP或者虎牙直播助等app环境执行时, 可使用 buildConfig 的 entry 字段来指定入口的 react-native 文件. 如果想直接显示html的内容, 可使用 @hyext/gameview 组件来简化编码, 详情请翻阅 gameview 文档

其他流程请翻阅虎牙小程序官方文档: https://dev.huya.com/docs/

插件

可以在配置里添加插件来跑一些自动化的脚本, 在 project.config.json 的 builder.config.plugins 中配置插件. 形式和babel插件类似, plugins中的每一项都是一个数组, 第一项是插件的名称, 第二项是插件的参数. 如果不需要配置参数, 也可以直接写插件名称

插件名称可以写成相对路径, 绝对路径, 也可以写成npm包名 为了安全考虑, 在云端构建时, 只有在白名单内的npm包(以@hyext开头)才会生效

目前同一个钩子的插件会按出现的顺序执行.

可配置如下钩子:

  • preStart: 开发阶段, 在builder启动内置开发服务器前执行
  • startResolved: 开发阶段, 在builder内置开发服务器就绪后执行
  • preRelease: 在执行 hyext-release 打包代码, 打包前执行
  • releaseEnd: 在执行 hyext-release 打包代码, 打包完成后执行

插件以函数的形式存在, 该函数返回一个 PluginConfig 对象:

export interface PluginConfig {
  name: string

  preStart?: (opt: StartPluginOpt) => void
  startResolved?: (opt: StartPluginOpt) => void
  preRelease?: (opt: ReleasePluginOpt) => void
  releaseEnd?: (opt: ReleasePluginOpt) => void
}

export type ProjectConfig = ExtCLI.ProjectConfig<BuilderConfig>
interface PluginContext {
  projectConfig: ProjectConfig
  inputPath: string
  error?: Error
}
type StartPluginOpt = PluginContext & { distDir: string, buildResult?: ExtCLI.BuildResult }
type ReleasePluginOpt = PluginContext & { releaseDir: string, releaseZip?: string }

一个简单的例子如下:

// plugin-demo.js
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms))

module.exports = function (options) {
  return {
    name: 'plugin-1-name',
    preStart: async (opt) => {
      await sleep(1000)
      console.log('plugin-1 preStart', opt)
    },
    startResolved: async (opt) => {
      console.log('error.message', opt.error.message)
      await sleep(2000)
      console.log('plugin-1 startDone', opt)
    },

    preRelease: async (opt) => {
      await sleep(2000)
      console.log('preRelease', opt)
    },
    releaseEnd: async (opt) => {
      await sleep(2000)
      console.log('releaseEnd', opt)
    },
  }
}



// project.config.json

{
  "builder": {
    "name": "@hyext/builder-webview",
    "config": {
      "webTitle": "TestAuto2",
      "https": true,
      "h5Dir": "h5",
      "buildConfig": [
      ],
      "plugins": [
        [
          "./plugin-demo.js",
          {
            "bar": true,
          }
        ]
      ]
    }
  }
}