neinth
v0.11.9
Published
multi file code manager and builder
Maintainers
Readme
neinth code manager
- is a code management library:
- to act as intermediary translation layer for your own runtime framework/language;
- is a
devToolthat optimize your dev timeJSruntimeexecution:
- during your developement time using
neinth, theNeintRuntimeInstancedynamically and renew importsneinthScritpsas you write and saves;- making it technically more efficient then using build in js
runtime--watch, since withneinth, yourJSruntimedoesn't need to run full code again when changes happens;
installing starter project
you might need to stick to single package manager to run the binary, (such as
bun/bunxor others):
npm i neinth
npx neinth-starter -p your-package-nameinstalling distributed neinth script project
from symlinked using
linkapi of your package manager,
⚠⚠⚠ the
iflag are for fresh installation, and might overwrite same name file, suggested to rename the every other thancoredirinto something else; ⚠⚠⚠
- ⚠⚠⚠ installation ⚠⚠⚠:
npm link your-package-name
npx neinth-package -p your-package-name -i- update:
npx neinth-package -p your-package-namedistributed npm library:
- ⚠⚠⚠ installation ⚠⚠⚠:
npm i your-package-name
npx neinth-package -p your-package-name -i- update:
npm i your-package-name
npx neinth-package -p your-package-namerunning neinth-src
- refer to NeinthComponent for handling your logic;
npx neinth- neinth only support
.mjsextention out of the box, but you can still use.tsor.mtsby generating.mjsfiles inside theneinth-src
convenience for distributing neinth script
dir structure:
package root
neinth-src
your-package-name: must refer to valid distributedpackage.json.name, whethersymlinkedor throughnpm;
core: this path are not to be edited by user and are used by dev for when updating distributed packages;- other then
core: these dirs are to be able to be safely edited, and must not be needed to be auto overwrited when updating, any update that requires modification in any of these dirs must be documented for manual update;
further documentation and example
- use cases will be posted at html-first/neinth;
.vscode snippets:
>>Neinth_Config:
- use to generate config class file, importable via options
listenToNeinth;- can also be used for autodocumentation, via @html_first/js_lib_template;
>>Neinth_Module:
- to generate neinth instance for modules;
>>Neinth_Watcher:
- generate
reactivechokidar watcher, fully managed vianeinthScript;- auto-notify on
allevent to anyneinth moduleimporting it vialistenToNeinth;
>>Neinth_UpdateValue:
- typehint helper for updating the value;
>>Neinth_UpdateValue$:
- typehint helper for updating the value;
- also an
vivth.$;
>>Neinth_Worker:
- generate worker defintion file string;
- should be named
${fileName}.worker.mjs;
>>Neinth_GetShared:
- generate typehelper for getSharedData;
>>Neinth_SetShared:
- generate typehelper for setSharedData;
version
-0.10.x:
- the
arg0areEffect, therefore main function will rerun on listener/importersautosubscribedSignals;
0.11.x:
- class renames;
Effectsare now callables viathis.new$orthis.updateValue$, for more granularity onautoSubscribedSignals;- this version is likely to be used as standards for future releases;
main classes for instantition:
- NeinthComponent: as main logic;
- NeinthWatcher: as helper for watcher;
- NeinthWorker: as
workerThreadwrapper;
exported-helpers
- Infos
- StdInHandler
- NeinthComponent
- PassiveSignal
- SetOfFiles
- NeinthWatcher
- DataWorkers
- NeinthWorker
- WorkerContract
- class typeHelper for file infos using neinthWatcher;
- containts
Direntand additional usefull property for the returnedfile/dir;
- class wrapper for several statics, mainly for handling
stdInput; - provides
listenToStdInfunctionality; - exported for more concise IDE for
bufferToStringsstatic method;
- is an extended Signal
PassiveSignal;
/**
* @template returnedValue
* @template sharedType
* @extends {PassiveSignal<returnedValue>}
*/- can be autoSubcribed by
Effect/; - constructor no longer get
handlersas parameters:
handlerscan be accessed viathisinsideconstructorarg0;
runInstanceFallback:fallbackto be called whenerroroccures by some implementation(eg. server crash);instancePath:getterforrelativePathof currentNeinthComponenttoprojectRoot;newSignal: local state management, for two way communication;updateValue: notify changes to allNeinthComponentInstancesubscribers, one way communication;updateValue$:vivth.$to unwrap listeners.valuegetter, uses returned value to notify changes to allNeinthComponentInstancesubscribers, one way communication, is to be used as return value;new$:vivth.$to unwrap listeners.valuegetterreturn void;SetOfFiles:Setinstance generator to be used bysynchronizeFiles;synchronizeFiles: neinth provide no individual fileWritter as you might need to manage write and unlink upon cleanup, and it can be quickly unmanageable if the file is then be written again anyway.listenToNeinth: getproxyPassiveSignalforNeinthComponent;listenToStdIn:PassiveSignal<Buffer>listened fromStdIn;generateWatcher: generateNeinthWatcherto same dir same basename with.watcher.mjsextention;listenToGeneratedWatcher: calllistenToNeinthtargettinggenerateWatchergeneratedNeinthWatcherof the sameNeinthComponent;indentedString: add indentation on each line;bufferToStrings: convertBuffertoArray<string>;bufferToCLIStrings: the same asbufferToStringshowever withCLIabstractionhelpers;normalizePath: convert string\to/;resolveProjectPath: relative project path to machine absolute;importWorker: for non blockingprocess, or just any longprocessrequiring it's own thread, implemented with typehinting, trycatched into{result, error}object for consistency and types;getSharedData:getprevious data onshared, usefull for handling through NeinthComponent lifecycle, or onvivth.$;setSharedData:setsharedobject, usefull for handling through NeinthComponent lifecycle, or onvivth.$;withCleanUp:NeinthComponentInstancelifecycle management, for setting up cleanup callbacks;safeUniquePing: wrap callback invivth.PingUniqueandvivth.TryAsync, to safely run them and debounce it's call:
- don't unwrap
SignalInstance.valueinside thiscallbackas it will be out of scope;
- further documentation on html-first/neinth
/**
* @template V
* @extends Signal<V>
*/- deliberate jsdoc lock for
valueassignment, require to be bypassed with// @ts-expect-error, if necessary;
- constructor helper for createing structured SetInstance for
neinth.handlers.synchronizeFiles;
neinth.handlers.synchronizeFilesarestorage read heavyforsynchronizationpurposes;
/**
* @typedef {Object} NeinthWatcherOptions
* @property {string} relativePath
* @property {boolean} addFileToSet
* @property {boolean} addDirToSet
* @property {BufferEncoding} [encoding]
*/
/**
* @extends NeinthComponent<{watcherOptions:NeinthWatcherOptions, infos:Set<Infos>}>
*/- export
NeinthWatcherInstanceas default onneitnh-src/**/*to be used asdirectory/filewatcher; neinthWatcheruseschokidarunder the hood;- this is a simplified helper for
FSwatcher, you can always implement your own extendedNeinthComponent, however once your class works as you intended recomended to export outsideneinth-src, so it's not treated as dynamic module;
- placeholder for
Workersmanagement;
- instance constructor for
workerThread; - by creating
fileName.worker.mjs, insideneinth-srcyou can generate worker definition file viainstantiation;
- can be used on
NeinthComponentby callingthis.importWorker('workerPath');- the return value is a
PassiveSignal, so you need to unwrap the.valuegetterinsidethis.new$then if result is to be used to changeNeinthComponentInstancevalueyou can usethis.updateValue;
- placeholder for
WorkerstypehintsonmainThread;
