@powerlines/plugin-env 0.14.26 → 0.14.27
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/components/docs.cjs +6 -6
- package/dist/components/docs.mjs +3 -3
- package/dist/components/env.cjs +35 -39
- package/dist/components/env.d.cts +2 -2
- package/dist/components/env.d.mts +2 -2
- package/dist/components/env.mjs +10 -14
- package/dist/helpers/create-reflection-resource.d.cts +2 -2
- package/dist/helpers/create-reflection-resource.d.mts +2 -2
- package/dist/index.d.cts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/plugin-alloy/src/core/components/single-line-comment.cjs +22 -0
- package/dist/plugin-alloy/src/core/components/single-line-comment.mjs +21 -0
- package/dist/plugin-alloy/src/core/components/source-file.cjs +64 -0
- package/dist/plugin-alloy/src/core/components/source-file.d.cts +23 -0
- package/dist/plugin-alloy/src/core/components/source-file.d.mts +23 -0
- package/dist/plugin-alloy/src/core/components/source-file.mjs +62 -0
- package/dist/plugin-alloy/src/core/contexts/context.cjs +50 -1
- package/dist/plugin-alloy/src/core/contexts/context.mjs +46 -2
- package/dist/plugin-alloy/src/core/contexts/index.cjs +2 -0
- package/dist/plugin-alloy/src/core/contexts/index.mjs +4 -0
- package/dist/plugin-alloy/src/core/contexts/reflection.cjs +46 -0
- package/dist/plugin-alloy/src/core/contexts/reflection.mjs +42 -0
- package/dist/plugin-alloy/src/helpers/refkey.cjs +16 -0
- package/dist/plugin-alloy/src/helpers/refkey.mjs +15 -0
- package/dist/plugin-alloy/src/markdown/components/markdown-file.cjs +115 -0
- package/dist/plugin-alloy/src/markdown/components/markdown-file.mjs +114 -0
- package/dist/plugin-alloy/src/markdown/components/markdown-table.cjs +39 -0
- package/dist/plugin-alloy/src/markdown/components/markdown-table.mjs +38 -0
- package/dist/plugin-alloy/src/markdown/contexts/markdown-table.cjs +18 -0
- package/dist/plugin-alloy/src/markdown/contexts/markdown-table.mjs +17 -0
- package/dist/plugin-alloy/src/types/components.d.cts +19 -0
- package/dist/plugin-alloy/src/types/components.d.mts +19 -1
- package/dist/plugin-alloy/src/types/index.d.mts +1 -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-alloy/src/typescript/components/builtin-file.cjs +57 -0
- package/dist/plugin-alloy/src/typescript/components/builtin-file.d.cts +25 -0
- package/dist/plugin-alloy/src/typescript/components/builtin-file.d.mts +26 -0
- package/dist/plugin-alloy/src/typescript/components/builtin-file.mjs +56 -0
- package/dist/plugin-alloy/src/typescript/components/tsdoc-reflection.cjs +126 -0
- package/dist/plugin-alloy/src/typescript/components/tsdoc-reflection.mjs +124 -0
- package/dist/plugin-alloy/src/typescript/components/tsdoc.cjs +442 -0
- package/dist/plugin-alloy/src/typescript/components/tsdoc.d.cts +27 -0
- package/dist/plugin-alloy/src/typescript/components/tsdoc.d.mts +28 -0
- package/dist/plugin-alloy/src/typescript/components/tsdoc.mjs +433 -0
- package/dist/plugin-alloy/src/typescript/components/typescript-file.cjs +193 -0
- package/dist/plugin-alloy/src/typescript/components/typescript-file.d.cts +14 -0
- package/dist/plugin-alloy/src/typescript/components/typescript-file.d.mts +15 -0
- package/dist/plugin-alloy/src/typescript/components/typescript-file.mjs +190 -0
- package/dist/plugin-alloy/src/typescript/components/typescript-interface.cjs +68 -0
- package/dist/plugin-alloy/src/typescript/components/typescript-interface.d.cts +11 -0
- package/dist/plugin-alloy/src/typescript/components/typescript-interface.d.mts +12 -0
- package/dist/plugin-alloy/src/typescript/components/typescript-interface.mjs +67 -0
- package/dist/plugin-alloy/src/typescript/components/typescript-object.cjs +124 -0
- package/dist/plugin-alloy/src/typescript/components/typescript-object.mjs +123 -0
- package/dist/plugin-automd/src/types/plugin.d.mts +2 -2
- 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/src/api.d.mts +2 -2
- package/dist/powerlines/src/index.d.mts +4 -4
- package/dist/powerlines/src/internal/helpers/hooks.d.mts +3 -3
- package/dist/powerlines/src/lib/build/esbuild.mjs +1 -1
- package/dist/powerlines/src/lib/entry.mjs +1 -1
- package/dist/powerlines/src/types/api.d.mts +2 -2
- package/dist/powerlines/src/types/babel.d.cts +1 -1
- package/dist/powerlines/src/types/babel.d.mts +1 -1
- package/dist/powerlines/src/types/commands.d.cts +1 -1
- package/dist/powerlines/src/types/commands.d.mts +1 -1
- package/dist/powerlines/src/types/config.d.cts +5 -5
- package/dist/powerlines/src/types/config.d.mts +5 -5
- package/dist/powerlines/src/types/context.d.cts +1 -1
- package/dist/powerlines/src/types/context.d.mts +2 -2
- package/dist/powerlines/src/types/fs.d.cts +1 -1
- package/dist/powerlines/src/types/index.d.mts +5 -5
- package/dist/powerlines/src/types/plugin.d.cts +3 -3
- package/dist/powerlines/src/types/plugin.d.mts +3 -3
- package/dist/powerlines/src/types/resolved.d.cts +1 -1
- package/dist/powerlines/src/types/resolved.d.mts +1 -1
- package/dist/powerlines/src/types/unplugin.d.mts +2 -2
- package/package.json +8 -8
package/dist/components/docs.cjs
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
2
|
const require_type = require('../deepkit/src/vendor/type.cjs');
|
|
3
|
+
const require_context = require('../plugin-alloy/src/core/contexts/context.cjs');
|
|
3
4
|
const require_create_reflection_resource = require('../helpers/create-reflection-resource.cjs');
|
|
5
|
+
const require_markdown_file = require('../plugin-alloy/src/markdown/components/markdown-file.cjs');
|
|
6
|
+
const require_markdown_table = require('../plugin-alloy/src/markdown/components/markdown-table.cjs');
|
|
4
7
|
let __alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
|
|
5
8
|
let __alloy_js_core = require("@alloy-js/core");
|
|
6
9
|
let __stryke_path_join = require("@stryke/path/join");
|
|
7
|
-
let __powerlines_alloy_core_contexts_context = require("@powerlines/alloy/core/contexts/context");
|
|
8
10
|
let __alloy_js_markdown = require("@alloy-js/markdown");
|
|
9
|
-
let __powerlines_alloy_markdown_components_markdown_file = require("@powerlines/alloy/markdown/components/markdown-file");
|
|
10
|
-
let __powerlines_alloy_markdown_components_markdown_table = require("@powerlines/alloy/markdown/components/markdown-table");
|
|
11
11
|
|
|
12
12
|
//#region src/components/docs.tsx
|
|
13
13
|
/**
|
|
14
14
|
* Generates the environment configuration markdown documentation for the Powerlines project.
|
|
15
15
|
*/
|
|
16
16
|
function EnvDocs() {
|
|
17
|
-
const context =
|
|
17
|
+
const context = require_context.usePowerlines();
|
|
18
18
|
if (!context) return null;
|
|
19
19
|
const reflection = require_create_reflection_resource.createReflectionResource(context);
|
|
20
|
-
return (0, __alloy_js_core_jsx_runtime.createComponent)(
|
|
20
|
+
return (0, __alloy_js_core_jsx_runtime.createComponent)(require_markdown_file.MarkdownFile, {
|
|
21
21
|
get path() {
|
|
22
22
|
return (0, __stryke_path_join.joinPaths)(context.config.projectRoot, "docs", "generated", "env.md");
|
|
23
23
|
},
|
|
@@ -51,7 +51,7 @@ function EnvDocs() {
|
|
|
51
51
|
}),
|
|
52
52
|
__alloy_js_core.code`The below list of environment variables are used as configuration parameters to drive the processing of the application. The data contained in these variables are **not** considered sensitive or confidential. Any values provided in these variables will be available in plain text to the public.`,
|
|
53
53
|
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
54
|
-
(0, __alloy_js_core_jsx_runtime.createComponent)(
|
|
54
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(require_markdown_table.MarkdownTable, { get data() {
|
|
55
55
|
return reflection.data?.getProperties().filter((property) => property.getNameAsString() !== "__STORM_INJECTED__").sort((a, b) => a.getNameAsString().localeCompare(b.getNameAsString())).map((reflectionProperty) => {
|
|
56
56
|
return {
|
|
57
57
|
name: reflectionProperty.getNameAsString().trim(),
|
package/dist/components/docs.mjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { type_exports } from "../deepkit/src/vendor/type.mjs";
|
|
2
|
+
import { usePowerlines } from "../plugin-alloy/src/core/contexts/context.mjs";
|
|
2
3
|
import { createReflectionResource } from "../helpers/create-reflection-resource.mjs";
|
|
4
|
+
import { MarkdownFile } from "../plugin-alloy/src/markdown/components/markdown-file.mjs";
|
|
5
|
+
import { MarkdownTable } from "../plugin-alloy/src/markdown/components/markdown-table.mjs";
|
|
3
6
|
import { createComponent, createIntrinsic } from "@alloy-js/core/jsx-runtime";
|
|
4
7
|
import { Show, code } from "@alloy-js/core";
|
|
5
8
|
import { joinPaths } from "@stryke/path/join";
|
|
6
|
-
import { usePowerlines } from "@powerlines/alloy/core/contexts/context";
|
|
7
9
|
import { Heading, Link } from "@alloy-js/markdown";
|
|
8
|
-
import { MarkdownFile } from "@powerlines/alloy/markdown/components/markdown-file";
|
|
9
|
-
import { MarkdownTable } from "@powerlines/alloy/markdown/components/markdown-table";
|
|
10
10
|
|
|
11
11
|
//#region src/components/docs.tsx
|
|
12
12
|
/**
|
package/dist/components/env.cjs
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
2
|
const require_type = require('../deepkit/src/vendor/type.cjs');
|
|
3
|
+
const require_context = require('../plugin-alloy/src/core/contexts/context.cjs');
|
|
4
|
+
const require_refkey = require('../plugin-alloy/src/helpers/refkey.cjs');
|
|
5
|
+
const require_tsdoc = require('../plugin-alloy/src/typescript/components/tsdoc.cjs');
|
|
6
|
+
const require_builtin_file = require('../plugin-alloy/src/typescript/components/builtin-file.cjs');
|
|
7
|
+
const require_typescript_interface = require('../plugin-alloy/src/typescript/components/typescript-interface.cjs');
|
|
8
|
+
const require_typescript_object = require('../plugin-alloy/src/typescript/components/typescript-object.cjs');
|
|
3
9
|
const require_load = require('../helpers/load.cjs');
|
|
4
10
|
const require_create_reflection_resource = require('../helpers/create-reflection-resource.cjs');
|
|
5
11
|
let __alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
|
|
@@ -9,12 +15,6 @@ defu = require_rolldown_runtime.__toESM(defu);
|
|
|
9
15
|
let __stryke_string_format_title_case = require("@stryke/string-format/title-case");
|
|
10
16
|
let __stryke_type_checks_is_null = require("@stryke/type-checks/is-null");
|
|
11
17
|
let __alloy_js_typescript = require("@alloy-js/typescript");
|
|
12
|
-
let __powerlines_alloy_core_contexts_context = require("@powerlines/alloy/core/contexts/context");
|
|
13
|
-
let __powerlines_alloy_helpers_refkey = require("@powerlines/alloy/helpers/refkey");
|
|
14
|
-
let __powerlines_alloy_typescript_components_builtin_file = require("@powerlines/alloy/typescript/components/builtin-file");
|
|
15
|
-
let __powerlines_alloy_typescript_components_tsdoc = require("@powerlines/alloy/typescript/components/tsdoc");
|
|
16
|
-
let __powerlines_alloy_typescript_components_typescript_interface = require("@powerlines/alloy/typescript/components/typescript-interface");
|
|
17
|
-
let __powerlines_alloy_typescript_components_typescript_object = require("@powerlines/alloy/typescript/components/typescript-object");
|
|
18
18
|
|
|
19
19
|
//#region src/components/env.tsx
|
|
20
20
|
/**
|
|
@@ -22,9 +22,9 @@ let __powerlines_alloy_typescript_components_typescript_object = require("@power
|
|
|
22
22
|
*/
|
|
23
23
|
function EnvTypeDefinition(props) {
|
|
24
24
|
const [{ defaultValue, reflection }] = (0, __alloy_js_core.splitProps)(props, ["defaultValue", "reflection"]);
|
|
25
|
-
const context =
|
|
25
|
+
const context = require_context.usePowerlines();
|
|
26
26
|
return [
|
|
27
|
-
(0, __alloy_js_core_jsx_runtime.createComponent)(
|
|
27
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(require_typescript_interface.TypeScriptInterface, {
|
|
28
28
|
name: " EnvBase",
|
|
29
29
|
"extends": ["EnvInterface"],
|
|
30
30
|
defaultValue,
|
|
@@ -186,15 +186,15 @@ function ConfigPropertySet(props) {
|
|
|
186
186
|
}
|
|
187
187
|
})];
|
|
188
188
|
}
|
|
189
|
-
const createEnvRefkey =
|
|
190
|
-
const envRefkey =
|
|
191
|
-
const envSerializerRefkey =
|
|
189
|
+
const createEnvRefkey = require_refkey.refkey("createEnv");
|
|
190
|
+
const envRefkey = require_refkey.refkey("env");
|
|
191
|
+
const envSerializerRefkey = require_refkey.refkey("EnvSerializer");
|
|
192
192
|
/**
|
|
193
193
|
* Generates the environment configuration module for the Powerlines project.
|
|
194
194
|
*/
|
|
195
195
|
function EnvBuiltin(props) {
|
|
196
196
|
const [{ defaultConfig }, rest] = (0, __alloy_js_core.splitProps)(props, ["defaultConfig"]);
|
|
197
|
-
const context =
|
|
197
|
+
const context = require_context.usePowerlines();
|
|
198
198
|
const defaultValue = (0, __alloy_js_core.computed)(() => context && require_load.loadEnvFromContext(context, process.env));
|
|
199
199
|
const reflection = require_create_reflection_resource.createReflectionResource(context);
|
|
200
200
|
const envInstance = (0, __alloy_js_core.computed)(() => {
|
|
@@ -206,7 +206,7 @@ function EnvBuiltin(props) {
|
|
|
206
206
|
});
|
|
207
207
|
const reflectionGetProperties = (0, __alloy_js_core.computed)(() => reflection.data?.getProperties().filter((property) => !property.isIgnored()).sort((a, b) => a.getNameAsString().localeCompare(b.getNameAsString())) ?? []);
|
|
208
208
|
const reflectionSetProperties = (0, __alloy_js_core.computed)(() => reflection.data?.getProperties().filter((property) => !property.isIgnored() && !property.isReadonly()).sort((a, b) => a.getNameAsString().localeCompare(b.getNameAsString())) ?? []);
|
|
209
|
-
return (0, __alloy_js_core_jsx_runtime.createComponent)(
|
|
209
|
+
return (0, __alloy_js_core_jsx_runtime.createComponent)(require_builtin_file.BuiltinFile, (0, __alloy_js_core_jsx_runtime.mergeProps)(rest, {
|
|
210
210
|
id: "env",
|
|
211
211
|
description: "The Powerlines environment configuration module provides an interface to define environment configuration parameters.",
|
|
212
212
|
get imports() {
|
|
@@ -247,7 +247,7 @@ function EnvBuiltin(props) {
|
|
|
247
247
|
];
|
|
248
248
|
}
|
|
249
249
|
}),
|
|
250
|
-
(0, __alloy_js_core_jsx_runtime.createComponent)(
|
|
250
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(require_typescript_object.TypescriptObject, {
|
|
251
251
|
name: "initialEnv",
|
|
252
252
|
type: "Partial<EnvBase>",
|
|
253
253
|
defaultValue,
|
|
@@ -257,13 +257,13 @@ function EnvBuiltin(props) {
|
|
|
257
257
|
}),
|
|
258
258
|
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
259
259
|
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
260
|
-
(0, __alloy_js_core_jsx_runtime.createComponent)(
|
|
260
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(require_tsdoc.TSDoc, {
|
|
261
261
|
heading: "The environment configuration serializer for the Powerlines application.",
|
|
262
262
|
get children() {
|
|
263
263
|
return [
|
|
264
|
-
(0, __alloy_js_core_jsx_runtime.createComponent)(
|
|
265
|
-
(0, __alloy_js_core_jsx_runtime.createComponent)(
|
|
266
|
-
(0, __alloy_js_core_jsx_runtime.createComponent)(
|
|
264
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(require_tsdoc.TSDocLink, { children: `https://deepkit.io/docs/serialization/serializers` }),
|
|
265
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(require_tsdoc.TSDocLink, { children: `https://github.com/marcj/untitled-code/blob/master/packages/type/src/serializer.ts#L1918` }),
|
|
266
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(require_tsdoc.TSDocRemarks, { children: `This serializer is used to serialize and deserialize the Powerlines environment configuration.` })
|
|
267
267
|
];
|
|
268
268
|
}
|
|
269
269
|
}),
|
|
@@ -293,13 +293,13 @@ function EnvBuiltin(props) {
|
|
|
293
293
|
}),
|
|
294
294
|
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
295
295
|
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
296
|
-
(0, __alloy_js_core_jsx_runtime.createComponent)(
|
|
296
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(require_tsdoc.TSDoc, {
|
|
297
297
|
heading: "A {@link EnvSerializer | environment configuration serializer} instance for the Powerlines application.",
|
|
298
298
|
get children() {
|
|
299
299
|
return [
|
|
300
|
-
(0, __alloy_js_core_jsx_runtime.createComponent)(
|
|
301
|
-
(0, __alloy_js_core_jsx_runtime.createComponent)(
|
|
302
|
-
(0, __alloy_js_core_jsx_runtime.createComponent)(
|
|
300
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(require_tsdoc.TSDocLink, { children: `https://deepkit.io/docs/serialization/serializers` }),
|
|
301
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(require_tsdoc.TSDocLink, { children: `https://github.com/marcj/untitled-code/blob/master/packages/type/src/serializer.ts#L1918` }),
|
|
302
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(require_tsdoc.TSDocRemarks, { children: `This serializer is used to serialize and deserialize the Powerlines environment configuration.` })
|
|
303
303
|
];
|
|
304
304
|
}
|
|
305
305
|
}),
|
|
@@ -316,13 +316,13 @@ function EnvBuiltin(props) {
|
|
|
316
316
|
}),
|
|
317
317
|
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
318
318
|
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
319
|
-
(0, __alloy_js_core_jsx_runtime.createComponent)(
|
|
319
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(require_tsdoc.TSDoc, {
|
|
320
320
|
heading: "Serialize a environment configuration object to JSON data objects (not a JSON string).",
|
|
321
321
|
get children() {
|
|
322
322
|
return [
|
|
323
|
-
(0, __alloy_js_core_jsx_runtime.createComponent)(
|
|
324
|
-
(0, __alloy_js_core_jsx_runtime.createComponent)(
|
|
325
|
-
(0, __alloy_js_core_jsx_runtime.createComponent)(
|
|
323
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(require_tsdoc.TSDocRemarks, { children: `The resulting JSON object can be stringified using JSON.stringify().` }),
|
|
324
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(require_tsdoc.TSDocExample, { children: `const json = serializeEnv(env);` }),
|
|
325
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(require_tsdoc.TSDocThrows, { children: `ValidationError when serialization or validation fails.` })
|
|
326
326
|
];
|
|
327
327
|
}
|
|
328
328
|
}),
|
|
@@ -334,13 +334,13 @@ function EnvBuiltin(props) {
|
|
|
334
334
|
}),
|
|
335
335
|
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
336
336
|
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
337
|
-
(0, __alloy_js_core_jsx_runtime.createComponent)(
|
|
337
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(require_tsdoc.TSDoc, {
|
|
338
338
|
heading: "Deserialize a environment configuration object from JSON data objects to JavaScript objects, without running any validators.",
|
|
339
339
|
get children() {
|
|
340
340
|
return [
|
|
341
|
-
(0, __alloy_js_core_jsx_runtime.createComponent)(
|
|
342
|
-
(0, __alloy_js_core_jsx_runtime.createComponent)(
|
|
343
|
-
(0, __alloy_js_core_jsx_runtime.createComponent)(
|
|
341
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(require_tsdoc.TSDocRemarks, { children: `Types that are already correct will be used as-is.` }),
|
|
342
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(require_tsdoc.TSDocExample, { children: `const env = deserializeEnv(json);` }),
|
|
343
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(require_tsdoc.TSDocThrows, { children: `ValidationError when deserialization fails.` })
|
|
344
344
|
];
|
|
345
345
|
}
|
|
346
346
|
}),
|
|
@@ -352,16 +352,16 @@ function EnvBuiltin(props) {
|
|
|
352
352
|
}),
|
|
353
353
|
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
354
354
|
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
355
|
-
(0, __alloy_js_core_jsx_runtime.createComponent)(
|
|
355
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(require_tsdoc.TSDoc, {
|
|
356
356
|
heading: "Initializes the Powerlines environment configuration module.",
|
|
357
357
|
get children() {
|
|
358
358
|
return [
|
|
359
|
-
(0, __alloy_js_core_jsx_runtime.createComponent)(
|
|
360
|
-
(0, __alloy_js_core_jsx_runtime.createComponent)(
|
|
359
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(require_tsdoc.TSDocRemarks, { children: `This function initializes the Powerlines environment configuration object.` }),
|
|
360
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(require_tsdoc.TSDocParam, {
|
|
361
361
|
name: "environmentConfig",
|
|
362
362
|
children: `The dynamic/runtime configuration - this could include the current environment variables or any other environment-specific settings provided by the runtime.`
|
|
363
363
|
}),
|
|
364
|
-
(0, __alloy_js_core_jsx_runtime.createComponent)(
|
|
364
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(require_tsdoc.TSDocReturns, { children: `The initialized Powerlines configuration object.` })
|
|
365
365
|
];
|
|
366
366
|
}
|
|
367
367
|
}),
|
|
@@ -438,11 +438,7 @@ function EnvBuiltin(props) {
|
|
|
438
438
|
"export": true,
|
|
439
439
|
"const": true,
|
|
440
440
|
get initializer() {
|
|
441
|
-
return [
|
|
442
|
-
__alloy_js_core.code`createEnv(`,
|
|
443
|
-
defaultConfig || "{}",
|
|
444
|
-
__alloy_js_core.code` as Partial<Env>)`
|
|
445
|
-
];
|
|
441
|
+
return [__alloy_js_core.code`createEnv(${defaultConfig || "{}"} as Partial<Env>);`];
|
|
446
442
|
}
|
|
447
443
|
})
|
|
448
444
|
];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { BuiltinFileProps } from "../plugin-alloy/src/typescript/components/builtin-file.cjs";
|
|
2
|
+
import { TypeScriptInterfaceProps } from "../plugin-alloy/src/typescript/components/typescript-interface.cjs";
|
|
1
3
|
import { Children } from "@alloy-js/core";
|
|
2
|
-
import { BuiltinFileProps } from "@powerlines/alloy/typescript/components/builtin-file";
|
|
3
|
-
import { TypeScriptInterfaceProps } from "@powerlines/alloy/typescript/components/typescript-interface";
|
|
4
4
|
|
|
5
5
|
//#region src/components/env.d.ts
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { BuiltinFileProps } from "../plugin-alloy/src/typescript/components/builtin-file.mjs";
|
|
2
|
+
import { TypeScriptInterfaceProps } from "../plugin-alloy/src/typescript/components/typescript-interface.mjs";
|
|
1
3
|
import { Children } from "@alloy-js/core";
|
|
2
|
-
import { BuiltinFileProps } from "@powerlines/alloy/typescript/components/builtin-file";
|
|
3
|
-
import { TypeScriptInterfaceProps } from "@powerlines/alloy/typescript/components/typescript-interface";
|
|
4
4
|
|
|
5
5
|
//#region src/components/env.d.ts
|
|
6
6
|
|
package/dist/components/env.mjs
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import { type_exports } from "../deepkit/src/vendor/type.mjs";
|
|
2
|
+
import { usePowerlines } from "../plugin-alloy/src/core/contexts/context.mjs";
|
|
3
|
+
import { refkey as refkey$1 } from "../plugin-alloy/src/helpers/refkey.mjs";
|
|
4
|
+
import { TSDoc, TSDocExample, TSDocLink, TSDocParam, TSDocRemarks, TSDocReturns, TSDocThrows } from "../plugin-alloy/src/typescript/components/tsdoc.mjs";
|
|
5
|
+
import { BuiltinFile } from "../plugin-alloy/src/typescript/components/builtin-file.mjs";
|
|
6
|
+
import { TypeScriptInterface } from "../plugin-alloy/src/typescript/components/typescript-interface.mjs";
|
|
7
|
+
import { TypescriptObject } from "../plugin-alloy/src/typescript/components/typescript-object.mjs";
|
|
2
8
|
import { loadEnvFromContext } from "../helpers/load.mjs";
|
|
3
9
|
import { createReflectionResource } from "../helpers/create-reflection-resource.mjs";
|
|
4
10
|
import { createComponent, createIntrinsic, memo, mergeProps } from "@alloy-js/core/jsx-runtime";
|
|
@@ -7,12 +13,6 @@ import defu from "defu";
|
|
|
7
13
|
import { titleCase } from "@stryke/string-format/title-case";
|
|
8
14
|
import { isNull } from "@stryke/type-checks/is-null";
|
|
9
15
|
import { ClassDeclaration, ClassMethod, ElseIfClause, FunctionDeclaration, IfStatement, NewExpression, TypeDeclaration, VarDeclaration } from "@alloy-js/typescript";
|
|
10
|
-
import { usePowerlines } from "@powerlines/alloy/core/contexts/context";
|
|
11
|
-
import { refkey } from "@powerlines/alloy/helpers/refkey";
|
|
12
|
-
import { BuiltinFile } from "@powerlines/alloy/typescript/components/builtin-file";
|
|
13
|
-
import { TSDoc, TSDocExample, TSDocLink, TSDocParam, TSDocRemarks, TSDocReturns, TSDocThrows } from "@powerlines/alloy/typescript/components/tsdoc";
|
|
14
|
-
import { TypeScriptInterface } from "@powerlines/alloy/typescript/components/typescript-interface";
|
|
15
|
-
import { TypescriptObject } from "@powerlines/alloy/typescript/components/typescript-object";
|
|
16
16
|
|
|
17
17
|
//#region src/components/env.tsx
|
|
18
18
|
/**
|
|
@@ -184,9 +184,9 @@ function ConfigPropertySet(props) {
|
|
|
184
184
|
}
|
|
185
185
|
})];
|
|
186
186
|
}
|
|
187
|
-
const createEnvRefkey = refkey("createEnv");
|
|
188
|
-
const envRefkey = refkey("env");
|
|
189
|
-
const envSerializerRefkey = refkey("EnvSerializer");
|
|
187
|
+
const createEnvRefkey = refkey$1("createEnv");
|
|
188
|
+
const envRefkey = refkey$1("env");
|
|
189
|
+
const envSerializerRefkey = refkey$1("EnvSerializer");
|
|
190
190
|
/**
|
|
191
191
|
* Generates the environment configuration module for the Powerlines project.
|
|
192
192
|
*/
|
|
@@ -436,11 +436,7 @@ function EnvBuiltin(props) {
|
|
|
436
436
|
"export": true,
|
|
437
437
|
"const": true,
|
|
438
438
|
get initializer() {
|
|
439
|
-
return [
|
|
440
|
-
code`createEnv(`,
|
|
441
|
-
defaultConfig || "{}",
|
|
442
|
-
code` as Partial<Env>)`
|
|
443
|
-
];
|
|
439
|
+
return [code`createEnv(${defaultConfig || "{}"} as Partial<Env>);`];
|
|
444
440
|
}
|
|
445
441
|
})
|
|
446
442
|
];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type_d_exports } from "../deepkit/src/vendor/type.cjs";
|
|
2
2
|
import { EnvPluginContext } from "../types/plugin.cjs";
|
|
3
|
-
import * as
|
|
3
|
+
import * as _alloy_js_core3 from "@alloy-js/core";
|
|
4
4
|
|
|
5
5
|
//#region src/helpers/create-reflection-resource.d.ts
|
|
6
6
|
|
|
@@ -10,6 +10,6 @@ import * as _alloy_js_core0 from "@alloy-js/core";
|
|
|
10
10
|
* @param context - The environment plugin context.
|
|
11
11
|
* @returns A resource that provides the reflection of the environment configuration.
|
|
12
12
|
*/
|
|
13
|
-
declare function createReflectionResource(context?: EnvPluginContext):
|
|
13
|
+
declare function createReflectionResource(context?: EnvPluginContext): _alloy_js_core3.Resource<type_d_exports.ReflectionClass<Record<string, any>>>;
|
|
14
14
|
//#endregion
|
|
15
15
|
export { createReflectionResource };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type_d_exports } from "../deepkit/src/vendor/type.mjs";
|
|
2
2
|
import { EnvPluginContext } from "../types/plugin.mjs";
|
|
3
|
-
import * as
|
|
3
|
+
import * as _alloy_js_core4 from "@alloy-js/core";
|
|
4
4
|
|
|
5
5
|
//#region src/helpers/create-reflection-resource.d.ts
|
|
6
6
|
|
|
@@ -10,6 +10,6 @@ import * as _alloy_js_core0 from "@alloy-js/core";
|
|
|
10
10
|
* @param context - The environment plugin context.
|
|
11
11
|
* @returns A resource that provides the reflection of the environment configuration.
|
|
12
12
|
*/
|
|
13
|
-
declare function createReflectionResource(context?: EnvPluginContext):
|
|
13
|
+
declare function createReflectionResource(context?: EnvPluginContext): _alloy_js_core4.Resource<type_d_exports.ReflectionClass<Record<string, any>>>;
|
|
14
14
|
//#endregion
|
|
15
15
|
export { createReflectionResource };
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { EnvDocs } from "./components/docs.cjs";
|
|
2
|
-
import { EnvBuiltin, EnvBuiltinProps, EnvTypeDefinition, __ΩEnvBuiltinProps } from "./components/env.cjs";
|
|
3
2
|
import { Plugin } from "./powerlines/src/types/plugin.cjs";
|
|
3
|
+
import { EnvBuiltin, EnvBuiltinProps, EnvTypeDefinition, __ΩEnvBuiltinProps } from "./components/env.cjs";
|
|
4
4
|
import { EnvInterface, SecretsInterface, __ΩEnvInterface, __ΩSecretsInterface } from "./types/runtime.cjs";
|
|
5
5
|
import { EnvPluginContext, EnvPluginOptions, EnvPluginResolvedConfig, EnvPluginUserConfig, EnvType, __ΩEnvPluginContext, __ΩEnvPluginOptions, __ΩEnvPluginResolvedConfig, __ΩEnvPluginUserConfig, __ΩEnvType } from "./types/plugin.cjs";
|
|
6
6
|
import { envBabelPlugin } from "./babel/plugin.cjs";
|
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { EnvDocs } from "./components/docs.mjs";
|
|
2
|
+
import { Plugin } from "./powerlines/src/types/plugin.mjs";
|
|
2
3
|
import { EnvBuiltin, EnvBuiltinProps, EnvTypeDefinition, __ΩEnvBuiltinProps } from "./components/env.mjs";
|
|
3
4
|
import "./components/index.mjs";
|
|
4
|
-
import { Plugin } from "./powerlines/src/types/plugin.mjs";
|
|
5
5
|
import "./powerlines/src/index.mjs";
|
|
6
6
|
import { EnvInterface, SecretsInterface, __ΩEnvInterface, __ΩSecretsInterface } from "./types/runtime.mjs";
|
|
7
7
|
import { EnvPluginContext, EnvPluginOptions, EnvPluginResolvedConfig, EnvPluginUserConfig, EnvType, __ΩEnvPluginContext, __ΩEnvPluginOptions, __ΩEnvPluginResolvedConfig, __ΩEnvPluginUserConfig, __ΩEnvType } from "./types/plugin.mjs";
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../../../../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
let __alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
|
|
3
|
+
let __alloy_js_core = require("@alloy-js/core");
|
|
4
|
+
|
|
5
|
+
//#region ../plugin-alloy/src/core/components/single-line-comment.tsx
|
|
6
|
+
/**
|
|
7
|
+
* A single line comment block. The children are rendered as a prose element, which means that they
|
|
8
|
+
* are broken into multiple lines
|
|
9
|
+
*/
|
|
10
|
+
function SingleLineComment(props) {
|
|
11
|
+
const { variant = "double-slash", children } = props;
|
|
12
|
+
const commentStart = variant === "slash-star" ? "/* " : variant === "slash-star-star" ? "/** " : variant === "triple-slash" ? "/// " : variant === "markdown" ? "<!-- " : "// ";
|
|
13
|
+
return [commentStart, (0, __alloy_js_core_jsx_runtime.createIntrinsic)("align", {
|
|
14
|
+
string: commentStart,
|
|
15
|
+
get children() {
|
|
16
|
+
return [(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Prose, { children }), variant === "slash-star" || variant === "slash-star-star" ? " */ " : variant === "markdown" ? " -->" : ""];
|
|
17
|
+
}
|
|
18
|
+
})];
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
//#endregion
|
|
22
|
+
exports.SingleLineComment = SingleLineComment;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { createComponent, createIntrinsic } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
import { Prose } from "@alloy-js/core";
|
|
3
|
+
|
|
4
|
+
//#region ../plugin-alloy/src/core/components/single-line-comment.tsx
|
|
5
|
+
/**
|
|
6
|
+
* A single line comment block. The children are rendered as a prose element, which means that they
|
|
7
|
+
* are broken into multiple lines
|
|
8
|
+
*/
|
|
9
|
+
function SingleLineComment(props) {
|
|
10
|
+
const { variant = "double-slash", children } = props;
|
|
11
|
+
const commentStart = variant === "slash-star" ? "/* " : variant === "slash-star-star" ? "/** " : variant === "triple-slash" ? "/// " : variant === "markdown" ? "<!-- " : "// ";
|
|
12
|
+
return [commentStart, createIntrinsic("align", {
|
|
13
|
+
string: commentStart,
|
|
14
|
+
get children() {
|
|
15
|
+
return [createComponent(Prose, { children }), variant === "slash-star" || variant === "slash-star-star" ? " */ " : variant === "markdown" ? " -->" : ""];
|
|
16
|
+
}
|
|
17
|
+
})];
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
//#endregion
|
|
21
|
+
export { SingleLineComment };
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../../../../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_context = require('../contexts/context.cjs');
|
|
3
|
+
require('../contexts/index.cjs');
|
|
4
|
+
let __alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
|
|
5
|
+
let __alloy_js_core = require("@alloy-js/core");
|
|
6
|
+
let __stryke_path_append = require("@stryke/path/append");
|
|
7
|
+
let defu = require("defu");
|
|
8
|
+
defu = require_rolldown_runtime.__toESM(defu);
|
|
9
|
+
|
|
10
|
+
//#region ../plugin-alloy/src/core/components/source-file.tsx
|
|
11
|
+
/**
|
|
12
|
+
* A base component representing a Powerlines generated source file.
|
|
13
|
+
*
|
|
14
|
+
* @param props - The properties for the source file.
|
|
15
|
+
* @returns The rendered source file component.
|
|
16
|
+
*/
|
|
17
|
+
function SourceFile(props) {
|
|
18
|
+
const [{ children, meta, path, header, storage, filetype, reference }] = (0, __alloy_js_core.splitProps)(props, [
|
|
19
|
+
"children",
|
|
20
|
+
"meta",
|
|
21
|
+
"path",
|
|
22
|
+
"header",
|
|
23
|
+
"storage",
|
|
24
|
+
"filetype",
|
|
25
|
+
"reference"
|
|
26
|
+
]);
|
|
27
|
+
const metadata = require_context.useMeta();
|
|
28
|
+
const parentDirectory = (0, __alloy_js_core.useContext)(__alloy_js_core.SourceDirectoryContext);
|
|
29
|
+
const sourceFile = {
|
|
30
|
+
path: (0, __stryke_path_append.appendPath)(path, parentDirectory.path),
|
|
31
|
+
filetype,
|
|
32
|
+
reference
|
|
33
|
+
};
|
|
34
|
+
parentDirectory?.addContent(sourceFile);
|
|
35
|
+
const printOptions = (0, __alloy_js_core.useFormatOptions)({
|
|
36
|
+
printWidth: props.printWidth,
|
|
37
|
+
tabWidth: props.tabWidth,
|
|
38
|
+
useTabs: props.useTabs,
|
|
39
|
+
insertFinalNewLine: props.insertFinalNewLine
|
|
40
|
+
});
|
|
41
|
+
const nodeContext = (0, __alloy_js_core.getContext)();
|
|
42
|
+
nodeContext.meta = (0, defu.default)({
|
|
43
|
+
sourceFile,
|
|
44
|
+
printOptions
|
|
45
|
+
}, meta ?? {});
|
|
46
|
+
metadata[sourceFile.path] = {
|
|
47
|
+
storage,
|
|
48
|
+
...meta ?? {}
|
|
49
|
+
};
|
|
50
|
+
return (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.SourceFileContext.Provider, {
|
|
51
|
+
value: sourceFile,
|
|
52
|
+
get children() {
|
|
53
|
+
return [(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
|
|
54
|
+
when: header !== void 0,
|
|
55
|
+
get children() {
|
|
56
|
+
return [header, (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {})];
|
|
57
|
+
}
|
|
58
|
+
}), children];
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
//#endregion
|
|
64
|
+
exports.SourceFile = SourceFile;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { StoragePreset } from "../../../../powerlines/src/types/fs.cjs";
|
|
2
|
+
import { ComponentProps } from "../../types/components.cjs";
|
|
3
|
+
import { SourceFileProps } from "@alloy-js/core";
|
|
4
|
+
|
|
5
|
+
//#region ../plugin-alloy/src/core/components/source-file.d.ts
|
|
6
|
+
type SourceFileProps$1 = SourceFileProps & ComponentProps & {
|
|
7
|
+
/**
|
|
8
|
+
* The storage preset for the output files.
|
|
9
|
+
*
|
|
10
|
+
* @remarks
|
|
11
|
+
* If not specified, the output mode will be determined by the provided `output.mode` value.
|
|
12
|
+
*/
|
|
13
|
+
storage?: StoragePreset;
|
|
14
|
+
/**
|
|
15
|
+
* The metadata associated with the source file.
|
|
16
|
+
*
|
|
17
|
+
* @remarks
|
|
18
|
+
* The values stored in the metadata will be available in the rendering context.
|
|
19
|
+
*/
|
|
20
|
+
meta?: Record<string, any>;
|
|
21
|
+
};
|
|
22
|
+
//#endregion
|
|
23
|
+
export { SourceFileProps$1 as SourceFileProps };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { StoragePreset } from "../../../../powerlines/src/types/fs.mjs";
|
|
2
|
+
import { ComponentProps } from "../../types/components.mjs";
|
|
3
|
+
import { SourceFileProps } from "@alloy-js/core";
|
|
4
|
+
|
|
5
|
+
//#region ../plugin-alloy/src/core/components/source-file.d.ts
|
|
6
|
+
type SourceFileProps$1 = SourceFileProps & ComponentProps & {
|
|
7
|
+
/**
|
|
8
|
+
* The storage preset for the output files.
|
|
9
|
+
*
|
|
10
|
+
* @remarks
|
|
11
|
+
* If not specified, the output mode will be determined by the provided `output.mode` value.
|
|
12
|
+
*/
|
|
13
|
+
storage?: StoragePreset;
|
|
14
|
+
/**
|
|
15
|
+
* The metadata associated with the source file.
|
|
16
|
+
*
|
|
17
|
+
* @remarks
|
|
18
|
+
* The values stored in the metadata will be available in the rendering context.
|
|
19
|
+
*/
|
|
20
|
+
meta?: Record<string, any>;
|
|
21
|
+
};
|
|
22
|
+
//#endregion
|
|
23
|
+
export { SourceFileProps$1 as SourceFileProps };
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { useMeta } from "../contexts/context.mjs";
|
|
2
|
+
import "../contexts/index.mjs";
|
|
3
|
+
import { createComponent, createIntrinsic } from "@alloy-js/core/jsx-runtime";
|
|
4
|
+
import { Show, SourceDirectoryContext, SourceFileContext, getContext, splitProps, useContext, useFormatOptions } from "@alloy-js/core";
|
|
5
|
+
import { appendPath } from "@stryke/path/append";
|
|
6
|
+
import defu from "defu";
|
|
7
|
+
|
|
8
|
+
//#region ../plugin-alloy/src/core/components/source-file.tsx
|
|
9
|
+
/**
|
|
10
|
+
* A base component representing a Powerlines generated source file.
|
|
11
|
+
*
|
|
12
|
+
* @param props - The properties for the source file.
|
|
13
|
+
* @returns The rendered source file component.
|
|
14
|
+
*/
|
|
15
|
+
function SourceFile(props) {
|
|
16
|
+
const [{ children, meta, path, header, storage, filetype, reference }] = splitProps(props, [
|
|
17
|
+
"children",
|
|
18
|
+
"meta",
|
|
19
|
+
"path",
|
|
20
|
+
"header",
|
|
21
|
+
"storage",
|
|
22
|
+
"filetype",
|
|
23
|
+
"reference"
|
|
24
|
+
]);
|
|
25
|
+
const metadata = useMeta();
|
|
26
|
+
const parentDirectory = useContext(SourceDirectoryContext);
|
|
27
|
+
const sourceFile = {
|
|
28
|
+
path: appendPath(path, parentDirectory.path),
|
|
29
|
+
filetype,
|
|
30
|
+
reference
|
|
31
|
+
};
|
|
32
|
+
parentDirectory?.addContent(sourceFile);
|
|
33
|
+
const printOptions = useFormatOptions({
|
|
34
|
+
printWidth: props.printWidth,
|
|
35
|
+
tabWidth: props.tabWidth,
|
|
36
|
+
useTabs: props.useTabs,
|
|
37
|
+
insertFinalNewLine: props.insertFinalNewLine
|
|
38
|
+
});
|
|
39
|
+
const nodeContext = getContext();
|
|
40
|
+
nodeContext.meta = defu({
|
|
41
|
+
sourceFile,
|
|
42
|
+
printOptions
|
|
43
|
+
}, meta ?? {});
|
|
44
|
+
metadata[sourceFile.path] = {
|
|
45
|
+
storage,
|
|
46
|
+
...meta ?? {}
|
|
47
|
+
};
|
|
48
|
+
return createComponent(SourceFileContext.Provider, {
|
|
49
|
+
value: sourceFile,
|
|
50
|
+
get children() {
|
|
51
|
+
return [createComponent(Show, {
|
|
52
|
+
when: header !== void 0,
|
|
53
|
+
get children() {
|
|
54
|
+
return [header, createIntrinsic("hbr", {})];
|
|
55
|
+
}
|
|
56
|
+
}), children];
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
//#endregion
|
|
62
|
+
export { SourceFile };
|
|
@@ -6,6 +6,55 @@ let __alloy_js_core = require("@alloy-js/core");
|
|
|
6
6
|
* The Powerlines context used in template rendering.
|
|
7
7
|
*/
|
|
8
8
|
const PowerlinesContext = (0, __alloy_js_core.createNamedContext)("powerlines");
|
|
9
|
+
/**
|
|
10
|
+
* Hook to access the Powerlines Context.
|
|
11
|
+
*
|
|
12
|
+
* @returns The Context.
|
|
13
|
+
*/
|
|
14
|
+
function usePowerlinesContext() {
|
|
15
|
+
return (0, __alloy_js_core.useContext)(PowerlinesContext);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Hook to safely access the {@link PluginContext | Powerlines context}.
|
|
19
|
+
*
|
|
20
|
+
* @returns The Powerlines context or undefined if not set.
|
|
21
|
+
*/
|
|
22
|
+
function usePowerlinesSafe() {
|
|
23
|
+
return usePowerlinesContext()?.ref?.value;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Hook to access the {@link PluginContext | Powerlines context}.
|
|
27
|
+
*
|
|
28
|
+
* @returns The Powerlines context.
|
|
29
|
+
*/
|
|
30
|
+
function usePowerlines() {
|
|
31
|
+
const powerlines = usePowerlinesSafe();
|
|
32
|
+
if (!powerlines) throw new Error("Powerlines - Context is not set. Please make sure the Alloy components are being provided to an invocation of the `render` function added to plugins by `@powerlines/plugin-alloy`.");
|
|
33
|
+
return powerlines;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Hook to safely access the render context's metadata.
|
|
37
|
+
*
|
|
38
|
+
* @returns The Powerlines context or undefined if not set.
|
|
39
|
+
*/
|
|
40
|
+
function useMetaSafe() {
|
|
41
|
+
return usePowerlinesContext()?.meta?.value;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Hook to access the render context's metadata.
|
|
45
|
+
*
|
|
46
|
+
* @returns The Powerlines context.
|
|
47
|
+
*/
|
|
48
|
+
function useMeta() {
|
|
49
|
+
const meta = useMetaSafe();
|
|
50
|
+
if (!meta) throw new Error("Powerlines metadata is not available in the rendering context. Please make sure the Alloy components are being provided to an invocation of the `render` function added to plugins by `@powerlines/plugin-alloy`.");
|
|
51
|
+
return meta;
|
|
52
|
+
}
|
|
9
53
|
|
|
10
54
|
//#endregion
|
|
11
|
-
exports.PowerlinesContext = PowerlinesContext;
|
|
55
|
+
exports.PowerlinesContext = PowerlinesContext;
|
|
56
|
+
exports.useMeta = useMeta;
|
|
57
|
+
exports.useMetaSafe = useMetaSafe;
|
|
58
|
+
exports.usePowerlines = usePowerlines;
|
|
59
|
+
exports.usePowerlinesContext = usePowerlinesContext;
|
|
60
|
+
exports.usePowerlinesSafe = usePowerlinesSafe;
|