@snack-kit/core 0.1.0 → 0.2.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/README.md +305 -395
- package/dist/cjs/index.js +56 -20
- package/dist/cjs/index.js.map +1 -1
- package/dist/es/index.mjs +63 -21
- package/dist/es/index.mjs.map +1 -1
- package/dist/types/index.d.ts +19 -1
- package/package.json +8 -4
package/dist/es/index.mjs
CHANGED
|
@@ -347,6 +347,16 @@ function _ts_values(o) {
|
|
|
347
347
|
};
|
|
348
348
|
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
349
349
|
}
|
|
350
|
+
var __require = /* @__PURE__ */ function(x) {
|
|
351
|
+
return typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
352
|
+
get: function get1(a, b) {
|
|
353
|
+
return (typeof require !== "undefined" ? require : a)[b];
|
|
354
|
+
}
|
|
355
|
+
}) : x;
|
|
356
|
+
}(function(x) {
|
|
357
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
358
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
359
|
+
});
|
|
350
360
|
// src/class/snack.tsx
|
|
351
361
|
import React3, { useState } from "react";
|
|
352
362
|
import { DeepClone } from "@snack-kit/lib";
|
|
@@ -3208,7 +3218,7 @@ var Core = /*#__PURE__*/ function() {
|
|
|
3208
3218
|
}();
|
|
3209
3219
|
var core_default = Core;
|
|
3210
3220
|
// src/sdk/index.tsx
|
|
3211
|
-
import
|
|
3221
|
+
import React6 from "react";
|
|
3212
3222
|
import { Get, DeepClone as DeepClone2 } from "@snack-kit/lib";
|
|
3213
3223
|
// src/sdk/renderSnack.tsx
|
|
3214
3224
|
var renderSnackPage = function renderSnackPage1(props, formatData, onComplete) {
|
|
@@ -3711,8 +3721,36 @@ var Error2 = function Error21(props) {
|
|
|
3711
3721
|
}, props.sub) : null));
|
|
3712
3722
|
};
|
|
3713
3723
|
var error_default = Error2;
|
|
3724
|
+
// src/utils/reactAdapter.ts
|
|
3725
|
+
import React5 from "react";
|
|
3726
|
+
import ReactDOM from "react-dom";
|
|
3727
|
+
function createReactRoot(container) {
|
|
3728
|
+
var major = parseInt(React5.version.split(".")[0], 10);
|
|
3729
|
+
if (major >= 18) {
|
|
3730
|
+
var clientModName = "react-dom/client";
|
|
3731
|
+
var createRoot = __require(clientModName).createRoot;
|
|
3732
|
+
var root = createRoot(container);
|
|
3733
|
+
return {
|
|
3734
|
+
render: function render(el) {
|
|
3735
|
+
return root.render(el);
|
|
3736
|
+
},
|
|
3737
|
+
unmount: function unmount() {
|
|
3738
|
+
return root.unmount();
|
|
3739
|
+
}
|
|
3740
|
+
};
|
|
3741
|
+
} else {
|
|
3742
|
+
var legacyReactDOM = ReactDOM;
|
|
3743
|
+
return {
|
|
3744
|
+
render: function render(el) {
|
|
3745
|
+
return legacyReactDOM.render(el, container);
|
|
3746
|
+
},
|
|
3747
|
+
unmount: function unmount() {
|
|
3748
|
+
return legacyReactDOM.unmountComponentAtNode(container);
|
|
3749
|
+
}
|
|
3750
|
+
};
|
|
3751
|
+
}
|
|
3752
|
+
}
|
|
3714
3753
|
// src/sdk/index.tsx
|
|
3715
|
-
import { createRoot } from "react-dom/client";
|
|
3716
3754
|
var base64Decode = function base64Decode1(str) {
|
|
3717
3755
|
try {
|
|
3718
3756
|
return decodeURIComponent(escape(atob(str)));
|
|
@@ -3825,7 +3863,7 @@ var SnackSDK = /*#__PURE__*/ function(core_default1) {
|
|
|
3825
3863
|
{
|
|
3826
3864
|
content: {
|
|
3827
3865
|
FC: function FC() {
|
|
3828
|
-
return /* @__PURE__ */
|
|
3866
|
+
return /* @__PURE__ */ React6.createElement(error_default, {
|
|
3829
3867
|
content: "drop \u6A21\u5757\u52A0\u8F7D\u5931\u8D25",
|
|
3830
3868
|
sub: "type: ".concat(_this.basicsType)
|
|
3831
3869
|
});
|
|
@@ -3890,7 +3928,7 @@ var SnackSDK = /*#__PURE__*/ function(core_default1) {
|
|
|
3890
3928
|
{
|
|
3891
3929
|
content: {
|
|
3892
3930
|
FC: function FC() {
|
|
3893
|
-
return /* @__PURE__ */
|
|
3931
|
+
return /* @__PURE__ */ React6.createElement(error_default, {
|
|
3894
3932
|
content: "\u9875\u9762\u6E32\u67D3\u5931\u8D25\u4E86",
|
|
3895
3933
|
sub: "id: ".concat(params === null || params === void 0 ? void 0 : params.id, " type: ").concat(params === null || params === void 0 ? void 0 : params.type)
|
|
3896
3934
|
});
|
|
@@ -4447,7 +4485,7 @@ var SnackSDK = /*#__PURE__*/ function(core_default1) {
|
|
|
4447
4485
|
return [
|
|
4448
4486
|
2,
|
|
4449
4487
|
function() {
|
|
4450
|
-
return /* @__PURE__ */
|
|
4488
|
+
return /* @__PURE__ */ React6.createElement(error_default, {
|
|
4451
4489
|
content: "\u9875\u9762\u6E32\u67D3\u5931\u8D25",
|
|
4452
4490
|
info: JSON.stringify(params, null, 4)
|
|
4453
4491
|
});
|
|
@@ -4497,8 +4535,8 @@ var SnackSDK = /*#__PURE__*/ function(core_default1) {
|
|
|
4497
4535
|
Page = function Page(e) {
|
|
4498
4536
|
return root.FC(e);
|
|
4499
4537
|
};
|
|
4500
|
-
parent =
|
|
4501
|
-
parent.render(/* @__PURE__ */
|
|
4538
|
+
parent = createReactRoot(el);
|
|
4539
|
+
parent.render(/* @__PURE__ */ React6.createElement(Page, _object_spread({}, {})));
|
|
4502
4540
|
return [
|
|
4503
4541
|
2,
|
|
4504
4542
|
root
|
|
@@ -4531,7 +4569,7 @@ var SnackSDK = /*#__PURE__*/ function(core_default1) {
|
|
|
4531
4569
|
return [
|
|
4532
4570
|
2,
|
|
4533
4571
|
function() {
|
|
4534
|
-
return /* @__PURE__ */
|
|
4572
|
+
return /* @__PURE__ */ React6.createElement(error_default, {
|
|
4535
4573
|
content: "\u6A21\u5757\u6E32\u67D3\u5931\u8D25",
|
|
4536
4574
|
info: JSON.stringify(args, null, 4)
|
|
4537
4575
|
});
|
|
@@ -4579,8 +4617,8 @@ var SnackSDK = /*#__PURE__*/ function(core_default1) {
|
|
|
4579
4617
|
Module = function Module(e) {
|
|
4580
4618
|
return mod.FC(e);
|
|
4581
4619
|
};
|
|
4582
|
-
parent =
|
|
4583
|
-
parent.render(/* @__PURE__ */
|
|
4620
|
+
parent = createReactRoot(el);
|
|
4621
|
+
parent.render(/* @__PURE__ */ React6.createElement(Module, _object_spread({}, {})));
|
|
4584
4622
|
return [
|
|
4585
4623
|
2,
|
|
4586
4624
|
mod
|
|
@@ -4663,11 +4701,11 @@ var GetDefaultEvents = function GetDefaultEvents1(language) {
|
|
|
4663
4701
|
];
|
|
4664
4702
|
};
|
|
4665
4703
|
// src/components/loading/index.tsx
|
|
4666
|
-
import
|
|
4704
|
+
import React7 from "react";
|
|
4667
4705
|
var Loading = function Loading1(props) {
|
|
4668
|
-
var ref =
|
|
4669
|
-
var
|
|
4670
|
-
|
|
4706
|
+
var ref = React7.useRef(null);
|
|
4707
|
+
var _React7_useState = _sliced_to_array(React7.useState(0), 2), opacity = _React7_useState[0], setOpacity = _React7_useState[1];
|
|
4708
|
+
React7.useEffect(function() {
|
|
4671
4709
|
var timeout = setTimeout(function() {
|
|
4672
4710
|
setOpacity(1);
|
|
4673
4711
|
}, 500);
|
|
@@ -4675,20 +4713,20 @@ var Loading = function Loading1(props) {
|
|
|
4675
4713
|
return clearTimeout(timeout);
|
|
4676
4714
|
};
|
|
4677
4715
|
}, []);
|
|
4678
|
-
return /* @__PURE__ */
|
|
4716
|
+
return /* @__PURE__ */ React7.createElement("div", {
|
|
4679
4717
|
className: "snack-core-loading ".concat(props.className || ""),
|
|
4680
4718
|
ref: ref,
|
|
4681
4719
|
style: {
|
|
4682
4720
|
opacity: opacity
|
|
4683
4721
|
}
|
|
4684
|
-
}, /* @__PURE__ */
|
|
4722
|
+
}, /* @__PURE__ */ React7.createElement("div", {
|
|
4685
4723
|
className: "spinner"
|
|
4686
4724
|
}));
|
|
4687
4725
|
};
|
|
4688
4726
|
// package.json
|
|
4689
4727
|
var package_default = {
|
|
4690
4728
|
name: "@snack-kit/core",
|
|
4691
|
-
version: "0.
|
|
4729
|
+
version: "0.2.0",
|
|
4692
4730
|
main: "dist/cjs/index.js",
|
|
4693
4731
|
module: "dist/es/index.js",
|
|
4694
4732
|
typings: "dist/types/index.d.ts",
|
|
@@ -4721,14 +4759,18 @@ var package_default = {
|
|
|
4721
4759
|
author: "",
|
|
4722
4760
|
license: "ISC",
|
|
4723
4761
|
dependencies: {
|
|
4724
|
-
"@snack-kit/lib": "^0.6.0"
|
|
4725
|
-
|
|
4726
|
-
|
|
4762
|
+
"@snack-kit/lib": "^0.6.0"
|
|
4763
|
+
},
|
|
4764
|
+
peerDependencies: {
|
|
4765
|
+
react: ">=17.0.0",
|
|
4766
|
+
"react-dom": ">=17.0.0"
|
|
4727
4767
|
},
|
|
4728
4768
|
devDependencies: {
|
|
4729
4769
|
"@swc/core": "^1.15.18",
|
|
4730
4770
|
"@types/react": "^19.2.7",
|
|
4731
4771
|
"@types/react-dom": "^19.2.3",
|
|
4772
|
+
react: "^19.2.0",
|
|
4773
|
+
"react-dom": "^19.2.0",
|
|
4732
4774
|
"@vitest/coverage-v8": "^2.0.0",
|
|
4733
4775
|
"css-loader": "^7.1.4",
|
|
4734
4776
|
"html-webpack-plugin": "^5.6.6",
|
|
@@ -4754,7 +4796,7 @@ var src_default = {
|
|
|
4754
4796
|
version: version2
|
|
4755
4797
|
};
|
|
4756
4798
|
console.log("\n ____ __ _______ __ __\n / __/__ ___ _____/ /__ / __/ _ \\/ //_/\n _\\ \\/ _ \\/ _ `/ __/ '_/_\\ \\/ // / ,< \n/___/_//_/\\_,_/\\__/_/\\_\\/___/____/_/|_| v.".concat(version2, "\n \n"));
|
|
4757
|
-
export { Core, DisplayModule, Error2 as Error, GetDefaultEvents, GetParamsDetails, Loading, ParamsDetails, Snack, SnackSDK, SnackSetting, src_default as default, enParamsDetails, evalFunc, replaceVars }; /**
|
|
4799
|
+
export { Core, DisplayModule, Error2 as Error, GetDefaultEvents, GetParamsDetails, Loading, ParamsDetails, Snack, SnackSDK, SnackSetting, createReactRoot, src_default as default, enParamsDetails, evalFunc, replaceVars }; /**
|
|
4758
4800
|
* @license Snack RequireJS 2.3.6
|
|
4759
4801
|
*/
|
|
4760
4802
|
//# sourceMappingURL=index.mjs.map
|