@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.
@@ -1229,8 +1229,26 @@ interface Props {
1229
1229
  }
1230
1230
  declare const Loading: (props: Props) => React.JSX.Element;
1231
1231
 
1232
+ /**
1233
+ * 统一的 React Root 接口,兼容 React 17/18/19
1234
+ */
1235
+ interface SnackReactRoot {
1236
+ render: (element: React.ReactElement) => void;
1237
+ unmount: () => void;
1238
+ }
1239
+ /**
1240
+ * 运行时检测 React 主版本号,返回对应的挂载/卸载接口。
1241
+ * - React 18+:使用 `createRoot`(react-dom/client)
1242
+ * - React 17:使用旧版 `ReactDOM.render` / `unmountComponentAtNode`
1243
+ *
1244
+ * 注意:通过变量存储模块名,绕过宿主项目 webpack 的静态模块解析。
1245
+ * webpack 仅解析 require() 的字符串字面量参数,变量形式不会被静态分析,
1246
+ * 从而避免 React 17 宿主环境因 react-dom/client 不存在而报 "Module not found"。
1247
+ */
1248
+ declare function createReactRoot(container: Element): SnackReactRoot;
1249
+
1232
1250
  declare const _default: {
1233
1251
  version: string;
1234
1252
  };
1235
1253
 
1236
- export { Core, type CoreConfig, DisplayModule, type DropChildrenItem, Error$1 as Error, type ExprArgv, type FormDataFormatArgs, GetDefaultEvents, GetParamsDetails, type I18nMap, type ImportModules, type LoadConfig, type LoadModuleConfig, type LoadModuleURLConfig, Loading, type ModuleConfig, ParamsDetails, type RenderPageConfig, type RenderPageRule, type RequireConfig, Snack, type SnackCreateModule, type SnackData, type SnackDefineFunction, type SnackEvent, type SnackFormAttribute, type SnackFormVerifyRule, type SnackMapItem, type SnackPageCompleteEvent, type SnackPageConfig, type SnackPageContent, type SnackPageContentModule, type SnackPageData, type SnackPageParams, type SnackRequireFunction, SnackSDK, SnackSetting, type SnackSettingModelItem, _default as default, enParamsDetails, evalFunc, replaceVars };
1254
+ export { Core, type CoreConfig, DisplayModule, type DropChildrenItem, Error$1 as Error, type ExprArgv, type FormDataFormatArgs, GetDefaultEvents, GetParamsDetails, type I18nMap, type ImportModules, type LoadConfig, type LoadModuleConfig, type LoadModuleURLConfig, Loading, type ModuleConfig, ParamsDetails, type RenderPageConfig, type RenderPageRule, type RequireConfig, Snack, type SnackCreateModule, type SnackData, type SnackDefineFunction, type SnackEvent, type SnackFormAttribute, type SnackFormVerifyRule, type SnackMapItem, type SnackPageCompleteEvent, type SnackPageConfig, type SnackPageContent, type SnackPageContentModule, type SnackPageData, type SnackPageParams, type SnackReactRoot, type SnackRequireFunction, SnackSDK, SnackSetting, type SnackSettingModelItem, createReactRoot, _default as default, enParamsDetails, evalFunc, replaceVars };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@snack-kit/core",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "main": "dist/cjs/index.js",
5
5
  "module": "dist/es/index.js",
6
6
  "typings": "dist/types/index.d.ts",
@@ -33,14 +33,18 @@
33
33
  "author": "",
34
34
  "license": "ISC",
35
35
  "dependencies": {
36
- "@snack-kit/lib": "^0.6.0",
37
- "react": "^19.2.0",
38
- "react-dom": "^19.2.0"
36
+ "@snack-kit/lib": "^0.6.0"
37
+ },
38
+ "peerDependencies": {
39
+ "react": ">=17.0.0",
40
+ "react-dom": ">=17.0.0"
39
41
  },
40
42
  "devDependencies": {
41
43
  "@swc/core": "^1.15.18",
42
44
  "@types/react": "^19.2.7",
43
45
  "@types/react-dom": "^19.2.3",
46
+ "react": "^19.2.0",
47
+ "react-dom": "^19.2.0",
44
48
  "@vitest/coverage-v8": "^2.0.0",
45
49
  "css-loader": "^7.1.4",
46
50
  "html-webpack-plugin": "^5.6.6",