@alloy-js/typescript 0.10.0 → 0.12.0
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/CHANGELOG.md +28 -0
- package/dist/src/builtins/node.js +1 -2
- package/dist/src/components/ArrayExpression.js +2 -5
- package/dist/src/components/ArrowFunction.d.ts +40 -0
- package/dist/src/components/ArrowFunction.d.ts.map +1 -0
- package/dist/src/components/ArrowFunction.js +67 -0
- package/dist/src/components/BarrelFile.js +1 -2
- package/dist/src/components/BlockScope.js +2 -4
- package/dist/src/components/CallSignature.js +2 -4
- package/dist/src/components/ClassDeclaration.d.ts +2 -0
- package/dist/src/components/ClassDeclaration.d.ts.map +1 -1
- package/dist/src/components/ClassDeclaration.js +16 -8
- package/dist/src/components/CommaList.js +2 -5
- package/dist/src/components/Declaration.js +3 -5
- package/dist/src/components/EnumDeclaration.js +2 -5
- package/dist/src/components/EnumMember.js +2 -4
- package/dist/src/components/ExportStatement.js +1 -2
- package/dist/src/components/FunctionBase.d.ts +60 -0
- package/dist/src/components/FunctionBase.d.ts.map +1 -0
- package/dist/src/components/FunctionBase.js +217 -0
- package/dist/src/components/FunctionCallExpression.js +2 -5
- package/dist/src/components/FunctionDeclaration.d.ts +3 -18
- package/dist/src/components/FunctionDeclaration.d.ts.map +1 -1
- package/dist/src/components/FunctionDeclaration.js +9 -157
- package/dist/src/components/FunctionExpression.d.ts +39 -0
- package/dist/src/components/FunctionExpression.d.ts.map +1 -0
- package/dist/src/components/FunctionExpression.js +66 -0
- package/dist/src/components/FunctionType.d.ts +38 -0
- package/dist/src/components/FunctionType.d.ts.map +1 -0
- package/dist/src/components/FunctionType.js +77 -0
- package/dist/src/components/IfStatement.js +2 -4
- package/dist/src/components/ImportStatement.d.ts.map +1 -1
- package/dist/src/components/ImportStatement.js +10 -4
- package/dist/src/components/Interface.d.ts +3 -2
- package/dist/src/components/Interface.d.ts.map +1 -1
- package/dist/src/components/Interface.js +40 -15
- package/dist/src/components/InterfaceMethod.d.ts +43 -0
- package/dist/src/components/InterfaceMethod.d.ts.map +1 -0
- package/dist/src/components/InterfaceMethod.js +87 -0
- package/dist/src/components/JSDoc.js +1 -2
- package/dist/src/components/JSDocComment.js +3 -5
- package/dist/src/components/JSDocExample.js +2 -5
- package/dist/src/components/JSDocParam.js +2 -5
- package/dist/src/components/MemberChainExpression.js +2 -4
- package/dist/src/components/MemberDeclaration.d.ts +34 -0
- package/dist/src/components/MemberDeclaration.d.ts.map +1 -0
- package/dist/src/components/MemberDeclaration.js +29 -0
- package/dist/src/components/MemberExpression.d.ts.map +1 -1
- package/dist/src/components/MemberExpression.js +5 -7
- package/dist/src/components/ObjectExpression.js +2 -5
- package/dist/src/components/PackageDirectory.js +2 -5
- package/dist/src/components/PackageJson.js +1 -2
- package/dist/src/components/PropertyName.js +1 -2
- package/dist/src/components/Reference.d.ts +8 -1
- package/dist/src/components/Reference.d.ts.map +1 -1
- package/dist/src/components/Reference.js +8 -4
- package/dist/src/components/SingleLineCommentBlock.js +2 -4
- package/dist/src/components/SourceFile.js +2 -4
- package/dist/src/components/SwitchStatement.js +2 -5
- package/dist/src/components/TsConfigJson.js +1 -2
- package/dist/src/components/TypeDeclaration.d.ts +1 -1
- package/dist/src/components/TypeDeclaration.d.ts.map +1 -1
- package/dist/src/components/TypeDeclaration.js +4 -7
- package/dist/src/components/TypeRefContext.d.ts +22 -0
- package/dist/src/components/TypeRefContext.d.ts.map +1 -0
- package/dist/src/components/TypeRefContext.js +41 -0
- package/dist/src/components/ValueExpression.js +1 -2
- package/dist/src/components/VarDeclaration.d.ts +1 -0
- package/dist/src/components/VarDeclaration.d.ts.map +1 -1
- package/dist/src/components/VarDeclaration.js +11 -8
- package/dist/src/components/index.d.ts +7 -0
- package/dist/src/components/index.d.ts.map +1 -1
- package/dist/src/components/index.js +7 -1
- package/dist/src/components/stc/index.d.ts +8 -0
- package/dist/src/components/stc/index.d.ts.map +1 -1
- package/dist/src/components/stc/index.js +9 -2
- package/dist/src/context/private-scope.js +1 -2
- package/dist/src/context/type-ref-context.d.ts +15 -0
- package/dist/src/context/type-ref-context.d.ts.map +1 -0
- package/dist/src/context/type-ref-context.js +12 -0
- package/dist/src/create-package.js +1 -2
- package/dist/src/index.js +1 -2
- package/dist/src/name-conflict-resolver.js +1 -2
- package/dist/src/name-policy.js +1 -2
- package/dist/src/parameter-descriptor.d.ts +33 -17
- package/dist/src/parameter-descriptor.d.ts.map +1 -1
- package/dist/src/source-directory-data.js +1 -2
- package/dist/src/symbols/index.js +1 -2
- package/dist/src/symbols/reference.d.ts +4 -1
- package/dist/src/symbols/reference.d.ts.map +1 -1
- package/dist/src/symbols/reference.js +13 -8
- package/dist/src/symbols/scopes.js +1 -2
- package/dist/src/symbols/ts-member-scope.js +1 -2
- package/dist/src/symbols/ts-module-scope.d.ts +4 -1
- package/dist/src/symbols/ts-module-scope.d.ts.map +1 -1
- package/dist/src/symbols/ts-module-scope.js +11 -5
- package/dist/src/symbols/ts-output-symbol.d.ts +2 -1
- package/dist/src/symbols/ts-output-symbol.d.ts.map +1 -1
- package/dist/src/symbols/ts-output-symbol.js +2 -2
- package/dist/src/symbols/ts-package-scope.js +1 -2
- package/dist/src/utils.js +1 -2
- package/dist/test/array.test.js +105 -0
- package/dist/test/arrow-function.test.d.ts +2 -0
- package/dist/test/arrow-function.test.d.ts.map +1 -0
- package/dist/test/arrow-function.test.js +194 -0
- package/dist/test/barrel.test.js +53 -0
- package/dist/test/basic.test.js +91 -0
- package/dist/test/block-scope.test.js +30 -0
- package/dist/test/class.test.js +438 -0
- package/dist/test/enum-jsdoc.test.js +88 -0
- package/dist/test/enum.test.js +247 -0
- package/dist/test/externals.test.js +145 -0
- package/dist/test/function-call-expression.test.js +87 -0
- package/dist/test/function-declaration-jsdoc.test.js +91 -0
- package/dist/test/function-declaration.test.js +228 -0
- package/dist/test/function-expression.test.d.ts +2 -0
- package/dist/test/function-expression.test.d.ts.map +1 -0
- package/dist/test/function-expression.test.js +194 -0
- package/dist/test/function-type.test.d.ts +2 -0
- package/dist/test/function-type.test.d.ts.map +1 -0
- package/dist/test/function-type.test.js +122 -0
- package/dist/test/if-statement.test.js +25 -0
- package/dist/test/imports.test.d.ts.map +1 -1
- package/dist/test/imports.test.js +640 -0
- package/dist/test/interface-jsdoc.test.js +178 -0
- package/dist/test/interface.test.d.ts.map +1 -1
- package/dist/test/interface.test.js +490 -0
- package/dist/test/jscomment.test.js +70 -0
- package/dist/test/jsdoc.test.js +134 -0
- package/dist/test/jsdocparam.test.js +164 -0
- package/dist/test/member-chain.test.js +141 -0
- package/dist/test/member-expression.test.js +575 -0
- package/dist/test/name-conflict.test.js +108 -0
- package/dist/test/name-policy.test.js +122 -0
- package/dist/test/package-external.test.js +196 -0
- package/dist/test/package-json.test.js +93 -0
- package/dist/test/package.test.js +136 -0
- package/dist/test/reference.test.js +81 -0
- package/dist/test/source-file.test.js +36 -0
- package/dist/test/switch-statement.test.js +61 -0
- package/dist/test/utils.js +45 -0
- package/dist/test/value-expression.test.js +30 -0
- package/dist/test/values.test.js +351 -0
- package/dist/test/var-declaration-jsdoc.test.js +50 -0
- package/dist/test/var-declaration.test.js +63 -0
- package/dist/test/vitest.d.js +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +13 -18
- package/src/components/ArrowFunction.tsx +87 -0
- package/src/components/ClassDeclaration.tsx +19 -3
- package/src/components/Declaration.tsx +1 -1
- package/src/components/FunctionBase.tsx +282 -0
- package/src/components/FunctionDeclaration.tsx +13 -195
- package/src/components/FunctionExpression.tsx +86 -0
- package/src/components/FunctionType.tsx +93 -0
- package/src/components/ImportStatement.tsx +30 -3
- package/src/components/Interface.tsx +58 -23
- package/src/components/InterfaceMethod.tsx +96 -0
- package/src/components/JSDocComment.tsx +1 -1
- package/src/components/MemberDeclaration.tsx +76 -0
- package/src/components/MemberExpression.tsx +7 -2
- package/src/components/Reference.tsx +12 -2
- package/src/components/TypeDeclaration.tsx +16 -13
- package/src/components/TypeRefContext.tsx +49 -0
- package/src/components/VarDeclaration.tsx +6 -2
- package/src/components/index.ts +11 -0
- package/src/components/stc/index.ts +8 -0
- package/src/context/type-ref-context.tsx +19 -0
- package/src/parameter-descriptor.ts +35 -17
- package/src/symbols/reference.ts +21 -6
- package/src/symbols/ts-module-scope.ts +19 -4
- package/src/symbols/ts-output-symbol.ts +1 -0
- package/temp/api.json +4999 -2681
- package/test/arrow-function.test.tsx +188 -0
- package/test/class.test.tsx +5 -6
- package/test/enum-jsdoc.test.tsx +6 -6
- package/test/function-call-expression.test.tsx +1 -2
- package/test/function-declaration-jsdoc.test.tsx +3 -3
- package/test/function-declaration.test.tsx +1 -2
- package/test/function-expression.test.tsx +195 -0
- package/test/function-type.test.tsx +118 -0
- package/test/imports.test.tsx +165 -1
- package/test/interface-jsdoc.test.tsx +9 -9
- package/test/interface.test.tsx +256 -6
- package/test/jsdoc.test.tsx +5 -5
- package/test/jsdocparam.test.tsx +8 -8
- package/test/member-expression.test.tsx +171 -2
- package/test/var-declaration-jsdoc.test.tsx +3 -3
- package/test/var-declaration.test.tsx +1 -1
- package/tsdoc-metadata.json +1 -1
- package/babel.config.cjs +0 -4
- package/dist/src/builtins/index.js.map +0 -1
- package/dist/src/builtins/node.js.map +0 -1
- package/dist/src/components/ArrayExpression.js.map +0 -1
- package/dist/src/components/BarrelFile.js.map +0 -1
- package/dist/src/components/BlockScope.js.map +0 -1
- package/dist/src/components/CallSignature.js.map +0 -1
- package/dist/src/components/ClassDeclaration.js.map +0 -1
- package/dist/src/components/CommaList.js.map +0 -1
- package/dist/src/components/Declaration.js.map +0 -1
- package/dist/src/components/EnumDeclaration.js.map +0 -1
- package/dist/src/components/EnumMember.js.map +0 -1
- package/dist/src/components/ExportStatement.js.map +0 -1
- package/dist/src/components/FunctionCallExpression.js.map +0 -1
- package/dist/src/components/FunctionDeclaration.js.map +0 -1
- package/dist/src/components/IfStatement.js.map +0 -1
- package/dist/src/components/ImportStatement.js.map +0 -1
- package/dist/src/components/Interface.js.map +0 -1
- package/dist/src/components/JSDoc.js.map +0 -1
- package/dist/src/components/JSDocComment.js.map +0 -1
- package/dist/src/components/JSDocExample.js.map +0 -1
- package/dist/src/components/JSDocParam.js.map +0 -1
- package/dist/src/components/MemberChainExpression.js.map +0 -1
- package/dist/src/components/MemberExpression.js.map +0 -1
- package/dist/src/components/ObjectExpression.js.map +0 -1
- package/dist/src/components/PackageDirectory.js.map +0 -1
- package/dist/src/components/PackageJson.js.map +0 -1
- package/dist/src/components/PropertyName.js.map +0 -1
- package/dist/src/components/Reference.js.map +0 -1
- package/dist/src/components/SingleLineCommentBlock.js.map +0 -1
- package/dist/src/components/SourceFile.js.map +0 -1
- package/dist/src/components/SwitchStatement.js.map +0 -1
- package/dist/src/components/TsConfigJson.js.map +0 -1
- package/dist/src/components/TypeDeclaration.js.map +0 -1
- package/dist/src/components/ValueExpression.js.map +0 -1
- package/dist/src/components/VarDeclaration.js.map +0 -1
- package/dist/src/components/index.js.map +0 -1
- package/dist/src/components/stc/index.js.map +0 -1
- package/dist/src/context/index.js.map +0 -1
- package/dist/src/context/private-scope.js.map +0 -1
- package/dist/src/create-package.js.map +0 -1
- package/dist/src/index.js.map +0 -1
- package/dist/src/name-conflict-resolver.js.map +0 -1
- package/dist/src/name-policy.js.map +0 -1
- package/dist/src/parameter-descriptor.js.map +0 -1
- package/dist/src/source-directory-data.js.map +0 -1
- package/dist/src/symbols/index.js.map +0 -1
- package/dist/src/symbols/reference.js.map +0 -1
- package/dist/src/symbols/scopes.js.map +0 -1
- package/dist/src/symbols/ts-member-scope.js.map +0 -1
- package/dist/src/symbols/ts-module-scope.js.map +0 -1
- package/dist/src/symbols/ts-output-symbol.js.map +0 -1
- package/dist/src/symbols/ts-package-scope.js.map +0 -1
- package/dist/src/utils.js.map +0 -1
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Refkey } from "@alloy-js/core";
|
|
2
|
+
import { Children } from "@alloy-js/core/jsx-runtime";
|
|
3
|
+
import { CallSignatureProps } from "./CallSignature.jsx";
|
|
4
|
+
/** Props for {@link (InterfaceMethod:namespace)} component */
|
|
5
|
+
export interface InterfaceMethodProps extends CallSignatureProps {
|
|
6
|
+
/** Interface member name */
|
|
7
|
+
readonly name: string;
|
|
8
|
+
/** If the method is async. It will change the returnType from `T` to `Promise<T>` */
|
|
9
|
+
readonly async?: boolean;
|
|
10
|
+
/** Documentation for this method. */
|
|
11
|
+
readonly doc?: Children;
|
|
12
|
+
/** Jsx content */
|
|
13
|
+
readonly children?: Children;
|
|
14
|
+
/** Ref key for the member declaration */
|
|
15
|
+
readonly refkey?: Refkey | Refkey[];
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* An interface method declaration.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```ts
|
|
22
|
+
* (foo: string, bar: number) => void
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* @remarks
|
|
26
|
+
*
|
|
27
|
+
* Providing parameters and type parameters can be accomplished in one of three
|
|
28
|
+
* ways:
|
|
29
|
+
*
|
|
30
|
+
* 1. As an array of {@link TypeParameterDescriptor}s or
|
|
31
|
+
* {@link TypeParameterDescriptor}s.
|
|
32
|
+
* 2. As raw content via the `parametersChildren` or `typeParametersChildren`
|
|
33
|
+
* props.
|
|
34
|
+
* 3. As a child of this component via the
|
|
35
|
+
* {@link (InterfaceMethod:namespace).Parameters} or
|
|
36
|
+
* {@link (InterfaceMethod:namespace).TypeParameters} components.
|
|
37
|
+
*/
|
|
38
|
+
export declare function InterfaceMethod(props: InterfaceMethodProps): Children;
|
|
39
|
+
export declare namespace InterfaceMethod {
|
|
40
|
+
var TypeParameters: import("@alloy-js/core").Component<import("./FunctionBase.jsx").TypeParametersProps> & Required<Pick<import("@alloy-js/core").Component<import("./FunctionBase.jsx").TypeParametersProps>, "tag">>;
|
|
41
|
+
var Parameters: import("@alloy-js/core").Component<import("./FunctionBase.jsx").FunctionTypeParametersProps> & Required<Pick<import("@alloy-js/core").Component<import("./FunctionBase.jsx").FunctionTypeParametersProps>, "tag">>;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=InterfaceMethod.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InterfaceMethod.d.ts","sourceRoot":"","sources":["../../../src/components/InterfaceMethod.tsx"],"names":[],"mappings":"AAAA,OAAO,EAKL,MAAM,EAGP,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAGtD,OAAO,EAAiB,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAUxE,8DAA8D;AAC9D,MAAM,WAAW,oBAAqB,SAAQ,kBAAkB;IAC9D,4BAA4B;IAC5B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,qFAAqF;IACrF,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;IACzB,qCAAqC;IACrC,QAAQ,CAAC,GAAG,CAAC,EAAE,QAAQ,CAAC;IACxB,kBAAkB;IAClB,QAAQ,CAAC,QAAQ,CAAC,EAAE,QAAQ,CAAC;IAC7B,yCAAyC;IACzC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;CACrC;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,YAmC1D;yBAnCe,eAAe"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { memo as _$memo, createComponent as _$createComponent, createIntrinsic as _$createIntrinsic, mergeProps as _$mergeProps } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
import { childrenArray, findKeyedChild, MemberDeclaration, Prose, Scope, Show } from "@alloy-js/core";
|
|
3
|
+
import { useTSNamePolicy } from "../name-policy.js";
|
|
4
|
+
import { getCallSignatureProps } from "../utils.js";
|
|
5
|
+
import { CallSignature } from "./CallSignature.js";
|
|
6
|
+
import { FunctionParameters, FunctionTypeParameters, getReturnType, TypeParameters } from "./FunctionBase.js";
|
|
7
|
+
import { JSDoc } from "./JSDoc.js";
|
|
8
|
+
import { JSDocParams } from "./JSDocParam.js";
|
|
9
|
+
|
|
10
|
+
/** Props for {@link (InterfaceMethod:namespace)} component */
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* An interface method declaration.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* (foo: string, bar: number) => void
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* @remarks
|
|
21
|
+
*
|
|
22
|
+
* Providing parameters and type parameters can be accomplished in one of three
|
|
23
|
+
* ways:
|
|
24
|
+
*
|
|
25
|
+
* 1. As an array of {@link TypeParameterDescriptor}s or
|
|
26
|
+
* {@link TypeParameterDescriptor}s.
|
|
27
|
+
* 2. As raw content via the `parametersChildren` or `typeParametersChildren`
|
|
28
|
+
* props.
|
|
29
|
+
* 3. As a child of this component via the
|
|
30
|
+
* {@link (InterfaceMethod:namespace).Parameters} or
|
|
31
|
+
* {@link (InterfaceMethod:namespace).TypeParameters} components.
|
|
32
|
+
*/
|
|
33
|
+
export function InterfaceMethod(props) {
|
|
34
|
+
const children = childrenArray(() => props.children);
|
|
35
|
+
const typeParametersChildren = findKeyedChild(children, TypeParameters.tag) ?? undefined;
|
|
36
|
+
const parametersChildren = findKeyedChild(children, FunctionParameters.tag) ?? undefined;
|
|
37
|
+
const returnType = getReturnType(props.returnType ?? "void", {
|
|
38
|
+
async: props.async
|
|
39
|
+
});
|
|
40
|
+
const callSignatureProps = getCallSignatureProps(props, {
|
|
41
|
+
parametersChildren,
|
|
42
|
+
typeParametersChildren
|
|
43
|
+
});
|
|
44
|
+
const namer = useTSNamePolicy();
|
|
45
|
+
const name = namer.getName(props.name, "interface-member");
|
|
46
|
+
return [_$createComponent(Show, {
|
|
47
|
+
get when() {
|
|
48
|
+
return Boolean(props.doc);
|
|
49
|
+
},
|
|
50
|
+
get children() {
|
|
51
|
+
return [_$createComponent(JSDoc, {
|
|
52
|
+
get children() {
|
|
53
|
+
return [_$memo(() => _$memo(() => !!props.doc)() && _$createComponent(Prose, {
|
|
54
|
+
get children() {
|
|
55
|
+
return props.doc;
|
|
56
|
+
}
|
|
57
|
+
})), _$memo(() => _$memo(() => !!Array.isArray(props.parameters))() && _$createComponent(JSDocParams, {
|
|
58
|
+
get parameters() {
|
|
59
|
+
return props.parameters;
|
|
60
|
+
}
|
|
61
|
+
}))];
|
|
62
|
+
}
|
|
63
|
+
}), _$createIntrinsic("hbr", {})];
|
|
64
|
+
}
|
|
65
|
+
}), _$createComponent(MemberDeclaration, _$mergeProps({
|
|
66
|
+
"static": true
|
|
67
|
+
}, props, {
|
|
68
|
+
get refkey() {
|
|
69
|
+
return props.refkey;
|
|
70
|
+
},
|
|
71
|
+
get children() {
|
|
72
|
+
return [name, _$createComponent(Scope, {
|
|
73
|
+
get name() {
|
|
74
|
+
return props.name;
|
|
75
|
+
},
|
|
76
|
+
kind: "function",
|
|
77
|
+
get children() {
|
|
78
|
+
return _$createComponent(CallSignature, _$mergeProps(callSignatureProps, {
|
|
79
|
+
returnType: returnType
|
|
80
|
+
}));
|
|
81
|
+
}
|
|
82
|
+
})];
|
|
83
|
+
}
|
|
84
|
+
}))];
|
|
85
|
+
}
|
|
86
|
+
InterfaceMethod.TypeParameters = TypeParameters;
|
|
87
|
+
InterfaceMethod.Parameters = FunctionTypeParameters;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { memo as _$memo } from "@alloy-js/core/jsx-runtime";
|
|
2
|
-
import { createIntrinsic as _$createIntrinsic } from "@alloy-js/core/jsx-runtime";
|
|
1
|
+
import { createIntrinsic as _$createIntrinsic, memo as _$memo } from "@alloy-js/core/jsx-runtime";
|
|
3
2
|
/**
|
|
4
3
|
* A JSDoc comment block. This is a low-level component that merely creates the
|
|
5
4
|
* block. Consider using {@link JSDoc} if you want to create more complex
|
|
@@ -11,6 +10,5 @@ export function JSDocComment(props) {
|
|
|
11
10
|
get children() {
|
|
12
11
|
return [_$createIntrinsic("hbr", {}), _$memo(() => props.children)];
|
|
13
12
|
}
|
|
14
|
-
}), _$createIntrinsic("hbr", {}), "
|
|
15
|
-
}
|
|
16
|
-
//# sourceMappingURL=JSDocComment.js.map
|
|
13
|
+
}), _$createIntrinsic("hbr", {}), " */"];
|
|
14
|
+
}
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
2
|
-
import { memo as _$memo } from "@alloy-js/core/jsx-runtime";
|
|
3
|
-
import { createIntrinsic as _$createIntrinsic } from "@alloy-js/core/jsx-runtime";
|
|
1
|
+
import { createIntrinsic as _$createIntrinsic, memo as _$memo, createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
4
2
|
import { Show } from "@alloy-js/core";
|
|
5
3
|
/**
|
|
6
4
|
* Create a JSDoc example set off with `@example`. When the `fenced` prop is true, a `language` prop can
|
|
@@ -22,5 +20,4 @@ export function JSDocExample(props) {
|
|
|
22
20
|
return [_$createIntrinsic("hbr", {}), "```"];
|
|
23
21
|
}
|
|
24
22
|
})];
|
|
25
|
-
}
|
|
26
|
-
//# sourceMappingURL=JSDocExample.js.map
|
|
23
|
+
}
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import { createIntrinsic as _$createIntrinsic } from "@alloy-js/core/jsx-runtime";
|
|
2
|
-
import { memo as _$memo } from "@alloy-js/core/jsx-runtime";
|
|
3
|
-
import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
1
|
+
import { createComponent as _$createComponent, memo as _$memo, createIntrinsic as _$createIntrinsic } from "@alloy-js/core/jsx-runtime";
|
|
4
2
|
import { For, Prose, Show } from "@alloy-js/core";
|
|
5
3
|
/**
|
|
6
4
|
* A component that creates a JSDoc block with `@param` tags for each parameter.
|
|
@@ -117,5 +115,4 @@ function JSDocParamDescription(props) {
|
|
|
117
115
|
})];
|
|
118
116
|
}
|
|
119
117
|
});
|
|
120
|
-
}
|
|
121
|
-
//# sourceMappingURL=JSDocParam.js.map
|
|
118
|
+
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { createIntrinsic as _$createIntrinsic } from "@alloy-js/core/jsx-runtime";
|
|
2
|
-
import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
1
|
+
import { createComponent as _$createComponent, createIntrinsic as _$createIntrinsic } from "@alloy-js/core/jsx-runtime";
|
|
3
2
|
import { childrenArray, computed, For, List, Show } from "@alloy-js/core";
|
|
4
3
|
import { isComponentCreator } from "@alloy-js/core/jsx-runtime";
|
|
5
4
|
import { FunctionCallExpression } from "./FunctionCallExpression.js";
|
|
@@ -96,5 +95,4 @@ function flattenCallChains(children) {
|
|
|
96
95
|
}
|
|
97
96
|
}
|
|
98
97
|
return flatChildren;
|
|
99
|
-
}
|
|
100
|
-
//# sourceMappingURL=MemberChainExpression.js.map
|
|
98
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { MemberDeclarationPropsWithInfo, OutputSymbolFlags } from "@alloy-js/core";
|
|
2
|
+
import { TypeScriptElements } from "../name-policy.js";
|
|
3
|
+
import { TSOutputSymbol } from "../symbols/index.js";
|
|
4
|
+
export interface MemberDeclarationProps extends Omit<MemberDeclarationPropsWithInfo, "name"> {
|
|
5
|
+
/**
|
|
6
|
+
* The name of this member declaration.
|
|
7
|
+
*/
|
|
8
|
+
name?: string;
|
|
9
|
+
/** Name that shouldn't go through the name policy resolver again. */
|
|
10
|
+
exactName?: string;
|
|
11
|
+
/**
|
|
12
|
+
* Whether this is a memberdeclaration of a type (e.g. interface, type alias) or a
|
|
13
|
+
* value (e.g. var, const, let).
|
|
14
|
+
*/
|
|
15
|
+
kind?: "type" | "value";
|
|
16
|
+
/**
|
|
17
|
+
* The name policy kind to apply to the memberdeclaration.
|
|
18
|
+
*/
|
|
19
|
+
nameKind?: TypeScriptElements;
|
|
20
|
+
/**
|
|
21
|
+
* Flags for the symbol created by this component.
|
|
22
|
+
*/
|
|
23
|
+
flags?: OutputSymbolFlags;
|
|
24
|
+
/**
|
|
25
|
+
* The symbol to use for this memberdeclaration.
|
|
26
|
+
*/
|
|
27
|
+
symbol?: TSOutputSymbol;
|
|
28
|
+
/**
|
|
29
|
+
* Whether this member can be null or undefined.
|
|
30
|
+
*/
|
|
31
|
+
nullish?: boolean;
|
|
32
|
+
}
|
|
33
|
+
export declare function MemberDeclaration(props: Readonly<MemberDeclarationProps>): import("@alloy-js/core").Children;
|
|
34
|
+
//# sourceMappingURL=MemberDeclaration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MemberDeclaration.d.ts","sourceRoot":"","sources":["../../../src/components/MemberDeclaration.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,8BAA8B,EAC9B,iBAAiB,EAClB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,kBAAkB,EAAmB,MAAM,mBAAmB,CAAC;AACxE,OAAO,EAEL,cAAc,EAEf,MAAM,qBAAqB,CAAC;AAE7B,MAAM,WAAW,sBACf,SAAQ,IAAI,CAAC,8BAA8B,EAAE,MAAM,CAAC;IACpD;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,sEAAsE;IACtE,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAExB;;OAEG;IACH,QAAQ,CAAC,EAAE,kBAAkB,CAAC;IAE9B;;OAEG;IACH,KAAK,CAAC,EAAE,iBAAiB,CAAC;IAE1B;;OAEG;IACH,MAAM,CAAC,EAAE,cAAc,CAAC;IACxB;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,QAAQ,CAAC,sBAAsB,CAAC,qCA2BxE"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
import { MemberDeclaration as CoreMemberDeclaration } from "@alloy-js/core";
|
|
3
|
+
import { useTSNamePolicy } from "../name-policy.js";
|
|
4
|
+
import { createTSSymbol, TSSymbolFlags } from "../symbols/index.js";
|
|
5
|
+
export function MemberDeclaration(props) {
|
|
6
|
+
let sym;
|
|
7
|
+
if (props.symbol) {
|
|
8
|
+
sym = props.symbol;
|
|
9
|
+
} else {
|
|
10
|
+
const namePolicy = useTSNamePolicy();
|
|
11
|
+
let tsFlags = props.nullish ? TSSymbolFlags.Nullish : TSSymbolFlags.None;
|
|
12
|
+
if (props.kind === "type") {
|
|
13
|
+
tsFlags |= TSSymbolFlags.TypeSymbol;
|
|
14
|
+
}
|
|
15
|
+
sym = createTSSymbol({
|
|
16
|
+
name: props.exactName ?? namePolicy.getName(props.name, props.nameKind),
|
|
17
|
+
refkey: props.refkey,
|
|
18
|
+
flags: props.flags,
|
|
19
|
+
tsFlags,
|
|
20
|
+
metadata: props.metadata
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
return _$createComponent(CoreMemberDeclaration, {
|
|
24
|
+
symbol: sym,
|
|
25
|
+
get children() {
|
|
26
|
+
return props.children;
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MemberExpression.d.ts","sourceRoot":"","sources":["../../../src/components/MemberExpression.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAKR,YAAY,EAGZ,MAAM,EAGP,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"MemberExpression.d.ts","sourceRoot":"","sources":["../../../src/components/MemberExpression.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAKR,YAAY,EAGZ,MAAM,EAGP,MAAM,gBAAgB,CAAC;AAIxB,MAAM,WAAW,qBAAqB;IACpC,QAAQ,EAAE,QAAQ,CAAC;CACpB;AASD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,GAAG,QAAQ,CA4HvE;yBA5He,gBAAgB;sBAmLS,yBAAyB;;AAhClE,MAAM,WAAW,yBAAyB;IACxC;;OAEG;IACH,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB;;OAEG;IACH,IAAI,CAAC,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;IAE5B;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
2
|
-
import { memo as _$memo } from "@alloy-js/core/jsx-runtime";
|
|
3
|
-
import { createIntrinsic as _$createIntrinsic } from "@alloy-js/core/jsx-runtime";
|
|
1
|
+
import { createIntrinsic as _$createIntrinsic, memo as _$memo, createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
4
2
|
import { childrenArray, computed, For, isComponentCreator, ref, toRef, useBinder } from "@alloy-js/core";
|
|
3
|
+
import { TSSymbolFlags } from "../symbols/ts-output-symbol.js";
|
|
5
4
|
import { isValidJSIdentifier } from "../utils.js";
|
|
6
5
|
/**
|
|
7
6
|
* Create a member expression from parts. Each part can provide one of
|
|
@@ -55,7 +54,7 @@ export function MemberExpression(props) {
|
|
|
55
54
|
const symbolRef = binder.getSymbolForRefkey(partProps.refkey);
|
|
56
55
|
part.base = computed(() => {
|
|
57
56
|
if (symbolRef.value) {
|
|
58
|
-
part.nullish.value = !!symbolRef.value.
|
|
57
|
+
part.nullish.value = !!(symbolRef.value.tsFlags & TSSymbolFlags.Nullish);
|
|
59
58
|
part.accessStyle.value = accessStyleForMemberName(symbolRef.value.name);
|
|
60
59
|
return symbolRef.value.name;
|
|
61
60
|
} else {
|
|
@@ -63,7 +62,7 @@ export function MemberExpression(props) {
|
|
|
63
62
|
}
|
|
64
63
|
});
|
|
65
64
|
} else if (partProps.symbol) {
|
|
66
|
-
part.nullish.value = !!partProps.symbol.
|
|
65
|
+
part.nullish.value = !!(partProps.symbol.tsFlags & TSSymbolFlags.Nullish);
|
|
67
66
|
part.accessStyle = computed(() => {
|
|
68
67
|
return accessStyleForMemberName(partProps.symbol.name);
|
|
69
68
|
});
|
|
@@ -175,5 +174,4 @@ MemberExpression.Part = function (props) {
|
|
|
175
174
|
* This component does nothing except hold props which are retrieved by
|
|
176
175
|
* the `MemberExpression` component.
|
|
177
176
|
*/
|
|
178
|
-
};
|
|
179
|
-
//# sourceMappingURL=MemberExpression.js.map
|
|
177
|
+
};
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import { createIntrinsic as _$createIntrinsic } from "@alloy-js/core/jsx-runtime";
|
|
2
|
-
import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
3
|
-
import { memo as _$memo } from "@alloy-js/core/jsx-runtime";
|
|
1
|
+
import { memo as _$memo, createComponent as _$createComponent, createIntrinsic as _$createIntrinsic } from "@alloy-js/core/jsx-runtime";
|
|
4
2
|
import { AssignmentContext, Block, computed, createAssignmentContext, For, getAssignmentSymbol, Match, MemberScope, OutputSymbolFlags, Switch, Wrap } from "@alloy-js/core";
|
|
5
3
|
import { useTSNamePolicy } from "../name-policy.js";
|
|
6
4
|
import { createTSSymbol } from "../symbols/index.js";
|
|
@@ -107,5 +105,4 @@ export function ObjectProperty(props) {
|
|
|
107
105
|
value: assignmentContext,
|
|
108
106
|
children: value
|
|
109
107
|
})];
|
|
110
|
-
}
|
|
111
|
-
//# sourceMappingURL=ObjectExpression.js.map
|
|
108
|
+
}
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
2
|
-
import { mergeProps as _$mergeProps } from "@alloy-js/core/jsx-runtime";
|
|
3
|
-
import { memo as _$memo } from "@alloy-js/core/jsx-runtime";
|
|
1
|
+
import { memo as _$memo, mergeProps as _$mergeProps, createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
4
2
|
import { createNamedContext, Scope, shallowRef, SourceDirectory, SourceDirectoryContext, splitProps, useBinder, useContext, useScope } from "@alloy-js/core";
|
|
5
3
|
import { join } from "pathe";
|
|
6
4
|
import { createTSPackageScope } from "../symbols/index.js";
|
|
@@ -51,5 +49,4 @@ function createPackageContext(name, version, path) {
|
|
|
51
49
|
scope,
|
|
52
50
|
outFileMapper: shallowRef(path => modulePath(path))
|
|
53
51
|
};
|
|
54
|
-
}
|
|
55
|
-
//# sourceMappingURL=PackageDirectory.js.map
|
|
52
|
+
}
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import { Refkey } from "@alloy-js/core";
|
|
2
2
|
export interface ReferenceProps {
|
|
3
3
|
refkey: Refkey;
|
|
4
|
+
/**
|
|
5
|
+
* Whether this is a reference to a type.
|
|
6
|
+
*
|
|
7
|
+
* @remarks
|
|
8
|
+
* This affect things like import where `type` keyword might be used.
|
|
9
|
+
*/
|
|
10
|
+
type?: boolean;
|
|
4
11
|
}
|
|
5
|
-
export declare function Reference({ refkey }: ReferenceProps): import("@alloy-js/core").Children;
|
|
12
|
+
export declare function Reference({ refkey, type }: ReferenceProps): import("@alloy-js/core").Children;
|
|
6
13
|
//# sourceMappingURL=Reference.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Reference.d.ts","sourceRoot":"","sources":["../../../src/components/Reference.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"Reference.d.ts","sourceRoot":"","sources":["../../../src/components/Reference.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAIxC,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAC;IAEf;;;;;OAKG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,wBAAgB,SAAS,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,cAAc,qCAKzD"}
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
+
import { isTypeRefContext } from "../context/type-ref-context.js";
|
|
1
2
|
import { ref } from "../symbols/index.js";
|
|
2
3
|
export function Reference({
|
|
3
|
-
refkey
|
|
4
|
+
refkey,
|
|
5
|
+
type
|
|
4
6
|
}) {
|
|
5
|
-
const
|
|
7
|
+
const inTypeRef = isTypeRefContext();
|
|
8
|
+
const reference = ref(refkey, {
|
|
9
|
+
type: type ?? inTypeRef
|
|
10
|
+
});
|
|
6
11
|
return [reference];
|
|
7
|
-
}
|
|
8
|
-
//# sourceMappingURL=Reference.js.map
|
|
12
|
+
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { createIntrinsic as _$createIntrinsic } from "@alloy-js/core/jsx-runtime";
|
|
2
|
-
import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
1
|
+
import { createComponent as _$createComponent, createIntrinsic as _$createIntrinsic } from "@alloy-js/core/jsx-runtime";
|
|
3
2
|
import { Prose } from "@alloy-js/core";
|
|
4
3
|
/**
|
|
5
4
|
* A single line comment block. The children are rendered as a prose element, which means that they
|
|
@@ -16,5 +15,4 @@ export function SingleLineCommentBlock(props) {
|
|
|
16
15
|
});
|
|
17
16
|
}
|
|
18
17
|
})];
|
|
19
|
-
}
|
|
20
|
-
//# sourceMappingURL=SingleLineCommentBlock.js.map
|
|
18
|
+
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { createIntrinsic as _$createIntrinsic } from "@alloy-js/core/jsx-runtime";
|
|
2
|
-
import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
1
|
+
import { createComponent as _$createComponent, createIntrinsic as _$createIntrinsic } from "@alloy-js/core/jsx-runtime";
|
|
3
2
|
import { SourceFile as CoreSourceFile, createNamedContext, Scope, Show, SourceDirectoryContext, useBinder, useContext, useScope } from "@alloy-js/core";
|
|
4
3
|
import { join } from "pathe";
|
|
5
4
|
import { getSourceDirectoryData } from "../source-directory-data.js";
|
|
@@ -96,5 +95,4 @@ function SourceFileHeader(props) {
|
|
|
96
95
|
return props.header;
|
|
97
96
|
}
|
|
98
97
|
}), _$createIntrinsic("hbr", {})];
|
|
99
|
-
}
|
|
100
|
-
//# sourceMappingURL=SourceFile.js.map
|
|
98
|
+
}
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import { createIntrinsic as _$createIntrinsic } from "@alloy-js/core/jsx-runtime";
|
|
2
|
-
import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
3
|
-
import { memo as _$memo } from "@alloy-js/core/jsx-runtime";
|
|
1
|
+
import { memo as _$memo, createComponent as _$createComponent, createIntrinsic as _$createIntrinsic } from "@alloy-js/core/jsx-runtime";
|
|
4
2
|
import { Block, Indent, Match, Switch } from "@alloy-js/core";
|
|
5
3
|
import { BlockScope } from "./BlockScope.js";
|
|
6
4
|
import { ValueExpression } from "./ValueExpression.js";
|
|
@@ -44,5 +42,4 @@ export function CaseClause(props) {
|
|
|
44
42
|
return [_$memo(() => props.children), _$memo(() => _$memo(() => !!props.break)() && [_$createIntrinsic("hbr", {}), "break;"])];
|
|
45
43
|
}
|
|
46
44
|
})];
|
|
47
|
-
}
|
|
48
|
-
//# sourceMappingURL=SwitchStatement.js.map
|
|
45
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BaseDeclarationProps } from "./Declaration.js";
|
|
2
2
|
export interface TypeDeclarationProps extends BaseDeclarationProps {
|
|
3
3
|
}
|
|
4
|
-
export declare
|
|
4
|
+
export declare const TypeDeclaration: (props: TypeDeclarationProps) => import("@alloy-js/core").Children;
|
|
5
5
|
//# sourceMappingURL=TypeDeclaration.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TypeDeclaration.d.ts","sourceRoot":"","sources":["../../../src/components/TypeDeclaration.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAe,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"TypeDeclaration.d.ts","sourceRoot":"","sources":["../../../src/components/TypeDeclaration.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAe,MAAM,kBAAkB,CAAC;AAIrE,MAAM,WAAW,oBAAqB,SAAQ,oBAAoB;CAAG;AAErE,eAAO,MAAM,eAAe,oEAc3B,CAAC"}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import { mergeProps as _$mergeProps } from "@alloy-js/core/jsx-runtime";
|
|
2
|
-
import { memo as _$memo } from "@alloy-js/core/jsx-runtime";
|
|
3
|
-
import { createIntrinsic as _$createIntrinsic } from "@alloy-js/core/jsx-runtime";
|
|
4
|
-
import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
1
|
+
import { createComponent as _$createComponent, createIntrinsic as _$createIntrinsic, memo as _$memo, mergeProps as _$mergeProps } from "@alloy-js/core/jsx-runtime";
|
|
5
2
|
import { Name, Show } from "@alloy-js/core";
|
|
6
3
|
import { Declaration } from "./Declaration.js";
|
|
7
4
|
import { JSDoc } from "./JSDoc.js";
|
|
8
|
-
|
|
5
|
+
import { ensureTypeRefContext } from "./TypeRefContext.js";
|
|
6
|
+
export const TypeDeclaration = ensureTypeRefContext(props => {
|
|
9
7
|
return [_$createComponent(Show, {
|
|
10
8
|
get when() {
|
|
11
9
|
return Boolean(props.doc);
|
|
@@ -23,5 +21,4 @@ export function TypeDeclaration(props) {
|
|
|
23
21
|
return ["type ", _$createComponent(Name, {}), " = ", _$memo(() => props.children), ";"];
|
|
24
22
|
}
|
|
25
23
|
}))];
|
|
26
|
-
}
|
|
27
|
-
//# sourceMappingURL=TypeDeclaration.js.map
|
|
24
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Children } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
export interface TypeRefContextProps {
|
|
3
|
+
/**
|
|
4
|
+
* Children
|
|
5
|
+
*/
|
|
6
|
+
children: Children;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Set the current context of reference to be type reference.
|
|
10
|
+
*
|
|
11
|
+
* @remarks
|
|
12
|
+
* References used inside the children of this component will be treated as type reference {@link Reference}.
|
|
13
|
+
*
|
|
14
|
+
* Prefer using {@link ensureTypeRefContext} when wrapping the whole component to reduce tree nodes.
|
|
15
|
+
*/
|
|
16
|
+
export declare const TypeRefContext: ({ children }: TypeRefContextProps) => Children;
|
|
17
|
+
/** Ensure the current component is inside a type ref context.
|
|
18
|
+
* If not it will wrap in a {@link TypeRefContext} component.
|
|
19
|
+
* If yes it will not add an extra node and return the original component.
|
|
20
|
+
*/
|
|
21
|
+
export declare function ensureTypeRefContext<A extends unknown[]>(fn: (...args: A) => Children): (...args: A) => Children;
|
|
22
|
+
//# sourceMappingURL=TypeRefContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TypeRefContext.d.ts","sourceRoot":"","sources":["../../../src/components/TypeRefContext.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAM3D,MAAM,WAAW,mBAAmB;IAClC;;OAEG;IACH,QAAQ,EAAE,QAAQ,CAAC;CACpB;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc,GAAI,cAAc,mBAAmB,aAM/D,CAAC;AAEF;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,SAAS,OAAO,EAAE,EACtD,EAAE,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,QAAQ,GAC3B,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,QAAQ,CAa1B"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { createComponent as _$createComponent, memo as _$memo } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
import { isTypeRefContext, TypeRefContext as TypeRefContextDef } from "../context/type-ref-context.js";
|
|
3
|
+
/**
|
|
4
|
+
* Set the current context of reference to be type reference.
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* References used inside the children of this component will be treated as type reference {@link Reference}.
|
|
8
|
+
*
|
|
9
|
+
* Prefer using {@link ensureTypeRefContext} when wrapping the whole component to reduce tree nodes.
|
|
10
|
+
*/
|
|
11
|
+
export const TypeRefContext = ({
|
|
12
|
+
children
|
|
13
|
+
}) => {
|
|
14
|
+
return _$createComponent(TypeRefContextDef.Provider, {
|
|
15
|
+
value: {
|
|
16
|
+
type: true
|
|
17
|
+
},
|
|
18
|
+
children: children
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
/** Ensure the current component is inside a type ref context.
|
|
23
|
+
* If not it will wrap in a {@link TypeRefContext} component.
|
|
24
|
+
* If yes it will not add an extra node and return the original component.
|
|
25
|
+
*/
|
|
26
|
+
export function ensureTypeRefContext(fn) {
|
|
27
|
+
return (...args) => {
|
|
28
|
+
const ref = isTypeRefContext();
|
|
29
|
+
if (!ref) {
|
|
30
|
+
return _$createComponent(TypeRefContextDef.Provider, {
|
|
31
|
+
value: {
|
|
32
|
+
type: true
|
|
33
|
+
},
|
|
34
|
+
get children() {
|
|
35
|
+
return fn(...args);
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
return fn(...args);
|
|
40
|
+
};
|
|
41
|
+
}
|
|
@@ -6,6 +6,7 @@ export interface VarDeclarationProps extends BaseDeclarationProps {
|
|
|
6
6
|
var?: boolean;
|
|
7
7
|
initializer?: Children;
|
|
8
8
|
type?: Children;
|
|
9
|
+
nullish?: boolean;
|
|
9
10
|
}
|
|
10
11
|
export declare function VarDeclaration(props: VarDeclarationProps): Children;
|
|
11
12
|
//# sourceMappingURL=VarDeclaration.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VarDeclaration.d.ts","sourceRoot":"","sources":["../../../src/components/VarDeclaration.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,QAAQ,EAKT,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"VarDeclaration.d.ts","sourceRoot":"","sources":["../../../src/components/VarDeclaration.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,QAAQ,EAKT,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAIxD,MAAM,WAAW,mBAAoB,SAAQ,oBAAoB;IAC/D,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,WAAW,CAAC,EAAE,QAAQ,CAAC;IACvB,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,mBAAmB,YAoCxD"}
|
|
@@ -1,20 +1,24 @@
|
|
|
1
|
-
import { createIntrinsic as _$createIntrinsic } from "@alloy-js/core/jsx-runtime";
|
|
2
|
-
import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
3
|
-
import { memo as _$memo } from "@alloy-js/core/jsx-runtime";
|
|
1
|
+
import { memo as _$memo, createComponent as _$createComponent, createIntrinsic as _$createIntrinsic } from "@alloy-js/core/jsx-runtime";
|
|
4
2
|
import { AssignmentContext, Declaration as CoreDeclaration, createAssignmentContext, Name, Show } from "@alloy-js/core";
|
|
5
3
|
import { useTSNamePolicy } from "../name-policy.js";
|
|
6
|
-
import { createTSSymbol } from "../symbols/index.js";
|
|
4
|
+
import { createTSSymbol, TSSymbolFlags } from "../symbols/index.js";
|
|
7
5
|
import { JSDoc } from "./JSDoc.js";
|
|
6
|
+
import { TypeRefContext } from "./TypeRefContext.js";
|
|
8
7
|
export function VarDeclaration(props) {
|
|
9
8
|
const keyword = props.var ? "var" : props.let ? "let" : "const";
|
|
10
|
-
const type = props.type ?
|
|
9
|
+
const type = props.type ? _$createComponent(TypeRefContext, {
|
|
10
|
+
get children() {
|
|
11
|
+
return [": ", _$memo(() => props.type)];
|
|
12
|
+
}
|
|
13
|
+
}) : undefined;
|
|
11
14
|
const name = useTSNamePolicy().getName(props.name, "variable");
|
|
12
15
|
const sym = createTSSymbol({
|
|
13
16
|
name: name,
|
|
14
17
|
refkey: props.refkey,
|
|
15
18
|
default: props.default,
|
|
16
19
|
export: props.export,
|
|
17
|
-
metadata: props.metadata
|
|
20
|
+
metadata: props.metadata,
|
|
21
|
+
tsFlags: props.nullish ? TSSymbolFlags.Nullish : TSSymbolFlags.None
|
|
18
22
|
});
|
|
19
23
|
const assignmentContext = createAssignmentContext(sym);
|
|
20
24
|
return [_$createComponent(Show, {
|
|
@@ -39,5 +43,4 @@ export function VarDeclaration(props) {
|
|
|
39
43
|
})];
|
|
40
44
|
}
|
|
41
45
|
})];
|
|
42
|
-
}
|
|
43
|
-
//# sourceMappingURL=VarDeclaration.js.map
|
|
46
|
+
}
|