rough-emoji-draw 0.2.0 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.en.md CHANGED
@@ -96,7 +96,12 @@ Load the IIFE bundle only; it automatically attaches `window.RoughEmoji`:
96
96
  </script>
97
97
  ```
98
98
 
99
- If the page includes the demo form DOM (`#rough-canvas`, `#emoji-form`, etc.), interaction and download handlers are wired up automatically.
99
+ If the page includes the demo form DOM (`#rough-canvas`, `#emoji-form`, etc.), load the root-level `rough-emoji-app.js` to wire up interaction and download handlers:
100
+
101
+ ```html
102
+ <script src="./dist/rough-emoji.js"></script>
103
+ <script src="./rough-emoji-app.js"></script>
104
+ ```
100
105
 
101
106
  ## API
102
107
 
@@ -118,7 +123,7 @@ Converts arbitrary input into a drawable flag emoji. Only valid flag emojis are
118
123
  import type { RoughEmojiApi } from "rough-emoji-draw";
119
124
  ```
120
125
 
121
- You can also import `RoughOptions`, `Point`, `RoughCanvasLike`, and the demo page helper `RoughEmojiApp` as needed.
126
+ You can also import `RoughOptions`, `Point`, and `RoughCanvasLike` as needed.
122
127
 
123
128
  ## Project Structure
124
129
 
@@ -128,11 +133,11 @@ You can also import `RoughOptions`, `Point`, `RoughCanvasLike`, and the demo pag
128
133
  │ ├── index.ts # npm library entry; exports API and types
129
134
  │ ├── browser.ts # browser IIFE entry; mounts window.RoughEmoji
130
135
  │ ├── rough-emoji.ts # core drawing logic
131
- │ ├── rough-emoji-app.ts # single-page demo DOM bindings
132
136
  │ ├── flag-utils.ts # flag emoji parsing and validation
133
137
  │ ├── render-context.ts # canvas context switching
134
138
  │ ├── constant.ts # static constants and template map
135
139
  │ └── types.ts # public type declarations
140
+ ├── rough-emoji-app.js # index.html demo DOM bindings (not in npm artifacts)
136
141
  ├── index.html # batch visual QA page
137
142
  ├── rslib.config.ts # Rslib multi-format build config
138
143
  ├── tsconfig.json # TypeScript config
package/README.md CHANGED
@@ -96,7 +96,12 @@ console.log(typeof RoughEmoji.draw); // "function"
96
96
  </script>
97
97
  ```
98
98
 
99
- 若页面包含演示表单 DOM(`#rough-canvas`、`#emoji-form` 等),还会自动绑定交互与下载逻辑。
99
+ 若页面包含演示表单 DOM(`#rough-canvas`、`#emoji-form` 等),可额外加载根目录下的 `rough-emoji-app.js` 绑定交互与下载逻辑:
100
+
101
+ ```html
102
+ <script src="./dist/rough-emoji.js"></script>
103
+ <script src="./rough-emoji-app.js"></script>
104
+ ```
100
105
 
101
106
  ## API
102
107
 
@@ -118,7 +123,7 @@ console.log(typeof RoughEmoji.draw); // "function"
118
123
  import type { RoughEmojiApi } from "rough-emoji-draw";
119
124
  ```
120
125
 
121
- 还可按需导入 `RoughOptions`、`Point`、`RoughCanvasLike`,以及演示页入口 `RoughEmojiApp`。
126
+ 还可按需导入 `RoughOptions`、`Point`、`RoughCanvasLike`。
122
127
 
123
128
  ## 项目结构
124
129
 
@@ -128,11 +133,11 @@ import type { RoughEmojiApi } from "rough-emoji-draw";
128
133
  │ ├── index.ts # npm 库入口,导出 API 与类型
129
134
  │ ├── browser.ts # 浏览器 IIFE 入口,挂载 window.RoughEmoji
130
135
  │ ├── rough-emoji.ts # 核心绘制逻辑
131
- │ ├── rough-emoji-app.ts # 单页演示 DOM 绑定
132
136
  │ ├── flag-utils.ts # 国旗 emoji 解析与校验
133
137
  │ ├── render-context.ts # Canvas 上下文切换
134
138
  │ ├── constant.ts # 静态常量与模板映射
135
139
  │ └── types.ts # 对外类型声明
140
+ ├── rough-emoji-app.js # index.html 演示页 DOM 绑定(不进入 npm 产物)
136
141
  ├── index.html # 批量视觉 QA 页面
137
142
  ├── rslib.config.ts # Rslib 多格式构建配置
138
143
  ├── tsconfig.json # TypeScript 配置
@@ -1,16 +1,5 @@
1
- /** 单页演示入口使用的 DOM 选择器,QA 页面不存在这些节点时只暴露全局 API。 */
2
- export declare const ELEMENT_SELECTORS: {
3
- readonly canvas: "#rough-canvas";
4
- readonly form: "#emoji-form";
5
- readonly input: "#emoji-input";
6
- readonly downloadButton: "#download-button";
7
- };
8
- /** 默认绘制国旗,供首次打开页面、prompt 默认值和非法输入回退共用。 */
1
+ /** 默认绘制国旗,供非法输入回退共用。 */
9
2
  export declare const DEFAULT_FLAG = "\uD83C\uDDE8\uD83C\uDDF3";
10
- /** 下载文件名前缀,最终文件名会追加当前绘制的国旗 emoji。 */
11
- export declare const DOWNLOAD_FILE_PREFIX = "rough-flag";
12
- /** 首次进入单页演示时提示用户输入国旗的文案。 */
13
- export declare const FLAG_PROMPT_MESSAGE = "\u8BF7\u8F93\u5165\u8981\u7ED8\u5236\u7684\u56FD\u65D7";
14
3
  /** 已有专门手写模板的国旗 emoji,避免绘制分支散落字面量。 */
15
4
  export declare const TEMPLATE_FLAGS: {
16
5
  readonly ad: "🇦🇩";
@@ -0,0 +1,9 @@
1
+ import { TEMPLATE_FLAGS } from "./constant";
2
+ /** 专门模板绘制函数签名。 */
3
+ export type FlagDrawer = () => void;
4
+ /** 专门模板覆盖的国旗 emoji 联合类型。 */
5
+ export type TemplateFlag = (typeof TEMPLATE_FLAGS)[keyof typeof TEMPLATE_FLAGS];
6
+ /** 未覆盖输入的兜底绘制流程,保留较克制的细节数量以控制性能。 */
7
+ export declare function drawGenericFlag(flagEmoji: string): void;
8
+ /** 专门模板分发表:每个标准国旗都有独立绘制入口,避免大量 if 分支。 */
9
+ export declare const templateDrawers: Record<TemplateFlag, FlagDrawer>;