@common-stack/rollup-vite-utils 6.0.8-alpha.37 → 6.0.8-alpha.40
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/lib/tools/codegen/readModules.cjs +53 -36
- package/lib/tools/codegen/readModules.cjs.map +1 -1
- package/lib/tools/codegen/readModules.d.ts +9 -4
- package/lib/tools/codegen/readModules.js +53 -36
- package/lib/tools/codegen/readModules.js.map +1 -1
- package/lib/tools/codegen/templates/common/src/configuration.ts.template +2 -2
- package/lib/tools/codegen/templates/common/src/types.ts.template +24 -10
- package/package.json +2 -2
|
@@ -3,71 +3,91 @@
|
|
|
3
3
|
// ESM-compatible require
|
|
4
4
|
const esmRequire = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('tools/codegen/readModules.cjs', document.baseURI).href)));
|
|
5
5
|
/**
|
|
6
|
-
* Reads modules from
|
|
7
|
-
*
|
|
8
|
-
*
|
|
6
|
+
* Reads modules from JSON config files and returns an array of module objects.
|
|
7
|
+
*
|
|
8
|
+
* The function separates modules into client and server arrays based on the suffix (“-server”),
|
|
9
|
+
* then it attempts to resolve each module’s location. If the resolution fails—often due to a missing
|
|
10
|
+
* "lib" folder on external packages—it falls back by removing any `/lib` reference from the module name.
|
|
11
|
+
*
|
|
12
|
+
* For local modules it always returns an object with { client, core, browser, server } keys.
|
|
13
|
+
* For modules from node_modules, it generates paths based on naming conventions.
|
|
9
14
|
*/
|
|
10
15
|
function readModules(serverConfigPaths = []) {
|
|
11
|
-
//
|
|
16
|
+
// Separate client and server modules while loading the JSON config files.
|
|
12
17
|
const [clientModules, serverModules] = serverConfigPaths.reduce((acc, configFile) => {
|
|
13
18
|
if (!fs.existsSync(configFile)) {
|
|
14
19
|
console.error(`Config file not found: ${configFile}`);
|
|
15
20
|
process.exit(1);
|
|
16
21
|
}
|
|
17
22
|
const configData = JSON.parse(fs.readFileSync(configFile, 'utf-8'));
|
|
18
|
-
// Process regular modules
|
|
19
|
-
configData.modules?.forEach((
|
|
20
|
-
if (
|
|
21
|
-
acc[1].push(
|
|
23
|
+
// Process regular modules.
|
|
24
|
+
configData.modules?.forEach((mod) => {
|
|
25
|
+
if (mod.endsWith('-server')) {
|
|
26
|
+
acc[1].push(mod);
|
|
22
27
|
}
|
|
23
28
|
else {
|
|
24
|
-
acc[0].push(
|
|
29
|
+
acc[0].push(mod);
|
|
25
30
|
}
|
|
26
31
|
});
|
|
27
|
-
// Process external modules
|
|
28
|
-
configData.externalModules?.forEach((
|
|
29
|
-
if (
|
|
30
|
-
acc[1].push(
|
|
32
|
+
// Process external modules.
|
|
33
|
+
configData.externalModules?.forEach((mod) => {
|
|
34
|
+
if (mod.endsWith('-server')) {
|
|
35
|
+
acc[1].push(mod);
|
|
31
36
|
}
|
|
32
37
|
else {
|
|
33
|
-
acc[0].push(
|
|
38
|
+
acc[0].push(mod);
|
|
34
39
|
}
|
|
35
40
|
});
|
|
36
|
-
//
|
|
37
|
-
configData.devModules?.forEach((
|
|
38
|
-
if (
|
|
39
|
-
acc[1].push(
|
|
41
|
+
// Process devModules.
|
|
42
|
+
configData.devModules?.forEach((mod) => {
|
|
43
|
+
if (mod.endsWith('-server')) {
|
|
44
|
+
acc[1].push(mod);
|
|
40
45
|
}
|
|
41
46
|
else {
|
|
42
|
-
acc[0].push(
|
|
47
|
+
acc[0].push(mod);
|
|
43
48
|
}
|
|
44
49
|
});
|
|
45
50
|
return acc;
|
|
46
51
|
}, [[], []]);
|
|
47
|
-
//
|
|
52
|
+
// Combine modules uniquely
|
|
48
53
|
const allModules = [...new Set([...clientModules, ...serverModules])];
|
|
49
|
-
// 3) Transform each moduleName into a module object
|
|
50
54
|
const processedModules = new Set();
|
|
51
55
|
return allModules.reduce((acc, moduleName) => {
|
|
52
56
|
try {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
57
|
+
let resolvedFile;
|
|
58
|
+
try {
|
|
59
|
+
// Attempt normal resolution.
|
|
60
|
+
resolvedFile = esmRequire.resolve(moduleName);
|
|
61
|
+
}
|
|
62
|
+
catch (err) {
|
|
63
|
+
// Fallback resolution: if the module name includes "/lib", remove it and try again.
|
|
64
|
+
const fallbackModule = moduleName.includes('/lib')
|
|
65
|
+
? moduleName.replace(/\/lib.*$/, '')
|
|
66
|
+
: moduleName;
|
|
67
|
+
try {
|
|
68
|
+
resolvedFile = esmRequire.resolve(fallbackModule);
|
|
69
|
+
}
|
|
70
|
+
catch (err2) {
|
|
71
|
+
console.warn(`Could not resolve module ${moduleName} even with fallback ${fallbackModule}. Skipping.`);
|
|
72
|
+
return acc;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
const dirName = path.dirname(resolvedFile);
|
|
56
76
|
const modulePath = path.relative(commonPaths.pathsConfig.repoRoot, dirName);
|
|
57
|
-
// Reverse
|
|
77
|
+
// Reverse the split parts to check if "node_modules" exists.
|
|
58
78
|
const [dir, pkg, ...rest] = modulePath.split('/').reverse();
|
|
59
79
|
const isLocal = !rest.includes('node_modules');
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
80
|
+
const baseModule = isLocal
|
|
81
|
+
? [...rest].reverse().join('/')
|
|
82
|
+
: modulePath.replace('/lib', '');
|
|
63
83
|
if (processedModules.has(baseModule)) {
|
|
64
84
|
return acc;
|
|
65
85
|
}
|
|
66
86
|
processedModules.add(baseModule);
|
|
67
|
-
//
|
|
87
|
+
// For local modules, use "src" directory; for node_modules, use "lib"
|
|
68
88
|
const srcOrLib = isLocal ? 'src' : 'lib';
|
|
69
89
|
const generatePath = (type) => `${baseModule}${isLocal ? `/${type}` : ''}/${srcOrLib}`;
|
|
70
|
-
//
|
|
90
|
+
// For local modules, always return all module keys.
|
|
71
91
|
if (isLocal) {
|
|
72
92
|
return [
|
|
73
93
|
...acc,
|
|
@@ -79,10 +99,9 @@ function readModules(serverConfigPaths = []) {
|
|
|
79
99
|
},
|
|
80
100
|
];
|
|
81
101
|
}
|
|
82
|
-
//
|
|
83
|
-
// If the baseModule ends with "-browser"
|
|
102
|
+
// Otherwise, handle node_module naming conventions.
|
|
103
|
+
// If the baseModule ends with "-browser".
|
|
84
104
|
if (baseModule.endsWith('-browser')) {
|
|
85
|
-
// If it ends with -browser, also provide -client, -core
|
|
86
105
|
return [
|
|
87
106
|
...acc,
|
|
88
107
|
{
|
|
@@ -93,7 +112,6 @@ function readModules(serverConfigPaths = []) {
|
|
|
93
112
|
];
|
|
94
113
|
}
|
|
95
114
|
if (baseModule.endsWith('-server')) {
|
|
96
|
-
// If it ends with -server
|
|
97
115
|
return [
|
|
98
116
|
...acc,
|
|
99
117
|
{
|
|
@@ -102,7 +120,6 @@ function readModules(serverConfigPaths = []) {
|
|
|
102
120
|
];
|
|
103
121
|
}
|
|
104
122
|
if (baseModule.includes('-browser')) {
|
|
105
|
-
// If it has '-browser' somewhere else
|
|
106
123
|
return [
|
|
107
124
|
...acc,
|
|
108
125
|
{
|
|
@@ -110,7 +127,7 @@ function readModules(serverConfigPaths = []) {
|
|
|
110
127
|
},
|
|
111
128
|
];
|
|
112
129
|
}
|
|
113
|
-
// Default fallback
|
|
130
|
+
// Default fallback.
|
|
114
131
|
return [
|
|
115
132
|
...acc,
|
|
116
133
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"readModules.cjs","sources":["../../../src/tools/codegen/readModules.ts"],"sourcesContent":[null],"names":["createRequire","pathsConfig"],"mappings":"8MAKA;AACA;AAEA;AACA,MAAM,UAAU,GAAGA,sBAAa,CAAC,+QAAe,CAAC,CAAC;AAElD
|
|
1
|
+
{"version":3,"file":"readModules.cjs","sources":["../../../src/tools/codegen/readModules.ts"],"sourcesContent":[null],"names":["createRequire","pathsConfig"],"mappings":"8MAKA;AACA;AAEA;AACA,MAAM,UAAU,GAAGA,sBAAa,CAAC,+QAAe,CAAC,CAAC;AAElD;;;;;;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-
*
|
|
2
|
+
* Reads modules from JSON config files and returns an array of module objects.
|
|
3
|
+
*
|
|
4
|
+
* The function separates modules into client and server arrays based on the suffix (“-server”),
|
|
5
|
+
* then it attempts to resolve each module’s location. If the resolution fails—often due to a missing
|
|
6
|
+
* "lib" folder on external packages—it falls back by removing any `/lib` reference from the module name.
|
|
7
|
+
*
|
|
8
|
+
* For local modules it always returns an object with { client, core, browser, server } keys.
|
|
9
|
+
* For modules from node_modules, it generates paths based on naming conventions.
|
|
5
10
|
*/
|
|
6
|
-
export declare function readModules(serverConfigPaths?:
|
|
11
|
+
export declare function readModules(serverConfigPaths?: string[]): any[];
|
|
@@ -3,71 +3,91 @@ import fs__default from'fs';import path__default from'path';import {createRequir
|
|
|
3
3
|
// ESM-compatible require
|
|
4
4
|
const esmRequire = createRequire(import.meta.url);
|
|
5
5
|
/**
|
|
6
|
-
* Reads modules from
|
|
7
|
-
*
|
|
8
|
-
*
|
|
6
|
+
* Reads modules from JSON config files and returns an array of module objects.
|
|
7
|
+
*
|
|
8
|
+
* The function separates modules into client and server arrays based on the suffix (“-server”),
|
|
9
|
+
* then it attempts to resolve each module’s location. If the resolution fails—often due to a missing
|
|
10
|
+
* "lib" folder on external packages—it falls back by removing any `/lib` reference from the module name.
|
|
11
|
+
*
|
|
12
|
+
* For local modules it always returns an object with { client, core, browser, server } keys.
|
|
13
|
+
* For modules from node_modules, it generates paths based on naming conventions.
|
|
9
14
|
*/
|
|
10
15
|
function readModules(serverConfigPaths = []) {
|
|
11
|
-
//
|
|
16
|
+
// Separate client and server modules while loading the JSON config files.
|
|
12
17
|
const [clientModules, serverModules] = serverConfigPaths.reduce((acc, configFile) => {
|
|
13
18
|
if (!fs__default.existsSync(configFile)) {
|
|
14
19
|
console.error(`Config file not found: ${configFile}`);
|
|
15
20
|
process.exit(1);
|
|
16
21
|
}
|
|
17
22
|
const configData = JSON.parse(fs__default.readFileSync(configFile, 'utf-8'));
|
|
18
|
-
// Process regular modules
|
|
19
|
-
configData.modules?.forEach((
|
|
20
|
-
if (
|
|
21
|
-
acc[1].push(
|
|
23
|
+
// Process regular modules.
|
|
24
|
+
configData.modules?.forEach((mod) => {
|
|
25
|
+
if (mod.endsWith('-server')) {
|
|
26
|
+
acc[1].push(mod);
|
|
22
27
|
}
|
|
23
28
|
else {
|
|
24
|
-
acc[0].push(
|
|
29
|
+
acc[0].push(mod);
|
|
25
30
|
}
|
|
26
31
|
});
|
|
27
|
-
// Process external modules
|
|
28
|
-
configData.externalModules?.forEach((
|
|
29
|
-
if (
|
|
30
|
-
acc[1].push(
|
|
32
|
+
// Process external modules.
|
|
33
|
+
configData.externalModules?.forEach((mod) => {
|
|
34
|
+
if (mod.endsWith('-server')) {
|
|
35
|
+
acc[1].push(mod);
|
|
31
36
|
}
|
|
32
37
|
else {
|
|
33
|
-
acc[0].push(
|
|
38
|
+
acc[0].push(mod);
|
|
34
39
|
}
|
|
35
40
|
});
|
|
36
|
-
//
|
|
37
|
-
configData.devModules?.forEach((
|
|
38
|
-
if (
|
|
39
|
-
acc[1].push(
|
|
41
|
+
// Process devModules.
|
|
42
|
+
configData.devModules?.forEach((mod) => {
|
|
43
|
+
if (mod.endsWith('-server')) {
|
|
44
|
+
acc[1].push(mod);
|
|
40
45
|
}
|
|
41
46
|
else {
|
|
42
|
-
acc[0].push(
|
|
47
|
+
acc[0].push(mod);
|
|
43
48
|
}
|
|
44
49
|
});
|
|
45
50
|
return acc;
|
|
46
51
|
}, [[], []]);
|
|
47
|
-
//
|
|
52
|
+
// Combine modules uniquely
|
|
48
53
|
const allModules = [...new Set([...clientModules, ...serverModules])];
|
|
49
|
-
// 3) Transform each moduleName into a module object
|
|
50
54
|
const processedModules = new Set();
|
|
51
55
|
return allModules.reduce((acc, moduleName) => {
|
|
52
56
|
try {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
57
|
+
let resolvedFile;
|
|
58
|
+
try {
|
|
59
|
+
// Attempt normal resolution.
|
|
60
|
+
resolvedFile = esmRequire.resolve(moduleName);
|
|
61
|
+
}
|
|
62
|
+
catch (err) {
|
|
63
|
+
// Fallback resolution: if the module name includes "/lib", remove it and try again.
|
|
64
|
+
const fallbackModule = moduleName.includes('/lib')
|
|
65
|
+
? moduleName.replace(/\/lib.*$/, '')
|
|
66
|
+
: moduleName;
|
|
67
|
+
try {
|
|
68
|
+
resolvedFile = esmRequire.resolve(fallbackModule);
|
|
69
|
+
}
|
|
70
|
+
catch (err2) {
|
|
71
|
+
console.warn(`Could not resolve module ${moduleName} even with fallback ${fallbackModule}. Skipping.`);
|
|
72
|
+
return acc;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
const dirName = path__default.dirname(resolvedFile);
|
|
56
76
|
const modulePath = path__default.relative(pathsConfig.repoRoot, dirName);
|
|
57
|
-
// Reverse
|
|
77
|
+
// Reverse the split parts to check if "node_modules" exists.
|
|
58
78
|
const [dir, pkg, ...rest] = modulePath.split('/').reverse();
|
|
59
79
|
const isLocal = !rest.includes('node_modules');
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
80
|
+
const baseModule = isLocal
|
|
81
|
+
? [...rest].reverse().join('/')
|
|
82
|
+
: modulePath.replace('/lib', '');
|
|
63
83
|
if (processedModules.has(baseModule)) {
|
|
64
84
|
return acc;
|
|
65
85
|
}
|
|
66
86
|
processedModules.add(baseModule);
|
|
67
|
-
//
|
|
87
|
+
// For local modules, use "src" directory; for node_modules, use "lib"
|
|
68
88
|
const srcOrLib = isLocal ? 'src' : 'lib';
|
|
69
89
|
const generatePath = (type) => `${baseModule}${isLocal ? `/${type}` : ''}/${srcOrLib}`;
|
|
70
|
-
//
|
|
90
|
+
// For local modules, always return all module keys.
|
|
71
91
|
if (isLocal) {
|
|
72
92
|
return [
|
|
73
93
|
...acc,
|
|
@@ -79,10 +99,9 @@ function readModules(serverConfigPaths = []) {
|
|
|
79
99
|
},
|
|
80
100
|
];
|
|
81
101
|
}
|
|
82
|
-
//
|
|
83
|
-
// If the baseModule ends with "-browser"
|
|
102
|
+
// Otherwise, handle node_module naming conventions.
|
|
103
|
+
// If the baseModule ends with "-browser".
|
|
84
104
|
if (baseModule.endsWith('-browser')) {
|
|
85
|
-
// If it ends with -browser, also provide -client, -core
|
|
86
105
|
return [
|
|
87
106
|
...acc,
|
|
88
107
|
{
|
|
@@ -93,7 +112,6 @@ function readModules(serverConfigPaths = []) {
|
|
|
93
112
|
];
|
|
94
113
|
}
|
|
95
114
|
if (baseModule.endsWith('-server')) {
|
|
96
|
-
// If it ends with -server
|
|
97
115
|
return [
|
|
98
116
|
...acc,
|
|
99
117
|
{
|
|
@@ -102,7 +120,6 @@ function readModules(serverConfigPaths = []) {
|
|
|
102
120
|
];
|
|
103
121
|
}
|
|
104
122
|
if (baseModule.includes('-browser')) {
|
|
105
|
-
// If it has '-browser' somewhere else
|
|
106
123
|
return [
|
|
107
124
|
...acc,
|
|
108
125
|
{
|
|
@@ -110,7 +127,7 @@ function readModules(serverConfigPaths = []) {
|
|
|
110
127
|
},
|
|
111
128
|
];
|
|
112
129
|
}
|
|
113
|
-
// Default fallback
|
|
130
|
+
// Default fallback.
|
|
114
131
|
return [
|
|
115
132
|
...acc,
|
|
116
133
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"readModules.js","sources":["../../../src/tools/codegen/readModules.ts"],"sourcesContent":[null],"names":["fs","path"],"mappings":"0IAKA;AACA;AAEA;AACA,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAElD
|
|
1
|
+
{"version":3,"file":"readModules.js","sources":["../../../src/tools/codegen/readModules.ts"],"sourcesContent":[null],"names":["fs","path"],"mappings":"0IAKA;AACA;AAEA;AACA,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAElD;;;;;;;;;AASG;AACa,SAAA,WAAW,CAAC,iBAAA,GAA8B,EAAE,EAAA;;AAExD,IAAA,MAAM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AAA,EAAG,UAAU,CAAC,OAAO,CAAC,WAAW,EAAE,SAAS,CAAC,CAAI,CAAA,EAAA,QAAQ,CAAE,CAAA;AACnE,wBAAA,IAAI,EAAE,CAAA,EAAG,UAAU,CAAC,OAAO,CAAC,WAAW,EAAE,OAAO,CAAC,CAAI,CAAA,EAAA,QAAQ,CAAE,CAAA;AAClE,qBAAA;iBACJ,CAAC;aACL;AACD,YAAA,IAAI,UAAU,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE;gBAChC,OAAO;AACH,oBAAA,GAAG,GAAG;AACN,oBAAA;AACI,wBAAA,MAAM,EAAE,CAAA,EAAG,UAAU,CAAA,CAAA,EAAI,QAAQ,CAAE,CAAA;AACtC,qBAAA;iBACJ,CAAC;aACL;AACD,YAAA,IAAI,UAAU,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE;gBACjC,OAAO;AACH,oBAAA,GAAG,GAAG;AACN,oBAAA;AACI,wBAAA,OAAO,EAAE,CAAA,EAAG,UAAU,CAAA,CAAA,EAAI,QAAQ,CAAE,CAAA;AACvC,qBAAA;iBACJ,CAAC;aACL;;YAED,OAAO;AACH,gBAAA,GAAG,GAAG;AACN,gBAAA;AACI,oBAAA,WAAW,EAAE,CAAA,EAAG,UAAU,CAAA,CAAA,EAAI,QAAQ,CAAE,CAAA;AAC3C,iBAAA;aACJ,CAAC;SACL;QAAC,OAAO,CAAC,EAAE;AACR,YAAA,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AACjB,YAAA,OAAO,CAAC,GAAG,CAAC,gCAAgC,EAAE,UAAU,CAAC,CAAC;AAC1D,YAAA,OAAO,GAAG,CAAC;SACd;KACJ,EAAE,EAAW,CAAC,CAAC;AACpB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IPreferences } from './generated/generated-models';
|
|
2
|
-
import {
|
|
2
|
+
import { FlattenKeys } from './types';
|
|
3
3
|
|
|
4
4
|
export const enum ConfigurationTarget {
|
|
5
5
|
/**
|
|
@@ -34,4 +34,4 @@ export const enum ConfigurationTarget {
|
|
|
34
34
|
MACHINE_OVERRIDABLE,
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
export type IConfigurationsFlattenedKeys =
|
|
37
|
+
export type IConfigurationsFlattenedKeys = FlattenKeys<IPreferences>;
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
export type GetFlattenedValue<
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
:
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
: never;
|
|
1
|
+
export type GetFlattenedValue<T, K extends string> = K extends ''
|
|
2
|
+
? T
|
|
3
|
+
: K extends `${infer Prop}.${infer Rest}`
|
|
4
|
+
? Prop extends keyof T
|
|
5
|
+
? GetFlattenedValue<T[Prop], Rest>
|
|
6
|
+
: never
|
|
7
|
+
: K extends keyof T
|
|
8
|
+
? T[K]
|
|
9
|
+
: never;
|
|
11
10
|
|
|
12
11
|
// Utility to limit recursion depth
|
|
13
12
|
export type Flatten<T, Prefix extends string = '', Depth extends number = 30> = [Depth] extends [never] // Check if depth limit is reached
|
|
@@ -26,3 +25,18 @@ export type FlattenWithFinite<T, Depth extends number = 10, Prefix extends strin
|
|
|
26
25
|
? FlattenWithFinite<T[K], Depth extends 1 ? never : Depth extends 2 ? 1 : 2, `${Prefix}${K}.`>
|
|
27
26
|
: `${Prefix}${K}`;
|
|
28
27
|
}[keyof T & (string | number)];
|
|
28
|
+
|
|
29
|
+
// Update the FlattenKeys type to handle circular references and add the empty key to return the entire preferences.
|
|
30
|
+
export type FlattenKeys<T> =
|
|
31
|
+
| ''
|
|
32
|
+
| (T extends object
|
|
33
|
+
? {
|
|
34
|
+
[K in keyof T]: T[K] extends object
|
|
35
|
+
? K extends string
|
|
36
|
+
? `${K}` | `${K}.${FlattenKeys<Omit<T[K], 'overrideOf'>>}`
|
|
37
|
+
: never
|
|
38
|
+
: K extends string
|
|
39
|
+
? `${K}`
|
|
40
|
+
: never;
|
|
41
|
+
}[keyof T]
|
|
42
|
+
: never);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@common-stack/rollup-vite-utils",
|
|
3
|
-
"version": "6.0.8-alpha.
|
|
3
|
+
"version": "6.0.8-alpha.40",
|
|
4
4
|
"description": "Client Module for react app",
|
|
5
5
|
"homepage": "https://github.com/cdmbase/fullstack-pro#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"publishConfig": {
|
|
57
57
|
"access": "public"
|
|
58
58
|
},
|
|
59
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "371dfeef901628ad19b44d47cfe60c512686b010",
|
|
60
60
|
"typescript": {
|
|
61
61
|
"definition": "lib/index.d.ts"
|
|
62
62
|
}
|