@powerlines/deepkit 0.4.92 → 0.5.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.
Files changed (100) hide show
  1. package/bin/deepkit-install.cjs +1 -1
  2. package/dist/capnp.cjs +48 -47
  3. package/dist/capnp.js +3 -2
  4. package/dist/chunk-4V4LIAN2.js +54 -0
  5. package/dist/chunk-7J3ZDT6O.cjs +30 -0
  6. package/dist/{chunk-U4JSDAXK.js → chunk-B6GTAZEL.js} +8 -7
  7. package/dist/chunk-ESVH44QW.cjs +56 -0
  8. package/dist/chunk-FFBZWTR7.cjs +63 -0
  9. package/dist/chunk-GRNJVY7I.cjs +19 -0
  10. package/dist/{chunk-DGXATHAN.js → chunk-I5CVIT7W.js} +41 -46
  11. package/dist/chunk-IRPJW6HH.js +16 -0
  12. package/dist/{chunk-SKYW5GV2.cjs → chunk-J2FVIV7W.cjs} +127 -132
  13. package/dist/chunk-J4SVRFV4.js +127 -0
  14. package/dist/{chunk-FEBG7WWO.js → chunk-MEMIQ5AA.js} +1 -3
  15. package/dist/chunk-ORA4UQMU.cjs +2 -0
  16. package/dist/chunk-OULCUN6I.js +1 -0
  17. package/dist/chunk-PKLLVKY2.cjs +193 -0
  18. package/dist/chunk-QLKLDV3V.cjs +135 -0
  19. package/dist/chunk-U5O6DHJ2.js +187 -0
  20. package/dist/{chunk-JHEBLHYK.cjs → chunk-VMRRVNO2.cjs} +2 -4
  21. package/dist/{chunk-55HOZO7D.cjs → chunk-VWKKT7CM.cjs} +5 -7
  22. package/dist/chunk-XGQQM64U.js +8 -0
  23. package/dist/{chunk-BTXPY3B4.js → chunk-YQQIT5YX.js} +2 -4
  24. package/dist/esbuild-plugin.cjs +13 -0
  25. package/dist/esbuild-plugin.d.cts +13 -0
  26. package/dist/esbuild-plugin.d.ts +13 -0
  27. package/dist/esbuild-plugin.js +4 -0
  28. package/dist/index.cjs +93 -88
  29. package/dist/index.d.cts +3 -1
  30. package/dist/index.d.ts +3 -1
  31. package/dist/index.js +10 -11
  32. package/dist/reflect-type.cjs +7 -3
  33. package/dist/reflect-type.js +6 -2
  34. package/dist/resolve-reflections.cjs +3 -3
  35. package/dist/resolve-reflections.js +2 -2
  36. package/dist/transformer.cjs +4 -4
  37. package/dist/transformer.js +2 -2
  38. package/dist/transpile.cjs +4 -4
  39. package/dist/transpile.js +3 -3
  40. package/dist/types.cjs +1 -2
  41. package/dist/types.js +1 -2
  42. package/dist/utilities.cjs +10 -9
  43. package/dist/utilities.js +3 -2
  44. package/dist/{chunk-YKFG2BZQ.cjs → vendor/chunk-5NPGWGPO.cjs} +0 -6
  45. package/dist/vendor/{chunk-BLN7QVCP.js → chunk-7LAB3COT.js} +7 -154
  46. package/dist/vendor/chunk-IOMA7ABE.js +359 -0
  47. package/dist/vendor/chunk-K5KCTNDL.cjs +2678 -0
  48. package/dist/vendor/chunk-L3KIZV6P.js +2664 -0
  49. package/dist/vendor/chunk-M3FJ3QXG.cjs +377 -0
  50. package/dist/vendor/chunk-SHUYVCID.js +4 -0
  51. package/dist/vendor/chunk-USNT2KNT.cjs +6 -0
  52. package/dist/{chunk-4WJJKR53.js → vendor/chunk-ZDFKNN7Y.cjs} +281 -322
  53. package/dist/vendor/compiler.cjs +12 -13
  54. package/dist/vendor/compiler.js +2 -5
  55. package/dist/vendor/config.cjs +9 -10
  56. package/dist/vendor/config.js +1 -5
  57. package/dist/vendor/core.cjs +130 -131
  58. package/dist/vendor/core.js +2 -5
  59. package/dist/vendor/index.cjs +14 -22
  60. package/dist/vendor/index.js +3 -11
  61. package/dist/vendor/type-spec.cjs +5 -6
  62. package/dist/vendor/type-spec.js +2 -5
  63. package/dist/vendor/type.cjs +631 -758
  64. package/dist/vendor/type.js +15 -138
  65. package/package.json +6 -5
  66. package/dist/chunk-2V4ET57D.js +0 -6954
  67. package/dist/chunk-6ETLMANX.js +0 -3472
  68. package/dist/chunk-6OXPIOZY.cjs +0 -43
  69. package/dist/chunk-7WAH4JD3.js +0 -115
  70. package/dist/chunk-B4PTD5KQ.js +0 -4
  71. package/dist/chunk-FX2P4HL7.cjs +0 -14
  72. package/dist/chunk-ITQKPDCW.cjs +0 -3859
  73. package/dist/chunk-LBHO5BRF.js +0 -2251
  74. package/dist/chunk-MERFAWZE.js +0 -12
  75. package/dist/chunk-OYRIJX67.cjs +0 -3487
  76. package/dist/chunk-PANPZ6S6.cjs +0 -6
  77. package/dist/chunk-QPSZUUB6.cjs +0 -2259
  78. package/dist/chunk-QQ7GKXIS.js +0 -43
  79. package/dist/chunk-SA3DCC4M.cjs +0 -6968
  80. package/dist/chunk-WVKPC33H.cjs +0 -49
  81. package/dist/vendor/chunk-5BKT4CS5.js +0 -28
  82. package/dist/vendor/chunk-BDXVTHBY.cjs +0 -3859
  83. package/dist/vendor/chunk-EQXMWOHO.cjs +0 -115
  84. package/dist/vendor/chunk-MCNMRQDT.js +0 -3513
  85. package/dist/vendor/chunk-MO4O4UYI.cjs +0 -42
  86. package/dist/vendor/chunk-RH4YMONA.js +0 -7064
  87. package/dist/vendor/chunk-RZKB5IQZ.cjs +0 -3531
  88. package/dist/vendor/chunk-WOXMCJJU.cjs +0 -7078
  89. package/dist/vendor/type-compiler/compiler.cjs +0 -46
  90. package/dist/vendor/type-compiler/compiler.d.cts +0 -1
  91. package/dist/vendor/type-compiler/compiler.d.ts +0 -1
  92. package/dist/vendor/type-compiler/compiler.js +0 -7
  93. package/dist/vendor/type-compiler/config.cjs +0 -36
  94. package/dist/vendor/type-compiler/config.d.cts +0 -6
  95. package/dist/vendor/type-compiler/config.d.ts +0 -6
  96. package/dist/vendor/type-compiler/config.js +0 -5
  97. package/dist/vendor/type-compiler/index.cjs +0 -108
  98. package/dist/vendor/type-compiler/index.d.cts +0 -1
  99. package/dist/vendor/type-compiler/index.d.ts +0 -1
  100. package/dist/vendor/type-compiler/index.js +0 -67
