@aeriajs/compiler 0.0.77 → 0.0.78

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.
@@ -4,15 +4,15 @@ const initialImportedFunctions = [
4
4
  'defineCollection',
5
5
  ];
6
6
  export const generateJSCollections = async (ast) => {
7
- let javascriptCode = '';
7
+ let code = '';
8
8
  const importsResult = makeASTImports(ast.collections, {
9
9
  [PACKAGE_NAME]: new Set(initialImportedFunctions),
10
10
  }, {
11
11
  includeRuntimeOnlyImports: true,
12
12
  });
13
- javascriptCode += importsResult.code.join('\n') + '\n\n';
14
- javascriptCode += await makeJSCollections(ast, importsResult.aliasedSymbols) + '\n\n';
15
- return javascriptCode;
13
+ code += importsResult.code.join('\n') + '\n\n';
14
+ code += await makeJSCollections(ast, importsResult.aliasedSymbols) + '\n\n';
15
+ return code;
16
16
  };
17
17
  const makeJSFunctions = async (collectionNode) => {
18
18
  let output = '';
@@ -36,16 +36,16 @@ const makeJSCollections = async (ast, aliasedSymbols) => {
36
36
  for (const collectionNode of ast.collections) {
37
37
  const id = getCollectionId(collectionNode.name);
38
38
  const extendCollectionName = getExtendName(collectionNode.name);
39
- const collectionDefinition = `export const ${id} = ${collectionNode.extends
39
+ const collectionDeclaration = `export const ${id} = ${collectionNode.extends
40
40
  ? `extendCollection(${id in aliasedSymbols
41
41
  ? aliasedSymbols[id]
42
42
  : id}, ${await makeJSCollectionSchema(ast, collectionNode, id)})`
43
43
  : `defineCollection(${await makeJSCollectionSchema(ast, collectionNode, id)})`}`;
44
- const collectionDeclaration = `export const ${extendCollectionName} = (collection) => extendCollection(${id}, collection)`;
44
+ const collectionExtendFunction = `export const ${extendCollectionName} = (collection) => extendCollection(${id}, collection)`;
45
45
  collectionCodes[collectionNode.name] = [
46
46
  '//' + collectionNode.name,
47
- collectionDefinition,
48
47
  collectionDeclaration,
48
+ collectionExtendFunction,
49
49
  ].join('\n');
50
50
  }
51
51
  return Object.values(collectionCodes).join('\n\n');
@@ -7,15 +7,15 @@ const initialImportedTypes = [
7
7
  'Context',
8
8
  ];
9
9
  const makeTSFunctions = (collectionNode) => {
10
- const funs = {};
10
+ const functions = {};
11
11
  for (const functionNode of collectionNode.functions) {
12
- funs[functionNode.name] = {
12
+ functions[functionNode.name] = {
13
13
  [UnquotedSymbol]: functionNode.exportSymbol
14
14
  ? `typeof import('${functionNode.exportSymbol.importPath}').${functionNode.exportSymbol.symbolName}`
15
15
  : 'unknown',
16
16
  };
17
17
  }
18
- return funs;
18
+ return functions;
19
19
  };
20
20
  export const generateTSCollections = async (ast) => {
21
21
  let code = '';
@@ -38,7 +38,7 @@ const makeTSCollections = (ast, aliasedSymbols) => {
38
38
  : makeTSCollectionSchema(collectionNode, id)}`;
39
39
  const collectionDeclaration = `export declare const ${id}: ${typeName} & { item: SchemaWithId<${typeName}["description"]> }`;
40
40
  const collectionSchema = `export declare type ${schemaName} = SchemaWithId<typeof ${id}.description>`;
41
- const collectionExtend = `export declare const extend${schemaName}Collection: <
41
+ const collectionExtendFunction = `export declare const extend${schemaName}Collection: <
42
42
  const TCollection extends {
43
43
  [P in Exclude<keyof Collection, "functions">]?: Partial<Collection[P]>
44
44
  } & {
@@ -51,7 +51,7 @@ const makeTSCollections = (ast, aliasedSymbols) => {
51
51
  collectionType,
52
52
  collectionDeclaration,
53
53
  collectionSchema,
54
- collectionExtend,
54
+ collectionExtendFunction,
55
55
  ].join('\n');
56
56
  }
57
57
  return Object.values(collectionCodes).join('\n\n');
package/dist/parser.js CHANGED
@@ -718,7 +718,7 @@ export const parse = (tokens) => {
718
718
  case 'required': {
719
719
  const { value, symbols } = parseArrayBlockWithAttributes(['if'], (attributeName, array, identifier) => {
720
720
  switch (attributeName) {
721
- case 'if': {
721
+ default: {
722
722
  const ifTerms = [];
723
723
  array[identifier] = parseCondition(ifTerms);
724
724
  node[AST.LOCATION_SYMBOL].requiredTerms = ifTerms;
@@ -829,7 +829,7 @@ export const parse = (tokens) => {
829
829
  if (match(TokenType.MacroName)) {
830
830
  const { value: macroName } = consume(TokenType.MacroName, ['include']);
831
831
  switch (macroName) {
832
- case 'include': {
832
+ default: {
833
833
  const { value: functionSetName, location } = consume(TokenType.Identifier);
834
834
  const functionSetSymbol = Symbol();
835
835
  locationMap.set(functionSetSymbol, location);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@aeriajs/compiler",
3
3
  "type": "module",
4
- "version": "0.0.77",
4
+ "version": "0.0.78",
5
5
  "description": "",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -21,8 +21,8 @@
21
21
  "dist"
22
22
  ],
23
23
  "peerDependencies": {
24
- "@aeriajs/common": "^0.0.163",
25
- "@aeriajs/types": "^0.0.138"
24
+ "@aeriajs/common": "^0.0.164",
25
+ "@aeriajs/types": "^0.0.139"
26
26
  },
27
27
  "devDependencies": {
28
28
  "@aeriajs/common": "link:../common",