boltex / leojs Goto Github PK
View Code? Open in Web Editor NEWLeo Literate Editor with Outline in Typescript
Home Page: https://boltex.github.io/leojs/
License: MIT License
Leo Literate Editor with Outline in Typescript
Home Page: https://boltex.github.io/leojs/
License: MIT License
one of the things that keeps me from using at-file nodes (i.e. with sentinels), is the lack of customization for the node identity's.
i'm aware that this came up a long time ago for leo proper and the issue was shut down (so i was forced to stop using them).
what i'd very much prefer to use are perhaps: KSUID = K-Sortable Unique IDentifier. a globally unique id that also sorts correctly by time. https://github.com/segmentio/ksuid
there are other options of course, but i work on a team and i really don't like/can't have my username and timestamp as the identifier. but ksuid's could even be used across applications.
ideally we could even alias these nodes so that named '#region' references could also/instead be used for imports.
i have much more to say on this, but this is/was one of my major pain points with leo.
thanks for considering.
ksuid background: https://segment.com/blog/a-brief-history-of-the-uuid/python lib example:
https://pypi.org/project/svix-ksuid/
The ekr-tests branch now contains the work. See PR #27.
Run Transcrypt (with -a -b -m -n option), inserting pragmas as needed, on at least these files:
See also Leo issue #1788.
A lot more syntax coloring for various other file-formats and languages could be easily supported just by finding the same config file that VSCode uses for those same types of file!
Add a setting in leojs extension for having the session (list of files to open automatically at startup) saved per workspace instead of using Leo's regular session state in it's db.
Leojs should default to that workspace session.
I no longer see the LeoJS icon in the icon strip at the left of the VSC window. It's there in VSCodium. Without this icon, when I closed the last LeoJS window I could no longer use it until I restarted VSC. I didn't see a setting to restore the icon, and I don't know what if anything I did to cause the situation.
Hi Felix, perhaps it might be possible to open the discussions and perhaps wiki sections here on github.
I'd like to contribute some comments here, i.e. some possible advantages of this platform (leojs), and try to draw some attention this project :-D
It seems to reload the parts of the outline based on the saved file, but removed or added @buttons in the button panel do not reflect what should be appearing in it from the saved file. (it does not seem to be rebuilt)
Perhaps the revert command does not really destroy and rebuild the commander?
As starting point/ hint to help fix this: There was a similar problem lately in the real Leo which was fixed. So this might be related.
This will prevent us from stepping on each other's toes.
This is a serious bug that might lead to corrupted data.
Using LeoJS in vscode.dev:
class NestedSplitterTopLevel (QWidget)
It appears that the body text is the text of the node's parent.
When saving to a .leojs file, the expanded, marked, etc. bits should only be put in if forced by a config setting.
They should be saved in, and pulled from, the db. Just like for regular .leo Files.
Also make sure it's the same in the original Leo itself !!
EKR: After cloning the repo, remember to do npm install
in the repo's top-level directory.
Félix: My first recommendation for building good vscode extension development knowledge is to 'git clone' this repo on your pc : https://github.com/microsoft/vscode-extension-samples
tip: do not open the whole thing in vscode, instead, right click one of the subfolders for a particular extension example, choose "open with vscode" and try out or look at the code for a project 'individually'. (to actually run and try a sample instead of just looking at its source code, in each case, a simple "npm install" in the terminal will install all dependencies for any particular example, and then hitting F5 will start the sample in its own window. But you know that already for finishing the basics tutorials ;) hehe)
It gives good examples for distinct and precise aspects of vscode without overwhelming aspects of a full-blown extension which tries to do a dozen things at once.
Basing all branches on devel seems like a good idea to me.
The markdown writer (for @auto nodes) adds an extra newline after each body content when writing files.
** @edreamleo Note: Leo does it but only on nodes with are non-terminal nodes.** (is it a bug also?)
Easily reproduce with this command to clone a minimal reproducible example repo:
git clone https://github.com/boltex/test-markdown.git
And then reproduce with ctrl+shift+w to re-write the markdown file and see the diff it creates.
During startup, when leoSettings.leo is read, there is an exception: TypeError: d.get is not a function
.
This does not seem to prevent viewing and editing an outline.
reading settings in leoSettings.leo
reading settings in C:/Users/tom/.leo/myLeoSettings.leo
read outline in 0.19 seconds
TypeError: d.get is not a function
at SettingsTreeParser.parseOpenWithLine (c:\Users\tom\.vscode\extensions\boltex.leojs-0.2.5\dist\extension-node.js:2:1107288)
at SettingsTreeParser.parseOpenWith (c:\Users\tom\.vscode\extensions\boltex.leojs-0.2.5\dist\extension-node.js:2:1106787)
at SettingsTreeParser.doOpenWith (c:\Users\tom\.vscode\extensions\boltex.leojs-0.2.5\dist\extension-node.js:2:1103369)
at SettingsTreeParser.visitNode (c:\Users\tom\.vscode\extensions\boltex.leojs-0.2.5\dist\extension-node.js:2:1122680)
at SettingsTreeParser.traverse (c:\Users\tom\.vscode\extensions\boltex.leojs-0.2.5\dist\extension-node.js:2:1109316)
at async LoadManager.createSettingsDicts (c:\Users\tom\.vscode\extensions\boltex.leojs-0.2.5\dist\extension-node.js:2:927028)
at async LoadManager.computeLocalSettings (c:\Users\tom\.vscode\extensions\boltex.leojs-0.2.5\dist\extension-node.js:2:926211)
at async LoadManager.readGlobalSettingsFiles (c:\Users\tom\.vscode\extensions\boltex.leojs-0.2.5\dist\extension-node.js:2:930584)
at async LoadManager.doPrePluginsInit (c:\Users\tom\.vscode\extensions\boltex.leojs-0.2.5\dist\extension-node.js:2:933058)
at async LoadManager.load (c:\Users\tom\.vscode\extensions\boltex.leojs-0.2.5\dist\extension-node.js:2:930893)
at async runLeo (c:\Users\tom\.vscode\extensions\boltex.leojs-0.2.5\dist\extension-node.js:2:1809091)
at async activate (c:\Users\tom\.vscode\extensions\boltex.leojs-0.2.5\dist\extension-node.js:2:1816422)
at async u.n (c:\Users\tom\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:140:6255)
at async u.m (c:\Users\tom\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:140:6218)
at async u.l (c:\Users\tom\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:140:5675)
es_exception called without error!
LeoJS 0.2.5, master branch, build 2f8dca6
2023-12-16 23:36:29 -0500
Node.js v18.15.0, VSCode version 1.85.0
Windows 10 Home x64 (build 10.0.19045)
home: C:\Users\tom
leo-editor: C:\Users\tom\.vscode\extensions\boltex.leojs-0.2.5
Currently, leoJS reads the standard Leo leoSettings.leo file, and I presume, myLeoSettings.leo. But in the future, there will be a need for settings files specific to leoJS. For example, @button nodes may need to contain contain javascript instead of Python code.
I propose that leoJS should first look for a settings file specific to leoJS. If not found, copy and rename the corresponding Leo file. For example, on startup:
I thought I remembered that leoInteg had a working Nav tab, but I can't find it in leoJS. I use the Nav tab for almost all my searches, so this is important to me.
LeoJS 0.2.5, master branch, build 2f8dca6
2023-12-16 23:36:29 -0500
Node.js v18.15.0, VSCode version 1.85.0
Windows 10 Home x64 (build 10.0.19045)
home: C:\Users\tom
leo-editor: C:\Users\tom\.vscode\extensions\boltex.leojs-0.2.5
Some icons overlap with LeoInteg and appear doubled. Make the context variables unique!
Opening a url or a unl is originally done in Leo by handleUrl in leoGLobals.
VSCode offers ways to implement following @url and UNL links.
For starters, see https://code.visualstudio.com/api/references/vscode-api#DocumentLink and https://code.visualstudio.com/api/references/vscode-api#DocumentLinkProvider
When opening a leo file with leojs, the windows size and position may be available in the db. If so preserve them.
Only set them to some default value if completely inexistent in the db prior to opening it.
If the detected language of a script initiated by Ctrl+B is 'typescipt', consider the code to be a typescript source instead of javascript and run it through TSC compiler before giving it to the regular leojs script runner.
see https://stackoverflow.com/questions/23075748/how-to-compile-typescript-code-in-the-browser
see microsoft/TypeScript#50758
For instance, the commands section.
Leo PR #3241, merged into devel, contains non-controversial changes to Leo as part of Leo issue #3235.
Within Leo itself, g.os_path_normslashes
translates backslash to forward slashes, but only on Windows. Imo, g.os_path_normslashes
should be a do-nothing method on leoJS:
g.os_path_normslashes
should be necessary,os.sep
might (as an edge case) invalidate otherwise valid file specs.g.os_path_normslashes
causes weird problems in Leo's Qt drawing code,Summary
g.os_path_normslashes
is non-intuitive and troubling. I would like to remove it from Leo.g.os_path_normslashes
a do-nothing in leoJS.g.os_path_normslashes
per Leo PR #3241 would encapsulate the dubious code to a single method. Comments in g.os_path_normslashes
can discuss and justify the difference between Leo and leoJS.This issue continues Leo issue #1774. This is the proper place for this discussion.
Félix: leojs...would be most useful to test things on the [vs-code/js] side, without communicating to python / bridge etc., in order to sometimes get some help from vscode's team when trying to have them install and run the extension to test things, and show live-examples of what an (non-literate) outliner can do, without the need for them to also get leo setup. And I would ultimately merge the project into leoInteg. It could also be a starting point for someone who wants to re-do leo in js / rust/webassembly"
EKR: Preliminary design
Hurray! leojs doesn't have to do any of the following.
The kernel of leojs
Later improvements
The following Leonine features could be postponed until after all essential features are in place:
In Leo, the user can add menu items and even entire menus by adding them to the @settings. I realize that VSC menus work differently, but I have come to depend on some of my custom additions. Some of them contain standard Leo commands, some my own command scripts.
Is there going to be a path to creating the equivalent of Leo's custom menus and menu items?
Recently I've been doing a lot of work with the CUE language + project.
It's really a new paradigm of structured data + logic programming.
One of the features of the language is non-locality, i.e. where you put things doesn't matter,
which makes using Leo and Cue a very nice pair.
The project started at Google but now their independent, funded, and open source.
Also, they have a growing presence in the CNCF (Cloud Native Computing Foundation),
so LeoJS could be run remotely and fit in very well here (imho).
https://cuelang.org/
https://cuetorials.com/introduction/
I recommend anyone interested to join their slack channel.
For now, cancelling leo id input sets it to 'None'.
But It should instead be set to empty string, and let the startup finish, but set the leoReadyFlag to false (making all commands unavailable except 'setLeoID') until a valid leo id is entered via the setLeoId command.
(Once a valid leoid is entered the 'setLeoID' command should then be hidden and unavailable.
leojs.leo is the "official" .leo file for this project.
Individual contributors should make a copy of leojs.leo, called myLeojs.leo, for their own use. .gitignore ignores myLeojs.leo, so you can change it freely.
Important: leojs.leo uses @clean for all files. This means that all collaborators should keep the outline structure of all external files in sync! Otherwise, the @clean update algorithm will "assign" lines to the wrong nodes when reading @clean files. So the rule is:
Update leojs.leo whenever adding, moving or deleting nodes in an @clean tree.
It is easy to update leojs.leo from myLeojs.leo. Just use @button write-leojs. This script writes the top-level 'Startup', 'Documentation', and 'Code' nodes to leojs.leo. The script checks that it is, in fact, being run from myLeojs.leo.
The present name is "LEOJS: BODY".
At minimum, it should be "LeoJS: Body". There is no need for all caps.
A static name is fine during startup.
After startup, I recommend the following:
LeoJS:
followed by c.p.h
.c.p
.I have a node in my Workbook that contains some unl strings to other nodes both in and outside of the Workbook so I can test Ctrl-click navigation. This navigation works in Leo but not in leoJS.
LeoJS 0.2.6, master branch, build 91d1141
2023-12-21 23:06:09 -0500
Node.js v18.15.0, VSCode version 1.85.1
Windows 10 Home x64 (build 10.0.19045)
Although the text operations are more easily done with vscode's commands, it would be cool to have the rest of the editCommands.py content translated into typescript. (Most of those functions are easy enough for chatGPT to convert)
I'm not a big fan of icons in general. Here are two (somewhat conflicting!) suggestions:
Add an option to suppress the icons in the 'Outline' pane.
These icons obscure the path, which imo is much more important.
True, these icons disappear when focus is outside the 'Outline' are, but an option to dispense with them would be welcome.
Add an icon/menu item to go to the LeoJS: Welcome
pane.
This would complement the standard "gear" icon.
This suggestion is less important imo.
When opening large files the command buttons (new, open and recent files) are still visible for a laps of time in the outline panel.
Replace them with an 'Opening...' message while opening with the help of a new 'viewWelcome' entry in the package.json file.
I noticed that when I open an outline, I see buttons that I've defined in myLeoSettings.leo. But they don't work since they contain Python code that works with Leo. Also, the right-click goto Script does not work with them.
These buttons should not be shown.
It just creates an @url node instead as its first child.
From @tbpassin :
All right, it installed in vsc and it did open an outline. I saw a lot of errors like this:
reading settings in C:/Users/tom/.leo/workbook.leo
TypeError: Cannot read properties of undefined (reading 'trim')
at Ini_Importer.find_blocks (c:\Users\tom.vscode\extensions\boltex.leojs-0.2.0\dist\extension-node.js:2:1507413)
at Ini_Importer.gen_block (c:\Users\tom.vscode\extensions\boltex.leojs-0.2.0\dist\extension-node.js:2:1508153)
at Ini_Importer.gen_lines (c:\Users\tom.vscode\extensions\boltex.leojs-0.2.0\dist\extension-node.js:2:1511889)
at Ini_Importer.import_from_string (c:\Users\tom.vscode\extensions\boltex.leojs-0.2.0\dist\extension-node.js:2:1512400)
at exports.do_import (c:\Users\tom.vscode\extensions\boltex.leojs-0.2.0\dist\extension-node.js:2:1522910)
at LeoImportCommands.createOutline (c:\Users\tom.vscode\extensions\boltex.leojs-0.2.0\dist\extension-node.js:2:1338218)
at async AtFile.readOneAtAutoNode (c:\Users\tom.vscode\extensions\boltex.leojs-0.2.0\dist\extension-node.js:2:955878)
at async AtFile.readFileAtPosition (c:\Users\tom.vscode\extensions\boltex.leojs-0.2.0\dist\extension-node.js:2:954544)
at async AtFile.readAll (c:\Users\tom.vscode\extensions\boltex.leojs-0.2.0\dist\extension-node.js:2:953359)
at async FileCommands.readExternalFiles (c:\Users\tom.vscode\extensions\boltex.leojs-0.2.0\dist\extension-node.js:2:1151896)
at async FileCommands._getLeoFileByName (c:\Users\tom.vscode\extensions\boltex.leojs-0.2.0\dist\extension-node.js:2:1151493)
at async FileCommands.getAnyLeoFileByName (c:\Users\tom.vscode\extensions\boltex.leojs-0.2.0\dist\extension-node.js:2:1149953)
at async LoadManager.openFileByName (c:\Users\tom.vscode\extensions\boltex.leojs-0.2.0\dist\extension-node.js:2:937514)
at async LoadManager.loadLocalFile (c:\Users\tom.vscode\extensions\boltex.leojs-0.2.0\dist\extension-node.js:2:936309)
at async SessionManager.load_session (c:\Users\tom.vscode\extensions\boltex.leojs-0.2.0\dist\extension-node.js:2:1439599)
at async LoadManager.doPostPluginsInit (c:\Users\tom.vscode\extensions\boltex.leojs-0.2.0\dist\extension-node.js:2:932259)
at async LoadManager.load (c:\Users\tom.vscode\extensions\boltex.leojs-0.2.0\dist\extension-node.js:2:931126)
at async runLeo (c:\Users\tom.vscode\extensions\boltex.leojs-0.2.0\dist\extension-node.js:2:1807739)
at async activate (c:\Users\tom.vscode\extensions\boltex.leojs-0.2.0\dist\extension-node.js:2:1815070)
at async u.n (c:\Users\tom\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:140:6255)
at async u.m (c:\Users\tom\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:140:6218)
at async u.l (c:\Users\tom\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:140:5675)
The leovue repo is here.
I have a study outline for the actual LeoVue sources. I'll be uploading that outline to the leo-editor-contrib repo soon.
There are two files in leovue/src that likely contain the code:
leoJS logs to a tab in one of the standard VSC panes, usually located at the bottom right of the VSC window. When there is time to write up some guidance on programming leoJS, please explain how to add another tab there and communicate with it.
In Leo, I have some applications that live in a tab in the Log pane, and I'd like to be able to do something similar in leoJS. They need to be able to respond to user typed input and clicks, and to display clickable links that navigate to places in the outline.
Alas, vs-code will accept neither '#' comments nor html block comments in package.json. This could be called a buglet in the vs-code parser, but we are stuck with it. So...
@file can not be used for package.json
@clean is good enough, provided that leojs.leo is kept up to date with @button write-leojs
.
The Theia IDE [https://theia-ide.org/] is a compatible alternative to VSCode. They're doing some very interesting work although it's still in the earlier stages. Particularly paired with the work that TypeFox [https://www.typefox.io/] is doing with Langium, Sprotty and GLSP (the Graphical Language Server protocol) makes this very compelling.
In theory, VSCode plugins and Language Servers are fully compatible with Theia, just thought it was worth pointing out and having a look at.
Also, VSCode sometimes seems to take over, so to have your code in VSCode, with Leo2 running separately in Theia might be a bit more straight-forward for some users.
As if the external file check was still active from the old commander or something... :/
(Just an annoying notification that does not corrupt files, but still a very annoying glitch)
Introducing a deliberate error into a script (using print()
) produces the message, as do other errors -
exception executing script
ReferenceError: print is not defined
at eval (eval at executeScriptHelper (c:\Users\tom\.vscode-oss\extensions\boltex.leojs-0.2.8-universal\dist\extension-node.js:2:1065610), <anonymous>:9:1)
at eval (eval at executeScriptHelper (c:\Users\tom\.vscode-oss\extensions\boltex.leojs-0.2.8-universal\dist\extension-node.js:2:1065610), <anonymous>:13:3)
at Commands.executeScriptHelper (c:\Users\tom\.vscode-oss\extensions\boltex.leojs-0.2.8-universal\dist\extension-node.js:2:1065648)
at Commands.executeScript (c:\Users\tom\.vscode-oss\extensions\boltex.leojs-0.2.8-universal\dist\extension-node.js:2:1064871)
es_exception called without error!
saved: workbook.leo
It seems to be a minor error, but it seems pointless it it gets omitted over and over. The exclamation mark at the end becomes annoying, too.
Most of leoRst.ts is implemented, but the following lines importing the 3rd party libraries to handle restructured text (rST) in leoRst.py can not easily be reproduces in leoRst.ts, preventing the whole of the rst functionality to run:
# Third-part imports...
try:
import docutils
import docutils.core
from docutils import parsers
from docutils.parsers import rst
except Exception:
docutils = None # type:ignore
Find some libraries to do the equivalent, or implement this functionality from scratch (or via transliterating the python sources) to enable the rst functionality in LeoJS.
Both of these ancient Leo issues are marked "Won'tDo". That label can always be changed :-)
I am willing to consider either issue if it would help leoInteg or leojs.
As stated in #84 This feature should be enabled relatively easily. :)
To supplement the exposition of g, c p and the vscode object that are already available for scripts, finish 'hook' system for plugins to react to common event
To reproduce: hoist a node and try to navigate its hoisted suboutline with the arrow keys.
Note: the top icons above the outline seem to change so it looks like the 'refresh' cycle only has 'states' refreshing but not the outline and body pane themselves.
I'll use info issues to document what I learn about vs-code, js/ts, etc. that might be valuable for others who might want to join this project.
See PR #23 for the ekr-scripts2 branch.
package.json contains a lot of data. Make the JSON as Leonine as possible by adding separate nodes for various entries.
@clean package.json
.After running these scripts, it will be easy to alphabetize nodes and organize them with organizer nodes.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.