@signal24/vue-foundation 4.2.2 → 4.3.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.
@@ -1,3 +1,4 @@
1
1
  import type { ObjectDirective } from 'vue';
2
- import { type IInfiniteScrollOptions } from '../hooks/infinite-scroll';
3
- export declare const vInfiniteScroll: ObjectDirective<Element, IInfiniteScrollOptions>;
2
+ type InfiniteScrollBindingValue = () => void;
3
+ export declare const vInfiniteScroll: ObjectDirective<Element, InfiniteScrollBindingValue>;
4
+ export {};
@@ -1,11 +1,15 @@
1
1
  #!/usr/bin/env node
2
2
  import { existsSync } from 'fs';
3
- import { generateOpenapiClient, loadOpenapiOverrides } from './vite-openapi-plugin.js';
4
- if (!process.argv[2]) {
5
- throw new Error('Usage: vf-generate-openapi-client <openapi-yaml-path> [<openapi-output-path>]');
3
+ import { generateConfiguredOpenapiClients, generateOpenapiClient } from './vite-openapi-plugin.js';
4
+ if (process.argv[2]) {
5
+ if (process.argv[2] === '--help') {
6
+ throw new Error('Usage: vf-generate-openapi-client [<openapi-yaml-path> [<openapi-output-path>]]');
7
+ }
8
+ if (!existsSync(process.argv[2])) {
9
+ throw new Error(`OpenAPI YAML file not found: ${process.argv[2]}`);
10
+ }
11
+ await generateOpenapiClient(process.argv[2], process.argv[3]);
6
12
  }
7
- if (!existsSync(process.argv[2])) {
8
- throw new Error(`OpenAPI YAML file not found: ${process.argv[2]}`);
13
+ else {
14
+ generateConfiguredOpenapiClients();
9
15
  }
10
- loadOpenapiOverrides();
11
- await generateOpenapiClient(process.argv[2], process.argv[3]);
@@ -1,8 +1,9 @@
1
- export declare function loadOpenapiOverrides(): void;
2
- export declare function openapiClientGeneratorPlugin(openapiYamlPath: string, outPath?: string): {
1
+ export declare function loadOpenapiConfig(): void;
2
+ export declare function openapiClientGeneratorPlugin(): {
3
3
  name: string;
4
4
  apply: 'serve';
5
5
  buildStart(): void;
6
6
  closeBundle(): void;
7
7
  };
8
+ export declare function generateConfiguredOpenapiClients(): Promise<void>;
8
9
  export declare function generateOpenapiClient(openapiYamlPath: string, outPath?: string): Promise<void>;
@@ -1,40 +1,67 @@
1
1
  import { createHash } from 'node:crypto';
2
- import { existsSync, readFileSync, watch } from 'node:fs';
2
+ import { copyFileSync, existsSync, readFileSync, watch } from 'node:fs';
3
3
  import { rm } from 'node:fs/promises';
4
4
  import * as OpenAPI from 'openapi-typescript-codegen';
5
5
  const DEFAULT_OUT_PATH = './src/openapi-client-generated';
6
6
  let generatedHash = null;
7
+ let generatorMap = {};
7
8
  let overridesMap = null;
8
- export function loadOpenapiOverrides() {
9
- if (!existsSync('./openapi-specs.overrides.json')) {
9
+ let overridesInverseMap = null;
10
+ export function loadOpenapiConfig() {
11
+ loadGeneratorMap();
12
+ loadOverridesMap();
13
+ }
14
+ function loadGeneratorMap() {
15
+ if (!existsSync('./openapi-specs.json')) {
16
+ console.error('openapi-specs.json not found. Cannot generate OpenAPI client.');
17
+ return;
18
+ }
19
+ try {
20
+ const specsContent = readFileSync('./openapi-specs.json', 'utf8');
21
+ generatorMap = JSON.parse(specsContent);
22
+ }
23
+ catch (e) {
24
+ console.error('Failed to load openapi-specs.json:', e);
25
+ }
26
+ }
27
+ function loadOverridesMap() {
28
+ if (!existsSync('./openapi-specs.dev.json')) {
10
29
  return;
11
30
  }
12
31
  try {
13
- const overridesContent = readFileSync('./openapi-specs.overrides.json', 'utf8');
32
+ const overridesContent = readFileSync('./openapi-specs.dev.json', 'utf8');
14
33
  overridesMap = JSON.parse(overridesContent);
34
+ overridesInverseMap = Object.fromEntries(Object.entries(overridesMap).map(([k, v]) => [v, k]));
15
35
  }
16
36
  catch (e) {
17
- console.error('Failed to load openapi-specs.overrides.json:', e);
37
+ console.error('Failed to load openapi-specs.dev.json:', e);
18
38
  }
19
39
  }
20
- export function openapiClientGeneratorPlugin(openapiYamlPath, outPath = DEFAULT_OUT_PATH) {
21
- let generator = null;
40
+ export function openapiClientGeneratorPlugin() {
41
+ let generators = null;
22
42
  return {
23
43
  name: 'openapi-types-generator',
24
44
  apply: 'serve',
25
45
  buildStart() {
26
46
  // apply a slight delay so any output doesn't get pushed off screen
27
47
  setTimeout(() => {
28
- loadOpenapiOverrides();
29
- generator = getGenerator(openapiYamlPath, outPath);
48
+ generators = createWatchfulGenerators();
30
49
  }, 250);
31
50
  },
32
51
  closeBundle() {
33
- generator?.close();
52
+ if (generators) {
53
+ for (const generator of generators) {
54
+ generator?.close();
55
+ }
56
+ }
34
57
  }
35
58
  };
36
59
  }
37
- function getGenerator(openapiYamlPath, outPath) {
60
+ function createWatchfulGenerators() {
61
+ loadOpenapiConfig();
62
+ return Object.entries(generatorMap).map(([openapiYamlPath, outPath]) => createWatchfulGenerator(openapiYamlPath, outPath));
63
+ }
64
+ function createWatchfulGenerator(openapiYamlPath, outPath) {
38
65
  const resolvedPath = overridesMap?.[openapiYamlPath] ?? openapiYamlPath;
39
66
  if (!existsSync(resolvedPath)) {
40
67
  console.log(`OpenAPI YAML file not found: ${resolvedPath}`);
@@ -52,7 +79,14 @@ function getGenerator(openapiYamlPath, outPath) {
52
79
  }
53
80
  };
54
81
  }
55
- async function generateOpenapiClientInternal(openapiYamlPath, outPath = DEFAULT_OUT_PATH) {
82
+ export async function generateConfiguredOpenapiClients() {
83
+ loadOpenapiConfig();
84
+ for (const [openapiYamlPath, outPath] of Object.entries(generatorMap)) {
85
+ const resolvedPath = overridesMap?.[openapiYamlPath] ?? openapiYamlPath;
86
+ await generateOpenapiClient(resolvedPath, outPath);
87
+ }
88
+ }
89
+ export async function generateOpenapiClient(openapiYamlPath, outPath = DEFAULT_OUT_PATH) {
56
90
  const yaml = readFileSync(openapiYamlPath, 'utf8');
57
91
  const hash = createHash('sha256').update(yaml).digest('hex');
58
92
  if (hash === generatedHash) {
@@ -73,13 +107,12 @@ async function generateOpenapiClientInternal(openapiYamlPath, outPath = DEFAULT_
73
107
  useOptions: true,
74
108
  useUnionTypes: true
75
109
  });
110
+ if (overridesInverseMap?.[openapiYamlPath]) {
111
+ copyFileSync(openapiYamlPath, overridesInverseMap[openapiYamlPath]);
112
+ }
76
113
  console.log(`[${new Date().toISOString()}] Generated client from ${openapiYamlPath} to ${outPath}/`);
77
114
  }
78
115
  catch (err) {
79
116
  console.error(`[${new Date().toISOString()}] Error generating client from ${openapiYamlPath}:`, err);
80
117
  }
81
118
  }
82
- export async function generateOpenapiClient(openapiYamlPath, outPath = DEFAULT_OUT_PATH) {
83
- const resolvedPath = overridesMap?.[openapiYamlPath] ?? openapiYamlPath;
84
- return generateOpenapiClientInternal(resolvedPath, outPath);
85
- }