{"id":20168988,"url":"https://github.com/mage/mage-parser","last_synced_at":"2026-04-25T11:33:30.897Z","repository":{"id":82165247,"uuid":"91893702","full_name":"mage/mage-parser","owner":"mage","description":"Parser module for TypeScript MAGE projects, used to extract user commands and messageStream messages.","archived":false,"fork":false,"pushed_at":"2017-05-20T14:19:49.000Z","size":14,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-09T19:48:58.570Z","etag":null,"topics":["mage","nodejs","parser","parser-generator","typescript"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mage.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":"Contributing.md","funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-05-20T14:14:23.000Z","updated_at":"2017-05-21T04:23:25.000Z","dependencies_parsed_at":null,"dependency_job_id":"a14cf218-ff4f-4f3a-a41f-aaf7e68fd081","html_url":"https://github.com/mage/mage-parser","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mage/mage-parser","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mage%2Fmage-parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mage%2Fmage-parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mage%2Fmage-parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mage%2Fmage-parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mage","download_url":"https://codeload.github.com/mage/mage-parser/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mage%2Fmage-parser/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32261115,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-25T09:15:33.318Z","status":"ssl_error","status_checked_at":"2026-04-25T09:15:31.997Z","response_time":59,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["mage","nodejs","parser","parser-generator","typescript"],"created_at":"2024-11-14T01:10:58.934Z","updated_at":"2026-04-25T11:33:30.880Z","avatar_url":"https://github.com/mage.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"mage-parser\n===========\n\n** Under active development **\n\nParser module for TypeScript MAGE projects, used to extract user commands and messageStream messages.\n\nThis module can be used to build language-specific client generators; it will take care of extracting:\n\n  - All types relevant to client applications\n  - All usercommands, per modules\n  - All messageStream messages (by finding all occurences of `state.emit` and `state.broadcast`)\n\nGenerators using mage-parser\n----------------------------\n\n| name                         | description                               | link                                                      |\n| ---------------------------- | ----------------------------------------- | --------------------------------------------------------- |\n| mage-unity-client-generator  | Client generator for the Unity framework  | https://www.npmjs.com/package/mage-unity-client-generator |\n\nFeel free to make a pull request to add new client generators!\n\nInstallation\n------------\n\n```shell\nnpm install --save mage-parser\n```\n\nUsage\n-----\n\n```javascript\nconst {\n    Parser\n} = require('mage-parser')\n\nconst parser = new Parser('/path/to/mage/project')\nconst modules = parser.parse()\n\nmodules.forEach(function (module) {\n  console.log(module)\n})\n```\n\nThis should output something similar to:\n\n```json\n{\n  \"name\": \"myModule\",\n  \"types\": [\n\n  ],\n  \"usercommands\": [\n\n  ],\n  \"messages\": [\n\n  ]\n}\n```\n\nEach modules will contain the following entries:\n\n  - *types*: containing the different types which may be returned by the module\n  - *usercommands*: containing each user commands exposed by the module\n  - *messages*: containing the details for each message that can be emitted through messageStream\n\nCommand-line tool\n-----------------\n\nThis module comes with a small binary that will parse a MAGE project, and output\nthe information it has extracted:\n\n```shell\n$ mage-parse\nUsage: mage-parse /path/to/mage/project\n```\n\nYou can use it to quickly show relevant information about your MAGE project.\n\nLimitations\n-----------\n\n### Extract built-in modules\n\nThis simply cannot be done reliably, since we won't be able to parse\nfor messageStream events. \n\n### Extract JavaScript types or modules\n\nThis can be done reliably, as long as:\n\n  - The concerned module contains a TypeScript type definition file\n  - The concerned module does not emit messageStream events\n\n### state.emit and state.broadcast\n\nThe event name passed to `state.emit` and `state.broadcast` must be one of\nthe following:\n\n  - a const enum value\n  - a string or number literal \n\n\u003e lib/modules/test/index.ts\n\n```typescript\nimport * as mage from 'mage'\n\nconst eventName = 'bad'\n\nexport const enum events {\n    Success = 5000,\n    Failure,\n    Dunno\n}\n\nexport function emitSuccess(state: mage.core.IState, message: string) {\n    state.broadcast(events.Success, message) // All good\n    state.broadcast('TESTEVENT', message) // All good\n    state.broadcast(eventName, message) // Will blow up\n}\n```\n\nThe reason for this is that only the following two types' values may safely be\nextracted at compile time by the TypeScript compiler.\n\nLicense\n-------\n\nMIT.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmage%2Fmage-parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmage%2Fmage-parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmage%2Fmage-parser/lists"}