@powerlines/plugin-env 0.14.21 → 0.14.23
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/_virtual/rolldown_runtime.cjs +37 -1
- package/dist/_virtual/rolldown_runtime.mjs +29 -1
- package/dist/babel/index.cjs +1 -1
- package/dist/babel/index.mjs +3 -1
- package/dist/babel/plugin.cjs +120 -4
- package/dist/babel/plugin.d.cts +2 -3
- package/dist/babel/plugin.d.mts +3 -2
- package/dist/babel/plugin.mjs +118 -4
- package/dist/components/docs.cjs +71 -1
- package/dist/components/docs.mjs +70 -1
- package/dist/components/env.cjs +432 -11
- package/dist/components/env.mjs +430 -9
- package/dist/components/index.cjs +6 -1
- package/dist/components/index.mjs +4 -1
- package/dist/deepkit/schemas/reflection.cjs +3940 -1
- package/dist/deepkit/schemas/reflection.mjs +3938 -1
- package/dist/deepkit/schemas/reflection2.cjs +4112 -1
- package/dist/deepkit/schemas/reflection2.mjs +4110 -1
- package/dist/deepkit/src/capnp.cjs +913 -1
- package/dist/deepkit/src/capnp.mjs +911 -1
- package/dist/deepkit/src/esbuild-plugin.cjs +47 -4
- package/dist/deepkit/src/esbuild-plugin.mjs +46 -4
- package/dist/deepkit/src/reflect-type.cjs +22 -1
- package/dist/deepkit/src/reflect-type.mjs +20 -1
- package/dist/deepkit/src/resolve-reflections.cjs +16 -1
- package/dist/deepkit/src/resolve-reflections.mjs +15 -1
- package/dist/deepkit/src/transformer.cjs +52 -1
- package/dist/deepkit/src/transformer.mjs +49 -1
- package/dist/deepkit/src/transpile.cjs +29 -1
- package/dist/deepkit/src/transpile.mjs +27 -1
- package/dist/deepkit/src/utilities.cjs +66 -1
- package/dist/deepkit/src/utilities.mjs +65 -1
- package/dist/deepkit/src/vendor/type-compiler/index.cjs +38 -1
- package/dist/deepkit/src/vendor/type-compiler/index.mjs +19 -1
- package/dist/deepkit/src/vendor/type.cjs +20 -1
- package/dist/deepkit/src/vendor/type.mjs +11 -1
- package/dist/helpers/automd-generator.cjs +22 -1
- package/dist/helpers/automd-generator.mjs +21 -1
- package/dist/helpers/create-reflection-resource.cjs +55 -1
- package/dist/helpers/create-reflection-resource.mjs +54 -1
- package/dist/helpers/index.cjs +6 -1
- package/dist/helpers/index.mjs +8 -1
- package/dist/helpers/load.cjs +83 -1
- package/dist/helpers/load.d.cts +2 -2
- package/dist/helpers/load.d.mts +3 -2
- package/dist/helpers/load.mjs +80 -1
- package/dist/helpers/persistence.cjs +214 -1
- package/dist/helpers/persistence.d.cts +1 -1
- package/dist/helpers/persistence.d.mts +1 -1
- package/dist/helpers/persistence.mjs +202 -1
- package/dist/helpers/reflect.cjs +111 -1
- package/dist/helpers/reflect.mjs +103 -1
- package/dist/helpers/source-file-env.cjs +28 -1
- package/dist/helpers/source-file-env.mjs +26 -1
- package/dist/helpers/template-helpers.cjs +42 -1
- package/dist/helpers/template-helpers.mjs +41 -1
- package/dist/index.cjs +203 -5
- package/dist/index.d.cts +1 -3
- package/dist/index.d.mts +2 -1
- package/dist/index.mjs +170 -5
- package/dist/plugin-alloy/src/core/components/output.cjs +45 -1
- package/dist/plugin-alloy/src/core/components/output.mjs +44 -1
- package/dist/plugin-alloy/src/core/contexts/context.cjs +11 -1
- package/dist/plugin-alloy/src/core/contexts/context.mjs +10 -1
- package/dist/plugin-alloy/src/index.cjs +93 -1
- package/dist/plugin-alloy/src/index.mjs +91 -1
- package/dist/plugin-alloy/src/types/plugin.d.cts +2 -2
- package/dist/plugin-alloy/src/types/plugin.d.mts +2 -2
- package/dist/plugin-automd/src/index.cjs +101 -1
- package/dist/plugin-automd/src/index.mjs +98 -1
- package/dist/plugin-automd/src/types/plugin.d.mts +2 -2
- package/dist/plugin-babel/src/helpers/ast-utils.cjs +10 -1
- package/dist/plugin-babel/src/helpers/ast-utils.mjs +9 -1
- package/dist/plugin-babel/src/helpers/create-plugin.cjs +41 -1
- package/dist/plugin-babel/src/helpers/create-plugin.mjs +39 -1
- package/dist/plugin-babel/src/helpers/filters.cjs +23 -1
- package/dist/plugin-babel/src/helpers/filters.mjs +21 -1
- package/dist/plugin-babel/src/helpers/index.cjs +5 -1
- package/dist/plugin-babel/src/helpers/index.mjs +7 -1
- package/dist/plugin-babel/src/helpers/module-helpers.cjs +38 -1
- package/dist/plugin-babel/src/helpers/module-helpers.mjs +35 -1
- package/dist/plugin-babel/src/helpers/options.cjs +50 -1
- package/dist/plugin-babel/src/helpers/options.mjs +47 -1
- package/dist/plugin-babel/src/index.cjs +91 -1
- package/dist/plugin-babel/src/index.mjs +89 -1
- package/dist/plugin-babel/src/types/plugin.d.cts +2 -2
- package/dist/plugin-babel/src/types/plugin.d.mts +2 -2
- package/dist/powerlines/schemas/fs.d.mts +1 -0
- package/dist/powerlines/src/api.d.mts +7 -0
- package/dist/powerlines/src/index.d.mts +12 -0
- package/dist/powerlines/src/internal/helpers/hooks.d.mts +5 -0
- package/dist/powerlines/src/lib/build/esbuild.cjs +102 -14
- package/dist/powerlines/src/lib/build/esbuild.mjs +100 -14
- package/dist/powerlines/src/lib/entry.cjs +12 -1
- package/dist/powerlines/src/lib/entry.mjs +14 -1
- package/dist/powerlines/src/lib/logger.cjs +41 -1
- package/dist/powerlines/src/lib/logger.mjs +39 -1
- package/dist/powerlines/src/lib/utilities/bundle.cjs +35 -1
- package/dist/powerlines/src/lib/utilities/bundle.mjs +34 -1
- package/dist/powerlines/src/lib/utilities/resolve.cjs +30 -1
- package/dist/powerlines/src/lib/utilities/resolve.mjs +29 -1
- package/dist/powerlines/src/plugin-utils/paths.cjs +1 -1
- package/dist/powerlines/src/plugin-utils/paths.mjs +3 -1
- package/dist/powerlines/src/types/api.d.mts +5 -0
- package/dist/powerlines/src/types/babel.d.cts +3 -2
- package/dist/powerlines/src/types/babel.d.mts +3 -2
- package/dist/powerlines/src/types/commands.d.cts +1 -1
- package/dist/powerlines/src/types/commands.d.mts +2 -2
- package/dist/powerlines/src/types/config.d.cts +5 -5
- package/dist/powerlines/src/types/config.d.mts +6 -6
- package/dist/powerlines/src/types/context.d.cts +28 -4
- package/dist/powerlines/src/types/context.d.mts +30 -6
- package/dist/powerlines/src/types/fs.d.cts +1 -1
- package/dist/powerlines/src/types/fs.d.mts +1 -1
- package/dist/powerlines/src/types/index.d.mts +12 -0
- package/dist/powerlines/src/types/plugin.d.cts +3 -3
- package/dist/powerlines/src/types/plugin.d.mts +4 -4
- package/dist/powerlines/src/types/resolved.d.cts +1 -1
- package/dist/powerlines/src/types/resolved.d.mts +2 -2
- package/dist/powerlines/src/types/tsconfig.d.mts +1 -1
- package/dist/powerlines/src/types/unplugin.d.mts +7 -0
- package/dist/types/index.mjs +1 -1
- package/dist/types/plugin.d.cts +1 -1
- package/dist/types/plugin.mjs +1 -1
- package/dist/types/runtime.mjs +1 -1
- package/package.json +16 -16
- package/dist/babel/index.d.cts +0 -1
- package/dist/helpers/index.d.cts +0 -6
|
@@ -1,4 +1,47 @@
|
|
|
1
|
-
const
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_transpile = require('./transpile.cjs');
|
|
3
|
+
let __stryke_type_checks = require("@stryke/type-checks");
|
|
4
|
+
let typescript = require("typescript");
|
|
5
|
+
|
|
6
|
+
//#region ../deepkit/src/esbuild-plugin.ts
|
|
7
|
+
/**
|
|
8
|
+
* Esbuild plugin for Deepkit Type reflections.
|
|
9
|
+
*
|
|
10
|
+
* @param context - The Powerlines context.
|
|
11
|
+
* @param options - Optional esbuild onLoad options.
|
|
12
|
+
* @returns An esbuild plugin instance.
|
|
13
|
+
*/
|
|
14
|
+
const esbuildPlugin = (context, options = {}) => {
|
|
15
|
+
return {
|
|
16
|
+
name: "powerlines:deepkit",
|
|
17
|
+
setup(build) {
|
|
18
|
+
build.onLoad({
|
|
19
|
+
filter: /\.(m|c)?tsx?$/,
|
|
20
|
+
...options
|
|
21
|
+
}, async (args) => {
|
|
22
|
+
const contents = await context.fs.read(args.path);
|
|
23
|
+
if (!contents) return null;
|
|
24
|
+
if (args.pluginData?.isReflected) return {
|
|
25
|
+
contents,
|
|
26
|
+
loader: "ts",
|
|
27
|
+
pluginData: { isReflected: true }
|
|
28
|
+
};
|
|
29
|
+
const result = require_transpile.transpile(context, contents, args.path);
|
|
30
|
+
if (result.diagnostics && result.diagnostics.length > 0) if (result.diagnostics.some((d) => d.category === typescript.DiagnosticCategory.Error)) {
|
|
31
|
+
const errorMessage = `Deepkit Type reflection transpilation errors: ${args.path} \n ${result.diagnostics.filter((d) => d.category === typescript.DiagnosticCategory.Error).map((d) => `-${d.file ? `${d.file.fileName}:` : ""} ${(0, __stryke_type_checks.isString)(d.messageText) ? d.messageText : d.messageText.messageText} (at ${d.start}:${d.length})`).join("\n")}`;
|
|
32
|
+
context.error(errorMessage);
|
|
33
|
+
throw new Error(errorMessage);
|
|
34
|
+
} else if (result.diagnostics.some((d) => d.category === typescript.DiagnosticCategory.Warning)) context.warn(`Deepkit Type reflection transpilation warnings: ${args.path} \n ${result.diagnostics.filter((d) => d.category === typescript.DiagnosticCategory.Warning).map((d) => `-${d.file ? `${d.file.fileName}:` : ""} ${(0, __stryke_type_checks.isString)(d.messageText) ? d.messageText : d.messageText.messageText} (at ${d.start}:${d.length})`).join("\n")}`);
|
|
35
|
+
else context.debug(`Deepkit Type reflection transpilation diagnostics: ${args.path} \n ${result.diagnostics.map((d) => `-${d.file ? `${d.file.fileName}:` : ""} ${(0, __stryke_type_checks.isString)(d.messageText) ? d.messageText : d.messageText.messageText} (at ${d.start}:${d.length})`).join("\n")}`);
|
|
36
|
+
return {
|
|
37
|
+
contents: result.outputText,
|
|
38
|
+
loader: "ts",
|
|
39
|
+
pluginData: { isReflected: true }
|
|
40
|
+
};
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
//#endregion
|
|
47
|
+
exports.esbuildPlugin = esbuildPlugin;
|
|
@@ -1,4 +1,46 @@
|
|
|
1
|
-
import{transpile
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { transpile } from "./transpile.mjs";
|
|
2
|
+
import { isString } from "@stryke/type-checks";
|
|
3
|
+
import { DiagnosticCategory } from "typescript";
|
|
4
|
+
|
|
5
|
+
//#region ../deepkit/src/esbuild-plugin.ts
|
|
6
|
+
/**
|
|
7
|
+
* Esbuild plugin for Deepkit Type reflections.
|
|
8
|
+
*
|
|
9
|
+
* @param context - The Powerlines context.
|
|
10
|
+
* @param options - Optional esbuild onLoad options.
|
|
11
|
+
* @returns An esbuild plugin instance.
|
|
12
|
+
*/
|
|
13
|
+
const esbuildPlugin = (context, options = {}) => {
|
|
14
|
+
return {
|
|
15
|
+
name: "powerlines:deepkit",
|
|
16
|
+
setup(build) {
|
|
17
|
+
build.onLoad({
|
|
18
|
+
filter: /\.(m|c)?tsx?$/,
|
|
19
|
+
...options
|
|
20
|
+
}, async (args) => {
|
|
21
|
+
const contents = await context.fs.read(args.path);
|
|
22
|
+
if (!contents) return null;
|
|
23
|
+
if (args.pluginData?.isReflected) return {
|
|
24
|
+
contents,
|
|
25
|
+
loader: "ts",
|
|
26
|
+
pluginData: { isReflected: true }
|
|
27
|
+
};
|
|
28
|
+
const result = transpile(context, contents, args.path);
|
|
29
|
+
if (result.diagnostics && result.diagnostics.length > 0) if (result.diagnostics.some((d) => d.category === DiagnosticCategory.Error)) {
|
|
30
|
+
const errorMessage = `Deepkit Type reflection transpilation errors: ${args.path} \n ${result.diagnostics.filter((d) => d.category === DiagnosticCategory.Error).map((d) => `-${d.file ? `${d.file.fileName}:` : ""} ${isString(d.messageText) ? d.messageText : d.messageText.messageText} (at ${d.start}:${d.length})`).join("\n")}`;
|
|
31
|
+
context.error(errorMessage);
|
|
32
|
+
throw new Error(errorMessage);
|
|
33
|
+
} else if (result.diagnostics.some((d) => d.category === DiagnosticCategory.Warning)) context.warn(`Deepkit Type reflection transpilation warnings: ${args.path} \n ${result.diagnostics.filter((d) => d.category === DiagnosticCategory.Warning).map((d) => `-${d.file ? `${d.file.fileName}:` : ""} ${isString(d.messageText) ? d.messageText : d.messageText.messageText} (at ${d.start}:${d.length})`).join("\n")}`);
|
|
34
|
+
else context.debug(`Deepkit Type reflection transpilation diagnostics: ${args.path} \n ${result.diagnostics.map((d) => `-${d.file ? `${d.file.fileName}:` : ""} ${isString(d.messageText) ? d.messageText : d.messageText.messageText} (at ${d.start}:${d.length})`).join("\n")}`);
|
|
35
|
+
return {
|
|
36
|
+
contents: result.outputText,
|
|
37
|
+
loader: "ts",
|
|
38
|
+
pluginData: { isReflected: true }
|
|
39
|
+
};
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
//#endregion
|
|
46
|
+
export { esbuildPlugin };
|
|
@@ -1 +1,22 @@
|
|
|
1
|
-
const
|
|
1
|
+
const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_type = require('./vendor/type.cjs');
|
|
3
|
+
const require_resolve = require('../../powerlines/src/lib/utilities/resolve.cjs');
|
|
4
|
+
const require_esbuild_plugin = require('./esbuild-plugin.cjs');
|
|
5
|
+
let defu = require("defu");
|
|
6
|
+
defu = require_rolldown_runtime.__toESM(defu);
|
|
7
|
+
|
|
8
|
+
//#region ../deepkit/src/reflect-type.ts
|
|
9
|
+
/**
|
|
10
|
+
* Compiles a type definition to a module.
|
|
11
|
+
*
|
|
12
|
+
* @param context - The context object containing the environment paths.
|
|
13
|
+
* @param type - The type definition to compile.
|
|
14
|
+
* @param overrides - Optional overrides for the ESBuild configuration.
|
|
15
|
+
* @returns A promise that resolves to the compiled module.
|
|
16
|
+
*/
|
|
17
|
+
async function reflectType(context, type, overrides = {}) {
|
|
18
|
+
return (0, require_type.type_exports.reflect)(await require_resolve.resolve(context, type, (0, defu.default)(overrides, { plugins: [require_esbuild_plugin.esbuildPlugin(context)] })));
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
//#endregion
|
|
22
|
+
exports.reflectType = reflectType;
|
|
@@ -1 +1,20 @@
|
|
|
1
|
-
import{type_exports
|
|
1
|
+
import { type_exports } from "./vendor/type.mjs";
|
|
2
|
+
import { resolve } from "../../powerlines/src/lib/utilities/resolve.mjs";
|
|
3
|
+
import { esbuildPlugin } from "./esbuild-plugin.mjs";
|
|
4
|
+
import defu from "defu";
|
|
5
|
+
|
|
6
|
+
//#region ../deepkit/src/reflect-type.ts
|
|
7
|
+
/**
|
|
8
|
+
* Compiles a type definition to a module.
|
|
9
|
+
*
|
|
10
|
+
* @param context - The context object containing the environment paths.
|
|
11
|
+
* @param type - The type definition to compile.
|
|
12
|
+
* @param overrides - Optional overrides for the ESBuild configuration.
|
|
13
|
+
* @returns A promise that resolves to the compiled module.
|
|
14
|
+
*/
|
|
15
|
+
async function reflectType(context, type, overrides = {}) {
|
|
16
|
+
return (0, type_exports.reflect)(await resolve(context, type, defu(overrides, { plugins: [esbuildPlugin(context)] })));
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
//#endregion
|
|
20
|
+
export { reflectType };
|
|
@@ -1 +1,16 @@
|
|
|
1
|
-
const
|
|
1
|
+
const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
let __stryke_path_join_paths = require("@stryke/path/join-paths");
|
|
3
|
+
|
|
4
|
+
//#region ../deepkit/src/resolve-reflections.ts
|
|
5
|
+
/**
|
|
6
|
+
* Returns the path to the reflections artifact directory.
|
|
7
|
+
*
|
|
8
|
+
* @param context - The context object containing the environment paths.
|
|
9
|
+
* @returns The path to the reflections artifact directory.
|
|
10
|
+
*/
|
|
11
|
+
function getReflectionsPath(context) {
|
|
12
|
+
return (0, __stryke_path_join_paths.joinPaths)(context.dataPath, "reflections");
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
//#endregion
|
|
16
|
+
exports.getReflectionsPath = getReflectionsPath;
|
|
@@ -1 +1,15 @@
|
|
|
1
|
-
import{joinPaths
|
|
1
|
+
import { joinPaths } from "@stryke/path/join-paths";
|
|
2
|
+
|
|
3
|
+
//#region ../deepkit/src/resolve-reflections.ts
|
|
4
|
+
/**
|
|
5
|
+
* Returns the path to the reflections artifact directory.
|
|
6
|
+
*
|
|
7
|
+
* @param context - The context object containing the environment paths.
|
|
8
|
+
* @returns The path to the reflections artifact directory.
|
|
9
|
+
*/
|
|
10
|
+
function getReflectionsPath(context) {
|
|
11
|
+
return joinPaths(context.dataPath, "reflections");
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
//#endregion
|
|
15
|
+
export { getReflectionsPath };
|
|
@@ -1 +1,52 @@
|
|
|
1
|
-
const
|
|
1
|
+
const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_index = require('./vendor/type-compiler/index.cjs');
|
|
3
|
+
let defu = require("defu");
|
|
4
|
+
defu = require_rolldown_runtime.__toESM(defu);
|
|
5
|
+
|
|
6
|
+
//#region ../deepkit/src/transformer.ts
|
|
7
|
+
let loaded = false;
|
|
8
|
+
const cache = new require_index.type_compiler_exports.Cache();
|
|
9
|
+
/**
|
|
10
|
+
* Creates a Deepkit TypeScript transformer.
|
|
11
|
+
*
|
|
12
|
+
* @param context - The Powerlines plugin context.
|
|
13
|
+
* @param options - The transformation options.
|
|
14
|
+
* @returns A Deepkit TypeScript custom transformer factory.
|
|
15
|
+
*/
|
|
16
|
+
function createTransformer(context, options = {}) {
|
|
17
|
+
return function transformer(ctx) {
|
|
18
|
+
if (!loaded) loaded = true;
|
|
19
|
+
cache.tick();
|
|
20
|
+
return new require_index.type_compiler_exports.ReflectionTransformer(ctx, cache).withReflection((0, defu.default)(options, {
|
|
21
|
+
reflection: context.tsconfig.tsconfigJson.compilerOptions?.reflection || context.tsconfig.tsconfigJson.reflection,
|
|
22
|
+
reflectionLevel: context.tsconfig.tsconfigJson.compilerOptions?.reflectionLevel || context.tsconfig.tsconfigJson.reflectionLevel
|
|
23
|
+
}, {
|
|
24
|
+
exclude: [],
|
|
25
|
+
reflection: "default",
|
|
26
|
+
reflectionLevel: "minimal"
|
|
27
|
+
}));
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Creates a Deepkit TypeScript declaration transformer.
|
|
32
|
+
*
|
|
33
|
+
* @param context - The Powerlines plugin context.
|
|
34
|
+
* @param options - The transformation options.
|
|
35
|
+
* @returns A Deepkit TypeScript custom declaration transformer factory.
|
|
36
|
+
*/
|
|
37
|
+
function createDeclarationTransformer(context, options = {}) {
|
|
38
|
+
return function declarationTransformer(ctx) {
|
|
39
|
+
return new require_index.type_compiler_exports.DeclarationTransformer(ctx, cache).withReflection((0, defu.default)(options, {
|
|
40
|
+
reflection: context.tsconfig.tsconfigJson.compilerOptions?.reflection || context.tsconfig.tsconfigJson.reflection,
|
|
41
|
+
reflectionLevel: context.tsconfig.tsconfigJson.compilerOptions?.reflectionLevel || context.tsconfig.tsconfigJson.reflectionLevel
|
|
42
|
+
}, {
|
|
43
|
+
exclude: [],
|
|
44
|
+
reflection: "default",
|
|
45
|
+
reflectionLevel: "minimal"
|
|
46
|
+
}));
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
//#endregion
|
|
51
|
+
exports.createDeclarationTransformer = createDeclarationTransformer;
|
|
52
|
+
exports.createTransformer = createTransformer;
|
|
@@ -1 +1,49 @@
|
|
|
1
|
-
import{type_compiler_exports
|
|
1
|
+
import { type_compiler_exports } from "./vendor/type-compiler/index.mjs";
|
|
2
|
+
import defu from "defu";
|
|
3
|
+
|
|
4
|
+
//#region ../deepkit/src/transformer.ts
|
|
5
|
+
let loaded = false;
|
|
6
|
+
const cache = new type_compiler_exports.Cache();
|
|
7
|
+
/**
|
|
8
|
+
* Creates a Deepkit TypeScript transformer.
|
|
9
|
+
*
|
|
10
|
+
* @param context - The Powerlines plugin context.
|
|
11
|
+
* @param options - The transformation options.
|
|
12
|
+
* @returns A Deepkit TypeScript custom transformer factory.
|
|
13
|
+
*/
|
|
14
|
+
function createTransformer(context, options = {}) {
|
|
15
|
+
return function transformer(ctx) {
|
|
16
|
+
if (!loaded) loaded = true;
|
|
17
|
+
cache.tick();
|
|
18
|
+
return new type_compiler_exports.ReflectionTransformer(ctx, cache).withReflection(defu(options, {
|
|
19
|
+
reflection: context.tsconfig.tsconfigJson.compilerOptions?.reflection || context.tsconfig.tsconfigJson.reflection,
|
|
20
|
+
reflectionLevel: context.tsconfig.tsconfigJson.compilerOptions?.reflectionLevel || context.tsconfig.tsconfigJson.reflectionLevel
|
|
21
|
+
}, {
|
|
22
|
+
exclude: [],
|
|
23
|
+
reflection: "default",
|
|
24
|
+
reflectionLevel: "minimal"
|
|
25
|
+
}));
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Creates a Deepkit TypeScript declaration transformer.
|
|
30
|
+
*
|
|
31
|
+
* @param context - The Powerlines plugin context.
|
|
32
|
+
* @param options - The transformation options.
|
|
33
|
+
* @returns A Deepkit TypeScript custom declaration transformer factory.
|
|
34
|
+
*/
|
|
35
|
+
function createDeclarationTransformer(context, options = {}) {
|
|
36
|
+
return function declarationTransformer(ctx) {
|
|
37
|
+
return new type_compiler_exports.DeclarationTransformer(ctx, cache).withReflection(defu(options, {
|
|
38
|
+
reflection: context.tsconfig.tsconfigJson.compilerOptions?.reflection || context.tsconfig.tsconfigJson.reflection,
|
|
39
|
+
reflectionLevel: context.tsconfig.tsconfigJson.compilerOptions?.reflectionLevel || context.tsconfig.tsconfigJson.reflectionLevel
|
|
40
|
+
}, {
|
|
41
|
+
exclude: [],
|
|
42
|
+
reflection: "default",
|
|
43
|
+
reflectionLevel: "minimal"
|
|
44
|
+
}));
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
//#endregion
|
|
49
|
+
export { createDeclarationTransformer, createTransformer };
|
|
@@ -1 +1,29 @@
|
|
|
1
|
-
const
|
|
1
|
+
const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_transformer = require('./transformer.cjs');
|
|
3
|
+
let typescript = require("typescript");
|
|
4
|
+
typescript = require_rolldown_runtime.__toESM(typescript);
|
|
5
|
+
|
|
6
|
+
//#region ../deepkit/src/transpile.ts
|
|
7
|
+
/**
|
|
8
|
+
* Transpile TypeScript code using the provided context and options.
|
|
9
|
+
*
|
|
10
|
+
* @param context - The base context containing TypeScript configuration and options.
|
|
11
|
+
* @param code - The TypeScript code to be transpiled.
|
|
12
|
+
* @param id - The identifier for the TypeScript file being transpiled.
|
|
13
|
+
* @returns The transpiled output.
|
|
14
|
+
*/
|
|
15
|
+
function transpile(context, code, id) {
|
|
16
|
+
const transformer = require_transformer.createTransformer(context);
|
|
17
|
+
const declarationTransformer = require_transformer.createDeclarationTransformer(context);
|
|
18
|
+
return typescript.default.transpileModule(code, {
|
|
19
|
+
compilerOptions: { ...context.tsconfig.options },
|
|
20
|
+
fileName: id,
|
|
21
|
+
transformers: {
|
|
22
|
+
before: [transformer],
|
|
23
|
+
after: [declarationTransformer]
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
//#endregion
|
|
29
|
+
exports.transpile = transpile;
|
|
@@ -1 +1,27 @@
|
|
|
1
|
-
import{createDeclarationTransformer
|
|
1
|
+
import { createDeclarationTransformer, createTransformer } from "./transformer.mjs";
|
|
2
|
+
import ts from "typescript";
|
|
3
|
+
|
|
4
|
+
//#region ../deepkit/src/transpile.ts
|
|
5
|
+
/**
|
|
6
|
+
* Transpile TypeScript code using the provided context and options.
|
|
7
|
+
*
|
|
8
|
+
* @param context - The base context containing TypeScript configuration and options.
|
|
9
|
+
* @param code - The TypeScript code to be transpiled.
|
|
10
|
+
* @param id - The identifier for the TypeScript file being transpiled.
|
|
11
|
+
* @returns The transpiled output.
|
|
12
|
+
*/
|
|
13
|
+
function transpile(context, code, id) {
|
|
14
|
+
const transformer = createTransformer(context);
|
|
15
|
+
const declarationTransformer = createDeclarationTransformer(context);
|
|
16
|
+
return ts.transpileModule(code, {
|
|
17
|
+
compilerOptions: { ...context.tsconfig.options },
|
|
18
|
+
fileName: id,
|
|
19
|
+
transformers: {
|
|
20
|
+
before: [transformer],
|
|
21
|
+
after: [declarationTransformer]
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
//#endregion
|
|
27
|
+
export { transpile };
|
|
@@ -1 +1,66 @@
|
|
|
1
|
-
const
|
|
1
|
+
const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_type = require('./vendor/type.cjs');
|
|
3
|
+
let __stryke_json_storm_json = require("@stryke/json/storm-json");
|
|
4
|
+
let __stryke_type_checks_is_string = require("@stryke/type-checks/is-string");
|
|
5
|
+
let __stryke_helpers_get_unique = require("@stryke/helpers/get-unique");
|
|
6
|
+
let __stryke_type_checks_is_null = require("@stryke/type-checks/is-null");
|
|
7
|
+
let __stryke_type_checks_is_undefined = require("@stryke/type-checks/is-undefined");
|
|
8
|
+
|
|
9
|
+
//#region ../deepkit/src/utilities.ts
|
|
10
|
+
/**
|
|
11
|
+
* Converts any {@link ReflectionProperty} or {@link ReflectionParameter}'s value to string representation.
|
|
12
|
+
*
|
|
13
|
+
* @param property - The {@link ReflectionProperty} or {@link ReflectionParameter} containing the value to stringify.
|
|
14
|
+
* @param value - The value to stringify.
|
|
15
|
+
* @returns A string representation of the value.
|
|
16
|
+
*/
|
|
17
|
+
function stringifyDefaultValue(property, value) {
|
|
18
|
+
return stringifyValue(property.type, value ?? property.getDefaultValue());
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Stringifies a value as a string.
|
|
22
|
+
*
|
|
23
|
+
* @param value - The value to stringify.
|
|
24
|
+
* @returns A string representation of the value.
|
|
25
|
+
*/
|
|
26
|
+
function stringifyStringValue(value) {
|
|
27
|
+
return `"${String(value).replaceAll("\"", "\\\"")}"`;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Converts any {@link Type}'s actual value to string representation.
|
|
31
|
+
*
|
|
32
|
+
* @param type - The {@link Type} of the value to stringify.
|
|
33
|
+
* @param value - The value to stringify.
|
|
34
|
+
* @returns A string representation of the value.
|
|
35
|
+
*/
|
|
36
|
+
function stringifyValue(type, value) {
|
|
37
|
+
return (0, __stryke_type_checks_is_undefined.isUndefined)(value) ? "undefined" : (0, __stryke_type_checks_is_null.isNull)(value) ? "null" : type.kind === require_type.type_exports.ReflectionKind.boolean ? String(value).trim().toLowerCase() === "true" ? "true" : "false" : type.kind === require_type.type_exports.ReflectionKind.string || type.kind === require_type.type_exports.ReflectionKind.literal && (0, __stryke_type_checks_is_string.isString)(type.literal) ? stringifyStringValue(value) : type.kind === require_type.type_exports.ReflectionKind.enum ? getEnumReflectionType(type).kind === require_type.type_exports.ReflectionKind.string ? stringifyStringValue(value) : `${String(value)}` : type.kind === require_type.type_exports.ReflectionKind.union ? isStringUnion(type) ? stringifyStringValue(value) : `${String(value)}` : type.kind === require_type.type_exports.ReflectionKind.array ? stringifyStringValue(__stryke_json_storm_json.StormJSON.stringify(value)) : type.kind === require_type.type_exports.ReflectionKind.object || type.kind === require_type.type_exports.ReflectionKind.objectLiteral ? __stryke_json_storm_json.StormJSON.stringify(value) : type.kind === require_type.type_exports.ReflectionKind.property || type.kind === require_type.type_exports.ReflectionKind.parameter ? stringifyValue(type.type, value) : String(value);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Converts a {@link TypeEnum} to its underlying primitive type representation.
|
|
41
|
+
*
|
|
42
|
+
* @param type - The {@link TypeEnum} to evaluate.
|
|
43
|
+
* @returns A string representation of the primitive type.
|
|
44
|
+
*/
|
|
45
|
+
function getEnumReflectionType(type) {
|
|
46
|
+
if (type.kind !== require_type.type_exports.ReflectionKind.enum) throw new Error(`Expected a TypeEnum, but received ${type.kind}.`);
|
|
47
|
+
const unique = (0, __stryke_helpers_get_unique.getUniqueBy)(type.values.filter((value) => value !== void 0 && value !== null), (enumMember) => (0, __stryke_type_checks_is_string.isString)(enumMember) ? { kind: require_type.type_exports.ReflectionKind.string } : { kind: require_type.type_exports.ReflectionKind.number });
|
|
48
|
+
if (unique.length === 0) throw new Error(`No valid enum members could be found.`);
|
|
49
|
+
return unique[0] && (0, __stryke_type_checks_is_string.isString)(unique[0]) ? { kind: require_type.type_exports.ReflectionKind.string } : { kind: require_type.type_exports.ReflectionKind.number };
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Converts a {@link TypeUnion} to its underlying primitive type representation.
|
|
53
|
+
*
|
|
54
|
+
* @param type - The {@link TypeUnion} to evaluate.
|
|
55
|
+
* @returns A string representation of the primitive type.
|
|
56
|
+
*/
|
|
57
|
+
function getUnionTypes(type) {
|
|
58
|
+
if (type.kind === require_type.type_exports.ReflectionKind.union && type.types.length > 0) return (0, __stryke_helpers_get_unique.getUniqueBy)(type.types, (member) => member.kind);
|
|
59
|
+
throw new Error(`Expected a TypeUnion, but received ${type.kind}.`);
|
|
60
|
+
}
|
|
61
|
+
function isStringUnion(type) {
|
|
62
|
+
return getUnionTypes(type).some((member) => member.kind === require_type.type_exports.ReflectionKind.string || member.kind === require_type.type_exports.ReflectionKind.literal && (0, __stryke_type_checks_is_string.isString)(member.literal));
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
//#endregion
|
|
66
|
+
exports.stringifyDefaultValue = stringifyDefaultValue;
|
|
@@ -1 +1,65 @@
|
|
|
1
|
-
import{type_exports
|
|
1
|
+
import { type_exports } from "./vendor/type.mjs";
|
|
2
|
+
import { StormJSON } from "@stryke/json/storm-json";
|
|
3
|
+
import { isString } from "@stryke/type-checks/is-string";
|
|
4
|
+
import { getUniqueBy } from "@stryke/helpers/get-unique";
|
|
5
|
+
import { isNull } from "@stryke/type-checks/is-null";
|
|
6
|
+
import { isUndefined } from "@stryke/type-checks/is-undefined";
|
|
7
|
+
|
|
8
|
+
//#region ../deepkit/src/utilities.ts
|
|
9
|
+
/**
|
|
10
|
+
* Converts any {@link ReflectionProperty} or {@link ReflectionParameter}'s value to string representation.
|
|
11
|
+
*
|
|
12
|
+
* @param property - The {@link ReflectionProperty} or {@link ReflectionParameter} containing the value to stringify.
|
|
13
|
+
* @param value - The value to stringify.
|
|
14
|
+
* @returns A string representation of the value.
|
|
15
|
+
*/
|
|
16
|
+
function stringifyDefaultValue(property, value) {
|
|
17
|
+
return stringifyValue(property.type, value ?? property.getDefaultValue());
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Stringifies a value as a string.
|
|
21
|
+
*
|
|
22
|
+
* @param value - The value to stringify.
|
|
23
|
+
* @returns A string representation of the value.
|
|
24
|
+
*/
|
|
25
|
+
function stringifyStringValue(value) {
|
|
26
|
+
return `"${String(value).replaceAll("\"", "\\\"")}"`;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Converts any {@link Type}'s actual value to string representation.
|
|
30
|
+
*
|
|
31
|
+
* @param type - The {@link Type} of the value to stringify.
|
|
32
|
+
* @param value - The value to stringify.
|
|
33
|
+
* @returns A string representation of the value.
|
|
34
|
+
*/
|
|
35
|
+
function stringifyValue(type, value) {
|
|
36
|
+
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);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Converts a {@link TypeEnum} to its underlying primitive type representation.
|
|
40
|
+
*
|
|
41
|
+
* @param type - The {@link TypeEnum} to evaluate.
|
|
42
|
+
* @returns A string representation of the primitive type.
|
|
43
|
+
*/
|
|
44
|
+
function getEnumReflectionType(type) {
|
|
45
|
+
if (type.kind !== type_exports.ReflectionKind.enum) throw new Error(`Expected a TypeEnum, but received ${type.kind}.`);
|
|
46
|
+
const unique = getUniqueBy(type.values.filter((value) => value !== void 0 && value !== null), (enumMember) => isString(enumMember) ? { kind: type_exports.ReflectionKind.string } : { kind: type_exports.ReflectionKind.number });
|
|
47
|
+
if (unique.length === 0) throw new Error(`No valid enum members could be found.`);
|
|
48
|
+
return unique[0] && isString(unique[0]) ? { kind: type_exports.ReflectionKind.string } : { kind: type_exports.ReflectionKind.number };
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Converts a {@link TypeUnion} to its underlying primitive type representation.
|
|
52
|
+
*
|
|
53
|
+
* @param type - The {@link TypeUnion} to evaluate.
|
|
54
|
+
* @returns A string representation of the primitive type.
|
|
55
|
+
*/
|
|
56
|
+
function getUnionTypes(type) {
|
|
57
|
+
if (type.kind === type_exports.ReflectionKind.union && type.types.length > 0) return getUniqueBy(type.types, (member) => member.kind);
|
|
58
|
+
throw new Error(`Expected a TypeUnion, but received ${type.kind}.`);
|
|
59
|
+
}
|
|
60
|
+
function isStringUnion(type) {
|
|
61
|
+
return getUnionTypes(type).some((member) => member.kind === type_exports.ReflectionKind.string || member.kind === type_exports.ReflectionKind.literal && isString(member.literal));
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
//#endregion
|
|
65
|
+
export { stringifyDefaultValue };
|
|
@@ -1 +1,38 @@
|
|
|
1
|
-
const
|
|
1
|
+
const require_rolldown_runtime = require('../../../../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
|
|
3
|
+
//#region ../deepkit/src/vendor/type-compiler/index.ts
|
|
4
|
+
var type_compiler_exports = {};
|
|
5
|
+
require_rolldown_runtime.__reExport(type_compiler_exports, require("@deepkit/type-compiler"));
|
|
6
|
+
require_rolldown_runtime.__reExport(type_compiler_exports, require("@deepkit/type-compiler/compiler"));
|
|
7
|
+
require_rolldown_runtime.__reExport(type_compiler_exports, require("@deepkit/type-compiler/config"));
|
|
8
|
+
|
|
9
|
+
//#endregion
|
|
10
|
+
Object.defineProperty(exports, 'type_compiler_exports', {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return type_compiler_exports;
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
var __deepkit_type_compiler = require("@deepkit/type-compiler");
|
|
17
|
+
Object.keys(__deepkit_type_compiler).forEach(function (k) {
|
|
18
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () { return __deepkit_type_compiler[k]; }
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
var __deepkit_type_compiler_compiler = require("@deepkit/type-compiler/compiler");
|
|
25
|
+
Object.keys(__deepkit_type_compiler_compiler).forEach(function (k) {
|
|
26
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
27
|
+
enumerable: true,
|
|
28
|
+
get: function () { return __deepkit_type_compiler_compiler[k]; }
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
var __deepkit_type_compiler_config = require("@deepkit/type-compiler/config");
|
|
33
|
+
Object.keys(__deepkit_type_compiler_config).forEach(function (k) {
|
|
34
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
35
|
+
enumerable: true,
|
|
36
|
+
get: function () { return __deepkit_type_compiler_config[k]; }
|
|
37
|
+
});
|
|
38
|
+
});
|
|
@@ -1 +1,19 @@
|
|
|
1
|
-
import{__reExport
|
|
1
|
+
import { __reExport } from "../../../../_virtual/rolldown_runtime.mjs";
|
|
2
|
+
|
|
3
|
+
export * from "@deepkit/type-compiler"
|
|
4
|
+
|
|
5
|
+
export * from "@deepkit/type-compiler/compiler"
|
|
6
|
+
|
|
7
|
+
export * from "@deepkit/type-compiler/config"
|
|
8
|
+
|
|
9
|
+
//#region ../deepkit/src/vendor/type-compiler/index.ts
|
|
10
|
+
var type_compiler_exports = {};
|
|
11
|
+
import * as import___deepkit_type_compiler from "@deepkit/type-compiler";
|
|
12
|
+
__reExport(type_compiler_exports, import___deepkit_type_compiler);
|
|
13
|
+
import * as import___deepkit_type_compiler_compiler from "@deepkit/type-compiler/compiler";
|
|
14
|
+
__reExport(type_compiler_exports, import___deepkit_type_compiler_compiler);
|
|
15
|
+
import * as import___deepkit_type_compiler_config from "@deepkit/type-compiler/config";
|
|
16
|
+
__reExport(type_compiler_exports, import___deepkit_type_compiler_config);
|
|
17
|
+
|
|
18
|
+
//#endregion
|
|
19
|
+
export { type_compiler_exports };
|
|
@@ -1 +1,20 @@
|
|
|
1
|
-
const
|
|
1
|
+
const require_rolldown_runtime = require('../../../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
|
|
3
|
+
//#region ../deepkit/src/vendor/type.ts
|
|
4
|
+
var type_exports = {};
|
|
5
|
+
require_rolldown_runtime.__reExport(type_exports, require("@deepkit/type"));
|
|
6
|
+
|
|
7
|
+
//#endregion
|
|
8
|
+
Object.defineProperty(exports, 'type_exports', {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function () {
|
|
11
|
+
return type_exports;
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
var __deepkit_type = require("@deepkit/type");
|
|
15
|
+
Object.keys(__deepkit_type).forEach(function (k) {
|
|
16
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
get: function () { return __deepkit_type[k]; }
|
|
19
|
+
});
|
|
20
|
+
});
|
|
@@ -1 +1,11 @@
|
|
|
1
|
-
import{__reExport
|
|
1
|
+
import { __reExport } from "../../../_virtual/rolldown_runtime.mjs";
|
|
2
|
+
|
|
3
|
+
export * from "@deepkit/type"
|
|
4
|
+
|
|
5
|
+
//#region ../deepkit/src/vendor/type.ts
|
|
6
|
+
var type_exports = {};
|
|
7
|
+
import * as import___deepkit_type from "@deepkit/type";
|
|
8
|
+
__reExport(type_exports, import___deepkit_type);
|
|
9
|
+
|
|
10
|
+
//#endregion
|
|
11
|
+
export { type_exports };
|
|
@@ -1 +1,22 @@
|
|
|
1
|
-
const
|
|
1
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
let __stryke_path_join_paths = require("@stryke/path/join-paths");
|
|
3
|
+
let automd = require("automd");
|
|
4
|
+
|
|
5
|
+
//#region src/helpers/automd-generator.ts
|
|
6
|
+
/**
|
|
7
|
+
* AutoMD generator to generate environment variable documentation
|
|
8
|
+
*
|
|
9
|
+
* @param context - The generator context.
|
|
10
|
+
* @returns The generated documentation content.
|
|
11
|
+
*/
|
|
12
|
+
const env = (context) => (0, automd.defineGenerator)({
|
|
13
|
+
name: "env",
|
|
14
|
+
async generate() {
|
|
15
|
+
const envDocFile = (0, __stryke_path_join_paths.joinPaths)(context.config.projectRoot, "docs", "generated", "env.md");
|
|
16
|
+
if (!context.fs.existsSync(envDocFile)) return { contents: "" };
|
|
17
|
+
return { contents: await context.fs.read(envDocFile) || "" };
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
//#endregion
|
|
22
|
+
exports.env = env;
|