{"id":27883359,"url":"https://github.com/zsakowitz/nya","last_synced_at":"2025-05-05T06:15:23.166Z","repository":{"id":276223866,"uuid":"890793689","full_name":"zsakowitz/nya","owner":"zsakowitz","description":"a math editor and graphing calculator with a plugin-based architecture","archived":false,"fork":false,"pushed_at":"2025-05-05T04:57:17.000Z","size":6696,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-05T06:15:14.702Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://nya.zsnout.com","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/zsakowitz.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-11-19T07:33:32.000Z","updated_at":"2025-04-29T17:05:23.000Z","dependencies_parsed_at":"2025-03-01T18:21:47.035Z","dependency_job_id":"a9e8f9ec-bddb-4ea9-8425-28707fa6cc60","html_url":"https://github.com/zsakowitz/nya","commit_stats":null,"previous_names":["zsakowitz/nya"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zsakowitz%2Fnya","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zsakowitz%2Fnya/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zsakowitz%2Fnya/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zsakowitz%2Fnya/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zsakowitz","download_url":"https://codeload.github.com/zsakowitz/nya/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252448579,"owners_count":21749496,"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":"2025-05-05T06:15:22.615Z","updated_at":"2025-05-05T06:15:23.148Z","avatar_url":"https://github.com/zsakowitz.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003e\u003ccode\u003enya\u003c/code\u003e\u003c/h1\u003e\n\nproject nya is a graphing calculator designed to be extended. It's 100%\nopen-source (you can look at our code if you want), and adding new features is\nas simple as writing and including a single JavaScript file.\n\n# Why choose project nya, as a user?\n\n**Totally new features:**\n\n- Shaders (running an equation for every pixel on your screen)\n- Quaternions\n- Piecewise functions use multiple lines (type `cases`)\n- Lists can optionally span multiple lines (type `list`)\n- Ithkuil utilities (parsing and generating text in the language Ithkuil)\n\n**Improvements over Desmos:**\n\n- Cleaner grammar (`sin a cos b`, `[7, 9, 5].mad`, `sec arctan x`, `ln²|x|`)\n- Cleaner syntax (automatic spaces after commas, improved spacing around + and -\n  signs)\n- Fewer restrictions (lists can be \u003e10,000 elements; functions like `stats` can\n  be used on multiple lists)\n- Includes both geometry tools _and_ complex numbers\n- Tells you if a value evaluated to infinity or NaN instead of writing\n  `undefined`\n- Modern color functions (oklab, oklch)\n- Outputs every value in a list[^2]\n\n**Downsides:**\n\n- It doesn't yet have 100% feature compatiability with Desmos.\n- It does not yet have as complete support for screen readers.\n\n[^2]:\n    This is no longer a unique feature; Desmos has recently added support for\n    displaying every element in a list. `nya`'s implementation was still first\n    though!\n\n\u003c!-- # Why choose project nya, as a developer?\n\nTODO: write something here --\u003e\n\n# Extensibility\n\n`nya` follows the principle of “everything is an extension”. The very core of\n`nya` is hardcoded, but these things are all easily extensible and replaceable:\n\n- what the user can type\n- which LaTeX commands can be parsed\n- the expression AST\n- every operator\n- every function\n- the type system\n- what an expression in a graph sheet does\n- how values are displayed as text\n- how values are rendered to the canvas\n- how values are dragged\n\nSome example of extensions which can easily be incorporated into `nya`'s model:\n\n- An extension which allows symbolic algebra to be computed by acting as a proxy\n  for WolframAlpha.\n- An extension which provides octonion support (8-dimensional numbers) and\n  overloads all built-in operators to work on octonions.\n- An extension which allows a graph expression to evaluate to a video which is\n  them streamed live to social media.\n- An extension which allows slider values to be taken from the orientation of\n  the device.\n\nIn the future, it's hoped that arbitrary extensions will be loadable directly\nfrom the graph paper. Since this poses possible security risks, it isn't\navailable yet.\n\n# Packages\n\nIn `nya`, these extensions are called \"packages\". The [src/pkg/](src/pkg/)\nfolder has many packages of various complexity, if you'd like to learn by\nlooking at the code.\n\nMaking a package is easy. Just export some variable with the type\n[`Package`](src/pkg/index.ts), then called `.load()` on it with\n[`SheetFactory`](src/sheet/factory.ts). For a list of the various abilities\npackages have, check out the interface signature for `Package`. There's a lot,\nand even more options are available through adding new typable commands, AST\nnodes and transformers, and [`Ext`](src/sheet/ext/index.ts)s for the graphpaper.\n\n# Repository Structure\n\nAll important code is in [src/](src/), which is separated into three components.\nOnly relatively important files, especially files which need to be edited to add\nnew extensions, are noted here.\n\n- [src/eval/](src/eval/) evaluates expressions, and defines the AST and type\n  system.\n  - [ast/](src/eval/ast/) defines the AST and its parser.\n    - [token.ts](src/eval/ast/token.ts) defines AST node kinds.\n    - [tx.ts](src/eval/ast/tx.ts) defines various methods to evaluate an AST.\n  - [ops/](src/eval/ops/) defines operators and functions.\n    - [fn/](src/eval/ops/fn/) defines named user-callable functions.\n    - [op/](src/eval/ops/op/) defines operators.\n    - [index.ts](src/eval/ops/index.ts) provides a list of all operators and\n      functions.\n  - [ty/](src/eval/ty/) defines the type system.\n    - [index.ts](src/eval/ty/index.ts) defines what TypeScript types correspond\n      to `nya` types.\n    - [info.ts](src/eval/ty/info.ts) defines metadata associated with each type.\n- [src/field/](src/field/) defines the math editor and everything which can be\n  typed.\n  - [cmd/](src/field/cmd/) defines everything which can be rendered and typed in\n    a math field.\n  - [defaults.ts](src/field/defaults.ts) defines all standard extensions used in\n    `nya` math fields.\n- [src/sheet/](src/sheet/) draws the graph paper, and defines expression kinds\n  (slider, point, etc.).\n  - [ext/defaults.ts](src/sheet/ext/defaults.ts) defines all standard extensions\n    used in the graph paper.\n  - [ext/exts/](src/sheet/ext/exts/) defines extensions which can render\n    expressions in the graph paper.\n\n# The Editor\n\n## High-level overview\n\n- Every number, variable, and `\\\\sqrt` is a **command**.\n- A command contains sub-fields (called **blocks**).\n- A **block** is a row of **commands**.\n\nModifying at a point:\n\n- A **cursor** is like a normal cursor.\n- Deletions and insertions can be done on the **cursor**.\n- Those can be done on blocks directly, but it is somewhat unsafe.\n\nModifying a range:\n\n- A **span** is a range of **commands**.\n- A **span** can be removed from its containing block (all commands are\n  contained by some block).\n- A **selection** is a span with a focus node. Think: normal computer selection.\n\n## Low-level details\n\nThe data model is basically a virtual DOM, albeit one with many changes:\n\n- Instead of `Command` arrays for children, children are stored in `Block`s,\n  with a single `Command` owning zero or more `Block`s.\n- Instead of direct `.insertNode()` operations, many operations are done using\n  `Cursor`s or `Span`s as proxies.\n- Instead of handling all edge cases, the model relies on the programmer not to\n  make many mistakes.\n\nThe [`src/field/model.ts`](src/field/model.ts) file defines the entire data\nmodel, if you want to look at the source instead. It's in a single file split\ninto many classes and interfaces, as all the implementation details are highly\ncoupled together.\n\nNote that many properties in the model are declared `readonly`. This is to\nprevent external code from changing it inadvertently. However, many of these\nproperties will change throughout the program's lifetime. Think of them more as\nDOM accessors like `.nextSibling` rather than as read-only data.\n\nMore useful details:\n\n- A `Cursor` is defined by 1) the `Block` which contains it and 2) the `Command`\n  to its right.\n- A `Span` is defined by 1) the `Block` which contains it and 2) the `Command`s\n  on either side.\n- A `Selection` is a `Span` where one side is designated as the focused side.\n- A `Command` contains references to 1) its child `Block`s, 2) the `Command`s on\n  either side, and 3) its containing `Block`.\n- A `Block` contains references to 1) its parent `Command` and 2) the left- and\n  rightmost `Command`s it contains.\n\n### Data invalidation\n\nThe easiest error to make is data invalidation. This happens if an object's\nreferences are no longer consistent, such as if:\n\n- A `Cursor`'s `Command` does not have the same parent as the `Cursor` itself.\n- A `Cursor`'s `Command` references the same parent as the `Cursor`, but has\n  been removed from said parent.\n\nIf you are planning to replace or remove a `Command`, it is safest to ensure the\n`Cursor` is not attached to said `Command`. Simply call\n`cursor.moveTo(command, R)` to do this.\n\n# The LaTeX Parser\n\nA future component of this project.\n\n# The JS/GLSL Emitter\n\nA future component of this project.\n\n# The Graphing Software\n\nA future component of this project.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzsakowitz%2Fnya","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzsakowitz%2Fnya","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzsakowitz%2Fnya/lists"}