Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

flow.js 16KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.AnyTypeAnnotation = AnyTypeAnnotation;
  6. exports.ArrayTypeAnnotation = ArrayTypeAnnotation;
  7. exports.BooleanTypeAnnotation = BooleanTypeAnnotation;
  8. exports.BooleanLiteralTypeAnnotation = BooleanLiteralTypeAnnotation;
  9. exports.NullLiteralTypeAnnotation = NullLiteralTypeAnnotation;
  10. exports.DeclareClass = DeclareClass;
  11. exports.DeclareFunction = DeclareFunction;
  12. exports.InferredPredicate = InferredPredicate;
  13. exports.DeclaredPredicate = DeclaredPredicate;
  14. exports.DeclareInterface = DeclareInterface;
  15. exports.DeclareModule = DeclareModule;
  16. exports.DeclareModuleExports = DeclareModuleExports;
  17. exports.DeclareTypeAlias = DeclareTypeAlias;
  18. exports.DeclareOpaqueType = DeclareOpaqueType;
  19. exports.DeclareVariable = DeclareVariable;
  20. exports.DeclareExportDeclaration = DeclareExportDeclaration;
  21. exports.DeclareExportAllDeclaration = DeclareExportAllDeclaration;
  22. exports.EnumDeclaration = EnumDeclaration;
  23. exports.EnumBooleanBody = EnumBooleanBody;
  24. exports.EnumNumberBody = EnumNumberBody;
  25. exports.EnumStringBody = EnumStringBody;
  26. exports.EnumSymbolBody = EnumSymbolBody;
  27. exports.EnumDefaultedMember = EnumDefaultedMember;
  28. exports.EnumBooleanMember = EnumBooleanMember;
  29. exports.EnumNumberMember = EnumNumberMember;
  30. exports.EnumStringMember = EnumStringMember;
  31. exports.ExistsTypeAnnotation = ExistsTypeAnnotation;
  32. exports.FunctionTypeAnnotation = FunctionTypeAnnotation;
  33. exports.FunctionTypeParam = FunctionTypeParam;
  34. exports.GenericTypeAnnotation = exports.ClassImplements = exports.InterfaceExtends = InterfaceExtends;
  35. exports._interfaceish = _interfaceish;
  36. exports._variance = _variance;
  37. exports.InterfaceDeclaration = InterfaceDeclaration;
  38. exports.InterfaceTypeAnnotation = InterfaceTypeAnnotation;
  39. exports.IntersectionTypeAnnotation = IntersectionTypeAnnotation;
  40. exports.MixedTypeAnnotation = MixedTypeAnnotation;
  41. exports.EmptyTypeAnnotation = EmptyTypeAnnotation;
  42. exports.NullableTypeAnnotation = NullableTypeAnnotation;
  43. exports.NumberTypeAnnotation = NumberTypeAnnotation;
  44. exports.StringTypeAnnotation = StringTypeAnnotation;
  45. exports.ThisTypeAnnotation = ThisTypeAnnotation;
  46. exports.TupleTypeAnnotation = TupleTypeAnnotation;
  47. exports.TypeofTypeAnnotation = TypeofTypeAnnotation;
  48. exports.TypeAlias = TypeAlias;
  49. exports.TypeAnnotation = TypeAnnotation;
  50. exports.TypeParameterDeclaration = exports.TypeParameterInstantiation = TypeParameterInstantiation;
  51. exports.TypeParameter = TypeParameter;
  52. exports.OpaqueType = OpaqueType;
  53. exports.ObjectTypeAnnotation = ObjectTypeAnnotation;
  54. exports.ObjectTypeInternalSlot = ObjectTypeInternalSlot;
  55. exports.ObjectTypeCallProperty = ObjectTypeCallProperty;
  56. exports.ObjectTypeIndexer = ObjectTypeIndexer;
  57. exports.ObjectTypeProperty = ObjectTypeProperty;
  58. exports.ObjectTypeSpreadProperty = ObjectTypeSpreadProperty;
  59. exports.QualifiedTypeIdentifier = QualifiedTypeIdentifier;
  60. exports.SymbolTypeAnnotation = SymbolTypeAnnotation;
  61. exports.UnionTypeAnnotation = UnionTypeAnnotation;
  62. exports.TypeCastExpression = TypeCastExpression;
  63. exports.Variance = Variance;
  64. exports.VoidTypeAnnotation = VoidTypeAnnotation;
  65. exports.IndexedAccessType = IndexedAccessType;
  66. exports.OptionalIndexedAccessType = OptionalIndexedAccessType;
  67. Object.defineProperty(exports, "NumberLiteralTypeAnnotation", {
  68. enumerable: true,
  69. get: function () {
  70. return _types2.NumericLiteral;
  71. }
  72. });
  73. Object.defineProperty(exports, "StringLiteralTypeAnnotation", {
  74. enumerable: true,
  75. get: function () {
  76. return _types2.StringLiteral;
  77. }
  78. });
  79. var t = require("@babel/types");
  80. var _modules = require("./modules");
  81. var _types2 = require("./types");
  82. function AnyTypeAnnotation() {
  83. this.word("any");
  84. }
  85. function ArrayTypeAnnotation(node) {
  86. this.print(node.elementType, node);
  87. this.token("[");
  88. this.token("]");
  89. }
  90. function BooleanTypeAnnotation() {
  91. this.word("boolean");
  92. }
  93. function BooleanLiteralTypeAnnotation(node) {
  94. this.word(node.value ? "true" : "false");
  95. }
  96. function NullLiteralTypeAnnotation() {
  97. this.word("null");
  98. }
  99. function DeclareClass(node, parent) {
  100. if (!t.isDeclareExportDeclaration(parent)) {
  101. this.word("declare");
  102. this.space();
  103. }
  104. this.word("class");
  105. this.space();
  106. this._interfaceish(node);
  107. }
  108. function DeclareFunction(node, parent) {
  109. if (!t.isDeclareExportDeclaration(parent)) {
  110. this.word("declare");
  111. this.space();
  112. }
  113. this.word("function");
  114. this.space();
  115. this.print(node.id, node);
  116. this.print(node.id.typeAnnotation.typeAnnotation, node);
  117. if (node.predicate) {
  118. this.space();
  119. this.print(node.predicate, node);
  120. }
  121. this.semicolon();
  122. }
  123. function InferredPredicate() {
  124. this.token("%");
  125. this.word("checks");
  126. }
  127. function DeclaredPredicate(node) {
  128. this.token("%");
  129. this.word("checks");
  130. this.token("(");
  131. this.print(node.value, node);
  132. this.token(")");
  133. }
  134. function DeclareInterface(node) {
  135. this.word("declare");
  136. this.space();
  137. this.InterfaceDeclaration(node);
  138. }
  139. function DeclareModule(node) {
  140. this.word("declare");
  141. this.space();
  142. this.word("module");
  143. this.space();
  144. this.print(node.id, node);
  145. this.space();
  146. this.print(node.body, node);
  147. }
  148. function DeclareModuleExports(node) {
  149. this.word("declare");
  150. this.space();
  151. this.word("module");
  152. this.token(".");
  153. this.word("exports");
  154. this.print(node.typeAnnotation, node);
  155. }
  156. function DeclareTypeAlias(node) {
  157. this.word("declare");
  158. this.space();
  159. this.TypeAlias(node);
  160. }
  161. function DeclareOpaqueType(node, parent) {
  162. if (!t.isDeclareExportDeclaration(parent)) {
  163. this.word("declare");
  164. this.space();
  165. }
  166. this.OpaqueType(node);
  167. }
  168. function DeclareVariable(node, parent) {
  169. if (!t.isDeclareExportDeclaration(parent)) {
  170. this.word("declare");
  171. this.space();
  172. }
  173. this.word("var");
  174. this.space();
  175. this.print(node.id, node);
  176. this.print(node.id.typeAnnotation, node);
  177. this.semicolon();
  178. }
  179. function DeclareExportDeclaration(node) {
  180. this.word("declare");
  181. this.space();
  182. this.word("export");
  183. this.space();
  184. if (node.default) {
  185. this.word("default");
  186. this.space();
  187. }
  188. FlowExportDeclaration.apply(this, arguments);
  189. }
  190. function DeclareExportAllDeclaration() {
  191. this.word("declare");
  192. this.space();
  193. _modules.ExportAllDeclaration.apply(this, arguments);
  194. }
  195. function EnumDeclaration(node) {
  196. const {
  197. id,
  198. body
  199. } = node;
  200. this.word("enum");
  201. this.space();
  202. this.print(id, node);
  203. this.print(body, node);
  204. }
  205. function enumExplicitType(context, name, hasExplicitType) {
  206. if (hasExplicitType) {
  207. context.space();
  208. context.word("of");
  209. context.space();
  210. context.word(name);
  211. }
  212. context.space();
  213. }
  214. function enumBody(context, node) {
  215. const {
  216. members
  217. } = node;
  218. context.token("{");
  219. context.indent();
  220. context.newline();
  221. for (const member of members) {
  222. context.print(member, node);
  223. context.newline();
  224. }
  225. if (node.hasUnknownMembers) {
  226. context.token("...");
  227. context.newline();
  228. }
  229. context.dedent();
  230. context.token("}");
  231. }
  232. function EnumBooleanBody(node) {
  233. const {
  234. explicitType
  235. } = node;
  236. enumExplicitType(this, "boolean", explicitType);
  237. enumBody(this, node);
  238. }
  239. function EnumNumberBody(node) {
  240. const {
  241. explicitType
  242. } = node;
  243. enumExplicitType(this, "number", explicitType);
  244. enumBody(this, node);
  245. }
  246. function EnumStringBody(node) {
  247. const {
  248. explicitType
  249. } = node;
  250. enumExplicitType(this, "string", explicitType);
  251. enumBody(this, node);
  252. }
  253. function EnumSymbolBody(node) {
  254. enumExplicitType(this, "symbol", true);
  255. enumBody(this, node);
  256. }
  257. function EnumDefaultedMember(node) {
  258. const {
  259. id
  260. } = node;
  261. this.print(id, node);
  262. this.token(",");
  263. }
  264. function enumInitializedMember(context, node) {
  265. const {
  266. id,
  267. init
  268. } = node;
  269. context.print(id, node);
  270. context.space();
  271. context.token("=");
  272. context.space();
  273. context.print(init, node);
  274. context.token(",");
  275. }
  276. function EnumBooleanMember(node) {
  277. enumInitializedMember(this, node);
  278. }
  279. function EnumNumberMember(node) {
  280. enumInitializedMember(this, node);
  281. }
  282. function EnumStringMember(node) {
  283. enumInitializedMember(this, node);
  284. }
  285. function FlowExportDeclaration(node) {
  286. if (node.declaration) {
  287. const declar = node.declaration;
  288. this.print(declar, node);
  289. if (!t.isStatement(declar)) this.semicolon();
  290. } else {
  291. this.token("{");
  292. if (node.specifiers.length) {
  293. this.space();
  294. this.printList(node.specifiers, node);
  295. this.space();
  296. }
  297. this.token("}");
  298. if (node.source) {
  299. this.space();
  300. this.word("from");
  301. this.space();
  302. this.print(node.source, node);
  303. }
  304. this.semicolon();
  305. }
  306. }
  307. function ExistsTypeAnnotation() {
  308. this.token("*");
  309. }
  310. function FunctionTypeAnnotation(node, parent) {
  311. this.print(node.typeParameters, node);
  312. this.token("(");
  313. if (node.this) {
  314. this.word("this");
  315. this.token(":");
  316. this.space();
  317. this.print(node.this.typeAnnotation, node);
  318. if (node.params.length || node.rest) {
  319. this.token(",");
  320. this.space();
  321. }
  322. }
  323. this.printList(node.params, node);
  324. if (node.rest) {
  325. if (node.params.length) {
  326. this.token(",");
  327. this.space();
  328. }
  329. this.token("...");
  330. this.print(node.rest, node);
  331. }
  332. this.token(")");
  333. if (parent.type === "ObjectTypeCallProperty" || parent.type === "DeclareFunction" || parent.type === "ObjectTypeProperty" && parent.method) {
  334. this.token(":");
  335. } else {
  336. this.space();
  337. this.token("=>");
  338. }
  339. this.space();
  340. this.print(node.returnType, node);
  341. }
  342. function FunctionTypeParam(node) {
  343. this.print(node.name, node);
  344. if (node.optional) this.token("?");
  345. if (node.name) {
  346. this.token(":");
  347. this.space();
  348. }
  349. this.print(node.typeAnnotation, node);
  350. }
  351. function InterfaceExtends(node) {
  352. this.print(node.id, node);
  353. this.print(node.typeParameters, node);
  354. }
  355. function _interfaceish(node) {
  356. var _node$extends;
  357. this.print(node.id, node);
  358. this.print(node.typeParameters, node);
  359. if ((_node$extends = node.extends) != null && _node$extends.length) {
  360. this.space();
  361. this.word("extends");
  362. this.space();
  363. this.printList(node.extends, node);
  364. }
  365. if (node.mixins && node.mixins.length) {
  366. this.space();
  367. this.word("mixins");
  368. this.space();
  369. this.printList(node.mixins, node);
  370. }
  371. if (node.implements && node.implements.length) {
  372. this.space();
  373. this.word("implements");
  374. this.space();
  375. this.printList(node.implements, node);
  376. }
  377. this.space();
  378. this.print(node.body, node);
  379. }
  380. function _variance(node) {
  381. if (node.variance) {
  382. if (node.variance.kind === "plus") {
  383. this.token("+");
  384. } else if (node.variance.kind === "minus") {
  385. this.token("-");
  386. }
  387. }
  388. }
  389. function InterfaceDeclaration(node) {
  390. this.word("interface");
  391. this.space();
  392. this._interfaceish(node);
  393. }
  394. function andSeparator() {
  395. this.space();
  396. this.token("&");
  397. this.space();
  398. }
  399. function InterfaceTypeAnnotation(node) {
  400. this.word("interface");
  401. if (node.extends && node.extends.length) {
  402. this.space();
  403. this.word("extends");
  404. this.space();
  405. this.printList(node.extends, node);
  406. }
  407. this.space();
  408. this.print(node.body, node);
  409. }
  410. function IntersectionTypeAnnotation(node) {
  411. this.printJoin(node.types, node, {
  412. separator: andSeparator
  413. });
  414. }
  415. function MixedTypeAnnotation() {
  416. this.word("mixed");
  417. }
  418. function EmptyTypeAnnotation() {
  419. this.word("empty");
  420. }
  421. function NullableTypeAnnotation(node) {
  422. this.token("?");
  423. this.print(node.typeAnnotation, node);
  424. }
  425. function NumberTypeAnnotation() {
  426. this.word("number");
  427. }
  428. function StringTypeAnnotation() {
  429. this.word("string");
  430. }
  431. function ThisTypeAnnotation() {
  432. this.word("this");
  433. }
  434. function TupleTypeAnnotation(node) {
  435. this.token("[");
  436. this.printList(node.types, node);
  437. this.token("]");
  438. }
  439. function TypeofTypeAnnotation(node) {
  440. this.word("typeof");
  441. this.space();
  442. this.print(node.argument, node);
  443. }
  444. function TypeAlias(node) {
  445. this.word("type");
  446. this.space();
  447. this.print(node.id, node);
  448. this.print(node.typeParameters, node);
  449. this.space();
  450. this.token("=");
  451. this.space();
  452. this.print(node.right, node);
  453. this.semicolon();
  454. }
  455. function TypeAnnotation(node) {
  456. this.token(":");
  457. this.space();
  458. if (node.optional) this.token("?");
  459. this.print(node.typeAnnotation, node);
  460. }
  461. function TypeParameterInstantiation(node) {
  462. this.token("<");
  463. this.printList(node.params, node, {});
  464. this.token(">");
  465. }
  466. function TypeParameter(node) {
  467. this._variance(node);
  468. this.word(node.name);
  469. if (node.bound) {
  470. this.print(node.bound, node);
  471. }
  472. if (node.default) {
  473. this.space();
  474. this.token("=");
  475. this.space();
  476. this.print(node.default, node);
  477. }
  478. }
  479. function OpaqueType(node) {
  480. this.word("opaque");
  481. this.space();
  482. this.word("type");
  483. this.space();
  484. this.print(node.id, node);
  485. this.print(node.typeParameters, node);
  486. if (node.supertype) {
  487. this.token(":");
  488. this.space();
  489. this.print(node.supertype, node);
  490. }
  491. if (node.impltype) {
  492. this.space();
  493. this.token("=");
  494. this.space();
  495. this.print(node.impltype, node);
  496. }
  497. this.semicolon();
  498. }
  499. function ObjectTypeAnnotation(node) {
  500. if (node.exact) {
  501. this.token("{|");
  502. } else {
  503. this.token("{");
  504. }
  505. const props = [...node.properties, ...(node.callProperties || []), ...(node.indexers || []), ...(node.internalSlots || [])];
  506. if (props.length) {
  507. this.space();
  508. this.printJoin(props, node, {
  509. addNewlines(leading) {
  510. if (leading && !props[0]) return 1;
  511. },
  512. indent: true,
  513. statement: true,
  514. iterator: () => {
  515. if (props.length !== 1 || node.inexact) {
  516. this.token(",");
  517. this.space();
  518. }
  519. }
  520. });
  521. this.space();
  522. }
  523. if (node.inexact) {
  524. this.indent();
  525. this.token("...");
  526. if (props.length) {
  527. this.newline();
  528. }
  529. this.dedent();
  530. }
  531. if (node.exact) {
  532. this.token("|}");
  533. } else {
  534. this.token("}");
  535. }
  536. }
  537. function ObjectTypeInternalSlot(node) {
  538. if (node.static) {
  539. this.word("static");
  540. this.space();
  541. }
  542. this.token("[");
  543. this.token("[");
  544. this.print(node.id, node);
  545. this.token("]");
  546. this.token("]");
  547. if (node.optional) this.token("?");
  548. if (!node.method) {
  549. this.token(":");
  550. this.space();
  551. }
  552. this.print(node.value, node);
  553. }
  554. function ObjectTypeCallProperty(node) {
  555. if (node.static) {
  556. this.word("static");
  557. this.space();
  558. }
  559. this.print(node.value, node);
  560. }
  561. function ObjectTypeIndexer(node) {
  562. if (node.static) {
  563. this.word("static");
  564. this.space();
  565. }
  566. this._variance(node);
  567. this.token("[");
  568. if (node.id) {
  569. this.print(node.id, node);
  570. this.token(":");
  571. this.space();
  572. }
  573. this.print(node.key, node);
  574. this.token("]");
  575. this.token(":");
  576. this.space();
  577. this.print(node.value, node);
  578. }
  579. function ObjectTypeProperty(node) {
  580. if (node.proto) {
  581. this.word("proto");
  582. this.space();
  583. }
  584. if (node.static) {
  585. this.word("static");
  586. this.space();
  587. }
  588. if (node.kind === "get" || node.kind === "set") {
  589. this.word(node.kind);
  590. this.space();
  591. }
  592. this._variance(node);
  593. this.print(node.key, node);
  594. if (node.optional) this.token("?");
  595. if (!node.method) {
  596. this.token(":");
  597. this.space();
  598. }
  599. this.print(node.value, node);
  600. }
  601. function ObjectTypeSpreadProperty(node) {
  602. this.token("...");
  603. this.print(node.argument, node);
  604. }
  605. function QualifiedTypeIdentifier(node) {
  606. this.print(node.qualification, node);
  607. this.token(".");
  608. this.print(node.id, node);
  609. }
  610. function SymbolTypeAnnotation() {
  611. this.word("symbol");
  612. }
  613. function orSeparator() {
  614. this.space();
  615. this.token("|");
  616. this.space();
  617. }
  618. function UnionTypeAnnotation(node) {
  619. this.printJoin(node.types, node, {
  620. separator: orSeparator
  621. });
  622. }
  623. function TypeCastExpression(node) {
  624. this.token("(");
  625. this.print(node.expression, node);
  626. this.print(node.typeAnnotation, node);
  627. this.token(")");
  628. }
  629. function Variance(node) {
  630. if (node.kind === "plus") {
  631. this.token("+");
  632. } else {
  633. this.token("-");
  634. }
  635. }
  636. function VoidTypeAnnotation() {
  637. this.word("void");
  638. }
  639. function IndexedAccessType(node) {
  640. this.print(node.objectType, node);
  641. this.token("[");
  642. this.print(node.indexType, node);
  643. this.token("]");
  644. }
  645. function OptionalIndexedAccessType(node) {
  646. this.print(node.objectType, node);
  647. if (node.optional) {
  648. this.token("?.");
  649. }
  650. this.token("[");
  651. this.print(node.indexType, node);
  652. this.token("]");
  653. }