Repository navigation
Conversation
…mported by id, kept in the map
A plugin provides a library through trigscript.build (service version 2): provideLibrary({ id, label,
version, modules }). A script imports "<id>/<module>" or "<id>" (index), as it imports the standard
library; only the modules something imports join the build, at __libraries__/<id>/.
When the script is applied, each library it imports is copied into the map under
trigscript\@libraries\<id>\ with a library.json, and the map builds with that copy from then on, with
or without the plugin. A newer provided version is offered in the editor (Keep / Update), never taken
by itself. The manifest's source hash covers the copies; with none it is the old hash, so existing
maps still read as built.
Also: Monaco gets each library's modules (completion, hovers), commands trigscript.libraries and
trigscript.updateLibraries, state() lists the copies, contract.d.ts documents provideLibrary, and
examples/library is a complete library plugin to copy. Played in the editor end to end.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WdKDdRDTseBGCMyjhrAiNG
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Lets another plugin give TrigScript scripts a library to import, the way the standard library is imported.
For map makers.
import { spawnWave } from "waves"imports a library a plugin provides ("waves/spawn"for one module,"waves"for itsindex). Applying the script copies each imported library into the map (trigscript\@libraries\<id>\), and the map builds with that copy from then on: it still builds where the plugin is not installed, or where a different version is. When the installed plugin has a different version, the editor offers Update / Keep the map's copy. It never updates by itself.For plugin authors.
trigscript.buildis now service version 2, withprovideLibrary({ id, label, version, modules }), documented incontract.d.tsand the README (Providing a library).examples/libraryis a complete library plugin to copy, installable asgithub:scm-js/plugin-trigscript/examples/library.How
compiler/libraries.ts):CompileOptions.libraries. Only modules something imports join the files (__libraries__/<id>/…), so aprogram()in a library module runs only where that module is imported. TypeScriptpathsand the linker resolve bare ids. A missing library or module gets a message saying where libraries come from.script.ts):readLibraries/withLibraries;pathOfkeeps the copy out of the script's own files. The manifest hash covers the copies viahashSources; with no libraries it equalshashFiles, so existing maps still read as built.trigscript.librariesandtrigscript.updateLibraries;state()lists the copies.Tested
tests/libraries.test.ts(compiler, map copy, the example library) and service tests (copy on apply, building without the plugin, update, dropping an unused library, contributions, refusals). There is also a test that the compile worker's own source forwardslibraries. Full suite: 1398 passed;tscclean.trigscript\@libraries\waves\…. Reopened with the example at 1.1.0 → the notice, then Update → "Changes not applied". Reopened with the example not installed → 0 problems, still built.Left open (in
docs/v4-plan.md, Libraries from other plugins): a Libraries view, cost per library, media in libraries, a template repository and a way to test a library in its own repo, libraries without a plugin, and the scm-js guide pages once a release pins this.🤖 Generated with Claude Code
https://claude.ai/code/session_01WdKDdRDTseBGCMyjhrAiNG