Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ All notable changes to `hy-event-store` are documented in this file.
actions, and action return values, plus compile-time regression coverage.
- Allow <code>off</code> to cancel a pending <code>once</code> listener by using
the original callback reference.
- Document the supported package-name import path for WeChat Mini Programs and
add a package-root entry-point regression test.

## 1.4.0 - 2026-08-19

Expand Down
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,20 @@ const store = new HYEventStore({
})
~~~

### Mini Program projects

The package currently uses CommonJS. In WeChat DevTools, enable **Use npm
modules**, run **Build npm**, and then import the package by its package name:

~~~js
const { HYEventStore } = require("hy-event-store")
~~~

Do not import `src/event-store.js` or a path such as `store/hy-event-store.js`.
Those paths refer to source files and are not the built Mini Program module
entry. If you use another bundler, configure it to resolve CommonJS packages
from `node_modules` and keep the same package-name import.

## Quick start

### Event bus
Expand Down
13 changes: 13 additions & 0 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,19 @@ const store = new HYEventStore({
})
~~~

### 小程序项目接入

当前发布包使用 CommonJS。在微信开发者工具中,请启用**使用 npm 模块**,
执行**构建 npm**,然后使用包名导入:

~~~js
const { HYEventStore } = require("hy-event-store")
~~~

不要直接导入 `src/event-store.js` 或 `store/hy-event-store.js` 这类路径。
这些路径指向源码文件,并不是构建后的小程序模块入口。如果使用其他构建
工具,请配置它从 `node_modules` 解析 CommonJS 包,并保持使用包名导入。

## 快速开始

### 事件总线
Expand Down
3 changes: 2 additions & 1 deletion ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ These items need API design or compatibility research before implementation:

- Add first-party TypeScript declarations and compile-time coverage
([#25](https://github.com/coderwhy/hy-event-store/issues/25)).
- Document and test CommonJS, ESM, and Mini Program import paths
- Document and test CommonJS and Mini Program import paths; native ESM remains
a separate compatibility item
([#27](https://github.com/coderwhy/hy-event-store/issues/27)).
- Evaluate a read-only state getter
([#26](https://github.com/coderwhy/hy-event-store/issues/26)).
Expand Down
7 changes: 7 additions & 0 deletions Test/event-store.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ const assert = require("node:assert/strict")

const { HYEventStore } = require("../src")

test("package root exposes the public constructors", () => {
const pkg = require("..")

assert.equal(typeof pkg.HYEventBus, "function")
assert.equal(typeof pkg.HYEventStore, "function")
})

test("constructor validates options, state, and actions", () => {
assert.throws(() => new HYEventStore(), /options must be object/)
assert.throws(() => new HYEventStore({}), /state must be object/)
Expand Down