@powerlines/plugin-date 0.12.140 → 0.12.142
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/index-CA4VvAY_.d.mts +1 -0
- package/dist/index-CmCelmEL.d.cts +1 -0
- package/dist/index.cjs +13844 -17
- package/dist/index.d.cts +40 -7
- package/dist/index.d.mts +40 -9
- package/dist/index.mjs +13800 -6
- package/dist/plugin-BUfZ6cT1.d.cts +4432 -0
- package/dist/plugin-CuNMs4r-.d.mts +4434 -0
- package/dist/plugin-DHXHjv16.cjs +0 -0
- package/dist/plugin-ufqFO5xS.mjs +1 -0
- package/dist/runtime-B7WoCmC4.mjs +1 -0
- package/dist/runtime-B8LVkjWB.d.cts +711 -0
- package/dist/runtime-CiYq8JJ6.d.mts +711 -0
- package/dist/runtime-D4zTdSwv.cjs +0 -0
- package/dist/types/index.cjs +3 -0
- package/dist/types/index.d.cts +3 -2
- package/dist/types/index.d.mts +3 -2
- package/dist/types/index.mjs +4 -0
- package/dist/types/plugin.cjs +1 -0
- package/dist/types/plugin.d.cts +1 -42
- package/dist/types/plugin.d.mts +1 -42
- package/dist/types/plugin.mjs +2 -0
- package/dist/types/runtime.cjs +1 -0
- package/dist/types/runtime.d.cts +1 -710
- package/dist/types/runtime.d.mts +1 -710
- package/dist/types/runtime.mjs +2 -0
- package/dist/types-BReKsBV6.mjs +1 -0
- package/dist/types-CBTc19th.cjs +0 -0
- package/package.json +3 -3
- package/dist/_virtual/rolldown_runtime.cjs +0 -37
- package/dist/_virtual/rolldown_runtime.mjs +0 -29
- package/dist/components/date-fns.cjs +0 -527
- package/dist/components/date-fns.d.cts +0 -13
- package/dist/components/date-fns.d.mts +0 -13
- package/dist/components/date-fns.mjs +0 -527
- package/dist/components/dayjs.cjs +0 -472
- package/dist/components/dayjs.d.cts +0 -13
- package/dist/components/dayjs.d.mts +0 -13
- package/dist/components/dayjs.mjs +0 -472
- package/dist/components/index.cjs +0 -4
- package/dist/components/index.d.mts +0 -4
- package/dist/components/index.mjs +0 -6
- package/dist/components/luxon.cjs +0 -476
- package/dist/components/luxon.d.cts +0 -13
- package/dist/components/luxon.d.mts +0 -13
- package/dist/components/luxon.mjs +0 -476
- package/dist/components/moment.cjs +0 -462
- package/dist/components/moment.d.cts +0 -13
- package/dist/components/moment.d.mts +0 -13
- package/dist/components/moment.mjs +0 -462
- package/dist/deepkit/schemas/reflection.cjs +0 -3998
- package/dist/deepkit/schemas/reflection.d.cts +0 -1560
- package/dist/deepkit/schemas/reflection.d.mts +0 -1560
- package/dist/deepkit/schemas/reflection.mjs +0 -3996
- package/dist/deepkit/schemas/reflection2.cjs +0 -4112
- package/dist/deepkit/schemas/reflection2.mjs +0 -4110
- package/dist/deepkit/src/capnp.cjs +0 -913
- package/dist/deepkit/src/capnp.mjs +0 -911
- package/dist/deepkit/src/esbuild-plugin.cjs +0 -47
- package/dist/deepkit/src/esbuild-plugin.mjs +0 -46
- package/dist/deepkit/src/reflect-type.cjs +0 -22
- package/dist/deepkit/src/reflect-type.mjs +0 -20
- package/dist/deepkit/src/resolve-reflections.cjs +0 -16
- package/dist/deepkit/src/resolve-reflections.mjs +0 -15
- package/dist/deepkit/src/transformer.cjs +0 -52
- package/dist/deepkit/src/transformer.mjs +0 -49
- package/dist/deepkit/src/transpile.cjs +0 -29
- package/dist/deepkit/src/transpile.mjs +0 -27
- package/dist/deepkit/src/types.d.cts +0 -10
- package/dist/deepkit/src/types.d.mts +0 -10
- package/dist/deepkit/src/utilities.cjs +0 -66
- package/dist/deepkit/src/utilities.mjs +0 -65
- package/dist/deepkit/src/vendor/type-compiler/index.cjs +0 -38
- package/dist/deepkit/src/vendor/type-compiler/index.mjs +0 -19
- package/dist/deepkit/src/vendor/type.cjs +0 -20
- package/dist/deepkit/src/vendor/type.d.cts +0 -7
- package/dist/deepkit/src/vendor/type.d.mts +0 -7
- package/dist/deepkit/src/vendor/type.mjs +0 -11
- package/dist/plugin-alloy/src/core/components/output.cjs +0 -38
- package/dist/plugin-alloy/src/core/components/output.mjs +0 -37
- package/dist/plugin-alloy/src/core/components/single-line-comment.cjs +0 -20
- package/dist/plugin-alloy/src/core/components/single-line-comment.mjs +0 -19
- package/dist/plugin-alloy/src/core/components/source-file.cjs +0 -60
- package/dist/plugin-alloy/src/core/components/source-file.mjs +0 -58
- package/dist/plugin-alloy/src/core/contexts/context.cjs +0 -60
- package/dist/plugin-alloy/src/core/contexts/context.mjs +0 -54
- package/dist/plugin-alloy/src/core/contexts/index.cjs +0 -2
- package/dist/plugin-alloy/src/core/contexts/index.mjs +0 -4
- package/dist/plugin-alloy/src/core/contexts/reflection.cjs +0 -46
- package/dist/plugin-alloy/src/core/contexts/reflection.mjs +0 -42
- package/dist/plugin-alloy/src/helpers/refkey.cjs +0 -16
- package/dist/plugin-alloy/src/helpers/refkey.mjs +0 -15
- package/dist/plugin-alloy/src/index.cjs +0 -90
- package/dist/plugin-alloy/src/index.mjs +0 -88
- package/dist/plugin-alloy/src/markdown/components/markdown-file.cjs +0 -7
- package/dist/plugin-alloy/src/markdown/components/markdown-file.mjs +0 -9
- package/dist/plugin-alloy/src/markdown/components/markdown-table.cjs +0 -5
- package/dist/plugin-alloy/src/markdown/components/markdown-table.mjs +0 -7
- package/dist/plugin-alloy/src/markdown/contexts/markdown-table.cjs +0 -17
- package/dist/plugin-alloy/src/markdown/contexts/markdown-table.mjs +0 -17
- package/dist/plugin-alloy/src/types/components.d.mts +0 -4
- package/dist/plugin-alloy/src/types/index.d.mts +0 -2
- package/dist/plugin-alloy/src/types/plugin.d.cts +0 -37
- package/dist/plugin-alloy/src/types/plugin.d.mts +0 -37
- package/dist/plugin-alloy/src/typescript/components/builtin-file.cjs +0 -47
- package/dist/plugin-alloy/src/typescript/components/builtin-file.mjs +0 -46
- package/dist/plugin-alloy/src/typescript/components/tsdoc-reflection.cjs +0 -75
- package/dist/plugin-alloy/src/typescript/components/tsdoc-reflection.mjs +0 -73
- package/dist/plugin-alloy/src/typescript/components/tsdoc.cjs +0 -359
- package/dist/plugin-alloy/src/typescript/components/tsdoc.mjs +0 -350
- package/dist/plugin-alloy/src/typescript/components/typescript-file.cjs +0 -143
- package/dist/plugin-alloy/src/typescript/components/typescript-file.mjs +0 -140
- package/dist/plugin-alloy/src/typescript/components/typescript-interface.cjs +0 -53
- package/dist/plugin-alloy/src/typescript/components/typescript-interface.mjs +0 -52
- package/dist/plugin-alloy/src/typescript/components/typescript-object.cjs +0 -94
- package/dist/plugin-alloy/src/typescript/components/typescript-object.mjs +0 -93
- package/dist/plugin-automd/src/index.cjs +0 -101
- package/dist/plugin-automd/src/index.mjs +0 -98
- package/dist/plugin-automd/src/types/plugin.d.cts +0 -38
- package/dist/plugin-automd/src/types/plugin.d.mts +0 -40
- package/dist/plugin-automd/src/types/toc.d.cts +0 -33
- package/dist/plugin-automd/src/types/toc.d.mts +0 -33
- package/dist/plugin-babel/src/helpers/ast-utils.cjs +0 -10
- package/dist/plugin-babel/src/helpers/ast-utils.mjs +0 -9
- package/dist/plugin-babel/src/helpers/create-plugin.cjs +0 -41
- package/dist/plugin-babel/src/helpers/create-plugin.mjs +0 -39
- package/dist/plugin-babel/src/helpers/filters.cjs +0 -23
- package/dist/plugin-babel/src/helpers/filters.mjs +0 -21
- package/dist/plugin-babel/src/helpers/index.cjs +0 -5
- package/dist/plugin-babel/src/helpers/index.mjs +0 -7
- package/dist/plugin-babel/src/helpers/module-helpers.cjs +0 -38
- package/dist/plugin-babel/src/helpers/module-helpers.mjs +0 -35
- package/dist/plugin-babel/src/helpers/options.cjs +0 -50
- package/dist/plugin-babel/src/helpers/options.mjs +0 -47
- package/dist/plugin-babel/src/index.cjs +0 -91
- package/dist/plugin-babel/src/index.mjs +0 -89
- package/dist/plugin-babel/src/types/index.d.mts +0 -1
- package/dist/plugin-babel/src/types/plugin.d.cts +0 -15
- package/dist/plugin-babel/src/types/plugin.d.mts +0 -15
- package/dist/plugin-env/src/babel/index.cjs +0 -1
- package/dist/plugin-env/src/babel/index.mjs +0 -3
- package/dist/plugin-env/src/babel/plugin.cjs +0 -121
- package/dist/plugin-env/src/babel/plugin.mjs +0 -119
- package/dist/plugin-env/src/components/docs.cjs +0 -9
- package/dist/plugin-env/src/components/docs.mjs +0 -11
- package/dist/plugin-env/src/components/env.cjs +0 -487
- package/dist/plugin-env/src/components/env.mjs +0 -484
- package/dist/plugin-env/src/components/index.cjs +0 -2
- package/dist/plugin-env/src/components/index.mjs +0 -4
- package/dist/plugin-env/src/helpers/automd-generator.cjs +0 -22
- package/dist/plugin-env/src/helpers/automd-generator.mjs +0 -21
- package/dist/plugin-env/src/helpers/create-reflection-resource.cjs +0 -55
- package/dist/plugin-env/src/helpers/create-reflection-resource.mjs +0 -54
- package/dist/plugin-env/src/helpers/index.cjs +0 -6
- package/dist/plugin-env/src/helpers/index.mjs +0 -8
- package/dist/plugin-env/src/helpers/load.cjs +0 -83
- package/dist/plugin-env/src/helpers/load.mjs +0 -80
- package/dist/plugin-env/src/helpers/persistence.cjs +0 -200
- package/dist/plugin-env/src/helpers/persistence.mjs +0 -189
- package/dist/plugin-env/src/helpers/reflect.cjs +0 -125
- package/dist/plugin-env/src/helpers/reflect.mjs +0 -117
- package/dist/plugin-env/src/helpers/source-file-env.cjs +0 -24
- package/dist/plugin-env/src/helpers/source-file-env.mjs +0 -23
- package/dist/plugin-env/src/helpers/template-helpers.cjs +0 -2
- package/dist/plugin-env/src/helpers/template-helpers.mjs +0 -4
- package/dist/plugin-env/src/index.cjs +0 -172
- package/dist/plugin-env/src/index.mjs +0 -170
- package/dist/plugin-env/src/types/plugin.d.cts +0 -151
- package/dist/plugin-env/src/types/plugin.d.mts +0 -153
- package/dist/plugin-env/src/types/runtime.d.cts +0 -792
- package/dist/plugin-env/src/types/runtime.d.mts +0 -792
- package/dist/powerlines/src/lib/build/esbuild.cjs +0 -102
- package/dist/powerlines/src/lib/build/esbuild.mjs +0 -100
- package/dist/powerlines/src/lib/entry.cjs +0 -12
- package/dist/powerlines/src/lib/entry.mjs +0 -14
- package/dist/powerlines/src/lib/logger.cjs +0 -41
- package/dist/powerlines/src/lib/logger.mjs +0 -39
- package/dist/powerlines/src/lib/utilities/bundle.cjs +0 -35
- package/dist/powerlines/src/lib/utilities/bundle.mjs +0 -34
- package/dist/powerlines/src/lib/utilities/file-header.cjs +0 -22
- package/dist/powerlines/src/lib/utilities/file-header.mjs +0 -21
- package/dist/powerlines/src/lib/utilities/resolve.cjs +0 -30
- package/dist/powerlines/src/lib/utilities/resolve.mjs +0 -29
- package/dist/powerlines/src/plugin-utils/paths.cjs +0 -1
- package/dist/powerlines/src/plugin-utils/paths.mjs +0 -3
- package/dist/powerlines/src/types/babel.d.cts +0 -22
- package/dist/powerlines/src/types/babel.d.mts +0 -22
- package/dist/powerlines/src/types/build.d.cts +0 -145
- package/dist/powerlines/src/types/build.d.mts +0 -147
- package/dist/powerlines/src/types/commands.d.cts +0 -8
- package/dist/powerlines/src/types/commands.d.mts +0 -9
- package/dist/powerlines/src/types/config.d.cts +0 -380
- package/dist/powerlines/src/types/config.d.mts +0 -381
- package/dist/powerlines/src/types/context.d.cts +0 -414
- package/dist/powerlines/src/types/context.d.mts +0 -416
- package/dist/powerlines/src/types/fs.d.cts +0 -486
- package/dist/powerlines/src/types/fs.d.mts +0 -486
- package/dist/powerlines/src/types/hooks.d.mts +0 -2
- package/dist/powerlines/src/types/plugin.d.cts +0 -231
- package/dist/powerlines/src/types/plugin.d.mts +0 -231
- package/dist/powerlines/src/types/resolved.d.cts +0 -82
- package/dist/powerlines/src/types/resolved.d.mts +0 -83
- package/dist/powerlines/src/types/tsconfig.d.cts +0 -69
- package/dist/powerlines/src/types/tsconfig.d.mts +0 -69
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
const require_rolldown_runtime = require('../../../../_virtual/rolldown_runtime.cjs');
|
|
2
|
-
const require_context = require('../../core/contexts/context.cjs');
|
|
3
|
-
const require_single_line_comment = require('../../core/components/single-line-comment.cjs');
|
|
4
|
-
const require_source_file = require('../../core/components/source-file.cjs');
|
|
5
|
-
let __alloy_js_core = require("@alloy-js/core");
|
|
6
|
-
let react_jsx_runtime = require("react/jsx-runtime");
|
|
7
|
-
let __stryke_path_append = require("@stryke/path/append");
|
|
8
|
-
let __stryke_string_format_title_case = require("@stryke/string-format/title-case");
|
|
9
|
-
let __stryke_type_checks_is_string = require("@stryke/type-checks/is-string");
|
|
10
|
-
let __alloy_js_typescript = require("@alloy-js/typescript");
|
|
11
|
-
let __stryke_type_checks_is_boolean = require("@stryke/type-checks/is-boolean");
|
|
12
|
-
|
|
13
|
-
//#region ../plugin-alloy/src/typescript/components/typescript-file.tsx
|
|
14
|
-
/**
|
|
15
|
-
* A base component representing a Powerlines generated Typescript source file.
|
|
16
|
-
*
|
|
17
|
-
* @param props - The properties for the source file.
|
|
18
|
-
* @returns The rendered source file component.
|
|
19
|
-
*/
|
|
20
|
-
function TypescriptFile(props) {
|
|
21
|
-
const [{ children, path, imports, tsx, header, hashbang }, rest] = (0, __alloy_js_core.splitProps)(props, [
|
|
22
|
-
"children",
|
|
23
|
-
"path",
|
|
24
|
-
"imports",
|
|
25
|
-
"tsx",
|
|
26
|
-
"header",
|
|
27
|
-
"hashbang"
|
|
28
|
-
]);
|
|
29
|
-
const directoryContext = (0, __alloy_js_core.useContext)(__alloy_js_core.SourceDirectoryContext);
|
|
30
|
-
const sdData = (0, __alloy_js_typescript.getSourceDirectoryData)(directoryContext);
|
|
31
|
-
const modulePath = (0, __stryke_path_append.appendPath)(path, directoryContext.path);
|
|
32
|
-
const scope = new __alloy_js_typescript.TSModuleScope(modulePath, (0, __alloy_js_core.useScope)());
|
|
33
|
-
sdData.modules.add(scope);
|
|
34
|
-
const pkg = (0, __alloy_js_core.useContext)(__alloy_js_typescript.PackageContext);
|
|
35
|
-
if (pkg) pkg.scope.addModule(scope);
|
|
36
|
-
if (props.export) {
|
|
37
|
-
if (pkg) if ((0, __stryke_type_checks_is_boolean.isBoolean)(props.export)) pkg.scope.addExport(modulePath, scope);
|
|
38
|
-
else pkg.scope.addExport(props.export, scope);
|
|
39
|
-
}
|
|
40
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__alloy_js_typescript.SourceFileContext.Provider, {
|
|
41
|
-
value: { scope },
|
|
42
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__alloy_js_core.Scope, {
|
|
43
|
-
value: scope,
|
|
44
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_source_file.SourceFile, {
|
|
45
|
-
...rest,
|
|
46
|
-
path: modulePath,
|
|
47
|
-
header: header ?? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TypescriptFileHeader, {
|
|
48
|
-
hashbang,
|
|
49
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TypescriptFileHeaderImports, {
|
|
50
|
-
imports,
|
|
51
|
-
scope
|
|
52
|
-
})
|
|
53
|
-
}),
|
|
54
|
-
filetype: tsx ? "tsx" : "typescript",
|
|
55
|
-
children
|
|
56
|
-
})
|
|
57
|
-
})
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Renders the header for a Powerlines Typescript source file.
|
|
62
|
-
*
|
|
63
|
-
* @param props - The properties for the source file header.
|
|
64
|
-
* @returns The rendered source file header.
|
|
65
|
-
*/
|
|
66
|
-
function TypescriptFileHeader(props) {
|
|
67
|
-
const { header, hashbang, disableEslint = true, disableBiome = true, disablePrettier = false, children } = props;
|
|
68
|
-
const context = require_context.usePowerlines();
|
|
69
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
70
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__alloy_js_core.Show, {
|
|
71
|
-
when: Boolean(hashbang),
|
|
72
|
-
children: [hashbang === true ? __alloy_js_core.code`#!/usr/bin/env ${context?.config.mode === "development" ? "-S NODE_OPTIONS=--enable-source-maps" : ""} node` : hashbang, /* @__PURE__ */ (0, react_jsx_runtime.jsx)("hbr", {})]
|
|
73
|
-
}),
|
|
74
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__alloy_js_core.Show, {
|
|
75
|
-
when: Boolean(header),
|
|
76
|
-
children: [header, /* @__PURE__ */ (0, react_jsx_runtime.jsx)("hbr", {})]
|
|
77
|
-
}),
|
|
78
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("hbr", {}),
|
|
79
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__alloy_js_core.Show, {
|
|
80
|
-
when: Boolean(disableEslint),
|
|
81
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_single_line_comment.SingleLineComment, {
|
|
82
|
-
variant: "slash-star",
|
|
83
|
-
children: "eslint-disable"
|
|
84
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("hbr", {})]
|
|
85
|
-
}),
|
|
86
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__alloy_js_core.Show, {
|
|
87
|
-
when: Boolean(disablePrettier),
|
|
88
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_single_line_comment.SingleLineComment, {
|
|
89
|
-
variant: "slash-star",
|
|
90
|
-
children: "prettier-ignore"
|
|
91
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("hbr", {})]
|
|
92
|
-
}),
|
|
93
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__alloy_js_core.Show, {
|
|
94
|
-
when: Boolean(disableBiome),
|
|
95
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_single_line_comment.SingleLineComment, { children: "biome-ignore lint: disable" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("hbr", {})]
|
|
96
|
-
}),
|
|
97
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__alloy_js_core.Show, {
|
|
98
|
-
when: Boolean(disableEslint) || Boolean(disablePrettier) || Boolean(disableBiome),
|
|
99
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("hbr", {})
|
|
100
|
-
}),
|
|
101
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__alloy_js_core.Show, {
|
|
102
|
-
when: Boolean(children),
|
|
103
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [children, /* @__PURE__ */ (0, react_jsx_runtime.jsx)("hbr", {})] })
|
|
104
|
-
}),
|
|
105
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_single_line_comment.SingleLineComment, { children: __alloy_js_core.code`Generated by ${(0, __stryke_string_format_title_case.titleCase)(context?.config.framework) || "Powerlines"}` }),
|
|
106
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("hbr", {}),
|
|
107
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_single_line_comment.SingleLineComment, { children: __alloy_js_core.code`NOTE: Do not edit this file manually - it will be overwritten automatically by the "prepare" command` }),
|
|
108
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("hbr", {})
|
|
109
|
-
] });
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
* Renders the header for a Powerlines Typescript source file.
|
|
113
|
-
*
|
|
114
|
-
* @param props - The properties for the source file header.
|
|
115
|
-
* @returns The rendered source file header.
|
|
116
|
-
*/
|
|
117
|
-
function TypescriptFileHeaderImports(props) {
|
|
118
|
-
const { imports } = props;
|
|
119
|
-
const context = require_context.usePowerlines();
|
|
120
|
-
const sourceFile = (0, __alloy_js_typescript.useSourceFile)();
|
|
121
|
-
const scope = props.scope ?? sourceFile.scope;
|
|
122
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__alloy_js_core.Show, {
|
|
123
|
-
when: scope.importedModules.size > 0 || !!imports && Object.keys(imports).length > 0,
|
|
124
|
-
children: [
|
|
125
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__alloy_js_core.Show, {
|
|
126
|
-
when: !!imports && Object.keys(imports).length > 0,
|
|
127
|
-
children: Object.entries(imports ?? {}).filter(([key]) => key !== "$builtins").concat(imports && imports.$builtins ? Object.entries(imports.$builtins).map(([key, entry]) => [key.includes(":") ? key : `${context.config.output.builtinPrefix}:${key}`, entry]) : []).map(([module$1, imported]) => {
|
|
128
|
-
return __alloy_js_core.code`import ${imported === null ? "" : imported.filter((i) => !(0, __stryke_type_checks_is_string.isString)(i) && i.default).map((i) => i.alias ? i.alias : i.name).join(", ") + (imported.filter((i) => !(0, __stryke_type_checks_is_string.isString)(i) && i.default).length > 0 && imported.filter((i) => (0, __stryke_type_checks_is_string.isString)(i) || !i.default).length > 0 ? ", " : "") + (imported.filter((i) => (0, __stryke_type_checks_is_string.isString)(i) || !i.default).length > 0 ? `{ ${imported.map((i) => (0, __stryke_type_checks_is_string.isString)(i) ? i : i.alias ? `${i.name} as ${i.alias}` : i.name).join(", ")} }` : "")} from "${module$1}";`;
|
|
129
|
-
})
|
|
130
|
-
}),
|
|
131
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__alloy_js_core.Show, {
|
|
132
|
-
when: scope.importedModules.size > 0,
|
|
133
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__alloy_js_typescript.ImportStatements, { records: scope.importedModules })
|
|
134
|
-
}),
|
|
135
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("hbr", {})
|
|
136
|
-
]
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
//#endregion
|
|
141
|
-
exports.TypescriptFile = TypescriptFile;
|
|
142
|
-
exports.TypescriptFileHeader = TypescriptFileHeader;
|
|
143
|
-
exports.TypescriptFileHeaderImports = TypescriptFileHeaderImports;
|
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
import { usePowerlines } from "../../core/contexts/context.mjs";
|
|
2
|
-
import { SingleLineComment } from "../../core/components/single-line-comment.mjs";
|
|
3
|
-
import { SourceFile } from "../../core/components/source-file.mjs";
|
|
4
|
-
import { Scope, Show, SourceDirectoryContext, code, splitProps, useContext, useScope } from "@alloy-js/core";
|
|
5
|
-
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
-
import { appendPath } from "@stryke/path/append";
|
|
7
|
-
import { titleCase } from "@stryke/string-format/title-case";
|
|
8
|
-
import { isString } from "@stryke/type-checks/is-string";
|
|
9
|
-
import { ImportStatements, PackageContext, SourceFileContext as SourceFileContext$1, TSModuleScope, getSourceDirectoryData, useSourceFile } from "@alloy-js/typescript";
|
|
10
|
-
import { isBoolean } from "@stryke/type-checks/is-boolean";
|
|
11
|
-
|
|
12
|
-
//#region ../plugin-alloy/src/typescript/components/typescript-file.tsx
|
|
13
|
-
/**
|
|
14
|
-
* A base component representing a Powerlines generated Typescript source file.
|
|
15
|
-
*
|
|
16
|
-
* @param props - The properties for the source file.
|
|
17
|
-
* @returns The rendered source file component.
|
|
18
|
-
*/
|
|
19
|
-
function TypescriptFile(props) {
|
|
20
|
-
const [{ children, path, imports, tsx, header, hashbang }, rest] = splitProps(props, [
|
|
21
|
-
"children",
|
|
22
|
-
"path",
|
|
23
|
-
"imports",
|
|
24
|
-
"tsx",
|
|
25
|
-
"header",
|
|
26
|
-
"hashbang"
|
|
27
|
-
]);
|
|
28
|
-
const directoryContext = useContext(SourceDirectoryContext);
|
|
29
|
-
const sdData = getSourceDirectoryData(directoryContext);
|
|
30
|
-
const modulePath = appendPath(path, directoryContext.path);
|
|
31
|
-
const scope = new TSModuleScope(modulePath, useScope());
|
|
32
|
-
sdData.modules.add(scope);
|
|
33
|
-
const pkg = useContext(PackageContext);
|
|
34
|
-
if (pkg) pkg.scope.addModule(scope);
|
|
35
|
-
if (props.export) {
|
|
36
|
-
if (pkg) if (isBoolean(props.export)) pkg.scope.addExport(modulePath, scope);
|
|
37
|
-
else pkg.scope.addExport(props.export, scope);
|
|
38
|
-
}
|
|
39
|
-
return /* @__PURE__ */ jsx(SourceFileContext$1.Provider, {
|
|
40
|
-
value: { scope },
|
|
41
|
-
children: /* @__PURE__ */ jsx(Scope, {
|
|
42
|
-
value: scope,
|
|
43
|
-
children: /* @__PURE__ */ jsx(SourceFile, {
|
|
44
|
-
...rest,
|
|
45
|
-
path: modulePath,
|
|
46
|
-
header: header ?? /* @__PURE__ */ jsx(TypescriptFileHeader, {
|
|
47
|
-
hashbang,
|
|
48
|
-
children: /* @__PURE__ */ jsx(TypescriptFileHeaderImports, {
|
|
49
|
-
imports,
|
|
50
|
-
scope
|
|
51
|
-
})
|
|
52
|
-
}),
|
|
53
|
-
filetype: tsx ? "tsx" : "typescript",
|
|
54
|
-
children
|
|
55
|
-
})
|
|
56
|
-
})
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Renders the header for a Powerlines Typescript source file.
|
|
61
|
-
*
|
|
62
|
-
* @param props - The properties for the source file header.
|
|
63
|
-
* @returns The rendered source file header.
|
|
64
|
-
*/
|
|
65
|
-
function TypescriptFileHeader(props) {
|
|
66
|
-
const { header, hashbang, disableEslint = true, disableBiome = true, disablePrettier = false, children } = props;
|
|
67
|
-
const context = usePowerlines();
|
|
68
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
69
|
-
/* @__PURE__ */ jsxs(Show, {
|
|
70
|
-
when: Boolean(hashbang),
|
|
71
|
-
children: [hashbang === true ? code`#!/usr/bin/env ${context?.config.mode === "development" ? "-S NODE_OPTIONS=--enable-source-maps" : ""} node` : hashbang, /* @__PURE__ */ jsx("hbr", {})]
|
|
72
|
-
}),
|
|
73
|
-
/* @__PURE__ */ jsxs(Show, {
|
|
74
|
-
when: Boolean(header),
|
|
75
|
-
children: [header, /* @__PURE__ */ jsx("hbr", {})]
|
|
76
|
-
}),
|
|
77
|
-
/* @__PURE__ */ jsx("hbr", {}),
|
|
78
|
-
/* @__PURE__ */ jsxs(Show, {
|
|
79
|
-
when: Boolean(disableEslint),
|
|
80
|
-
children: [/* @__PURE__ */ jsx(SingleLineComment, {
|
|
81
|
-
variant: "slash-star",
|
|
82
|
-
children: "eslint-disable"
|
|
83
|
-
}), /* @__PURE__ */ jsx("hbr", {})]
|
|
84
|
-
}),
|
|
85
|
-
/* @__PURE__ */ jsxs(Show, {
|
|
86
|
-
when: Boolean(disablePrettier),
|
|
87
|
-
children: [/* @__PURE__ */ jsx(SingleLineComment, {
|
|
88
|
-
variant: "slash-star",
|
|
89
|
-
children: "prettier-ignore"
|
|
90
|
-
}), /* @__PURE__ */ jsx("hbr", {})]
|
|
91
|
-
}),
|
|
92
|
-
/* @__PURE__ */ jsxs(Show, {
|
|
93
|
-
when: Boolean(disableBiome),
|
|
94
|
-
children: [/* @__PURE__ */ jsx(SingleLineComment, { children: "biome-ignore lint: disable" }), /* @__PURE__ */ jsx("hbr", {})]
|
|
95
|
-
}),
|
|
96
|
-
/* @__PURE__ */ jsx(Show, {
|
|
97
|
-
when: Boolean(disableEslint) || Boolean(disablePrettier) || Boolean(disableBiome),
|
|
98
|
-
children: /* @__PURE__ */ jsx("hbr", {})
|
|
99
|
-
}),
|
|
100
|
-
/* @__PURE__ */ jsx(Show, {
|
|
101
|
-
when: Boolean(children),
|
|
102
|
-
children: /* @__PURE__ */ jsxs(Fragment, { children: [children, /* @__PURE__ */ jsx("hbr", {})] })
|
|
103
|
-
}),
|
|
104
|
-
/* @__PURE__ */ jsx(SingleLineComment, { children: code`Generated by ${titleCase(context?.config.framework) || "Powerlines"}` }),
|
|
105
|
-
/* @__PURE__ */ jsx("hbr", {}),
|
|
106
|
-
/* @__PURE__ */ jsx(SingleLineComment, { children: code`NOTE: Do not edit this file manually - it will be overwritten automatically by the "prepare" command` }),
|
|
107
|
-
/* @__PURE__ */ jsx("hbr", {})
|
|
108
|
-
] });
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* Renders the header for a Powerlines Typescript source file.
|
|
112
|
-
*
|
|
113
|
-
* @param props - The properties for the source file header.
|
|
114
|
-
* @returns The rendered source file header.
|
|
115
|
-
*/
|
|
116
|
-
function TypescriptFileHeaderImports(props) {
|
|
117
|
-
const { imports } = props;
|
|
118
|
-
const context = usePowerlines();
|
|
119
|
-
const sourceFile = useSourceFile();
|
|
120
|
-
const scope = props.scope ?? sourceFile.scope;
|
|
121
|
-
return /* @__PURE__ */ jsxs(Show, {
|
|
122
|
-
when: scope.importedModules.size > 0 || !!imports && Object.keys(imports).length > 0,
|
|
123
|
-
children: [
|
|
124
|
-
/* @__PURE__ */ jsx(Show, {
|
|
125
|
-
when: !!imports && Object.keys(imports).length > 0,
|
|
126
|
-
children: Object.entries(imports ?? {}).filter(([key]) => key !== "$builtins").concat(imports && imports.$builtins ? Object.entries(imports.$builtins).map(([key, entry]) => [key.includes(":") ? key : `${context.config.output.builtinPrefix}:${key}`, entry]) : []).map(([module, imported]) => {
|
|
127
|
-
return code`import ${imported === null ? "" : imported.filter((i) => !isString(i) && i.default).map((i) => i.alias ? i.alias : i.name).join(", ") + (imported.filter((i) => !isString(i) && i.default).length > 0 && imported.filter((i) => isString(i) || !i.default).length > 0 ? ", " : "") + (imported.filter((i) => isString(i) || !i.default).length > 0 ? `{ ${imported.map((i) => isString(i) ? i : i.alias ? `${i.name} as ${i.alias}` : i.name).join(", ")} }` : "")} from "${module}";`;
|
|
128
|
-
})
|
|
129
|
-
}),
|
|
130
|
-
/* @__PURE__ */ jsx(Show, {
|
|
131
|
-
when: scope.importedModules.size > 0,
|
|
132
|
-
children: /* @__PURE__ */ jsx(ImportStatements, { records: scope.importedModules })
|
|
133
|
-
}),
|
|
134
|
-
/* @__PURE__ */ jsx("hbr", {})
|
|
135
|
-
]
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
//#endregion
|
|
140
|
-
export { TypescriptFile, TypescriptFileHeader, TypescriptFileHeaderImports };
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
const require_rolldown_runtime = require('../../../../_virtual/rolldown_runtime.cjs');
|
|
2
|
-
const require_type = require('../../../../deepkit/src/vendor/type.cjs');
|
|
3
|
-
const require_reflection = require('../../core/contexts/reflection.cjs');
|
|
4
|
-
const require_tsdoc_reflection = require('./tsdoc-reflection.cjs');
|
|
5
|
-
let __alloy_js_core = require("@alloy-js/core");
|
|
6
|
-
let react_jsx_runtime = require("react/jsx-runtime");
|
|
7
|
-
let __stryke_type_checks_is_string = require("@stryke/type-checks/is-string");
|
|
8
|
-
let __alloy_js_typescript = require("@alloy-js/typescript");
|
|
9
|
-
let __stryke_string_format_pascal_case = require("@stryke/string-format/pascal-case");
|
|
10
|
-
|
|
11
|
-
//#region ../plugin-alloy/src/typescript/components/typescript-interface.tsx
|
|
12
|
-
/**
|
|
13
|
-
* Generates a TypeScript interface for the given reflection class.
|
|
14
|
-
*/
|
|
15
|
-
function TypeScriptInterface(props) {
|
|
16
|
-
const [{ name, reflection }, rest] = (0, __alloy_js_core.splitProps)(props, ["name", "reflection"]);
|
|
17
|
-
const interfaceName = (0, __alloy_js_core.computed)(() => (0, __stryke_string_format_pascal_case.pascalCase)(((0, __stryke_type_checks_is_string.isString)(name) ? name : name.toString()) || reflection.getName()));
|
|
18
|
-
const properties = reflection.getProperties().filter((item) => !item.isIgnored()).sort((a, b) => a.isReadonly() && b.isReadonly() || !a.isReadonly() && !b.isReadonly() ? a.getNameAsString().localeCompare(b.getNameAsString()) : a.isReadonly() ? 1 : -1);
|
|
19
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_reflection.ReflectionClassContext.Provider, {
|
|
20
|
-
value: { reflection },
|
|
21
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_tsdoc_reflection.TSDocReflectionClass, {}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__alloy_js_typescript.InterfaceDeclaration, {
|
|
22
|
-
export: true,
|
|
23
|
-
name: interfaceName.value,
|
|
24
|
-
...rest,
|
|
25
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__alloy_js_core.For, {
|
|
26
|
-
each: properties,
|
|
27
|
-
doubleHardline: true,
|
|
28
|
-
semicolon: true,
|
|
29
|
-
children: (prop) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TypescriptInterfaceProperty, { property: prop })
|
|
30
|
-
})
|
|
31
|
-
})]
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Generates a TypeScript interface property for the given reflection class.
|
|
36
|
-
*/
|
|
37
|
-
function TypescriptInterfaceProperty(props) {
|
|
38
|
-
const [{ property }, rest] = (0, __alloy_js_core.splitProps)(props, ["property"]);
|
|
39
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_reflection.ReflectionPropertyContext.Provider, {
|
|
40
|
-
value: property,
|
|
41
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_tsdoc_reflection.TSDocReflectionProperty, {}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__alloy_js_typescript.InterfaceMember, {
|
|
42
|
-
name: property.getNameAsString(),
|
|
43
|
-
readonly: property.isReadonly(),
|
|
44
|
-
optional: property.isOptional(),
|
|
45
|
-
nullish: property.isNullable(),
|
|
46
|
-
type: (0, require_type.type_exports.stringifyType)(property.getType()),
|
|
47
|
-
...rest
|
|
48
|
-
})]
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
//#endregion
|
|
53
|
-
exports.TypeScriptInterface = TypeScriptInterface;
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { type_exports } from "../../../../deepkit/src/vendor/type.mjs";
|
|
2
|
-
import { ReflectionClassContext, ReflectionPropertyContext } from "../../core/contexts/reflection.mjs";
|
|
3
|
-
import { TSDocReflectionClass, TSDocReflectionProperty } from "./tsdoc-reflection.mjs";
|
|
4
|
-
import { For, computed, splitProps } from "@alloy-js/core";
|
|
5
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
-
import { isString } from "@stryke/type-checks/is-string";
|
|
7
|
-
import { InterfaceDeclaration, InterfaceMember } from "@alloy-js/typescript";
|
|
8
|
-
import { pascalCase } from "@stryke/string-format/pascal-case";
|
|
9
|
-
|
|
10
|
-
//#region ../plugin-alloy/src/typescript/components/typescript-interface.tsx
|
|
11
|
-
/**
|
|
12
|
-
* Generates a TypeScript interface for the given reflection class.
|
|
13
|
-
*/
|
|
14
|
-
function TypeScriptInterface(props) {
|
|
15
|
-
const [{ name, reflection }, rest] = splitProps(props, ["name", "reflection"]);
|
|
16
|
-
const interfaceName = computed(() => pascalCase((isString(name) ? name : name.toString()) || reflection.getName()));
|
|
17
|
-
const properties = reflection.getProperties().filter((item) => !item.isIgnored()).sort((a, b) => a.isReadonly() && b.isReadonly() || !a.isReadonly() && !b.isReadonly() ? a.getNameAsString().localeCompare(b.getNameAsString()) : a.isReadonly() ? 1 : -1);
|
|
18
|
-
return /* @__PURE__ */ jsxs(ReflectionClassContext.Provider, {
|
|
19
|
-
value: { reflection },
|
|
20
|
-
children: [/* @__PURE__ */ jsx(TSDocReflectionClass, {}), /* @__PURE__ */ jsx(InterfaceDeclaration, {
|
|
21
|
-
export: true,
|
|
22
|
-
name: interfaceName.value,
|
|
23
|
-
...rest,
|
|
24
|
-
children: /* @__PURE__ */ jsx(For, {
|
|
25
|
-
each: properties,
|
|
26
|
-
doubleHardline: true,
|
|
27
|
-
semicolon: true,
|
|
28
|
-
children: (prop) => /* @__PURE__ */ jsx(TypescriptInterfaceProperty, { property: prop })
|
|
29
|
-
})
|
|
30
|
-
})]
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Generates a TypeScript interface property for the given reflection class.
|
|
35
|
-
*/
|
|
36
|
-
function TypescriptInterfaceProperty(props) {
|
|
37
|
-
const [{ property }, rest] = splitProps(props, ["property"]);
|
|
38
|
-
return /* @__PURE__ */ jsxs(ReflectionPropertyContext.Provider, {
|
|
39
|
-
value: property,
|
|
40
|
-
children: [/* @__PURE__ */ jsx(TSDocReflectionProperty, {}), /* @__PURE__ */ jsx(InterfaceMember, {
|
|
41
|
-
name: property.getNameAsString(),
|
|
42
|
-
readonly: property.isReadonly(),
|
|
43
|
-
optional: property.isOptional(),
|
|
44
|
-
nullish: property.isNullable(),
|
|
45
|
-
type: (0, type_exports.stringifyType)(property.getType()),
|
|
46
|
-
...rest
|
|
47
|
-
})]
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
//#endregion
|
|
52
|
-
export { TypeScriptInterface };
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
const require_rolldown_runtime = require('../../../../_virtual/rolldown_runtime.cjs');
|
|
2
|
-
const require_utilities = require('../../../../deepkit/src/utilities.cjs');
|
|
3
|
-
const require_reflection = require('../../core/contexts/reflection.cjs');
|
|
4
|
-
const require_tsdoc_reflection = require('./tsdoc-reflection.cjs');
|
|
5
|
-
let __alloy_js_core = require("@alloy-js/core");
|
|
6
|
-
let react_jsx_runtime = require("react/jsx-runtime");
|
|
7
|
-
let __stryke_type_checks_is_string = require("@stryke/type-checks/is-string");
|
|
8
|
-
let __stryke_type_checks_is_undefined = require("@stryke/type-checks/is-undefined");
|
|
9
|
-
let __stryke_string_format_camel_case = require("@stryke/string-format/camel-case");
|
|
10
|
-
let __alloy_js_typescript = require("@alloy-js/typescript");
|
|
11
|
-
let __stryke_string_format_pascal_case = require("@stryke/string-format/pascal-case");
|
|
12
|
-
|
|
13
|
-
//#region ../plugin-alloy/src/typescript/components/typescript-object.tsx
|
|
14
|
-
/**
|
|
15
|
-
* Generates a TypeScript object for the given reflection class.
|
|
16
|
-
*/
|
|
17
|
-
function TypescriptObject(props) {
|
|
18
|
-
if (!props.reflection?.value) return null;
|
|
19
|
-
const objectName = (0, __alloy_js_core.computed)(() => (0, __stryke_string_format_camel_case.camelCase)(((0, __stryke_type_checks_is_string.isString)(props.name) ? props.name : props.name.toString()) || props.reflection.value.getName()));
|
|
20
|
-
const objectType = (0, __alloy_js_core.computed)(() => props.type || (0, __stryke_string_format_pascal_case.pascalCase)(props.reflection.value.getName()));
|
|
21
|
-
const properties = (0, __alloy_js_core.computed)(() => props.reflection.value.getProperties().filter((item) => !item.isIgnored() && !(0, __stryke_type_checks_is_undefined.isUndefined)(props.defaultValue?.value?.[item.getNameAsString()] ?? item.getAlias().reduce((ret, alias) => {
|
|
22
|
-
if ((0, __stryke_type_checks_is_undefined.isUndefined)(ret) && !(0, __stryke_type_checks_is_undefined.isUndefined)(props.defaultValue?.value?.[alias])) return props.defaultValue?.value?.[alias];
|
|
23
|
-
return ret;
|
|
24
|
-
}, void 0) ?? item.getDefaultValue())).sort((a, b) => a.isReadonly() && b.isReadonly() || !a.isReadonly() && !b.isReadonly() ? a.getNameAsString().localeCompare(b.getNameAsString()) : a.isReadonly() ? 1 : -1));
|
|
25
|
-
const TypeSymbolSlot = (0, __alloy_js_core.createSymbolSlot)();
|
|
26
|
-
const ValueTypeSymbolSlot = (0, __alloy_js_core.createSymbolSlot)();
|
|
27
|
-
const sym = (0, __alloy_js_typescript.createValueSymbol)(props.name, {
|
|
28
|
-
refkeys: props.refkey,
|
|
29
|
-
default: props.default,
|
|
30
|
-
export: props.export,
|
|
31
|
-
metadata: props.metadata,
|
|
32
|
-
tsFlags: props.nullish ? __alloy_js_typescript.TSSymbolFlags.Nullish : __alloy_js_typescript.TSSymbolFlags.None,
|
|
33
|
-
type: props.type ? TypeSymbolSlot.firstSymbol : void 0,
|
|
34
|
-
namePolicy: (0, __alloy_js_typescript.useTSNamePolicy)().for("variable")
|
|
35
|
-
});
|
|
36
|
-
if (!props.type) ValueTypeSymbolSlot.moveMembersTo(sym);
|
|
37
|
-
const keyword = props.var ? "var" : props.let ? "let" : "const";
|
|
38
|
-
const type = props.type ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__alloy_js_typescript.TypeRefContext, { children: [": ", /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TypeSymbolSlot, { children: props.type })] }) : void 0;
|
|
39
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__alloy_js_core.Show, {
|
|
40
|
-
when: !!props.reflection.value,
|
|
41
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_reflection.ReflectionClassContext.Provider, {
|
|
42
|
-
value: {
|
|
43
|
-
reflection: props.reflection.value,
|
|
44
|
-
override: {
|
|
45
|
-
name: objectName.value,
|
|
46
|
-
type: objectType.value,
|
|
47
|
-
defaultValue: props.defaultValue?.value
|
|
48
|
-
}
|
|
49
|
-
},
|
|
50
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__alloy_js_core.Show, {
|
|
51
|
-
when: !!objectName.value && !!objectType.value,
|
|
52
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_tsdoc_reflection.TSDocReflectionClass, {}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__alloy_js_core.Declaration, {
|
|
53
|
-
symbol: sym,
|
|
54
|
-
children: [
|
|
55
|
-
props.export ? "export " : "",
|
|
56
|
-
props.default ? "default " : "",
|
|
57
|
-
keyword,
|
|
58
|
-
" ",
|
|
59
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__alloy_js_core.Name, {}),
|
|
60
|
-
type,
|
|
61
|
-
" =",
|
|
62
|
-
" ",
|
|
63
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ValueTypeSymbolSlot, { children: props.initializer ?? props.children ?? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__alloy_js_typescript.ObjectExpression, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__alloy_js_core.For, {
|
|
64
|
-
each: properties.value ?? [],
|
|
65
|
-
comma: true,
|
|
66
|
-
doubleHardline: true,
|
|
67
|
-
children: (prop) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TypescriptObjectProperty, { property: prop })
|
|
68
|
-
}) }) })
|
|
69
|
-
]
|
|
70
|
-
})]
|
|
71
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("hbr", {})]
|
|
72
|
-
})
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Generates a TypeScript object property for the given reflection class.
|
|
77
|
-
*/
|
|
78
|
-
function TypescriptObjectProperty(props) {
|
|
79
|
-
const [{ property }] = (0, __alloy_js_core.splitProps)(props, ["property"]);
|
|
80
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_reflection.ReflectionPropertyContext.Provider, {
|
|
81
|
-
value: property,
|
|
82
|
-
children: [
|
|
83
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_tsdoc_reflection.TSDocReflectionProperty, {}),
|
|
84
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__alloy_js_typescript.ObjectProperty, {
|
|
85
|
-
name: property.getNameAsString(),
|
|
86
|
-
value: require_utilities.stringifyDefaultValue(property)
|
|
87
|
-
}),
|
|
88
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("hbr", {})
|
|
89
|
-
]
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
//#endregion
|
|
94
|
-
exports.TypescriptObject = TypescriptObject;
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import { stringifyDefaultValue } from "../../../../deepkit/src/utilities.mjs";
|
|
2
|
-
import { ReflectionClassContext, ReflectionPropertyContext } from "../../core/contexts/reflection.mjs";
|
|
3
|
-
import { TSDocReflectionClass, TSDocReflectionProperty } from "./tsdoc-reflection.mjs";
|
|
4
|
-
import { Declaration, For, Name, Show, computed, createSymbolSlot, splitProps } from "@alloy-js/core";
|
|
5
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
-
import { isString } from "@stryke/type-checks/is-string";
|
|
7
|
-
import { isUndefined } from "@stryke/type-checks/is-undefined";
|
|
8
|
-
import { camelCase } from "@stryke/string-format/camel-case";
|
|
9
|
-
import { ObjectExpression, ObjectProperty, TSSymbolFlags, TypeRefContext, createValueSymbol, useTSNamePolicy } from "@alloy-js/typescript";
|
|
10
|
-
import { pascalCase } from "@stryke/string-format/pascal-case";
|
|
11
|
-
|
|
12
|
-
//#region ../plugin-alloy/src/typescript/components/typescript-object.tsx
|
|
13
|
-
/**
|
|
14
|
-
* Generates a TypeScript object for the given reflection class.
|
|
15
|
-
*/
|
|
16
|
-
function TypescriptObject(props) {
|
|
17
|
-
if (!props.reflection?.value) return null;
|
|
18
|
-
const objectName = computed(() => camelCase((isString(props.name) ? props.name : props.name.toString()) || props.reflection.value.getName()));
|
|
19
|
-
const objectType = computed(() => props.type || pascalCase(props.reflection.value.getName()));
|
|
20
|
-
const properties = computed(() => props.reflection.value.getProperties().filter((item) => !item.isIgnored() && !isUndefined(props.defaultValue?.value?.[item.getNameAsString()] ?? item.getAlias().reduce((ret, alias) => {
|
|
21
|
-
if (isUndefined(ret) && !isUndefined(props.defaultValue?.value?.[alias])) return props.defaultValue?.value?.[alias];
|
|
22
|
-
return ret;
|
|
23
|
-
}, void 0) ?? item.getDefaultValue())).sort((a, b) => a.isReadonly() && b.isReadonly() || !a.isReadonly() && !b.isReadonly() ? a.getNameAsString().localeCompare(b.getNameAsString()) : a.isReadonly() ? 1 : -1));
|
|
24
|
-
const TypeSymbolSlot = createSymbolSlot();
|
|
25
|
-
const ValueTypeSymbolSlot = createSymbolSlot();
|
|
26
|
-
const sym = createValueSymbol(props.name, {
|
|
27
|
-
refkeys: props.refkey,
|
|
28
|
-
default: props.default,
|
|
29
|
-
export: props.export,
|
|
30
|
-
metadata: props.metadata,
|
|
31
|
-
tsFlags: props.nullish ? TSSymbolFlags.Nullish : TSSymbolFlags.None,
|
|
32
|
-
type: props.type ? TypeSymbolSlot.firstSymbol : void 0,
|
|
33
|
-
namePolicy: useTSNamePolicy().for("variable")
|
|
34
|
-
});
|
|
35
|
-
if (!props.type) ValueTypeSymbolSlot.moveMembersTo(sym);
|
|
36
|
-
const keyword = props.var ? "var" : props.let ? "let" : "const";
|
|
37
|
-
const type = props.type ? /* @__PURE__ */ jsxs(TypeRefContext, { children: [": ", /* @__PURE__ */ jsx(TypeSymbolSlot, { children: props.type })] }) : void 0;
|
|
38
|
-
return /* @__PURE__ */ jsx(Show, {
|
|
39
|
-
when: !!props.reflection.value,
|
|
40
|
-
children: /* @__PURE__ */ jsxs(ReflectionClassContext.Provider, {
|
|
41
|
-
value: {
|
|
42
|
-
reflection: props.reflection.value,
|
|
43
|
-
override: {
|
|
44
|
-
name: objectName.value,
|
|
45
|
-
type: objectType.value,
|
|
46
|
-
defaultValue: props.defaultValue?.value
|
|
47
|
-
}
|
|
48
|
-
},
|
|
49
|
-
children: [/* @__PURE__ */ jsxs(Show, {
|
|
50
|
-
when: !!objectName.value && !!objectType.value,
|
|
51
|
-
children: [/* @__PURE__ */ jsx(TSDocReflectionClass, {}), /* @__PURE__ */ jsxs(Declaration, {
|
|
52
|
-
symbol: sym,
|
|
53
|
-
children: [
|
|
54
|
-
props.export ? "export " : "",
|
|
55
|
-
props.default ? "default " : "",
|
|
56
|
-
keyword,
|
|
57
|
-
" ",
|
|
58
|
-
/* @__PURE__ */ jsx(Name, {}),
|
|
59
|
-
type,
|
|
60
|
-
" =",
|
|
61
|
-
" ",
|
|
62
|
-
/* @__PURE__ */ jsx(ValueTypeSymbolSlot, { children: props.initializer ?? props.children ?? /* @__PURE__ */ jsx(ObjectExpression, { children: /* @__PURE__ */ jsx(For, {
|
|
63
|
-
each: properties.value ?? [],
|
|
64
|
-
comma: true,
|
|
65
|
-
doubleHardline: true,
|
|
66
|
-
children: (prop) => /* @__PURE__ */ jsx(TypescriptObjectProperty, { property: prop })
|
|
67
|
-
}) }) })
|
|
68
|
-
]
|
|
69
|
-
})]
|
|
70
|
-
}), /* @__PURE__ */ jsx("hbr", {})]
|
|
71
|
-
})
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Generates a TypeScript object property for the given reflection class.
|
|
76
|
-
*/
|
|
77
|
-
function TypescriptObjectProperty(props) {
|
|
78
|
-
const [{ property }] = splitProps(props, ["property"]);
|
|
79
|
-
return /* @__PURE__ */ jsxs(ReflectionPropertyContext.Provider, {
|
|
80
|
-
value: property,
|
|
81
|
-
children: [
|
|
82
|
-
/* @__PURE__ */ jsx(TSDocReflectionProperty, {}),
|
|
83
|
-
/* @__PURE__ */ jsx(ObjectProperty, {
|
|
84
|
-
name: property.getNameAsString(),
|
|
85
|
-
value: stringifyDefaultValue(property)
|
|
86
|
-
}),
|
|
87
|
-
/* @__PURE__ */ jsx("hbr", {})
|
|
88
|
-
]
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
//#endregion
|
|
93
|
-
export { TypescriptObject };
|