@@ -0,0 +1,127 @@
1
+ import { type_exports } from './chunk-XGQQM64U.js';
2
+ import { __name } from './chunk-IRPJW6HH.js';
3
+ import { getUniqueBy } from '@stryke/helpers/get-unique';
4
+ import { StormJSON } from '@stryke/json/storm-json';
5
+ import { isNull } from '@stryke/type-checks/is-null';
6
+ import { isString } from '@stryke/type-checks/is-string';
7
+ import { isUndefined } from '@stryke/type-checks/is-undefined';
8
+
9
+ function stringifyDefaultValue(property, value) {
10
+ return stringifyValue(property.type, value ?? property.getDefaultValue());
11
+ }
12
+ __name(stringifyDefaultValue, "stringifyDefaultValue");
13
+ function stringifyStringValue(value) {
14
+ return `"${String(value).replaceAll('"', '\\"')}"`;
15
+ }
16
+ __name(stringifyStringValue, "stringifyStringValue");
17
+ function stringifyValue(type, value) {
18
+ return isUndefined(value) ? "undefined" : isNull(value) ? "null" : type.kind === type_exports.ReflectionKind.boolean ? String(value).trim().toLowerCase() === "true" ? "true" : "false" : type.kind === type_exports.ReflectionKind.string || type.kind === type_exports.ReflectionKind.literal && isString(type.literal) ? stringifyStringValue(value) : type.kind === type_exports.ReflectionKind.enum ? getEnumReflectionType(type).kind === type_exports.ReflectionKind.string ? stringifyStringValue(value) : `${String(value)}` : type.kind === type_exports.ReflectionKind.union ? isStringUnion(type) ? stringifyStringValue(value) : `${String(value)}` : type.kind === type_exports.ReflectionKind.array ? stringifyStringValue(StormJSON.stringify(value)) : type.kind === type_exports.ReflectionKind.object || type.kind === type_exports.ReflectionKind.objectLiteral ? StormJSON.stringify(value) : type.kind === type_exports.ReflectionKind.property || type.kind === type_exports.ReflectionKind.parameter ? stringifyValue(type.type, value) : String(value);
19
+ }
20
+ __name(stringifyValue, "stringifyValue");
21
+ function getEnumReflectionType(type) {
22
+ if (type.kind !== type_exports.ReflectionKind.enum) {
23
+ throw new Error(`Expected a TypeEnum, but received ${type.kind}.`);
24
+ }
25
+ const unique = getUniqueBy(type.values.filter((value) => value !== void 0 && value !== null), (enumMember) => isString(enumMember) ? {
26
+ kind: type_exports.ReflectionKind.string
27
+ } : {
28
+ kind: type_exports.ReflectionKind.number
29
+ });
30
+ if (unique.length === 0) {
31
+ throw new Error(`No valid enum members could be found.`);
32
+ }
33
+ return unique[0] && isString(unique[0]) ? {
34
+ kind: type_exports.ReflectionKind.string
35
+ } : {
36
+ kind: type_exports.ReflectionKind.number
37
+ };
38
+ }
39
+ __name(getEnumReflectionType, "getEnumReflectionType");
40
+ function getUnionTypes(type) {
41
+ if (type.kind === type_exports.ReflectionKind.union && type.types.length > 0) {
42
+ return getUniqueBy(type.types, (member) => member.kind);
43
+ }
44
+ throw new Error(`Expected a TypeUnion, but received ${type.kind}.`);
45
+ }
46
+ __name(getUnionTypes, "getUnionTypes");
47
+ function isStringUnion(type) {
48
+ return getUnionTypes(type).some((member) => member.kind === type_exports.ReflectionKind.string || member.kind === type_exports.ReflectionKind.literal && isString(member.literal));
49
+ }
50
+ __name(isStringUnion, "isStringUnion");
51
+ function kindToName(kind) {
52
+ if (kind === type_exports.ReflectionKind.void) {
53
+ return "void";
54
+ } else if (kind === type_exports.ReflectionKind.never) {
55
+ return "never";
56
+ } else if (kind === type_exports.ReflectionKind.null) {
57
+ return "null";
58
+ } else if (kind === type_exports.ReflectionKind.undefined) {
59
+ return "undefined";
60
+ } else if (kind === type_exports.ReflectionKind.symbol) {
61
+ return "symbol";
62
+ } else if (kind === type_exports.ReflectionKind.bigint) {
63
+ return "bigint";
64
+ } else if (kind === type_exports.ReflectionKind.number) {
65
+ return "number";
66
+ } else if (kind === type_exports.ReflectionKind.string) {
67
+ return "string";
68
+ } else if (kind === type_exports.ReflectionKind.boolean) {
69
+ return "boolean";
70
+ } else if (kind === type_exports.ReflectionKind.literal) {
71
+ return "literal";
72
+ } else if (kind === type_exports.ReflectionKind.class) {
73
+ return "class";
74
+ } else if (kind === type_exports.ReflectionKind.array) {
75
+ return "array";
76
+ } else if (kind === type_exports.ReflectionKind.object) {
77
+ return "object";
78
+ } else if (kind === type_exports.ReflectionKind.objectLiteral) {
79
+ return "objectLiteral";
80
+ } else if (kind === type_exports.ReflectionKind.union) {
81
+ return "union";
82
+ } else if (kind === type_exports.ReflectionKind.enum) {
83
+ return "enum";
84
+ } else if (kind === type_exports.ReflectionKind.regexp) {
85
+ return "regexp";
86
+ } else if (kind === type_exports.ReflectionKind.templateLiteral) {
87
+ return "templateLiteral";
88
+ } else if (kind === type_exports.ReflectionKind.property) {
89
+ return "property";
90
+ } else if (kind === type_exports.ReflectionKind.method) {
91
+ return "method";
92
+ } else if (kind === type_exports.ReflectionKind.function) {
93
+ return "function";
94
+ } else if (kind === type_exports.ReflectionKind.parameter) {
95
+ return "parameter";
96
+ } else if (kind === type_exports.ReflectionKind.promise) {
97
+ return "promise";
98
+ } else if (kind === type_exports.ReflectionKind.typeParameter) {
99
+ return "typeParameter";
100
+ } else if (kind === type_exports.ReflectionKind.tuple) {
101
+ return "tuple";
102
+ } else if (kind === type_exports.ReflectionKind.tupleMember) {
103
+ return "tupleMember";
104
+ } else if (kind === type_exports.ReflectionKind.enumMember) {
105
+ return "enumMember";
106
+ } else if (kind === type_exports.ReflectionKind.rest) {
107
+ return "rest";
108
+ } else if (kind === type_exports.ReflectionKind.indexSignature) {
109
+ return "indexSignature";
110
+ } else if (kind === type_exports.ReflectionKind.propertySignature) {
111
+ return "propertySignature";
112
+ } else if (kind === type_exports.ReflectionKind.methodSignature) {
113
+ return "methodSignature";
114
+ } else if (kind === type_exports.ReflectionKind.infer) {
115
+ return "infer";
116
+ } else if (kind === type_exports.ReflectionKind.callSignature) {
117
+ return "callSignature";
118
+ } else if (kind === type_exports.ReflectionKind.any) {
119
+ return "any";
120
+ } else if (kind === type_exports.ReflectionKind.intersection) {
121
+ return "intersection";
122
+ }
123
+ return "unknown";
124
+ }
125
+ __name(kindToName, "kindToName");
126
+
127
+ export { getEnumReflectionType, getUnionTypes, isStringUnion, kindToName, stringifyDefaultValue, stringifyStringValue, stringifyValue };
@@ -1,8 +1,6 @@
1
- import { init_esm_shims, __name } from './chunk-QQ7GKXIS.js';
1
+ import { __name } from './chunk-IRPJW6HH.js';
2
2
  import { joinPaths } from '@stryke/path/join-paths';
