UNPKG

5.34 kBJavaScriptView Raw
1var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
2 if (kind === "m") throw new TypeError("Private method is not writable");
3 if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
4 if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
5 return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
6};
7var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8 if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
9 if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10 return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11};
12var _DocumentationBuilder_props, _DocumentationBuilder_context, _DocumentationBuilder_childContext, _DocumentationBuilder_composes, _DocumentationBuilder_data;
13class DocumentationBuilder {
14 constructor() {
15 _DocumentationBuilder_props.set(this, void 0);
16 _DocumentationBuilder_context.set(this, void 0);
17 _DocumentationBuilder_childContext.set(this, void 0);
18 _DocumentationBuilder_composes.set(this, void 0);
19 _DocumentationBuilder_data.set(this, void 0);
20 __classPrivateFieldSet(this, _DocumentationBuilder_props, new Map(), "f");
21 __classPrivateFieldSet(this, _DocumentationBuilder_context, new Map(), "f");
22 __classPrivateFieldSet(this, _DocumentationBuilder_childContext, new Map(), "f");
23 __classPrivateFieldSet(this, _DocumentationBuilder_composes, new Set(), "f");
24 __classPrivateFieldSet(this, _DocumentationBuilder_data, new Map(), "f");
25 }
26 addComposes(moduleName) {
27 __classPrivateFieldGet(this, _DocumentationBuilder_composes, "f").add(moduleName);
28 }
29 set(key, value) {
30 __classPrivateFieldGet(this, _DocumentationBuilder_data, "f").set(key, value);
31 }
32 get(key) {
33 return __classPrivateFieldGet(this, _DocumentationBuilder_data, "f").get(key);
34 }
35 getPropDescriptor(propName) {
36 let propDescriptor = __classPrivateFieldGet(this, _DocumentationBuilder_props, "f").get(propName);
37 if (!propDescriptor) {
38 __classPrivateFieldGet(this, _DocumentationBuilder_props, "f").set(propName, (propDescriptor = {}));
39 }
40 return propDescriptor;
41 }
42 getContextDescriptor(propName) {
43 let propDescriptor = __classPrivateFieldGet(this, _DocumentationBuilder_context, "f").get(propName);
44 if (!propDescriptor) {
45 __classPrivateFieldGet(this, _DocumentationBuilder_context, "f").set(propName, (propDescriptor = {}));
46 }
47 return propDescriptor;
48 }
49 getChildContextDescriptor(propName) {
50 let propDescriptor = __classPrivateFieldGet(this, _DocumentationBuilder_childContext, "f").get(propName);
51 if (!propDescriptor) {
52 __classPrivateFieldGet(this, _DocumentationBuilder_childContext, "f").set(propName, (propDescriptor = {}));
53 }
54 return propDescriptor;
55 }
56 build() {
57 const obj = {};
58 for (const [key, value] of __classPrivateFieldGet(this, _DocumentationBuilder_data, "f")) {
59 // @ts-expect-error custom handlers can add any properties to Documentation
60 obj[key] = value;
61 }
62 if (__classPrivateFieldGet(this, _DocumentationBuilder_props, "f").size > 0) {
63 obj.props = {};
64 for (const [propName, propDescriptor] of __classPrivateFieldGet(this, _DocumentationBuilder_props, "f")) {
65 if (Object.keys(propDescriptor).length > 0) {
66 obj.props[propName] = propDescriptor;
67 }
68 }
69 }
70 if (__classPrivateFieldGet(this, _DocumentationBuilder_context, "f").size > 0) {
71 obj.context = {};
72 for (const [contextName, contextDescriptor] of __classPrivateFieldGet(this, _DocumentationBuilder_context, "f")) {
73 if (Object.keys(contextDescriptor).length > 0) {
74 obj.context[contextName] = contextDescriptor;
75 }
76 }
77 }
78 if (__classPrivateFieldGet(this, _DocumentationBuilder_childContext, "f").size > 0) {
79 obj.childContext = {};
80 for (const [childContextName, childContextDescriptor] of __classPrivateFieldGet(this, _DocumentationBuilder_childContext, "f")) {
81 obj.childContext[childContextName] = childContextDescriptor;
82 }
83 }
84 if (__classPrivateFieldGet(this, _DocumentationBuilder_composes, "f").size > 0) {
85 obj.composes = Array.from(__classPrivateFieldGet(this, _DocumentationBuilder_composes, "f"));
86 }
87 return obj;
88 }
89}
90_DocumentationBuilder_props = new WeakMap(), _DocumentationBuilder_context = new WeakMap(), _DocumentationBuilder_childContext = new WeakMap(), _DocumentationBuilder_composes = new WeakMap(), _DocumentationBuilder_data = new WeakMap();
91export default DocumentationBuilder;