@d-matrix/utils 1.1.0 → 1.1.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/dist/index.d.ts +1 -0
- package/dist/index.js +2 -1
- package/dist/react.d.ts +3 -0
- package/dist/react.js +38 -0
- package/package.json +5 -2
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -19,5 +19,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
19
19
|
return result;
|
|
20
20
|
};
|
|
21
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
exports.clipboard = void 0;
|
|
22
|
+
exports.react = exports.clipboard = void 0;
|
|
23
23
|
exports.clipboard = __importStar(require("./clipboard"));
|
|
24
|
+
exports.react = __importStar(require("./react"));
|
package/dist/react.d.ts
ADDED
package/dist/react.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.cleanup = exports.render = void 0;
|
|
7
|
+
var react_dom_1 = __importDefault(require("react-dom"));
|
|
8
|
+
var container;
|
|
9
|
+
var render = function (element) {
|
|
10
|
+
return new Promise(function (resolve, reject) {
|
|
11
|
+
if (document === undefined) {
|
|
12
|
+
return reject('只支持浏览器环境');
|
|
13
|
+
}
|
|
14
|
+
container = document.createElement('div');
|
|
15
|
+
container.id = 'template-container';
|
|
16
|
+
container.style.cssText = 'position: absolute; left: -9999px;';
|
|
17
|
+
document.body.appendChild(container);
|
|
18
|
+
react_dom_1.default.render(element, container, function () {
|
|
19
|
+
if (container) {
|
|
20
|
+
resolve(container.innerHTML);
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
reject('组件容器不存在');
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
exports.render = render;
|
|
29
|
+
var cleanup = function () {
|
|
30
|
+
if (container === null)
|
|
31
|
+
return;
|
|
32
|
+
var isUnmounted = react_dom_1.default.unmountComponentAtNode(container);
|
|
33
|
+
if (isUnmounted) {
|
|
34
|
+
document.body.removeChild(container);
|
|
35
|
+
container = null;
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
exports.cleanup = cleanup;
|
package/package.json
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@d-matrix/utils",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"description": "A dozen of utils for Front-End Development",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"build": "tsc"
|
|
7
|
+
"build": "tsc",
|
|
8
|
+
"clean": "tsc --build --clean",
|
|
9
|
+
"prepublish": "npm run clean && npm run build",
|
|
10
|
+
"publish": "npm publish --access public"
|
|
8
11
|
},
|
|
9
12
|
"engines": {
|
|
10
13
|
"node": ">=16.20.0"
|