swico 2.8.0-beta.8 → 2.8.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/package.json CHANGED
@@ -1,9 +1,23 @@
1
1
  {
2
2
  "name": "swico",
3
- "version": "2.8.0-beta.8",
3
+ "version": "2.8.0",
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",
@@ -1,20 +1,20 @@
1
- import { GlobalData, GlobalSwicoConfigType } from '../src/main-config';
1
+ import { GlobalData, GlobalSwicoConfigType } from './main-config';
2
2
  import { CSSProperties, FC, ReactNode } from 'react';
3
- import { useNav, useLocation } from '../src/template-root/.swico-react/hooks';
4
- import { SwicoHistoryOptionType } from '../src/typings/global-type';
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
- export { history } from '../src/mock-history';
17
+ export { history } from './mock-history';
18
18
  export interface DefineSwicoConfigType {
19
19
  (env: 'base', config: CustomConfigType['base']): any;
20
20
  (env: 'dev', config: CustomConfigType['dev']): any;
@@ -5,9 +5,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  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
- const hooks_1 = require("../src/template-root/.swico-react/hooks");
9
- Object.defineProperty(exports, "useNav", { enumerable: true, get: function () { return hooks_1.useNav; } });
8
+ const hooks_1 = require("./template-root/.swico-react/hooks");
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: () => {
@@ -17,7 +17,7 @@ const Link = ({ replace, to, style, className, children }) => {
17
17
  exports.Link = Link;
18
18
  var react_router_1 = require("react-router");
19
19
  Object.defineProperty(exports, "Outlet", { enumerable: true, get: function () { return react_router_1.Outlet; } });
20
- var mock_history_1 = require("../src/mock-history");
20
+ var mock_history_1 = require("./mock-history");
21
21
  Object.defineProperty(exports, "history", { enumerable: true, get: function () { return mock_history_1.history; } });
22
22
  const defineConfig = (env, config) => config;
23
23
  exports.defineConfig = defineConfig;
@@ -0,0 +1,28 @@
1
+ import { GlobalData, GlobalSwicoConfigType } from './main-config';
2
+ import { App } from 'vue';
3
+ import { Router } from 'vue-router';
4
+ import { useLocation, useNav } from './template-root/.swico-vue/hooks';
5
+ import { SwicoHistoryOptionType } from './typings/global-type';
6
+ export type CustomConfigType = GlobalData['customConfig'];
7
+ export { RouterView } from 'vue-router';
8
+ export { useLocation, useNav };
9
+ export { history } from './mock-history';
10
+ export type { GlobalSwicoConfigType };
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>;
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<{}>, {
17
+ [x: string]: any;
18
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
19
+ export interface DefineSwicoConfigType {
20
+ (env: 'base', config: CustomConfigType['base']): any;
21
+ (env: 'dev', config: CustomConfigType['dev']): any;
22
+ (env: 'prod', config: CustomConfigType['prod']): any;
23
+ }
24
+ export declare const defineConfig: DefineSwicoConfigType;
25
+ export interface DefineGlobalConfigType {
26
+ onInit?: (app: App, router: Router) => void;
27
+ }
28
+ export declare const defineGlobal: (config: DefineGlobalConfigType) => DefineGlobalConfigType;
@@ -2,12 +2,12 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.defineGlobal = exports.defineConfig = exports.Link = exports.Outlet = exports.history = exports.useNav = exports.useLocation = exports.RouterView = void 0;
4
4
  const vue_1 = require("vue");
5
- const hooks_1 = require("../src/template-root/.swico-vue/hooks");
5
+ const hooks_1 = require("./template-root/.swico-vue/hooks");
6
6
  Object.defineProperty(exports, "useLocation", { enumerable: true, get: function () { return hooks_1.useLocation; } });
7
7
  Object.defineProperty(exports, "useNav", { enumerable: true, get: function () { return hooks_1.useNav; } });
8
8
  var vue_router_1 = require("vue-router");
9
9
  Object.defineProperty(exports, "RouterView", { enumerable: true, get: function () { return vue_router_1.RouterView; } });
10
- var mock_history_1 = require("../src/mock-history");
10
+ var mock_history_1 = require("./mock-history");
11
11
  Object.defineProperty(exports, "history", { enumerable: true, get: function () { return mock_history_1.history; } });
12
12
  exports.Outlet = (0, vue_1.defineComponent)({
13
13
  name: 'Outlet',
@@ -160,11 +160,11 @@ const initCliEntryFile = (projectPath, templateType, env) => __awaiter(void 0, v
160
160
  const formatHooksPath = path_1.default
161
161
  .resolve(projectPath, './.swico/hooks')
162
162
  .replaceAll('\\', '/');
163
- replaceEntryText = replaceEntryText.replaceAll(`require("../src/template-root/.swico-${templateType}/hooks");`, `require("${formatHooksPath}");`);
163
+ replaceEntryText = replaceEntryText.replaceAll(`require("./template-root/.swico-${templateType}/hooks");`, `require("${formatHooksPath}");`);
164
164
  const formatHistoryPath = path_1.default
165
165
  .resolve(projectPath, `./.swico/.${env}/history`)
166
166
  .replaceAll('\\', '/');
167
- replaceEntryText = replaceEntryText.replaceAll('require("../src/mock-history");', `require("${formatHistoryPath}");`);
167
+ replaceEntryText = replaceEntryText.replaceAll('require("./mock-history");', `require("${formatHistoryPath}");`);
168
168
  yield fs_extra_1.default.writeFile(entryFilePath, replaceEntryText);
169
169
  });
170
170
  const formatRouterConfig = ({ routes = [], type = 'browser', base = '/' }, templateType, env) => {
@@ -253,7 +253,7 @@ const initTemplateConfig = (routerConfig, templateType, env) => {
253
253
  yield (0, utils_1.copyDirFiles)(path_1.default.resolve(__dirname, `../template-root/.swico-${templateType}/$env`), copyTargetPath, (fileName) => !fileName.endsWith('.d.ts') && !['hooks.js'].includes(fileName));
254
254
  yield (0, utils_1.copyDirFiles)(path_1.default.resolve(__dirname, `../template-root/.swico-${templateType}`), path_1.default.resolve(projectPath, './.swico'), (fileName) => ['hooks.js'].includes(fileName));
255
255
  const entryFilePath = path_1.default.resolve(projectPath, './.swico/index.js');
256
- yield fs_extra_1.default.copyFile(path_1.default.resolve(__dirname, `../../${templateType}/index.js`), entryFilePath);
256
+ yield fs_extra_1.default.copyFile(path_1.default.resolve(__dirname, `../index.${templateType}.js`), entryFilePath);
257
257
  yield formatRouterConfig(routerConfig, templateType, env);
258
258
  const hooksFilePath = path_1.default.resolve(projectPath, './.swico/hooks.js');
259
259
  let replaceHooksText = yield fs_extra_1.default.readFile(hooksFilePath, 'utf8');
@@ -90,8 +90,8 @@ export default function ({ projectPath, entryPath, env, customConfig }: GlobalDa
90
90
  alias: {
91
91
  '@': string;
92
92
  'react-router': string;
93
- swico: string;
94
93
  'swico/react': string;
94
+ swico: string;
95
95
  qs: string;
96
96
  };
97
97
  };
@@ -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'), 'swico/react': path_1.default.resolve(path_1.default.dirname(require.resolve('qs')), './react'), 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,8 +125,8 @@ export default function ({ projectPath, entryPath, env, customConfig }: GlobalDa
125
125
  '@': string;
126
126
  vue: string;
127
127
  'vue-router': string;
128
- swico: string;
129
128
  'swico/vue': string;
129
+ swico: string;
130
130
  qs: string;
131
131
  };
132
132
  };
@@ -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'), 'swico/vue': path_1.default.resolve(path_1.default.dirname(require.resolve('qs')), './vue'), 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: [
@@ -24,7 +24,7 @@ const router = (0, history_1.getRouter)();
24
24
  const app = (0, vue_1.createApp)(Container);
25
25
  app.component('SwicoLayout', Layout_1.default);
26
26
  app.use(router);
27
+ (_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);
27
28
  const rootEle = document.createElement('div');
28
29
  document.body.appendChild(rootEle);
29
30
  app.mount(rootEle);
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);
package/vue/index.d.ts DELETED
@@ -1,43 +0,0 @@
1
- import { GlobalData, GlobalSwicoConfigType } from '../src/main-config';
2
- import { App } from 'vue';
3
- import { Router } from 'vue-router';
4
- import { useLocation, useNav } from '../src/template-root/.swico-vue/hooks';
5
- export type CustomConfigType = GlobalData['customConfig'];
6
- export { RouterView } from 'vue-router';
7
- export { useLocation, useNav };
8
- export { history } from '../src/mock-history';
9
- export type { GlobalSwicoConfigType };
10
- 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("../src/typings/global-type").NavOptionsType): void;
21
- (to: number): void;
22
- (to: import("../src/typings/global-type").SwicoHistoryOptionType, options?: import("../src/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>;
34
- export interface DefineSwicoConfigType {
35
- (env: 'base', config: CustomConfigType['base']): any;
36
- (env: 'dev', config: CustomConfigType['dev']): any;
37
- (env: 'prod', config: CustomConfigType['prod']): any;
38
- }
39
- export declare const defineConfig: DefineSwicoConfigType;
40
- export interface DefineGlobalConfigType {
41
- onInit?: (app: App, router: Router) => void;
42
- }
43
- export declare const defineGlobal: (config: DefineGlobalConfigType) => DefineGlobalConfigType;