@creopse/bridge 0.0.1 → 0.1.1

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.
@@ -1,152 +1,135 @@
1
- import federation from '@originjs/vite-plugin-federation';
2
- import basicSsl from '@vitejs/plugin-basic-ssl';
3
- import react from '@vitejs/plugin-react';
4
- import { parse, stringify } from 'comment-json';
5
- import fs from 'fs';
6
- import path from 'path';
7
- import copy from 'rollup-plugin-copy';
8
- import UnoCSS from 'unocss/vite';
9
- import AutoImportPlugin from 'vite-plugin-auto-import-lite';
10
- import i18nextLoader from 'vite-plugin-i18next-loader';
11
- import json5Plugin from 'vite-plugin-json5';
12
- import topLevelAwait from 'vite-plugin-top-level-await';
13
- import { DASHBOARD_MODULE_NAME, SETTINGS_MODULE_NAME } from '../utils/constants';
14
- import { sanitizeId } from '../utils/functions';
15
- // ——— Plugin ——————————————————————————————————————————————————————————————————
16
- export function CreopseReactPlugin(options = {}) {
17
- const { manifestPath = './manifest.jsonc', srcDir = './src', outDir = 'frontend', i18nLocalesPath, hooksDirs = ['src/hooks'], shared = [], unocss = false, eslintAutoImport = false, } = options;
18
- let root;
19
- let manifest;
20
- let pluginId;
21
- let pluginEntry;
22
- let exposes;
23
- let previewPort;
24
- let serverPort;
25
- let sslEnabled;
26
- function loadManifest() {
27
- const fullPath = path.resolve(root, manifestPath);
28
- const raw = fs.readFileSync(fullPath, 'utf-8');
29
- manifest = parse(raw || '{}');
30
- exposes = {};
31
- if (manifest.pages && Array.isArray(manifest.pages)) {
32
- for (const page of manifest.pages) {
33
- exposes[`./${page.name}`] = page.module;
1
+ import { D as y, S as b, s as D } from "../index-BWhWXGj9.js";
2
+ import L from "@originjs/vite-plugin-federation";
3
+ import C from "@vitejs/plugin-basic-ssl";
4
+ import x from "@vitejs/plugin-react";
5
+ import { stringify as M, parse as O } from "comment-json";
6
+ import j from "fs";
7
+ import s from "path";
8
+ import k from "rollup-plugin-copy";
9
+ import N from "unocss/vite";
10
+ import B from "vite-plugin-auto-import-lite";
11
+ import $ from "vite-plugin-i18next-loader";
12
+ import z from "vite-plugin-json5";
13
+ import R from "vite-plugin-top-level-await";
14
+ function Z(A = {}) {
15
+ const {
16
+ manifestPath: p = "./manifest.jsonc",
17
+ srcDir: c = "./src",
18
+ outDir: d = "frontend",
19
+ i18nLocalesPath: f,
20
+ hooksDirs: _ = ["src/hooks"],
21
+ shared: E = [],
22
+ unocss: S = !1,
23
+ eslintAutoImport: w = !1
24
+ } = A;
25
+ let r, e, u, g, t, v, P, h;
26
+ function I() {
27
+ const l = s.resolve(r, p), m = j.readFileSync(l, "utf-8");
28
+ if (e = O(m || "{}"), t = {}, e.pages && Array.isArray(e.pages))
29
+ for (const a of e.pages)
30
+ t[`./${a.name}`] = a.module;
31
+ const n = e.dashboard;
32
+ n?.module && (t[`./${y}`] = n.module);
33
+ const i = e.settings;
34
+ i?.module && (t[`./${b}`] = i.module);
35
+ const o = e.development;
36
+ u = D(String(e.id)) || "creopse-plugin", g = e.entry || "remoteEntry.js", v = o?.previewPort || 2160, P = o?.serverPort || 2161, h = o?.ssl || !1;
37
+ }
38
+ return {
39
+ name: "creopse-react-plugin",
40
+ config(l) {
41
+ r = l.root || process.cwd(), I();
42
+ const m = process.env.APP_IS_PREVIEW === "true", n = f ? s.resolve(r, f) : s.resolve(r, c, "i18n/locales"), i = ["react", "react-dom", "zustand", ...E];
43
+ return {
44
+ envPrefix: "APP_",
45
+ plugins: [
46
+ x(),
47
+ L({
48
+ name: u,
49
+ filename: g,
50
+ exposes: t,
51
+ shared: i
52
+ }),
53
+ R({
54
+ promiseExportName: "__tla",
55
+ promiseImportName: (o) => `__tla_${o}`
56
+ }),
57
+ z(),
58
+ $({
59
+ paths: [n],
60
+ include: ["**/*.json"]
61
+ }),
62
+ B({
63
+ dirs: _,
64
+ imports: ["react"],
65
+ vueTemplate: !1,
66
+ ...w ? {
67
+ eslintrc: {
68
+ enabled: !0,
69
+ filepath: "./.eslintrc-auto-import.json",
70
+ globalsPropValue: !0
71
+ }
72
+ } : {}
73
+ }),
74
+ ...S ? [N()] : [],
75
+ ...h ? [C()] : []
76
+ ],
77
+ resolve: {
78
+ alias: [
79
+ {
80
+ find: "@",
81
+ replacement: s.resolve(r, c)
34
82
  }
35
- }
36
- const dashboard = manifest.dashboard;
37
- if (dashboard?.module) {
38
- exposes[`./${DASHBOARD_MODULE_NAME}`] = dashboard.module;
39
- }
40
- const settings = manifest.settings;
41
- if (settings?.module) {
42
- exposes[`./${SETTINGS_MODULE_NAME}`] = settings.module;
43
- }
44
- const dev = manifest.development;
45
- pluginId = sanitizeId(String(manifest.id)) || 'creopse-plugin';
46
- pluginEntry = (manifest.entry || 'remoteEntry.js');
47
- previewPort = (dev?.previewPort || 2160);
48
- serverPort = (dev?.serverPort || 2161);
49
- sslEnabled = (dev?.ssl || false);
50
- }
51
- return {
52
- name: 'creopse-react-plugin',
53
- config(config) {
54
- root = config.root || process.cwd();
55
- loadManifest();
56
- const isPreview = process.env.APP_IS_PREVIEW === 'true';
57
- const localesPath = i18nLocalesPath
58
- ? path.resolve(root, i18nLocalesPath)
59
- : path.resolve(root, srcDir, 'i18n/locales');
60
- const sharedModules = ['react', 'react-dom', 'zustand', ...shared];
61
- return {
62
- envPrefix: 'APP_',
63
- plugins: [
64
- react(),
65
- federation({
66
- name: pluginId,
67
- filename: pluginEntry,
68
- exposes,
69
- shared: sharedModules,
70
- }),
71
- topLevelAwait({
72
- promiseExportName: '__tla',
73
- promiseImportName: (i) => `__tla_${i}`,
74
- }),
75
- json5Plugin(),
76
- i18nextLoader({
77
- paths: [localesPath],
78
- include: ['**/*.json'],
79
- }),
80
- AutoImportPlugin({
81
- dirs: hooksDirs,
82
- imports: ['react'],
83
- vueTemplate: false,
84
- ...(eslintAutoImport
85
- ? {
86
- eslintrc: {
87
- enabled: true,
88
- filepath: './.eslintrc-auto-import.json',
89
- globalsPropValue: true,
90
- },
91
- }
92
- : {}),
93
- }),
94
- ...(unocss ? [UnoCSS()] : []),
95
- ...(sslEnabled ? [basicSsl()] : []),
83
+ ],
84
+ dedupe: ["react", "react-dom", "zustand"]
85
+ },
86
+ build: {
87
+ target: "esnext",
88
+ outDir: d,
89
+ rollupOptions: {
90
+ plugins: [
91
+ k({
92
+ targets: [
93
+ {
94
+ src: s.resolve(r, p),
95
+ dest: d,
96
+ transform() {
97
+ return e?.mode && (e.mode = m ? "development" : "production"), ((a) => a.replace(/(,)\s*\n/g, `,
98
+
99
+ `))(
100
+ M(e, null, 2)
101
+ );
102
+ }
103
+ }
96
104
  ],
97
- resolve: {
98
- alias: [
99
- {
100
- find: '@',
101
- replacement: path.resolve(root, srcDir),
102
- },
103
- ],
104
- dedupe: ['react', 'react-dom', 'zustand'],
105
- },
106
- build: {
107
- target: 'esnext',
108
- outDir,
109
- rollupOptions: {
110
- plugins: [
111
- copy({
112
- targets: [
113
- {
114
- src: path.resolve(root, manifestPath),
115
- dest: outDir,
116
- transform() {
117
- if (manifest?.mode) {
118
- manifest.mode = isPreview ? 'development' : 'production';
119
- }
120
- const addBlankLineAfterCommas = (jsonc) => jsonc.replace(/(,)\s*\n/g, ',\n\n');
121
- return addBlankLineAfterCommas(stringify(manifest, null, 2));
122
- },
123
- },
124
- ],
125
- hook: 'writeBundle',
126
- verbose: false,
127
- flatten: true,
128
- }),
129
- ],
130
- },
131
- assetsInlineLimit: Infinity,
132
- cssCodeSplit: false,
133
- },
134
- preview: {
135
- port: previewPort,
136
- strictPort: true,
137
- cors: true,
138
- headers: {
139
- 'Access-Control-Allow-Origin': '*',
140
- },
141
- },
142
- server: {
143
- port: serverPort,
144
- cors: true,
145
- headers: {
146
- 'Access-Control-Allow-Origin': '*',
147
- },
148
- },
149
- };
105
+ hook: "writeBundle",
106
+ verbose: !1,
107
+ flatten: !0
108
+ })
109
+ ]
110
+ },
111
+ assetsInlineLimit: 1 / 0,
112
+ cssCodeSplit: !1
113
+ },
114
+ preview: {
115
+ port: v,
116
+ strictPort: !0,
117
+ cors: !0,
118
+ headers: {
119
+ "Access-Control-Allow-Origin": "*"
120
+ }
150
121
  },
151
- };
122
+ server: {
123
+ port: P,
124
+ cors: !0,
125
+ headers: {
126
+ "Access-Control-Allow-Origin": "*"
127
+ }
128
+ }
129
+ };
130
+ }
131
+ };
152
132
  }
133
+ export {
134
+ Z as CreopseReactPlugin
135
+ };
package/dist/vite/vue.js CHANGED
@@ -1,143 +1,127 @@
1
- import federation from '@originjs/vite-plugin-federation';
2
- import basicSsl from '@vitejs/plugin-basic-ssl';
3
- import vue from '@vitejs/plugin-vue';
4
- import { parse, stringify } from 'comment-json';
5
- import fs from 'fs';
6
- import path from 'path';
7
- import copy from 'rollup-plugin-copy';
8
- import UnoCSS from 'unocss/vite';
9
- import AutoImportPlugin from 'vite-plugin-auto-import-lite';
10
- import i18nextLoader from 'vite-plugin-i18next-loader';
11
- import json5Plugin from 'vite-plugin-json5';
12
- import topLevelAwait from 'vite-plugin-top-level-await';
13
- import { DASHBOARD_MODULE_NAME, SETTINGS_MODULE_NAME } from '../utils/constants';
14
- import { sanitizeId } from '../utils/functions';
15
- // ——— Plugin ——————————————————————————————————————————————————————————————————
16
- export function CreopseVuePlugin(options = {}) {
17
- const { manifestPath = './manifest.jsonc', srcDir = './src', outDir = 'frontend', i18nLocalesPath, composablesDirs = ['src/composables'], shared = [], unocss = false, } = options;
18
- let root;
19
- let manifest;
20
- let pluginId;
21
- let pluginEntry;
22
- let exposes;
23
- let previewPort;
24
- let serverPort;
25
- let sslEnabled;
26
- function loadManifest() {
27
- const fullPath = path.resolve(root, manifestPath);
28
- const raw = fs.readFileSync(fullPath, 'utf-8');
29
- manifest = parse(raw || '{}');
30
- exposes = {};
31
- if (manifest.pages && Array.isArray(manifest.pages)) {
32
- for (const page of manifest.pages) {
33
- exposes[`./${page.name}`] = page.module;
1
+ import { D as y, S as I, s as b } from "../index-BWhWXGj9.js";
2
+ import D from "@originjs/vite-plugin-federation";
3
+ import L from "@vitejs/plugin-basic-ssl";
4
+ import C from "@vitejs/plugin-vue";
5
+ import { stringify as x, parse as M } from "comment-json";
6
+ import O from "fs";
7
+ import t from "path";
8
+ import N from "rollup-plugin-copy";
9
+ import j from "unocss/vite";
10
+ import B from "vite-plugin-auto-import-lite";
11
+ import $ from "vite-plugin-i18next-loader";
12
+ import k from "vite-plugin-json5";
13
+ import T from "vite-plugin-top-level-await";
14
+ function Y(h = {}) {
15
+ const {
16
+ manifestPath: p = "./manifest.jsonc",
17
+ srcDir: c = "./src",
18
+ outDir: u = "frontend",
19
+ i18nLocalesPath: d,
20
+ composablesDirs: _ = ["src/composables"],
21
+ shared: E = [],
22
+ unocss: S = !1
23
+ } = h;
24
+ let r, e, f, v, s, g, P, A;
25
+ function w() {
26
+ const a = t.resolve(r, p), m = O.readFileSync(a, "utf-8");
27
+ if (e = M(m || "{}"), s = {}, e.pages && Array.isArray(e.pages))
28
+ for (const l of e.pages)
29
+ s[`./${l.name}`] = l.module;
30
+ const n = e.dashboard;
31
+ n?.module && (s[`./${y}`] = n.module);
32
+ const i = e.settings;
33
+ i?.module && (s[`./${I}`] = i.module);
34
+ const o = e.development;
35
+ f = b(String(e.id)) || "creopse-plugin", v = e.entry || "remoteEntry.js", g = o?.previewPort || 2160, P = o?.serverPort || 2161, A = o?.ssl || !1;
36
+ }
37
+ return {
38
+ name: "creopse-vue-plugin",
39
+ config(a) {
40
+ r = a.root || process.cwd(), w();
41
+ const m = process.env.APP_IS_PREVIEW === "true", n = d ? t.resolve(r, d) : t.resolve(r, c, "i18n/locales"), i = ["vue", "pinia", ...E];
42
+ return {
43
+ envPrefix: "APP_",
44
+ plugins: [
45
+ C(),
46
+ D({
47
+ name: f,
48
+ filename: v,
49
+ exposes: s,
50
+ shared: i
51
+ }),
52
+ T({
53
+ promiseExportName: "__tla",
54
+ promiseImportName: (o) => `__tla_${o}`
55
+ }),
56
+ k(),
57
+ $({
58
+ paths: [n],
59
+ include: ["**/*.json"]
60
+ }),
61
+ B({
62
+ dirs: _,
63
+ imports: ["vue", "pinia"],
64
+ vueTemplate: !0
65
+ }),
66
+ ...S ? [j()] : [],
67
+ ...A ? [L()] : []
68
+ ],
69
+ resolve: {
70
+ alias: [
71
+ {
72
+ find: "@",
73
+ replacement: t.resolve(r, c)
34
74
  }
35
- }
36
- const dashboard = manifest.dashboard;
37
- if (dashboard?.module) {
38
- exposes[`./${DASHBOARD_MODULE_NAME}`] = dashboard.module;
39
- }
40
- const settings = manifest.settings;
41
- if (settings?.module) {
42
- exposes[`./${SETTINGS_MODULE_NAME}`] = settings.module;
43
- }
44
- const dev = manifest.development;
45
- pluginId = sanitizeId(String(manifest.id)) || 'creopse-plugin';
46
- pluginEntry = (manifest.entry || 'remoteEntry.js');
47
- previewPort = (dev?.previewPort || 2160);
48
- serverPort = (dev?.serverPort || 2161);
49
- sslEnabled = (dev?.ssl || false);
50
- }
51
- return {
52
- name: 'creopse-vue-plugin',
53
- config(config) {
54
- root = config.root || process.cwd();
55
- loadManifest();
56
- const isPreview = process.env.APP_IS_PREVIEW === 'true';
57
- const localesPath = i18nLocalesPath
58
- ? path.resolve(root, i18nLocalesPath)
59
- : path.resolve(root, srcDir, 'i18n/locales');
60
- const sharedModules = ['vue', 'pinia', ...shared];
61
- return {
62
- envPrefix: 'APP_',
63
- plugins: [
64
- vue(),
65
- federation({
66
- name: pluginId,
67
- filename: pluginEntry,
68
- exposes,
69
- shared: sharedModules,
70
- }),
71
- topLevelAwait({
72
- promiseExportName: '__tla',
73
- promiseImportName: (i) => `__tla_${i}`,
74
- }),
75
- json5Plugin(),
76
- i18nextLoader({
77
- paths: [localesPath],
78
- include: ['**/*.json'],
79
- }),
80
- AutoImportPlugin({
81
- dirs: composablesDirs,
82
- imports: ['vue', 'pinia'],
83
- vueTemplate: true,
84
- }),
85
- ...(unocss ? [UnoCSS()] : []),
86
- ...(sslEnabled ? [basicSsl()] : []),
75
+ ],
76
+ dedupe: ["vue"]
77
+ },
78
+ build: {
79
+ target: "esnext",
80
+ outDir: u,
81
+ rollupOptions: {
82
+ plugins: [
83
+ N({
84
+ targets: [
85
+ {
86
+ src: t.resolve(r, p),
87
+ dest: u,
88
+ transform() {
89
+ return e?.mode && (e.mode = m ? "development" : "production"), ((l) => l.replace(/(,)\s*\n/g, `,
90
+
91
+ `))(
92
+ x(e, null, 2)
93
+ );
94
+ }
95
+ }
87
96
  ],
88
- resolve: {
89
- alias: [
90
- {
91
- find: '@',
92
- replacement: path.resolve(root, srcDir),
93
- },
94
- ],
95
- dedupe: ['vue'],
96
- },
97
- build: {
98
- target: 'esnext',
99
- outDir,
100
- rollupOptions: {
101
- plugins: [
102
- copy({
103
- targets: [
104
- {
105
- src: path.resolve(root, manifestPath),
106
- dest: outDir,
107
- transform() {
108
- if (manifest?.mode) {
109
- manifest.mode = isPreview ? 'development' : 'production';
110
- }
111
- const addBlankLineAfterCommas = (jsonc) => jsonc.replace(/(,)\s*\n/g, ',\n\n');
112
- return addBlankLineAfterCommas(stringify(manifest, null, 2));
113
- },
114
- },
115
- ],
116
- hook: 'writeBundle',
117
- verbose: false,
118
- flatten: true,
119
- }),
120
- ],
121
- },
122
- assetsInlineLimit: Infinity,
123
- cssCodeSplit: false,
124
- },
125
- preview: {
126
- port: previewPort,
127
- strictPort: true,
128
- cors: true,
129
- headers: {
130
- 'Access-Control-Allow-Origin': '*',
131
- },
132
- },
133
- server: {
134
- port: serverPort,
135
- cors: true,
136
- headers: {
137
- 'Access-Control-Allow-Origin': '*',
138
- },
139
- },
140
- };
97
+ hook: "writeBundle",
98
+ verbose: !1,
99
+ flatten: !0
100
+ })
101
+ ]
102
+ },
103
+ assetsInlineLimit: 1 / 0,
104
+ cssCodeSplit: !1
105
+ },
106
+ preview: {
107
+ port: g,
108
+ strictPort: !0,
109
+ cors: !0,
110
+ headers: {
111
+ "Access-Control-Allow-Origin": "*"
112
+ }
141
113
  },
142
- };
114
+ server: {
115
+ port: P,
116
+ cors: !0,
117
+ headers: {
118
+ "Access-Control-Allow-Origin": "*"
119
+ }
120
+ }
121
+ };
122
+ }
123
+ };
143
124
  }
125
+ export {
126
+ Y as CreopseVuePlugin
127
+ };
@@ -0,0 +1,15 @@
1
+ import "vue";
2
+ import "@iconify/vue";
3
+ import "naive-ui";
4
+ import { useResponsive as i } from "./bridge2.js";
5
+ import "./bridge3.js";
6
+ import { useCoreBridge as u } from "./bridge4.js";
7
+ import "./bridge5.js";
8
+ import { useAccess as c } from "./bridge6.js";
9
+ import { useUserPreference as d } from "./bridge7.js";
10
+ export {
11
+ c as useAccess,
12
+ u as useCoreBridge,
13
+ i as useResponsive,
14
+ d as useUserPreference
15
+ };
@@ -0,0 +1,27 @@
1
+ import { useMediaQuery as i } from "@vueuse/core";
2
+ import { computed as o } from "vue";
3
+ const f = () => {
4
+ const s = i("(min-width: 1536px)"), e = i(
5
+ "(min-width: 1280px) and (max-width: 1535px)"
6
+ ), m = i(
7
+ "(min-width: 1024px) and (max-width: 1279px)"
8
+ ), c = i("(min-width: 768px) and (max-width: 1023px)"), d = i("(max-width: 767px)"), p = i("(min-width: 640px)"), t = i("(min-width: 768px)"), n = i("(min-width: 1024px)"), r = i("(min-width: 1280px)"), x = i("(min-width: 1536px)"), a = o(() => !t.value), h = o(() => t.value && !n.value), w = o(() => n.value);
9
+ return {
10
+ is2XlScreen: s,
11
+ isXlScreen: e,
12
+ isLgScreen: m,
13
+ isMdScreen: c,
14
+ isSmScreen: d,
15
+ fromSm: p,
16
+ fromMd: t,
17
+ fromLg: n,
18
+ fromXl: r,
19
+ from2Xl: x,
20
+ isMobile: a,
21
+ isTablet: h,
22
+ isDesktop: w
23
+ };
24
+ };
25
+ export {
26
+ f as useResponsive
27
+ };
@@ -0,0 +1 @@
1
+
@@ -0,0 +1,18 @@
1
+ const t = () => {
2
+ const { sharedData: e, api: o, i18n: a, router: s, helpers: n, stores: r } = window.__creopse__;
3
+ return {
4
+ locale: e?.locale,
5
+ env: e?.env,
6
+ appConfig: e?.appConfig,
7
+ api: o,
8
+ i18n: a,
9
+ router: s,
10
+ helpers: n,
11
+ auth: r.auth,
12
+ server: r.server,
13
+ ui: r.ui
14
+ };
15
+ };
16
+ export {
17
+ t as useCoreBridge
18
+ };
@@ -0,0 +1 @@
1
+
@@ -0,0 +1,41 @@
1
+ import { AccessGuard as a, UserRole as i, Permission as d } from "@creopse/utils/enums";
2
+ import { useI18n as g } from "vue-i18n";
3
+ const I = () => {
4
+ const { t: u } = g(), c = (e, s) => (e?.findIndex(
5
+ (n) => n.name === s
6
+ ) ?? -1) > -1, t = (e, s) => (e?.findIndex((n) => n.name === s) ?? -1) > -1, l = (e) => t(e, i.SUPER_ADMIN), o = (e) => Object.values(d).includes(e), r = [
7
+ {
8
+ label: "API",
9
+ value: a.API,
10
+ tagType: "warning"
11
+ },
12
+ {
13
+ label: "Web",
14
+ value: a.WEB,
15
+ tagType: "info"
16
+ },
17
+ {
18
+ label: "Admin",
19
+ value: a.ADMIN,
20
+ tagType: "success"
21
+ },
22
+ {
23
+ label: "Mobile",
24
+ value: a.MOBILE,
25
+ tagType: "error"
26
+ }
27
+ ];
28
+ return {
29
+ accessGuards: r,
30
+ getAccessGuardLabel: (e) => r.find((s) => s.value === e)?.label,
31
+ getAccessGuardTagType: (e) => r.find((s) => s.value === e)?.tagType || "default",
32
+ getRoleName: (e, s) => e?.find((n) => n.id === s)?.name || u("undefined"),
33
+ isPermissionNative: o,
34
+ userIsSuperAdmin: l,
35
+ userCan: c,
36
+ userIs: t
37
+ };
38
+ };
39
+ export {
40
+ I as useAccess
41
+ };