{"id":15658332,"url":"https://github.com/nartc/super-expressive-playground","last_synced_at":"2025-05-05T16:43:50.522Z","repository":{"id":45774578,"uuid":"283027728","full_name":"nartc/super-expressive-playground","owner":"nartc","description":"SuperExpressive Playground","archived":false,"fork":false,"pushed_at":"2020-08-04T01:13:50.000Z","size":1052,"stargazers_count":22,"open_issues_count":5,"forks_count":5,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-30T22:31:59.705Z","etag":null,"topics":["angular","netlify","regexp","scully","superexpressive","typescript"],"latest_commit_sha":null,"homepage":"https://sepg.netlify.app","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/nartc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-07-27T22:06:16.000Z","updated_at":"2023-10-13T15:06:09.000Z","dependencies_parsed_at":"2022-08-28T13:30:42.183Z","dependency_job_id":null,"html_url":"https://github.com/nartc/super-expressive-playground","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nartc%2Fsuper-expressive-playground","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nartc%2Fsuper-expressive-playground/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nartc%2Fsuper-expressive-playground/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nartc%2Fsuper-expressive-playground/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nartc","download_url":"https://codeload.github.com/nartc/super-expressive-playground/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252535254,"owners_count":21763921,"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":["angular","netlify","regexp","scully","superexpressive","typescript"],"created_at":"2024-10-03T13:11:59.669Z","updated_at":"2025-05-05T16:43:50.498Z","avatar_url":"https://github.com/nartc.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SuperExpressive Playground\n\nThis is the playground for [SuperExpressive Library](https://github.com/francisrstokes/super-expressive).\n\n\u003cdetails\u003e\n  \u003csummary\u003eTable Of Content\u003c/summary\u003e\n  \u003cp\u003e\n\n- [SuperExpressive Playground](#superexpressive-playground)\n  - [Working application](#working-application)\n  - [Features](#features)\n  - [Technologies](#technologies)\n  - [Challenges](#challenges)\n    - [Monaco Editor](#monaco-editor)\n    - [Executing the value of the editor](#executing-the-value-of-the-editor)\n    - [Scully and Monaco](#scully-and-monaco)\n    - [Mobile Responsiveness](#mobile-responsiveness)\n  - [Contribution](#contribution)\n  - [Credit](#credit)\n  - [License](#license)\n  \u003c/p\u003e\n\u003c/details\u003e\n\n## Working application\n\nCheck out the **working app** -\u003e https://sepg.netlify.app/\n\n![SuperExpressive Playground by @nartc][demo]\n\n## Features\n\n- Use the code editor to write **Regular Expression** using **SuperExpressive API**\n- Test the generated RegExp\n\n- [x] Mobile friendly - [@trungk18][trung]\n- [ ] Automatic execution\n\n## Technologies\n\n- [Angular](https://angular.io)\n- [Scully](https://scully.io)\n- [Monaco Editor](https://microsoft.github.io/monaco-editor/)\n- [NgxMonacoEditor](https://github.com/atularen/ngx-monaco-editor)\n- [TailwindCSS](https://tailwindcss.com/)\n\n## Challenges\n\nThere are a couple of challenges that I ran into while working on this project.\n\n### Monaco Editor\n\nMonaco is a powerful library, but it's also very complex. The way it's loaded is pretty tricky. However, the integration is quite smooth using `ngx-monaco-editor`. It was quite satisfied when I was able to load extra library type definitions (for SuperExpressive intellisense) into the Monaco instance\n\n### Executing the value of the editor\n\nThis is one tricky task as `eval()` is considered bad practice. So, I use `new Function()` instead. Also, I need to execute a snippet like:\n\n```ts\nSuperExpressive().anyChar.toRegex();\n```\n\nwhich will execute `SuperExpressive()` which is a 3rd-party API. Hence, in order for me to execute that, I need to assign `SuperExpressive` onto the `window` object.\n\n```ts\nimport SuperExpressive from \"super-expressive\";\n\nwindow.SuperExpressive = SuperExpressive;\n```\n\nFurthermore, I only want to execute a single-invoke of `SuperExpressive()` at a time, so I need to trim the editor's value.\n\n### Scully and Monaco\n\nScully **will not** work with Monaco as is because Scully will generate the `html` from the Angular build bundle and in turns will inject several `\u003cscript\u003e` tags that were used to load Monaco. With multiple `\u003cscript\u003e` tags with the same value (because Scully generates multiple `html` for multiple routes), Monaco complains that it's already been loaded.\n\nTo resolve that, I write a quick plugin to remove Monaco related `\u003cscript\u003e` from the generated `html` by Scully.\n\n```ts\nfunction removeMonacoScriptPluginHandler(html: string) {\n  return Promise.resolve(\n    html\n      .replace(/\u003cscript.+(?:editor\\.main(?:\\.nls)\\.js)\"\u003e\u003c\\/script\u003e/g, \"\") // remove duplicate loader\n      .replace(/\u003cscript.+(?:tsMode\\.js|typescript\\.js)\"\u003e\u003c\\/script\u003e/g, \"\") // remove duplicate loader\n      .replace(/\u003cngx-monaco-editor.+\u003e\u003c\\/ngx-monaco-editor\u003e/g, \"\") // remove flickering\n  );\n}\n```\n\n### Mobile Responsiveness\n\nAgain, because of how Monaco is loaded and rendered, it's tricky to get Mobile Responsiveness right which I haven't paid too much attention to for the first iteration.\n\n## Contribution\n\nAny contribution is welcome\n\n## Credit\n\n- [Francis Stokes](https://github.com/francisrstokes) for the SuperExpressive logo\n\n## License\n\nThe MIT License (MIT)\n\nCopyright (c) 2015 Chris Kibble\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n[trung]: https://github.com/trungk18\n[demo]: src/assets/images/super-expressive-demo.gif\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnartc%2Fsuper-expressive-playground","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnartc%2Fsuper-expressive-playground","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnartc%2Fsuper-expressive-playground/lists"}