@aeriajs/compiler 0.0.76 → 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.
package/dist/ast.d.ts CHANGED
@@ -79,6 +79,7 @@ export type CollectionNode = NodeBase<'collection'> & {
79
79
  functions?: FunctionNode[];
80
80
  functionSets?: [string, symbol][];
81
81
  required?: RequiredProperties;
82
+ immutable?: readonly string[];
82
83
  indexes?: readonly string[];
83
84
  presets?: DescriptionPreset[];
84
85
  form?: readonly string[];
@@ -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/lexer.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { type Token } from './token.js';
2
2
  import { Diagnostic } from './diagnostic.js';
3
- export declare const COLLECTION_KEYWORDS: readonly ["actions", "additionalProperties", "filters", "form", "formLayout", "functions", "icon", "indexes", "individualActions", "layout", "middlewares", "owned", "presets", "properties", "required", "search", "table", "tableMeta", "unique", "writable"];
3
+ export declare const COLLECTION_KEYWORDS: readonly ["actions", "additionalProperties", "filters", "form", "formLayout", "functions", "icon", "immutable", "indexes", "individualActions", "layout", "middlewares", "owned", "presets", "properties", "required", "search", "table", "tableMeta", "unique", "writable"];
4
4
  export declare const COLLECTION_ACTIONS_KEYWORDS: readonly ["ask", "button", "clearItem", "effect", "event", "fetchItem", "function", "icon", "label", "params", "query", "requires", "roles", "route", "selection", "setItem", "translate"];
5
5
  export declare const COLLECTION_SEARCH_KEYWORDS: readonly ["indexes", "placeholder", "exactMatches"];
6
6
  export declare const COLLECTION_LAYOUT_KEYWORDS: readonly ["name", "options"];
package/dist/lexer.js CHANGED
@@ -8,6 +8,7 @@ export const COLLECTION_KEYWORDS = [
8
8
  'formLayout',
9
9
  'functions',
10
10
  'icon',
11
+ 'immutable',
11
12
  'indexes',
12
13
  'individualActions',
13
14
  'layout',
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;
@@ -736,6 +736,7 @@ export const parse = (tokens) => {
736
736
  node[AST.LOCATION_SYMBOL].arrays[keyword] = symbols;
737
737
  break;
738
738
  }
739
+ case 'immutable':
739
740
  case 'indexes':
740
741
  case 'form':
741
742
  case 'table':
@@ -828,7 +829,7 @@ export const parse = (tokens) => {
828
829
  if (match(TokenType.MacroName)) {
829
830
  const { value: macroName } = consume(TokenType.MacroName, ['include']);
830
831
  switch (macroName) {
831
- case 'include': {
832
+ default: {
832
833
  const { value: functionSetName, location } = consume(TokenType.Identifier);
833
834
  const functionSetSymbol = Symbol();
834
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.76",
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",