@inzombieland/nuxt-common 1.18.15 → 1.18.17

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/dist/module.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inzombieland/nuxt-common",
3
- "version": "1.18.15",
3
+ "version": "1.18.17",
4
4
  "configKey": "nuxt-common",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "0.6.0",
package/dist/module.mjs CHANGED
@@ -2,7 +2,7 @@ import { fileURLToPath } from 'node:url';
2
2
  import { defineNuxtModule, createResolver, addServerHandler, addImportsDir, addPlugin, addComponent } from '@nuxt/kit';
3
3
 
4
4
  const name = "@inzombieland/nuxt-common";
5
- const version = "1.18.15";
5
+ const version = "1.18.17";
6
6
 
7
7
  const module = defineNuxtModule({
8
8
  meta: {
@@ -109,6 +109,10 @@ const optionsHandler = (options = {}, config) => {
109
109
  };
110
110
  const fetchRequest = (url, options = {}, fetch, config) => {
111
111
  const request = async () => {
112
+ const apiActions = useApiActions();
113
+ if (typeof window !== "undefined") {
114
+ await apiActions.value?.getVisitorIdentifier?.();
115
+ }
112
116
  const opts = optionsHandler(options, config);
113
117
  try {
114
118
  const response = await fetch.raw(url, opts);
@@ -116,7 +120,6 @@ const fetchRequest = (url, options = {}, fetch, config) => {
116
120
  } catch (error) {
117
121
  const { status } = error?.response ?? { status: 500 };
118
122
  if (status === 401 && url !== "/account/1/offline") {
119
- const apiActions = useApiActions();
120
123
  await apiActions.value?.refreshToken?.();
121
124
  return request();
122
125
  }
@@ -1,13 +1,10 @@
1
1
  export declare const useApiActions: () => import("vue").Ref<{
2
- initialized: boolean;
3
2
  getVisitorIdentifier?: (() => Promise<void>) | undefined;
4
3
  refreshToken?: (() => Promise<string>) | undefined;
5
4
  }, {
6
- initialized: boolean;
7
5
  getVisitorIdentifier?: () => Promise<void>;
8
6
  refreshToken?: () => Promise<string>;
9
7
  } | {
10
- initialized: boolean;
11
8
  getVisitorIdentifier?: (() => Promise<void>) | undefined;
12
9
  refreshToken?: (() => Promise<string>) | undefined;
13
10
  }>;
@@ -1,5 +1,5 @@
1
1
  import { ref } from "vue";
2
- const apiActions = ref({ initialized: false });
2
+ const apiActions = ref({});
3
3
  export const useApiActions = () => {
4
4
  return apiActions;
5
5
  };
@@ -16,7 +16,6 @@ async function getUserRequest(fetch, config) {
16
16
  }
17
17
  try {
18
18
  const apiActions = useApiActions();
19
- await apiActions.value?.getVisitorIdentifier?.();
20
19
  await apiActions.value?.refreshToken?.();
21
20
  } catch {
22
21
  flush();
@@ -8,7 +8,7 @@ const setVisitor = (newVisitor) => {
8
8
  };
9
9
  const getVisitorRequest = async (config) => {
10
10
  const visitor = useVisitor();
11
- if (typeof window === "undefined" || visitor.value) {
11
+ if (visitor.value) {
12
12
  return;
13
13
  }
14
14
  const fp = await load();
@@ -22,11 +22,7 @@ export function initApiFetch($fetch, config) {
22
22
  const initApplication = createInitApplication();
23
23
  const refreshToken = createApiRefreshToken(fetch, config);
24
24
  userActions = ref(createApiUserActions(fetch, config, getUser));
25
- apiActions.value = {
26
- initialized: true,
27
- getVisitorIdentifier,
28
- refreshToken
29
- };
25
+ apiActions.value = { getVisitorIdentifier, refreshToken };
30
26
  if (typeof window !== "undefined") {
31
27
  const loggedIn = useLocalStorage("lin", "no");
32
28
  const cometServerURL = config.cometServerURL;
@@ -45,7 +41,8 @@ export function initApiFetch($fetch, config) {
45
41
  }
46
42
  loggedIn.value = user ? "yes" : "no";
47
43
  });
48
- bus.subscribe("app:beforeMount", () => {
44
+ const subscription = bus.subscribe("app:beforeMount", () => {
45
+ subscription.unsubscribe();
49
46
  console.log("Service started in mode", import.meta.env.MODE);
50
47
  getVisitorIdentifier();
51
48
  initApplication();
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inzombieland/core",
3
- "version": "1.18.15",
3
+ "version": "1.18.17",
4
4
  "type": "module",
5
5
  "license": "ISC",
6
6
  "main": "./index.mjs",
@@ -46,6 +46,7 @@ if (typeof component === "string") {
46
46
  />
47
47
  <component
48
48
  :is="component"
49
+ :params="layer.params"
49
50
  :search-params="layer.searchParams"
50
51
  @close-layer="closeLayer"
51
52
  @close-all-layers="closeAllLayers"
@@ -22,22 +22,31 @@ function getLayerHash(s: string): string {
22
22
  return Math.abs(hash).toString()
23
23
  }
24
24
 
25
- const createLayer = (name: string): ActiveLayer => {
25
+ const createLayer = (name: string, params?: { [p: string]: any }): ActiveLayer => {
26
26
  return {
27
27
  name,
28
28
  layerId: getLayerHash(name),
29
29
  component: name.charAt(0).toUpperCase() + name.slice(1),
30
- searchParams: history.value.query || {},
30
+ params: Object.assign({}, history.value.query, params),
31
+ searchParams: Object.assign({}, history.value.query, params),
31
32
  closeLayer: typeof window !== "undefined" ? () => {} : undefined,
32
33
  }
33
34
  }
34
35
 
35
- const resolveLayer = (layerName: string, options: { isCloseOtherLayers: boolean } = { isCloseOtherLayers: false }) => {
36
+ const resolveLayer = (
37
+ layerName: string,
38
+ options: { isCloseOtherLayers: boolean } = { isCloseOtherLayers: false },
39
+ params?: { [p: string]: any }
40
+ ) => {
36
41
  const activeLayer = activeLayers.value.find(({ name }) => name === layerName)
37
42
  if (activeLayer) {
38
43
  // слой с таким именем уже есть
39
44
  const layer = activeLayers.value.splice(activeLayers.value.indexOf(activeLayer), 1)[0]
40
45
  if (layer) {
46
+ if (params) {
47
+ layer.params = params
48
+ layer.searchParams = params
49
+ }
41
50
  activeLayers.value.push(layer)
42
51
  }
43
52
  } else {
@@ -47,7 +56,7 @@ const resolveLayer = (layerName: string, options: { isCloseOtherLayers: boolean
47
56
  if (activeLayers.value.length >= layersLimit) {
48
57
  activeLayers.value.shift()
49
58
  }
50
- activeLayers.value.push(createLayer(layerName))
59
+ activeLayers.value.push(createLayer(layerName, params))
51
60
  }
52
61
  }
53
62
 
@@ -76,7 +85,7 @@ const closeLayer = (layerId: string) => {
76
85
  activeLayers.value = activeLayers.value.filter(s => s.layerId !== layerId)
77
86
 
78
87
  const layer = activeLayers.value.at(-1)
79
- const queryLayer = layer ? { layer: layer.name, ...layer.searchParams } : {}
88
+ const queryLayer = layer ? { layer: layer.name, ...layer.params, ...layer.searchParams } : {}
80
89
  const query = { ...(history.value.query?.layer ? queryLayer : {}) }
81
90
 
82
91
  router.push({ path: history.value.path, query })
@@ -107,6 +116,7 @@ watch(reactiveHistory, (value, prevValue) => {
107
116
  } else {
108
117
  const activeLayer = activeLayers.value.find(({ name }) => name === value.query.layer)
109
118
  if (activeLayer) {
119
+ activeLayer.params = value.query
110
120
  activeLayer.searchParams = value.query
111
121
  }
112
122
  }
@@ -122,7 +132,12 @@ onMounted(() => {
122
132
  layerActions.value = {
123
133
  initialized: true,
124
134
  open: (layerName: string, params?: { [p: string]: any }) => {
125
- router.push({ path: history.value.path, query: { layer: layerName, ...(params ?? {}) } })
135
+ if (params?.mode === "router") {
136
+ const { mode, ...restParams } = params
137
+ router.push({ path: history.value.path, query: { layer: layerName, ...(restParams ?? {}) } })
138
+ } else {
139
+ resolveLayer(layerName, undefined, params)
140
+ }
126
141
  },
127
142
  getLayer: (layerName: string) => {
128
143
  return activeLayers.value.find(({ name }) => name === layerName)
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inzombieland/layer-manager",
3
- "version": "1.16.7",
3
+ "version": "1.17.0",
4
4
  "type": "module",
5
5
  "license": "ISC",
6
6
  "main": "./index.mjs",
@@ -1,8 +1,12 @@
1
- import type { LocationQuery } from "vue-router";
2
1
  export type ActiveLayer = {
3
2
  readonly name: string;
4
3
  readonly layerId: string;
5
4
  readonly component: string;
6
- searchParams: LocationQuery;
5
+ params: {
6
+ [p: string]: any;
7
+ };
8
+ searchParams: {
9
+ [p: string]: any;
10
+ };
7
11
  closeLayer: (() => void) | undefined;
8
12
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inzombieland/nuxt-common",
3
- "version": "1.18.15",
3
+ "version": "1.18.17",
4
4
  "license": "ISC",
5
5
  "type": "module",
6
6
  "exports": {