@xihan-ui/web-components 1.1.0 → 2.0.0
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/CHANGELOG.md +4706 -6
- package/README.md +10 -3
- package/custom-elements.json +36929 -19159
- package/dist/backgrounds.d.ts +7 -7
- package/dist/backgrounds.d.ts.map +1 -1
- package/dist/backgrounds.js +8 -8
- package/dist/backgrounds.js.map +1 -1
- package/dist/{config-Cz16-P4i.d.ts → config-etfwIorI.d.ts} +17 -8
- package/dist/config-etfwIorI.d.ts.map +1 -0
- package/dist/define.d.ts +8383 -4143
- package/dist/define.d.ts.map +1 -1
- package/dist/define.js +11235 -5943
- package/dist/define.js.map +1 -1
- package/dist/{element-b0p0Q8Py.js → element-BKQR3ce3.js} +4 -4
- package/dist/element-BKQR3ce3.js.map +1 -0
- package/dist/{element-DRoFjrYO.d.ts → element-DFbmhZLP.d.ts} +3 -3
- package/dist/{element-DRoFjrYO.d.ts.map → element-DFbmhZLP.d.ts.map} +1 -1
- package/dist/index.d.ts +11 -12
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/{machine-controller-DE6edQbK.js → machine-controller-C1ffftux.js} +35 -29
- package/dist/machine-controller-C1ffftux.js.map +1 -0
- package/dist/registry-DR6I2_zF.js.map +1 -1
- package/dist/services.d.ts +184 -0
- package/dist/services.d.ts.map +1 -0
- package/dist/services.js +701 -0
- package/dist/services.js.map +1 -0
- package/dist/toast-BTlM12YF.js +1405 -0
- package/dist/toast-BTlM12YF.js.map +1 -0
- package/dist/{types-BvWWqMd_.d.ts → types-C1Bybm6P.d.ts} +2 -2
- package/dist/{types-BvWWqMd_.d.ts.map → types-C1Bybm6P.d.ts.map} +1 -1
- package/package.json +23 -17
- package/dist/config-Cz16-P4i.d.ts.map +0 -1
- package/dist/element-b0p0Q8Py.js.map +0 -1
- package/dist/machine-controller-DE6edQbK.js.map +0 -1
package/dist/backgrounds.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { r as PropertyValues } from "./types-
|
|
2
|
-
import { t as XhReactiveElement } from "./element-
|
|
1
|
+
import { r as PropertyValues } from "./types-C1Bybm6P.js";
|
|
2
|
+
import { t as XhReactiveElement } from "./element-DFbmhZLP.js";
|
|
3
3
|
import { BackgroundEffect, BackgroundQuality, BackgroundSurface, MorphOptions, ParamValue, PointCloud } from "@xihan-ui/backgrounds";
|
|
4
4
|
//#region src/backgrounds.d.ts
|
|
5
5
|
/**
|
|
6
|
-
* `<xh-background
|
|
6
|
+
* `<xh-background>`:视觉画面宿主。
|
|
7
7
|
*
|
|
8
|
-
*
|
|
9
|
-
* 画布是 pointer-events: none
|
|
8
|
+
* 元素自身就是画布的容器:内容照常写在其中,效果铺在内容下方,
|
|
9
|
+
* 画布是 pointer-events: none,不会遮挡其中的交互。
|
|
10
10
|
*
|
|
11
11
|
* @customElement xh-background
|
|
12
12
|
* @attr {string} effect - 效果名,须先注册(defineXhBackground 会把内置效果一并注册)
|
|
@@ -67,8 +67,8 @@ declare class XhBackgroundElement extends XhReactiveElement {
|
|
|
67
67
|
protected updated(_changed: PropertyValues): void;
|
|
68
68
|
}
|
|
69
69
|
/**
|
|
70
|
-
* 注册 `<xh-background
|
|
71
|
-
*
|
|
70
|
+
* 注册 `<xh-background>`,并把内置效果一并注册进效果注册表:
|
|
71
|
+
* 元素只识别效果名字,注册表为空时任何 effect 属性都无法解析。
|
|
72
72
|
*/
|
|
73
73
|
declare function defineXhBackground(): void;
|
|
74
74
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"backgrounds.d.ts","names":[],"sources":["../src/backgrounds.ts"],"mappings":";;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"backgrounds.d.ts","names":[],"sources":["../src/backgrounds.ts"],"mappings":";;;;;;;;;;;;;;;;;;;cAoDa,4BAA4B;SACvB;;;;;;;;;;;QApBO,gBAAA;;;;;;QAAA,gBAAA;;;;;;QAAA,gBAAA;;;;EA8Bf,kBAAkB;EAClB,UAAU;EACV,SAAS,eAAe;EACxB;EACA;EACA;EACA;UAEA;UACA;;UAEA;;UAEA;;EAGR,SAAS,OAAO,YAAY,UAAU;;EAQtC,cAAc;EAIL;EAOA;YAOU,QAAQ,UAAU;;;;;;iBAuDvB"}
|
package/dist/backgrounds.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { t as defineElement } from "./registry-DR6I2_zF.js";
|
|
2
|
-
import { n as version, t as XhReactiveElement } from "./element-
|
|
3
|
-
import { DIAGNOSTIC_CODES, reportDiagnostic } from "@xihan-ui/
|
|
2
|
+
import { n as version, t as XhReactiveElement } from "./element-BKQR3ce3.js";
|
|
3
|
+
import { DIAGNOSTIC_CODES, reportDiagnostic } from "@xihan-ui/core";
|
|
4
4
|
import { createBackgroundSurface, registerBuiltinEffects } from "@xihan-ui/backgrounds";
|
|
5
5
|
//#region src/backgrounds.ts
|
|
6
|
-
/**
|
|
6
|
+
/** 属性缺席转换为 undefined(使用引擎默认值),写为 "false" 才是关闭。 */
|
|
7
7
|
const optionalBool = { fromAttribute: (value) => value === null ? void 0 : value !== "false" };
|
|
8
8
|
/**
|
|
9
|
-
* `<xh-background
|
|
9
|
+
* `<xh-background>`:视觉画面宿主。
|
|
10
10
|
*
|
|
11
|
-
*
|
|
12
|
-
* 画布是 pointer-events: none
|
|
11
|
+
* 元素自身就是画布的容器:内容照常写在其中,效果铺在内容下方,
|
|
12
|
+
* 画布是 pointer-events: none,不会遮挡其中的交互。
|
|
13
13
|
*
|
|
14
14
|
* @customElement xh-background
|
|
15
15
|
* @attr {string} effect - 效果名,须先注册(defineXhBackground 会把内置效果一并注册)
|
|
@@ -107,8 +107,8 @@ var XhBackgroundElement = class extends XhReactiveElement {
|
|
|
107
107
|
}
|
|
108
108
|
};
|
|
109
109
|
/**
|
|
110
|
-
* 注册 `<xh-background
|
|
111
|
-
*
|
|
110
|
+
* 注册 `<xh-background>`,并把内置效果一并注册进效果注册表:
|
|
111
|
+
* 元素只识别效果名字,注册表为空时任何 effect 属性都无法解析。
|
|
112
112
|
*/
|
|
113
113
|
function defineXhBackground() {
|
|
114
114
|
registerBuiltinEffects();
|
package/dist/backgrounds.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"backgrounds.js","names":["VERSION"],"sources":["../src/backgrounds.ts"],"sourcesContent":["// @xihan-ui/web-components/backgrounds —— 背景层的 Web Components 适配。\n//\n// 与主入口和 /define 都分开:@xihan-ui/backgrounds 是可选 peer,不用视觉效果的应用不会\n// 因为装了本包而多出一个 WebGL 引擎。用之前先装 @xihan-ui/backgrounds。\n//\n// ```html\n// <xh-background effect=\"aurora\" quality=\"balanced\" style=\"height: 180px\">\n// <h3>卡片标题</h3>\n// </xh-background>\n// ```\n\nimport type {\n BackgroundEffect,\n BackgroundQuality,\n BackgroundSurface,\n MorphOptions,\n ParamValue,\n PointCloud,\n} from '@xihan-ui/backgrounds'\nimport type { PropertyValues } from './reactive'\nimport { createBackgroundSurface, registerBuiltinEffects } from '@xihan-ui/backgrounds'\nimport { DIAGNOSTIC_CODES, reportDiagnostic } from '@xihan-ui/
|
|
1
|
+
{"version":3,"file":"backgrounds.js","names":["VERSION"],"sources":["../src/backgrounds.ts"],"sourcesContent":["/*\n * Copyright (c) 2021-Present XiHanFun and contributors.\n * Licensed under the MIT License. See LICENSE in the project root for license information.\n */\n\n// @xihan-ui/web-components/backgrounds —— 背景层的 Web Components 适配。\n//\n// 与主入口和 /define 都分开:@xihan-ui/backgrounds 是可选 peer,不用视觉效果的应用不会\n// 因为装了本包而多出一个 WebGL 引擎。用之前先装 @xihan-ui/backgrounds。\n//\n// ```html\n// <xh-background effect=\"aurora\" quality=\"balanced\" style=\"height: 180px\">\n// <h3>卡片标题</h3>\n// </xh-background>\n// ```\n\nimport type {\n BackgroundEffect,\n BackgroundQuality,\n BackgroundSurface,\n MorphOptions,\n ParamValue,\n PointCloud,\n} from '@xihan-ui/backgrounds'\nimport type { PropertyValues } from './reactive'\nimport { createBackgroundSurface, registerBuiltinEffects } from '@xihan-ui/backgrounds'\nimport { DIAGNOSTIC_CODES, reportDiagnostic } from '@xihan-ui/core'\nimport { version as VERSION } from '../package.json'\nimport { XhReactiveElement } from './reactive'\nimport { defineElement } from './runtime/registry'\n\n/** 属性缺席转换为 undefined(使用引擎默认值),写为 \"false\" 才是关闭。 */\nconst optionalBool = {\n fromAttribute: (value: string | null): boolean | undefined =>\n value === null ? undefined : value !== 'false',\n}\n\n/**\n * `<xh-background>`:视觉画面宿主。\n *\n * 元素自身就是画布的容器:内容照常写在其中,效果铺在内容下方,\n * 画布是 pointer-events: none,不会遮挡其中的交互。\n *\n * @customElement xh-background\n * @attr {string} effect - 效果名,须先注册(defineXhBackground 会把内置效果一并注册)\n * @attr {'auto'|'high'|'balanced'|'eco'} quality - 画质档位\n * @attr {object} params - 效果参数,JSON 对象\n * @attr {boolean} paused - 暂停绘制\n * @attr {boolean} pointer - 是否绑定指针事件,写 \"false\" 关闭\n * @attr {boolean} reduced-motion - 是否尊重系统的减弱动态效果,写 \"false\" 关闭\n * @attr {boolean} pause-offscreen - 滚出视口是否暂停,写 \"false\" 关闭\n */\nexport class XhBackgroundElement extends XhReactiveElement {\n static override properties = {\n effect: {},\n quality: {},\n params: { type: Object },\n paused: { type: Boolean },\n pointer: { converter: optionalBool },\n reducedMotion: { attribute: 'reduced-motion', converter: optionalBool },\n pauseOffscreen: { attribute: 'pause-offscreen', converter: optionalBool },\n }\n\n declare effect?: string | BackgroundEffect\n declare quality?: BackgroundQuality\n declare params?: Record<string, ParamValue>\n declare paused?: boolean\n declare pointer?: boolean\n declare reducedMotion?: boolean\n declare pauseOffscreen?: boolean\n\n private surface: BackgroundSurface | null = null\n private appliedEffect: string | BackgroundEffect | undefined\n /** 记住上次生效的画质:setQuality 会重建着色器程序,不能每次更新都调一遍。 */\n private appliedQuality: BackgroundQuality | undefined\n /** 画面还没建起来时先收着,建好后补发。 */\n private pendingCloud: { cloud: PointCloud, options?: MorphOptions } | null = null\n\n /** 换点云。属性传不了二进制,只能用 JS 调。 */\n setCloud(cloud: PointCloud, options?: MorphOptions): void {\n if (this.surface === null)\n this.pendingCloud = { cloud, options }\n else\n this.surface.setCloud(cloud, options)\n }\n\n /** 拿底层画面实例,用于自定义调度或调参。 */\n getSurface(): BackgroundSurface | null {\n return this.surface\n }\n\n override connectedCallback(): void {\n // 自定义元素默认是行内元素,行内元素量不出高度,画布会一直是 0×0\n if (getComputedStyle(this).display === 'inline')\n this.style.display = 'block'\n super.connectedCallback()\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback()\n this.surface?.destroy()\n this.surface = null\n this.appliedEffect = undefined\n }\n\n protected override updated(_changed: PropertyValues): void {\n if (this.effect === undefined)\n return\n\n if (this.surface === null) {\n try {\n this.surface = createBackgroundSurface(this, {\n effect: this.effect,\n params: this.params,\n quality: this.quality,\n pointer: this.pointer,\n autoplay: this.paused !== true,\n respectReducedMotion: this.reducedMotion,\n pauseOffscreen: this.pauseOffscreen,\n })\n }\n catch (error) {\n // 效果名没注册就把整页带崩不划算,报出来即可\n reportDiagnostic({\n code: DIAGNOSTIC_CODES.warn,\n level: 'error',\n message: `[backgrounds] <xh-background> 创建失败:${(error as Error).message}`,\n })\n return\n }\n this.appliedEffect = this.effect\n this.appliedQuality = this.quality\n if (this.pendingCloud !== null) {\n this.surface.setCloud(this.pendingCloud.cloud, this.pendingCloud.options)\n this.pendingCloud = null\n }\n return\n }\n\n if (this.effect !== this.appliedEffect) {\n this.surface.setEffect(this.effect)\n this.appliedEffect = this.effect\n }\n if (this.quality !== undefined && this.quality !== this.appliedQuality) {\n this.surface.setQuality(this.quality)\n this.appliedQuality = this.quality\n }\n if (this.params !== undefined)\n this.surface.setParams(this.params)\n if (this.paused === true)\n this.surface.pause()\n else\n this.surface.play()\n }\n}\n\n/**\n * 注册 `<xh-background>`,并把内置效果一并注册进效果注册表:\n * 元素只识别效果名字,注册表为空时任何 effect 属性都无法解析。\n */\nexport function defineXhBackground(): void {\n registerBuiltinEffects()\n defineElement('xh-background', XhBackgroundElement, VERSION)\n}\n"],"mappings":";;;;;;AAgCA,MAAM,eAAe,EACnB,gBAAgB,UACd,UAAU,OAAO,KAAA,IAAY,UAAU,QAC3C;;;;;;;;;;;;;;;;AAiBA,IAAa,sBAAb,cAAyC,kBAAkB;CACzD,OAAgB,aAAa;EAC3B,QAAQ,CAAC;EACT,SAAS,CAAC;EACV,QAAQ,EAAE,MAAM,OAAO;EACvB,QAAQ,EAAE,MAAM,QAAQ;EACxB,SAAS,EAAE,WAAW,aAAa;EACnC,eAAe;GAAE,WAAW;GAAkB,WAAW;EAAa;EACtE,gBAAgB;GAAE,WAAW;GAAmB,WAAW;EAAa;CAC1E;CAUA,UAA4C;CAC5C;;CAEA;;CAEA,eAA6E;;CAG7E,SAAS,OAAmB,SAA8B;EACxD,IAAI,KAAK,YAAY,MACnB,KAAK,eAAe;GAAE;GAAO;EAAQ;OAErC,KAAK,QAAQ,SAAS,OAAO,OAAO;CACxC;;CAGA,aAAuC;EACrC,OAAO,KAAK;CACd;CAEA,oBAAmC;EAEjC,IAAI,iBAAiB,IAAI,CAAC,CAAC,YAAY,UACrC,KAAK,MAAM,UAAU;EACvB,MAAM,kBAAkB;CAC1B;CAEA,uBAAsC;EACpC,MAAM,qBAAqB;EAC3B,KAAK,SAAS,QAAQ;EACtB,KAAK,UAAU;EACf,KAAK,gBAAgB,KAAA;CACvB;CAEA,QAA2B,UAAgC;EACzD,IAAI,KAAK,WAAW,KAAA,GAClB;EAEF,IAAI,KAAK,YAAY,MAAM;GACzB,IAAI;IACF,KAAK,UAAU,wBAAwB,MAAM;KAC3C,QAAQ,KAAK;KACb,QAAQ,KAAK;KACb,SAAS,KAAK;KACd,SAAS,KAAK;KACd,UAAU,KAAK,WAAW;KAC1B,sBAAsB,KAAK;KAC3B,gBAAgB,KAAK;IACvB,CAAC;GACH,SACO,OAAO;IAEZ,iBAAiB;KACf,MAAM,iBAAiB;KACvB,OAAO;KACP,SAAS,sCAAuC,MAAgB;IAClE,CAAC;IACD;GACF;GACA,KAAK,gBAAgB,KAAK;GAC1B,KAAK,iBAAiB,KAAK;GAC3B,IAAI,KAAK,iBAAiB,MAAM;IAC9B,KAAK,QAAQ,SAAS,KAAK,aAAa,OAAO,KAAK,aAAa,OAAO;IACxE,KAAK,eAAe;GACtB;GACA;EACF;EAEA,IAAI,KAAK,WAAW,KAAK,eAAe;GACtC,KAAK,QAAQ,UAAU,KAAK,MAAM;GAClC,KAAK,gBAAgB,KAAK;EAC5B;EACA,IAAI,KAAK,YAAY,KAAA,KAAa,KAAK,YAAY,KAAK,gBAAgB;GACtE,KAAK,QAAQ,WAAW,KAAK,OAAO;GACpC,KAAK,iBAAiB,KAAK;EAC7B;EACA,IAAI,KAAK,WAAW,KAAA,GAClB,KAAK,QAAQ,UAAU,KAAK,MAAM;EACpC,IAAI,KAAK,WAAW,MAClB,KAAK,QAAQ,MAAM;OAEnB,KAAK,QAAQ,KAAK;CACtB;AACF;;;;;AAMA,SAAgB,qBAA2B;CACzC,uBAAuB;CACvB,cAAc,iBAAiB,qBAAqBA,OAAO;AAC7D"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { VisualEnvironmentController, VisualEnvironmentControllerOptions } from "@xihan-ui/core/visual-environment";
|
|
1
2
|
import { XhConfigBase, XhTranslationOverrides as XhTranslationOverrides$1 } from "@xihan-ui/headless";
|
|
2
3
|
//#region src/dom/spread.d.ts
|
|
3
4
|
interface Spreader {
|
|
@@ -7,23 +8,31 @@ interface Spreader {
|
|
|
7
8
|
declare function createSpreader(): Spreader;
|
|
8
9
|
//#endregion
|
|
9
10
|
//#region src/config.d.ts
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
type BindVisualRoot<T> = T extends unknown ? Omit<T, 'parent' | 'root'> & {
|
|
12
|
+
root: Element;
|
|
13
|
+
} : never;
|
|
14
|
+
type XhVisualEnvironmentConfig = BindVisualRoot<VisualEnvironmentControllerOptions>;
|
|
15
|
+
/** Web Components 的应用/子树配置;Portal 容器与视觉环境以 property-only 值表达。 */
|
|
16
|
+
interface XhConfig extends XhConfigBase {
|
|
17
|
+
portalContainer?: () => Element | null;
|
|
18
|
+
visualEnvironment?: XhVisualEnvironmentConfig;
|
|
19
|
+
}
|
|
20
|
+
/** 覆写全局配置。整份替换,不做深合并:需要修改一处时把整份取出修改后写回。 */
|
|
21
|
+
declare function setXhConfig(config: XhConfig): void;
|
|
14
22
|
declare function getXhConfig(): Readonly<XhConfig>;
|
|
15
23
|
/** 订阅配置变更,返回退订函数。已挂载的元素靠它在切语言时重渲。 */
|
|
16
24
|
declare function onXhConfigChange(listener: () => void): () => void;
|
|
17
25
|
/**
|
|
18
26
|
* 外层与内层逐键合并。
|
|
19
27
|
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
28
|
+
* 键缺席与写为 undefined 都视为本层未声明,一律回落外层:子树中只需要改文案时,
|
|
29
|
+
* 不应把外层的 locale 一并清除。
|
|
22
30
|
*/
|
|
23
31
|
declare function mergeXhConfig$1(base: XhConfig | undefined, over: XhConfig | undefined): XhConfig;
|
|
24
32
|
/** `<xh-config>` 认领这个接口,配置解析沿 DOM 祖先链找它,不必反向依赖元素类。 */
|
|
25
33
|
interface XhConfigScope extends Element {
|
|
26
34
|
readonly xhConfig: XhConfig;
|
|
35
|
+
readonly visualEnvironmentController?: VisualEnvironmentController;
|
|
27
36
|
}
|
|
28
37
|
/**
|
|
29
38
|
* 某个节点看到的配置:从全局那份起,沿祖先链自外向内逐层并进来。
|
|
@@ -33,5 +42,5 @@ interface XhConfigScope extends Element {
|
|
|
33
42
|
*/
|
|
34
43
|
declare function resolveXhConfig(node: Element | null | undefined): XhConfig;
|
|
35
44
|
//#endregion
|
|
36
|
-
export {
|
|
37
|
-
//# sourceMappingURL=config-
|
|
45
|
+
export { getXhConfig as a, resolveXhConfig as c, createSpreader as d, XhVisualEnvironmentConfig as i, setXhConfig as l, XhConfigScope as n, mergeXhConfig$1 as o, XhTranslationOverrides$1 as r, onXhConfigChange as s, XhConfig as t, Spreader as u };
|
|
46
|
+
//# sourceMappingURL=config-etfwIorI.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-etfwIorI.d.ts","names":[],"sources":["../src/dom/spread.ts","../src/config.ts"],"mappings":";;;UAgCiB;EACf,SAAS,MAAM,aAAa,OAAO;EACnC,UAAU,MAAM;;iBASF,kBAAkB;;;KCtB7B,eAAe,KAAK,oBAAoB,KAAK;EAA0B,MAAM;;KACtE,4BAA4B,eAAe;;UAGtC,iBAAiB;EAChC,wBAAwB;EACxB,oBAAoB;;;iBAaN,YAAY,QAAQ;iBASpB,eAAe,SAAS;;iBAKxB,iBAAiB;;;;;;;iBAWjB,gBAAc,MAAM,sBAAsB,MAAM,uBAAuB;;UAKtE,sBAAsB;WAC5B,UAAU;WACV,8BAA8B;;;;;;;;iBAazB,gBAAgB,MAAM,6BAA6B"}
|