swico 2.8.0-beta.1 → 2.8.0-beta.11

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/package.json CHANGED
@@ -1,9 +1,23 @@
1
1
  {
2
2
  "name": "swico",
3
- "version": "2.8.0-beta.1",
3
+ "version": "2.8.0-beta.11",
4
4
  "description": "Simple, efficient, and practical front-end framework",
5
5
  "main": "./src/index.js",
6
6
  "types": "./src/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "default": "./src/index.js",
10
+ "types": "./src/index.d.ts"
11
+ },
12
+ "./react": {
13
+ "default": "./src/index.react.js",
14
+ "types": "./src/index.react.d.ts"
15
+ },
16
+ "./vue": {
17
+ "default": "./src/index.vue.js",
18
+ "types": "./src/index.vue.d.ts"
19
+ }
20
+ },
7
21
  "keywords": [
8
22
  "typescript",
9
23
  "javascript",
@@ -25,7 +25,7 @@ const chalk_1 = __importDefault(require("chalk"));
25
25
  const dev_server_1 = require("@rspack/dev-server");
26
26
  const fs_extra_1 = __importDefault(require("fs-extra"));
27
27
  const core_1 = require("@rspack/core");
28
- let currentPort, currentRouterBase = '/';
28
+ let currentPort, currentTemplateType, currentRouterBase = '/';
29
29
  const handleWatch = (projectPath, devServer, env) => {
30
30
  const envPath = env === 'dev' ? '/.dev/' : '/.prod/';
31
31
  const configFilesWatcher = chokidar_1.default
package/src/index.d.ts CHANGED
@@ -1,13 +1,11 @@
1
1
  import { GlobalData, GlobalSwicoConfigType } from './main-config';
2
2
  import { UseLocationType, UseNavType } from './typings/global-type';
3
- import { Outlet as ReactOutlet, Link as ReactLink } from './index.react';
4
- import { Outlet as VueOutlet, Link as VueLink } from './index.vue';
5
3
  import { App } from 'vue';
6
4
  import { Router } from 'vue-router';
7
5
  export type CustomConfigType = GlobalData['customConfig'];
8
6
  export type { GlobalSwicoConfigType };
9
7
  export { history } from './mock-history';
10
- declare let Outlet: typeof ReactOutlet | typeof VueOutlet, Link: typeof ReactLink | typeof VueLink, useLocation: UseLocationType, useNav: UseNavType;
8
+ declare let Outlet: any, Link: any, useLocation: UseLocationType, useNav: UseNavType;
11
9
  export { Outlet, Link, useLocation, useNav };
12
10
  export interface DefineSwicoConfigType {
13
11
  (env: 'base', config: CustomConfigType['base']): CustomConfigType['base'];
@@ -16,6 +14,6 @@ export interface DefineSwicoConfigType {
16
14
  }
17
15
  export declare const defineConfig: DefineSwicoConfigType;
18
16
  export interface DefineGlobalConfigType {
19
- onInit?: ((app: App, router: Router) => void) | (() => void);
17
+ onInit?: (app?: App, router?: Router) => void;
20
18
  }
21
19
  export declare const defineGlobal: (config: DefineGlobalConfigType) => DefineGlobalConfigType;
@@ -1,17 +1,17 @@
1
1
  import { GlobalData, GlobalSwicoConfigType } from './main-config';
2
2
  import { CSSProperties, FC, ReactNode } from 'react';
3
- import { useNav, useLocation } from './template-root/.swico-react/hooks';
4
3
  import { SwicoHistoryOptionType } from './typings/global-type';
4
+ import { useLocation, useNav } from './template-root/.swico-react/hooks';
5
5
  export type CustomConfigType = GlobalData['customConfig'];
6
- interface PropsType {
6
+ export type { GlobalSwicoConfigType };
7
+ interface LinkPropsType {
7
8
  replace?: boolean;
8
9
  to: string | number | SwicoHistoryOptionType;
9
10
  style?: CSSProperties;
10
11
  className?: string;
11
12
  children: ReactNode;
12
13
  }
13
- export declare const Link: FC<PropsType>;
14
- export type { GlobalSwicoConfigType };
14
+ export declare const Link: FC<LinkPropsType>;
15
15
  export { Outlet } from 'react-router';
16
16
  export { useLocation, useNav };
17
17
  export { history } from './mock-history';
@@ -6,8 +6,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.defineGlobal = exports.defineConfig = exports.history = exports.useNav = exports.useLocation = exports.Outlet = exports.Link = void 0;
7
7
  const react_1 = __importDefault(require("react"));
8
8
  const hooks_1 = require("./template-root/.swico-react/hooks");
9
- Object.defineProperty(exports, "useNav", { enumerable: true, get: function () { return hooks_1.useNav; } });
10
9
  Object.defineProperty(exports, "useLocation", { enumerable: true, get: function () { return hooks_1.useLocation; } });
10
+ Object.defineProperty(exports, "useNav", { enumerable: true, get: function () { return hooks_1.useNav; } });
11
11
  const Link = ({ replace, to, style, className, children }) => {
12
12
  const nav = (0, hooks_1.useNav)();
13
13
  return (react_1.default.createElement("a", { onClick: () => {
@@ -2,35 +2,18 @@ import { GlobalData, GlobalSwicoConfigType } from './main-config';
2
2
  import { App } from 'vue';
3
3
  import { Router } from 'vue-router';
4
4
  import { useLocation, useNav } from './template-root/.swico-vue/hooks';
5
+ import { SwicoHistoryOptionType } from './typings/global-type';
5
6
  export type CustomConfigType = GlobalData['customConfig'];
6
7
  export { RouterView } from 'vue-router';
7
8
  export { useLocation, useNav };
8
9
  export { history } from './mock-history';
9
10
  export type { GlobalSwicoConfigType };
10
11
  export declare const Outlet: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
11
- export declare const Link: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
12
- to: {
13
- required: true;
14
- };
15
- replace: {
16
- type: BooleanConstructor;
17
- };
18
- }>, {
19
- nav: {
20
- (to: string, options?: import("./typings/global-type").NavOptionsType): void;
21
- (to: number): void;
22
- (to: import("./typings/global-type").SwicoHistoryOptionType, options?: import("./typings/global-type").NavOptionsType): void;
23
- };
24
- }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
25
- to: {
26
- required: true;
27
- };
28
- replace: {
29
- type: BooleanConstructor;
30
- };
31
- }>> & Readonly<{}>, {
32
- replace: boolean;
33
- }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
12
+ interface LinkPropsType {
13
+ replace?: boolean;
14
+ to: string | number | SwicoHistoryOptionType;
15
+ }
16
+ export declare const Link: import("vue").DefineComponent<LinkPropsType, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<LinkPropsType> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
34
17
  export interface DefineSwicoConfigType {
35
18
  (env: 'base', config: CustomConfigType['base']): any;
36
19
  (env: 'dev', config: CustomConfigType['dev']): any;
@@ -219,10 +219,10 @@ const handleLoadingFile = (projectPath, replaceIndexText) => __awaiter(void 0, v
219
219
  let newReplaceIndexText = replaceIndexText;
220
220
  try {
221
221
  yield fs_extra_1.default.access(path_1.default.resolve(projectPath, './src/loading/index.tsx'), fs_extra_1.default.constants.F_OK);
222
- newReplaceIndexText = newReplaceIndexText.replace('const Loading = () => null;', 'const loading = __importDefault(require("../../src/loading"));');
222
+ newReplaceIndexText = newReplaceIndexText.replace('const Loading = () => null;', 'const Loading = __importDefault(require("../../src/loading")).default;');
223
223
  }
224
224
  catch (e) {
225
- newReplaceIndexText = newReplaceIndexText.replace('__importDefault(require("../../src/loading"));', '() => null;');
225
+ newReplaceIndexText = newReplaceIndexText.replace('__importDefault(require("../../src/loading")).default;', '() => null;');
226
226
  }
227
227
  return newReplaceIndexText;
228
228
  });
@@ -90,6 +90,7 @@ export default function ({ projectPath, entryPath, env, customConfig }: GlobalDa
90
90
  alias: {
91
91
  '@': string;
92
92
  'react-router': string;
93
+ 'swico/react': string;
93
94
  swico: string;
94
95
  qs: string;
95
96
  };
@@ -146,7 +146,7 @@ function default_1(_a) {
146
146
  },
147
147
  resolve: {
148
148
  extensions: ['.ts', '.tsx', '.js', '.jsx', '.json'],
149
- alias: Object.assign({ '@': path_1.default.join(projectPath, '/src'), 'react-router': path_1.default.dirname(require.resolve('react-router')), swico: path_1.default.join(projectPath, '/.swico/index'), qs: path_1.default.dirname(require.resolve('qs')) }, getCustomAliasConfig())
149
+ alias: Object.assign({ '@': path_1.default.join(projectPath, '/src'), 'react-router': path_1.default.dirname(require.resolve('react-router')), 'swico/react': path_1.default.join(projectPath, '/.swico/index'), swico: path_1.default.join(projectPath, '/.swico/index'), qs: path_1.default.dirname(require.resolve('qs')) }, getCustomAliasConfig())
150
150
  },
151
151
  externals: customConfig.base.externals,
152
152
  plugins: [
@@ -125,6 +125,7 @@ export default function ({ projectPath, entryPath, env, customConfig }: GlobalDa
125
125
  '@': string;
126
126
  vue: string;
127
127
  'vue-router': string;
128
+ 'swico/vue': string;
128
129
  swico: string;
129
130
  qs: string;
130
131
  };
@@ -254,7 +254,7 @@ function default_1(_a) {
254
254
  },
255
255
  resolve: {
256
256
  extensions: ['.ts', '.js', '.vue', '.json'],
257
- alias: Object.assign({ '@': path_1.default.join(projectPath, '/src'), vue: 'vue/dist/vue.esm-bundler.js', 'vue-router': path_1.default.dirname(require.resolve('vue-router')), swico: path_1.default.join(projectPath, '/.swico/index'), qs: path_1.default.dirname(require.resolve('qs')) }, getCustomAliasConfig())
257
+ alias: Object.assign({ '@': path_1.default.join(projectPath, '/src'), vue: 'vue/dist/vue.esm-bundler.js', 'vue-router': path_1.default.dirname(require.resolve('vue-router')), 'swico/vue': path_1.default.join(projectPath, '/.swico/index'), swico: path_1.default.join(projectPath, '/.swico/index'), qs: path_1.default.dirname(require.resolve('qs')) }, getCustomAliasConfig())
258
258
  },
259
259
  externals: customBaseConfig === null || customBaseConfig === void 0 ? void 0 : customBaseConfig.externals,
260
260
  plugins: [
@@ -98,7 +98,6 @@ const App = () => {
98
98
  return react_1.default.createElement(react_router_1.RouterProvider, { router: router });
99
99
  };
100
100
  const rootEle = document.createElement('div');
101
- rootEle.id = 'swico-root';
102
101
  document.body.appendChild(rootEle);
103
102
  const root = (0, client_1.createRoot)(rootEle);
104
103
  root.render(react_1.default.createElement(App, null));
@@ -25,7 +25,6 @@ const app = (0, vue_1.createApp)(Container);
25
25
  app.component('SwicoLayout', Layout_1.default);
26
26
  app.use(router);
27
27
  const rootEle = document.createElement('div');
28
- rootEle.id = 'swico-root';
29
28
  document.body.appendChild(rootEle);
30
29
  app.mount(rootEle);
31
30
  (_a = global_1.default === null || global_1.default === void 0 ? void 0 : global_1.default.onInit) === null || _a === void 0 ? void 0 : _a.call(global_1.default, app, router);