3
3
 
4
- // src/resolve-reflections.ts
5
- init_esm_shims();
6
4
  function getReflectionsPath(context) {
7
5
  return joinPaths(context.dataPath, "reflections");
8
6
  }
@@ -0,0 +1,2 @@
1
+ 'use strict';
2
+
@@ -0,0 +1 @@
1
+
@@ -0,0 +1,193 @@
1
+ 'use strict';
2
+
3
+ var chunk7J3ZDT6O_cjs = require('./chunk-7J3ZDT6O.cjs');
4
+ var chunkESVH44QW_cjs = require('./chunk-ESVH44QW.cjs');
5
+ var chunkGRNJVY7I_cjs = require('./chunk-GRNJVY7I.cjs');
6
+ var defu = require('defu');
7
+ var parseTypeDefinition = require('@stryke/convert/parse-type-definition');
8
+ var isSetString = require('@stryke/type-checks/is-set-string');
9
+ var types = require('@storm-software/config-tools/types');
10
+ var esbuild = require('esbuild');
11
+ var omit = require('@stryke/helpers/omit');
12
+ var joinPaths = require('@stryke/path/join-paths');
13
+ require('@stryke/path/replace');
14
+ var camelCase = require('@stryke/string-format/camel-case');
15
+ require('@stryke/type-checks/is-string');
16
+ require('@stryke/convert/to-array');
17
+ require('@stryke/fs/is-file');
18
+ require('@stryke/fs/list-files');
19
+ require('@stryke/hash/murmurhash');
20
+ require('@stryke/helpers/get-unique');
21
+ require('@stryke/path/append');
22
+
23
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
24
+
25
+ var defu__default = /*#__PURE__*/_interopDefault(defu);
26
+
27
+ // ../powerlines/src/lib/build/esbuild.ts
28
+ var DEFAULT_ESBUILD_CONFIG = {
29
+ target: "esnext",
30
+ platform: "neutral",
31
+ format: "esm",
32
+ write: true,
33
+ minify: true,
34
+ sourcemap: false,
35
+ bundle: true,
36
+ treeShaking: true,
37
+ keepNames: true,
38
+ splitting: true,
39
+ logLevel: "silent"
40
+ };
41
+ function extractESBuildConfig(context) {
42
+ const inject = context.config.build.override.inject ?? context.config.build.inject;
43
+ if (inject && Object.keys(inject).length > 0) {
44
+ context.fs.writeSync(joinPaths.joinPaths(context.workspaceConfig.workspaceRoot, context.config.projectRoot, context.artifactsPath, "inject-shim.js"), Object.entries(inject).map(([key, value]) => {
45
+ if (value) {
46
+ if (Array.isArray(value)) {
47
+ if (camelCase.camelCase(key) !== key) {
48
+ if (value.length === 1) {
49
+ return `
50
+ import ${camelCase.camelCase(key)} from "${value[0]}";
51
+ export { ${camelCase.camelCase(key)} as "${key}" }`;
52
+ } else if (value.length > 1) {
53
+ return `
54
+ import ${value[1] === "*" ? `* as ${camelCase.camelCase(key)}` : `{ ${value[1]} as ${camelCase.camelCase(key)} }`} from "${value[0]}";
55
+ export { ${camelCase.camelCase(key)} as "${key}" }`;
56
+ }
57
+ } else if (value.length === 1) {
58
+ return `
59
+ import ${key} from "${value[0]}";
60
+ export { ${key} };`;
61
+ } else if (value.length > 1) {
62
+ return `
63
+ import ${value[1] === "*" ? `* as ${key}` : `{ ${value[1]} as ${key} }`} from "${value[0]}";
64
+ export { ${key} };`;
65
+ }
66
+ } else if (camelCase.camelCase(key) !== key) {
67
+ return `
68
+ import ${camelCase.camelCase(key)} from "${value[0]}";
69
+ export { ${camelCase.camelCase(key)} as "${key}" }`;
70
+ } else {
71
+ return `
72
+ import ${key} from "${value}";
73
+ export { ${key} };`;
74
+ }
75
+ }
76
+ return "";
77
+ }).join("\n"));
78
+ }
79
+ return defu__default.default({
80
+ alias: context.builtins.reduce((ret, id) => {
81
+ if (!ret[id]) {
82
+ const path = context.fs.ids[id];
83
+ if (path) {
84
+ ret[id] = path;
85
+ }
86
+ }
87
+ return ret;
88
+ }, context.config.build.alias ? Array.isArray(context.config.build.alias) ? context.config.build.alias.reduce((ret, alias) => {
89
+ if (!ret[alias.find.toString()]) {
90
+ ret[alias.find.toString()] = alias.replacement;
91
+ }
92
+ return ret;
93
+ }, {}) : context.config.build.alias : {}),
94
+ inject: inject && Object.keys(inject).length > 0 ? [
95
+ joinPaths.joinPaths(context.workspaceConfig.workspaceRoot, context.config.projectRoot, context.artifactsPath, "inject-shim.js")
96
+ ] : void 0
97
+ }, context.config.build.variant === "esbuild" ? omit.omit(context.config.build.override, [
98
+ "alias",
99
+ "inject",
100
+ "external",
101
+ "noExternal",
102
+ "skipNodeModulesBundle",
103
+ "extensions"
104
+ ]) : {}, context.config.build.variant === "esbuild" ? omit.omit(context.config.build, [
105
+ "alias",
106
+ "inject",
107
+ "external",
108
+ "noExternal",
109
+ "skipNodeModulesBundle",
110
+ "extensions",
111
+ "variant",
112
+ "override"
113
+ ]) : {}, {
114
+ mainFields: context.config.build.mainFields,
115
+ conditions: context.config.build.conditions,
116
+ define: context.config.build.define,
117
+ resolveExtensions: context.config.build.extensions,
118
+ packages: context.config.build.skipNodeModulesBundle ? "external" : context.config.build.variant === "esbuild" ? context.config.build.packages : void 0,
119
+ format: Array.isArray(context.config.output.format) ? context.config.output.format[0] : context.config.output.format,
120
+ platform: context.config.build.platform,
121
+ treeShaking: Boolean(context.config.build?.treeshake) || context.config.build?.treeShaking,
122
+ outdir: context.config.output.buildPath,
123
+ tsconfig: context.tsconfig.tsconfigFilePath,
124
+ minify: context.config.mode !== "development",
125
+ metafile: context.config.mode === "development",
126
+ sourcemap: context.config.mode === "development"
127
+ }, DEFAULT_ESBUILD_CONFIG);
128
+ }
129
+ chunkGRNJVY7I_cjs.__name(extractESBuildConfig, "extractESBuildConfig");
130
+
131
+ // ../powerlines/src/lib/utilities/bundle.ts
132
+ async function bundle(context, file, overrides = {}) {
133
+ const path = await context.fs.resolve(file);
134
+ if (!path || !context.fs.existsSync(path)) {
135
+ throw new Error(`Module not found: "${file}". Please check the path and try again.`);
136
+ }
137
+ const result = await esbuild.build({
138
+ ...extractESBuildConfig(context),
139
+ entryPoints: [
140
+ path
141
+ ],
142
+ write: false,
143
+ sourcemap: false,
144
+ splitting: false,
145
+ treeShaking: false,
146
+ bundle: true,
147
+ ...overrides
148
+ });
149
+ if (result.errors.length > 0) {
150
+ throw new Error(`Failed to transpile ${file}: ${result.errors.map((error) => error.text).join(", ")}`);
151
+ }
152
+ if (result.warnings.length > 0) {
153
+ context.log(types.LogLevelLabel.WARN, `Warnings while transpiling ${file}: ${result.warnings.map((warning) => warning.text).join(", ")}`);
154
+ }
155
+ if (!result.outputFiles || result.outputFiles.filter(Boolean).length === 0) {
156
+ throw new Error(`No output files generated for ${file}. Please check the configuration and try again.`);
157
+ }
158
+ return result.outputFiles.filter(Boolean)[0];
159
+ }
160
+ chunkGRNJVY7I_cjs.__name(bundle, "bundle");
161
+
162
+ // ../powerlines/src/lib/utilities/resolve.ts
163
+ async function resolve(context, type, overrides = {}) {
164
+ let typeDefinition;
165
+ if (isSetString.isSetString(type)) {
166
+ typeDefinition = parseTypeDefinition.parseTypeDefinition(type);
167
+ } else {
168
+ typeDefinition = type;
169
+ }
170
+ const result = await bundle(context, typeDefinition.file, overrides);
171
+ const resolved = await context.resolver.evalModule(result.text, {
172
+ filename: result.path,
173
+ forceTranspile: true
174
+ });
175
+ let exportName = typeDefinition.name;
176
+ if (!exportName) {
177
+ exportName = "default";
178
+ }
179
+ return resolved[exportName] ?? resolved[`__\u03A9${exportName}`];
180
+ }
181
+ chunkGRNJVY7I_cjs.__name(resolve, "resolve");
182
+
183
+ // src/reflect-type.ts
184
+ async function reflectType(context, type, overrides = {}) {
185
+ return (0, chunk7J3ZDT6O_cjs.type_exports.reflect)(await resolve(context, type, defu__default.default(overrides, {
186
+ plugins: [
187
+ chunkESVH44QW_cjs.esbuildPlugin(context)
188
+ ]
189
+ })));
190
+ }
191
+ chunkGRNJVY7I_cjs.__name(reflectType, "reflectType");
192
+
193
+ exports.reflectType = reflectType;
@@ -0,0 +1,135 @@
1
+ 'use strict';
2
+
3
+ var chunk7J3ZDT6O_cjs = require('./chunk-7J3ZDT6O.cjs');
4
+ var chunkGRNJVY7I_cjs = require('./chunk-GRNJVY7I.cjs');
5
+ var getUnique = require('@stryke/helpers/get-unique');
6
+ var stormJson = require('@stryke/json/storm-json');
7
+ var isNull = require('@stryke/type-checks/is-null');
8
+ var isString = require('@stryke/type-checks/is-string');
9
+ var isUndefined = require('@stryke/type-checks/is-undefined');
10
+
11
+ function stringifyDefaultValue(property, value) {
12
+ return stringifyValue(property.type, value ?? property.getDefaultValue());
13
+ }
14
+ chunkGRNJVY7I_cjs.__name(stringifyDefaultValue, "stringifyDefaultValue");
15
+ function stringifyStringValue(value) {
16
+ return `"${String(value).replaceAll('"', '\\"')}"`;
17
+ }
18
+ chunkGRNJVY7I_cjs.__name(stringifyStringValue, "stringifyStringValue");
19
+ function stringifyValue(type, value) {
20
+ return isUndefined.isUndefined(value) ? "undefined" : isNull.isNull(value) ? "null" : type.kind === chunk7J3ZDT6O_cjs.type_exports.ReflectionKind.boolean ? String(value).trim().toLowerCase() === "true" ? "true" : "false" : type.kind === chunk7J3ZDT6O_cjs.type_exports.ReflectionKind.string || type.kind === chunk7J3ZDT6O_cjs.type_exports.ReflectionKind.literal && isString.isString(type.literal) ? stringifyStringValue(value) : type.kind === chunk7J3ZDT6O_cjs.type_exports.ReflectionKind.enum ? getEnumReflectionType(type).kind === chunk7J3ZDT6O_cjs.type_exports.ReflectionKind.string ? stringifyStringValue(value) : `${String(value)}` : type.kind === chunk7J3ZDT6O_cjs.type_exports.ReflectionKind.union ? isStringUnion(type) ? stringifyStringValue(value) : `${String(value)}` : type.kind === chunk7J3ZDT6O_cjs.type_exports.ReflectionKind.array ? stringifyStringValue(stormJson.StormJSON.stringify(value)) : type.kind === chunk7J3ZDT6O_cjs.type_exports.ReflectionKind.object || type.kind === chunk7J3ZDT6O_cjs.type_exports.ReflectionKind.objectLiteral ? stormJson.StormJSON.stringify(value) : type.kind === chunk7J3ZDT6O_cjs.type_exports.ReflectionKind.property || type.kind === chunk7J3ZDT6O_cjs.type_exports.ReflectionKind.parameter ? stringifyValue(type.type, value) : String(value);
21
+ }
22
+ chunkGRNJVY7I_cjs.__name(stringifyValue, "stringifyValue");
23
+ function getEnumReflectionType(type) {
24
+ if (type.kind !== chunk7J3ZDT6O_cjs.type_exports.ReflectionKind.enum) {
25
+ throw new Error(`Expected a TypeEnum, but received ${type.kind}.`);
26
+ }
27
+ const unique = getUnique.getUniqueBy(type.values.filter((value) => value !== void 0 && value !== null), (enumMember) => isString.isString(enumMember) ? {
28
+ kind: chunk7J3ZDT6O_cjs.type_exports.ReflectionKind.string
29
+ } : {
30
+ kind: chunk7J3ZDT6O_cjs.type_exports.ReflectionKind.number
31
+ });
32
+ if (unique.length === 0) {
33
+ throw new Error(`No valid enum members could be found.`);
34
+ }
35
+ return unique[0] && isString.isString(unique[0]) ? {
36
+ kind: chunk7J3ZDT6O_cjs.type_exports.ReflectionKind.string
37
+ } : {
38
+ kind: chunk7J3ZDT6O_cjs.type_exports.ReflectionKind.number
39
+ };
40
+ }
41
+ chunkGRNJVY7I_cjs.__name(getEnumReflectionType, "getEnumReflectionType");
42
+ function getUnionTypes(type) {
43
+ if (type.kind === chunk7J3ZDT6O_cjs.type_exports.ReflectionKind.union && type.types.length > 0) {
44
+ return getUnique.getUniqueBy(type.types, (member) => member.kind);
45
+ }
46
+ throw new Error(`Expected a TypeUnion, but received ${type.kind}.`);
47
+ }
48
+ chunkGRNJVY7I_cjs.__name(getUnionTypes, "getUnionTypes");
49
+ function isStringUnion(type) {
50
+ return getUnionTypes(type).some((member) => member.kind === chunk7J3ZDT6O_cjs.type_exports.ReflectionKind.string || member.kind === chunk7J3ZDT6O_cjs.type_exports.ReflectionKind.literal && isString.isString(member.literal));
51
+ }
52
+ chunkGRNJVY7I_cjs.__name(isStringUnion, "isStringUnion");
53
+ function kindToName(kind) {
54
+ if (kind === chunk7J3ZDT6O_cjs.type_exports.ReflectionKind.void) {
55
+ return "void";
56
+ } else if (kind === chunk7J3ZDT6O_cjs.type_exports.ReflectionKind.never) {
57
+ return "never";
58
+ } else if (kind === chunk7J3ZDT6O_cjs.type_exports.ReflectionKind.null) {
59
+ return "null";
60
+ } else if (kind === chunk7J3ZDT6O_cjs.type_exports.ReflectionKind.undefined) {
61
+ return "undefined";
62
+ } else if (kind === chunk7J3ZDT6O_cjs.type_exports.ReflectionKind.symbol) {
63
+ return "symbol";
64
+ } else if (kind === chunk7J3ZDT6O_cjs.type_exports.ReflectionKind.bigint) {
65
+ return "bigint";
66
+ } else if (kind === chunk7J3ZDT6O_cjs.type_exports.ReflectionKind.number) {
67
+ return "number";
68
+ } else if (kind === chunk7J3ZDT6O_cjs.type_exports.ReflectionKind.string) {
69
+ return "string";
70
+ } else if (kind === chunk7J3ZDT6O_cjs.type_exports.ReflectionKind.boolean) {
71
+ return "boolean";
72
+ } else if (kind === chunk7J3ZDT6O_cjs.type_exports.ReflectionKind.literal) {
73
+ return "literal";
74
+ } else if (kind === chunk7J3ZDT6O_cjs.type_exports.ReflectionKind.class) {
75
+ return "class";
76
+ } else if (kind === chunk7J3ZDT6O_cjs.type_exports.ReflectionKind.array) {
77
+ return "array";
78
+ } else if (kind === chunk7J3ZDT6O_cjs.type_exports.ReflectionKind.object) {
79
+ return "object";
80
+ } else if (kind === chunk7J3ZDT6O_cjs.type_exports.ReflectionKind.objectLiteral) {
81
+ return "objectLiteral";
82
+ } else if (kind === chunk7J3ZDT6O_cjs.type_exports.ReflectionKind.union) {
83
+ return "union";
84
+ } else if (kind === chunk7J3ZDT6O_cjs.type_exports.ReflectionKind.enum) {
85
+ return "enum";
86
+ } else if (kind === chunk7J3ZDT6O_cjs.type_exports.ReflectionKind.regexp) {
87
+ return "regexp";
88
+ } else if (kind === chunk7J3ZDT6O_cjs.type_exports.ReflectionKind.templateLiteral) {
89
+ return "templateLiteral";
90
+ } else if (kind === chunk7J3ZDT6O_cjs.type_exports.ReflectionKind.property) {
91
+ return "property";
92
+ } else if (kind === chunk7J3ZDT6O_cjs.type_exports.ReflectionKind.method) {
93
+ return "method";
94
+ } else if (kind === chunk7J3ZDT6O_cjs.type_exports.ReflectionKind.function) {
95
+ return "function";
96
+ } else if (kind === chunk7J3ZDT6O_cjs.type_exports.ReflectionKind.parameter) {
97
+ return "parameter";
98
+ } else if (kind === chunk7J3ZDT6O_cjs.type_exports.ReflectionKind.promise) {
99
+ return "promise";
100
+ } else if (kind === chunk7J3ZDT6O_cjs.type_exports.ReflectionKind.typeParameter) {
101
+ return "typeParameter";
102
+ } else if (kind === chunk7J3ZDT6O_cjs.type_exports.ReflectionKind.tuple) {
103
+ return "tuple";
104
+ } else if (kind === chunk7J3ZDT6O_cjs.type_exports.ReflectionKind.tupleMember) {
105
+ return "tupleMember";
106
+ } else if (kind === chunk7J3ZDT6O_cjs.type_exports.ReflectionKind.enumMember) {
107
+ return "enumMember";
108
+ } else if (kind === chunk7J3ZDT6O_cjs.type_exports.ReflectionKind.rest) {
109
+ return "rest";
110
+ } else if (kind === chunk7J3ZDT6O_cjs.type_exports.ReflectionKind.indexSignature) {
111
+ return "indexSignature";
112
+ } else if (kind === chunk7J3ZDT6O_cjs.type_exports.ReflectionKind.propertySignature) {
113
+ return "propertySignature";
114
+ } else if (kind === chunk7J3ZDT6O_cjs.type_exports.ReflectionKind.methodSignature) {
115
+ return "methodSignature";
116
+ } else if (kind === chunk7J3ZDT6O_cjs.type_exports.ReflectionKind.infer) {
117
+ return "infer";
118
+ } else if (kind === chunk7J3ZDT6O_cjs.type_exports.ReflectionKind.callSignature) {
119
+ return "callSignature";
120
+ } else if (kind === chunk7J3ZDT6O_cjs.type_exports.ReflectionKind.any) {
121
+ return "any";
122
+ } else if (kind === chunk7J3ZDT6O_cjs.type_exports.ReflectionKind.intersection) {
123
+ return "intersection";
124
+ }
125
+ return "unknown";
126
+ }
127
+ chunkGRNJVY7I_cjs.__name(kindToName, "kindToName");
128
+
129
+ exports.getEnumReflectionType = getEnumReflectionType;
130
+ exports.getUnionTypes = getUnionTypes;
131
+ exports.isStringUnion = isStringUnion;
132
+ exports.kindToName = kindToName;
133
+ exports.stringifyDefaultValue = stringifyDefaultValue;
134
+ exports.stringifyStringValue = stringifyStringValue;
135
+ exports.stringifyValue = stringifyValue;
@@ -0,0 +1,187 @@
1
+ import { type_exports } from './chunk-XGQQM64U.js';
2
+ import { esbuildPlugin } from './chunk-4V4LIAN2.js';
3
+ import { __name } from './chunk-IRPJW6HH.js';
4
+ import defu from 'defu';
5
+ import { parseTypeDefinition } from '@stryke/convert/parse-type-definition';
6
+ import { isSetString } from '@stryke/type-checks/is-set-string';
7
+ import { LogLevelLabel } from '@storm-software/config-tools/types';
8
+ import { build } from 'esbuild';
9
+ import { omit } from '@stryke/helpers/omit';
10
+ import { joinPaths } from '@stryke/path/join-paths';
11
+ import '@stryke/path/replace';
12
+ import { camelCase } from '@stryke/string-format/camel-case';
13
+ import '@stryke/type-checks/is-string';
14
+ import '@stryke/convert/to-array';
15
+ import '@stryke/fs/is-file';
16
+ import '@stryke/fs/list-files';
17
+ import '@stryke/hash/murmurhash';
18
+ import '@stryke/helpers/get-unique';
19
+ import '@stryke/path/append';
20
+
21
+ // ../powerlines/src/lib/build/esbuild.ts
22
+ var DEFAULT_ESBUILD_CONFIG = {
23
+ target: "esnext",
24
+ platform: "neutral",
25
+ format: "esm",
26
+ write: true,
27
+ minify: true,
28
+ sourcemap: false,
29
+ bundle: true,
30
+ treeShaking: true,
31
+ keepNames: true,
32
+ splitting: true,
33
+ logLevel: "silent"
34
+ };
35
+ function extractESBuildConfig(context) {
36
+ const inject = context.config.build.override.inject ?? context.config.build.inject;
37
+ if (inject && Object.keys(inject).length > 0) {
38
+ context.fs.writeSync(joinPaths(context.workspaceConfig.workspaceRoot, context.config.projectRoot, context.artifactsPath, "inject-shim.js"), Object.entries(inject).map(([key, value]) => {
39
+ if (value) {
40
+ if (Array.isArray(value)) {
41
+ if (camelCase(key) !== key) {
42
+ if (value.length === 1) {
43
+ return `
44
+ import ${camelCase(key)} from "${value[0]}";
45
+ export { ${camelCase(key)} as "${key}" }`;
46
+ } else if (value.length > 1) {
47
+ return `
48
+ import ${value[1] === "*" ? `* as ${camelCase(key)}` : `{ ${value[1]} as ${camelCase(key)} }`} from "${value[0]}";
49
+ export { ${camelCase(key)} as "${key}" }`;
50
+ }
51
+ } else if (value.length === 1) {
52
+ return `
53
+ import ${key} from "${value[0]}";
54
+ export { ${key} };`;
55
+ } else if (value.length > 1) {
56
+ return `
57
+ import ${value[1] === "*" ? `* as ${key}` : `{ ${value[1]} as ${key} }`} from "${value[0]}";
58
+ export { ${key} };`;
59
+ }
60
+ } else if (camelCase(key) !== key) {
61
+ return `
62
+ import ${camelCase(key)} from "${value[0]}";
63
+ export { ${camelCase(key)} as "${key}" }`;
64
+ } else {
65
+ return `
66
+ import ${key} from "${value}";
67
+ export { ${key} };`;
68
+ }
69
+ }
70
+ return "";
71
+ }).join("\n"));
72
+ }
73
+ return defu({
74
+ alias: context.builtins.reduce((ret, id) => {
75
+ if (!ret[id]) {
76
+ const path = context.fs.ids[id];
77
+ if (path) {
78
+ ret[id] = path;
79
+ }
80
+ }
81
+ return ret;
82
+ }, context.config.build.alias ? Array.isArray(context.config.build.alias) ? context.config.build.alias.reduce((ret, alias) => {
83
+ if (!ret[alias.find.toString()]) {
84
+ ret[alias.find.toString()] = alias.replacement;
85
+ }
86
+ return ret;
87
+ }, {}) : context.config.build.alias : {}),
88
+ inject: inject && Object.keys(inject).length > 0 ? [
89
+ joinPaths(context.workspaceConfig.workspaceRoot, context.config.projectRoot, context.artifactsPath, "inject-shim.js")
90
+ ] : void 0
91
+ }, context.config.build.variant === "esbuild" ? omit(context.config.build.override, [
92
+ "alias",
93
+ "inject",
94
+ "external",
95
+ "noExternal",
96
+ "skipNodeModulesBundle",
97
+ "extensions"
98
+ ]) : {}, context.config.build.variant === "esbuild" ? omit(context.config.build, [
99
+ "alias",
100
+ "inject",
101
+ "external",
102
+ "noExternal",
103
+ "skipNodeModulesBundle",
104
+ "extensions",
105
+ "variant",
106
+ "override"
107
+ ]) : {}, {
108
+ mainFields: context.config.build.mainFields,
109
+ conditions: context.config.build.conditions,
110
+ define: context.config.build.define,
111
+ resolveExtensions: context.config.build.extensions,
112
+ packages: context.config.build.skipNodeModulesBundle ? "external" : context.config.build.variant === "esbuild" ? context.config.build.packages : void 0,
113
+ format: Array.isArray(context.config.output.format) ? context.config.output.format[0] : context.config.output.format,
114
+ platform: context.config.build.platform,
115
+ treeShaking: Boolean(context.config.build?.treeshake) || context.config.build?.treeShaking,
116
+ outdir: context.config.output.buildPath,
117
+ tsconfig: context.tsconfig.tsconfigFilePath,
118
+ minify: context.config.mode !== "development",
119
+ metafile: context.config.mode === "development",
120
+ sourcemap: context.config.mode === "development"
121
+ }, DEFAULT_ESBUILD_CONFIG);
122
+ }
123
+ __name(extractESBuildConfig, "extractESBuildConfig");
124
+
125
+ // ../powerlines/src/lib/utilities/bundle.ts
126
+ async function bundle(context, file, overrides = {}) {
127
+ const path = await context.fs.resolve(file);
128
+ if (!path || !context.fs.existsSync(path)) {
129
+ throw new Error(`Module not found: "${file}". Please check the path and try again.`);
130
+ }
131
+ const result = await build({
132
+ ...extractESBuildConfig(context),
133
+ entryPoints: [
134
+ path
135
+ ],
136
+ write: false,
137
+ sourcemap: false,
138
+ splitting: false,
139
+ treeShaking: false,
140
+ bundle: true,
141
+ ...overrides
142
+ });
143
+ if (result.errors.length > 0) {
144
+ throw new Error(`Failed to transpile ${file}: ${result.errors.map((error) => error.text).join(", ")}`);
145
+ }
146
+ if (result.warnings.length > 0) {
147
+ context.log(LogLevelLabel.WARN, `Warnings while transpiling ${file}: ${result.warnings.map((warning) => warning.text).join(", ")}`);
148
+ }
149
+ if (!result.outputFiles || result.outputFiles.filter(Boolean).length === 0) {
150
+ throw new Error(`No output files generated for ${file}. Please check the configuration and try again.`);
151
+ }
152
+ return result.outputFiles.filter(Boolean)[0];
153
+ }
154
+ __name(bundle, "bundle");
155
+
156
+ // ../powerlines/src/lib/utilities/resolve.ts
157
+ async function resolve(context, type, overrides = {}) {
158
+ let typeDefinition;
159
+ if (isSetString(type)) {
160
+ typeDefinition = parseTypeDefinition(type);
161
+ } else {
162
+ typeDefinition = type;
163
+ }
164
+ const result = await bundle(context, typeDefinition.file, overrides);
165
+ const resolved = await context.resolver.evalModule(result.text, {
166
+ filename: result.path,
167
+ forceTranspile: true
168
+ });
169
+ let exportName = typeDefinition.name;
170
+ if (!exportName) {
171
+ exportName = "default";
172
+ }
173
+ return resolved[exportName] ?? resolved[`__\u03A9${exportName}`];
174
+ }
175
+ __name(resolve, "resolve");
176
+
177
+ // src/reflect-type.ts
178
+ async function reflectType(context, type, overrides = {}) {
179
+ return (0, type_exports.reflect)(await resolve(context, type, defu(overrides, {
180
+ plugins: [
181
+ esbuildPlugin(context)
182
+ ]
183
+ })));
184
+ }
185
+ __name(reflectType, "reflectType");
186
+
187
+ export { reflectType };
@@ -1,13 +1,11 @@
1
1
  'use strict';
2
2
 
3
- var chunkWVKPC33H_cjs = require('./chunk-WVKPC33H.cjs');
3
+ var chunkGRNJVY7I_cjs = require('./chunk-GRNJVY7I.cjs');
4
4
  var joinPaths = require('@stryke/path/join-paths');
5
5
 
6
- // src/resolve-reflections.ts
7
- chunkWVKPC33H_cjs.init_cjs_shims();
8
6
  function getReflectionsPath(context) {
9
7
  return joinPaths.joinPaths(context.dataPath, "reflections");
10
8
  }
11
- chunkWVKPC33H_cjs.__name(getReflectionsPath, "getReflectionsPath");
9
+ chunkGRNJVY7I_cjs.__name(getReflectionsPath, "getReflectionsPath");
12
10
 
13
11
  exports.getReflectionsPath = getReflectionsPath;