@fibrae/semi-polyfill 0.0.0-stage → 0.1.1

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/LICENSE ADDED
@@ -0,0 +1,84 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021 DouyinFE
4
+ Copyright (c) 2026 smile-alive
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
23
+
24
+ The code implementation of the external library is referenced by DouyinFe are:
25
+
26
+ - animate.css
27
+
28
+ The MIT License (MIT)
29
+
30
+ Copyright (c) 2020 Daniel Eden
31
+
32
+ Permission is hereby granted, free of charge, to any person obtaining a copy
33
+ of this software and associated documentation files (the "Software"), to deal
34
+ in the Software without restriction, including without limitation the rights
35
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
36
+ copies of the Software, and to permit persons to whom the Software is
37
+ furnished to do so, subject to the following conditions:
38
+
39
+ The above copyright notice and this permission notice shall be included in all
40
+ copies or substantial portions of the Software.
41
+
42
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
43
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
44
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
45
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
46
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
47
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
48
+ SOFTWARE.
49
+
50
+ - Ant Design
51
+ MIT LICENSE
52
+
53
+ Copyright (c) 2015-present Ant UED, https://xtech.antfin.com/
54
+
55
+ Permission is hereby granted, free of charge, to any person obtaining
56
+ a copy of this software and associated documentation files (the
57
+ "Software"), to deal in the Software without restriction, including
58
+ without limitation the rights to use, copy, modify, merge, publish,
59
+ distribute, sublicense, and/or sell copies of the Software, and to
60
+ permit persons to whom the Software is furnished to do so, subject to
61
+ the following conditions:
62
+
63
+ The above copyright notice and this permission notice shall be
64
+ included in all copies or substantial portions of the Software.
65
+
66
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
67
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
68
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
69
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
70
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
71
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
72
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
73
+
74
+ - rc-tree
75
+
76
+ MIT LICENSE
77
+
78
+ Copyright (c) 2015-present Alipay.com, https://www.alipay.com/
79
+
80
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
81
+
82
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
83
+
84
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,29 @@
1
- # Temporary Holding Version
1
+ # @fibrae/semi-polyfill
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Semi Design Next 的可选 polyfill。组件代码直接使用原生 API,目标浏览器中个别版本缺少的 API 由本包补齐。
4
+
5
+ ## 目标浏览器
6
+
7
+ Chrome 120、Firefox 125、Safari 17.2 及以上。Chrome 与 Firefox 已原生支持本包的全部内容,只有 Safari 17.2 与 17.3 需要它;只面向其余浏览器时不必安装。
8
+
9
+ ## 安装与使用
10
+
11
+ ```sh
12
+ pnpm add @fibrae/semi-polyfill
13
+ ```
14
+
15
+ 在应用入口最先导入,保证组件代码运行前 API 已就绪:
16
+
17
+ ```js
18
+ import '@fibrae/semi-polyfill';
19
+ ```
20
+
21
+ 只需要其中一项时导入单项入口。每个 shim 只在原生缺失时安装;服务端渲染时没有对应全局,什么都不做。
22
+
23
+ ## 入口
24
+
25
+ | 入口 | 补齐的 API | 原生支持 | 说明 |
26
+ | --- | --- | --- | --- |
27
+ | `@fibrae/semi-polyfill` | 下面全部 | | 引入所有 shim |
28
+ | `@fibrae/semi-polyfill/abort-signal-any` | `AbortSignal.any` | Safari 17.4 | 任一源 signal abort 时结果 abort,reason 取先 abort 的源;源已 abort 时立即 abort |
29
+ | `@fibrae/semi-polyfill/check-visibility` | `Element.prototype.checkVisibility` | Safari 17.4 | 支持 `checkOpacity`、`checkVisibilityCSS` 与旧名 `opacityProperty`、`visibilityProperty`;渲染以 `getClientRects().length > 0` 判断,祖先 `content-visibility: hidden` 视为不可见。不支持 `contentVisibilityAuto`,该选项被忽略 |
@@ -0,0 +1,19 @@
1
+ // src/abort-signal-any.ts
2
+ const abortSignal = typeof AbortSignal === "undefined" ? void 0 : AbortSignal;
3
+ if (abortSignal && !("any" in abortSignal)) abortSignal.any = (signals) => {
4
+ const controller = new AbortController();
5
+ const aborted = signals.find((signal) => signal.aborted);
6
+ if (aborted) {
7
+ controller.abort(aborted.reason);
8
+ return controller.signal;
9
+ }
10
+ const listeners = signals.map((signal) => {
11
+ const listener = () => {
12
+ signals.forEach((other, index) => other.removeEventListener("abort", listeners[index]));
13
+ controller.abort(signal.reason);
14
+ };
15
+ signal.addEventListener("abort", listener);
16
+ return listener;
17
+ });
18
+ return controller.signal;
19
+ };
@@ -0,0 +1,18 @@
1
+ // src/check-visibility.ts
2
+ function parentOf(node) {
3
+ return node.parentElement ?? node.getRootNode().host ?? null;
4
+ }
5
+ const elementProto = typeof Element === "undefined" ? void 0 : Element.prototype;
6
+ if (elementProto && !("checkVisibility" in elementProto)) elementProto.checkVisibility = function checkVisibility(options = {}) {
7
+ if (!this.isConnected || this.getClientRects().length === 0) return false;
8
+ const checkOpacity = options.checkOpacity ?? options.opacityProperty;
9
+ if (options.checkVisibilityCSS ?? options.visibilityProperty) {
10
+ const { visibility } = getComputedStyle(this);
11
+ if (visibility === "hidden" || visibility === "collapse") return false;
12
+ }
13
+ for (let node = this; node; node = parentOf(node)) {
14
+ const style = getComputedStyle(node);
15
+ if (checkOpacity && style.opacity === "0" || node !== this && style.getPropertyValue("content-visibility") === "hidden") return false;
16
+ }
17
+ return true;
18
+ };
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ import "./abort-signal-any.js";
2
+ import "./check-visibility.js";
package/package.json CHANGED
@@ -1,6 +1,36 @@
1
1
  {
2
2
  "name": "@fibrae/semi-polyfill",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.1",
4
+ "description": "Optional polyfills for the APIs Semi uses that Safari 17.2 lacks",
5
+ "license": "MIT",
6
+ "homepage": "https://semi-design-next.pages.dev",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/smile-alive/semi-design-next.git",
10
+ "directory": "packages/semi-polyfill"
11
+ },
12
+ "bugs": {
13
+ "url": "https://github.com/smile-alive/semi-design-next/issues"
14
+ },
15
+ "keywords": [
16
+ "polyfill",
17
+ "semi"
18
+ ],
19
+ "type": "module",
20
+ "exports": {
21
+ ".": "./dist/index.js",
22
+ "./abort-signal-any": "./dist/abort-signal-any.js",
23
+ "./check-visibility": "./dist/check-visibility.js",
24
+ "./package.json": "./package.json"
25
+ },
26
+ "files": [
27
+ "dist"
28
+ ],
29
+ "sideEffects": true,
30
+ "devDependencies": {
31
+ "typescript": "^6.0.3"
32
+ },
33
+ "scripts": {
34
+ "build": "vp pack"
35
+ }
6
36
  }