{"id":20976461,"url":"https://github.com/he4et/cheap-glkote","last_synced_at":"2026-04-22T12:05:00.399Z","repository":{"id":57197379,"uuid":"341465600","full_name":"He4eT/cheap-glkote","owner":"He4eT","description":"Abstract JavaScript implementation of GlkOte","archived":false,"fork":false,"pushed_at":"2023-05-21T21:36:22.000Z","size":176,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-08T09:05:04.294Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/He4eT.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2021-02-23T07:26:01.000Z","updated_at":"2023-05-20T21:19:37.000Z","dependencies_parsed_at":"2024-10-30T14:34:33.605Z","dependency_job_id":null,"html_url":"https://github.com/He4eT/cheap-glkote","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/He4eT%2Fcheap-glkote","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/He4eT%2Fcheap-glkote/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/He4eT%2Fcheap-glkote/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/He4eT%2Fcheap-glkote/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/He4eT","download_url":"https://codeload.github.com/He4eT/cheap-glkote/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243374762,"owners_count":20280737,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2024-11-19T04:54:02.594Z","updated_at":"2025-12-27T15:56:59.567Z","avatar_url":"https://github.com/He4eT.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# cheap-glkote\n[![NPM Version](https://img.shields.io/npm/v/cheap-glkote.svg?style=flat-square)](https://www.npmjs.org/package/cheap-glkote)\n\nThis is an abstract implementation of the [GlkOte](https://github.com/erkyrath/glkote) library interface designed to be used with [Emglken](https://github.com/curiousdannii/emglken).\u003cbr\u003e\nCan be used in Node.js or in a web browser.\n\n\n## Usage\n\nThis repository includes examples of [stdio interface implementation](https://github.com/He4eT/cheap-glkote/blob/master/bin/stdio.js) and [integration with Emglken](https://github.com/He4eT/cheap-glkote/blob/master/bin/player.stdio.js).\n\n### Initialization\n```js\nconst { Dialog, GlkOte, send } =\n  CheapGlkOte(handlers [, { loggers, size }])\n```\n\n### Input\n```js\nsend('open door', inputType, targetWindow)\n```\nYou can obtain `inputType` and `id` of `targetWindow` inside the `onUpdateInputs` handler.\u003cbr\u003e\nYou can specify `targetWindow` by its `id` inside the `onUpdateWindows` handler.\u003cbr\u003e\nAs I know, `inputType` can be `line` or `char`.\n\n### Output and lifecycle\n```js\nconst handlers = {\n  onInit: () =\u003e {\n    /**\n      * It's time to initialize the user interface.\n      */\n  },\n  onUpdateWindows: windows =\u003e {\n    /**\n      * Game wants to change the number of windows.\n      */\n  },\n  onUpdateInputs: data =\u003e {\n    /**\n      * Game wants to change input type.\n      * 'data' is a list with info about\n      * the target window and the input type.\n      */\n  },\n  onUpdateContent: messages =\u003e {\n    /**\n      * Process the game output here.\n      */\n  },\n  onDisable: () =\u003e {\n    /**\n      * Game wants to disable user interface.\n      */\n  },\n  onFileNameRequest: (tosave, usage, gameid, callback) =\u003e {\n    /**\n      * Game wants the user to specify the file name.\n      * This name will be passed as an argument\n      * to the \"onFileRead\" and \"onFileWrite\" functions.\n      */\n    callback({ filename: 'filename', usage })\n  },\n  onFileRead: filename =\u003e {\n    /**\n      * Game wants to read the contents from the file.\n      */\n    return 'content'\n  },\n  onFileWrite: (filename, content) =\u003e {\n    /**\n      * Game wants to write the contents in the file.\n      */\n  },\n  onExit: () =\u003e {\n    /**\n      * Game is over.\n      */\n  }\n}\n```\n### Logging\nBy default, the `console` is used for logging, but you can pass custom loggers to the constructor.\n\nDefault loggers:\n```js\nconst defaultLoggers = {\n  log: console.log,\n  warning: console.warn,\n  error: console.error,\n}\n```\n\n### Size\nDefault sizes:\n```js\nconst defaultSize = {\n  width: 80,\n  height: 25,\n}\n```\n\n## Inspired and powered by\n\n- [glkote-term](https://github.com/curiousdannii/glkote-term)\n- [GlkOte](https://github.com/erkyrath/glkote)\n- [Cheapglk](https://github.com/erkyrath/cheapglk)\n- [Emglken](https://github.com/curiousdannii/emglken)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhe4et%2Fcheap-glkote","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhe4et%2Fcheap-glkote","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhe4et%2Fcheap-glkote/lists"}