Questions and answers
Short answers, each with the page that goes deeper. Every command and every snippet was run on the Hello Amber project from the install page.
Getting started
How do I start a new project? Install the tools once with npm install -g grunt-cli grunt-init @ambers/cli. Then, in an empty directory, run amber init, answer its questions, and run amber serve. Open http://localhost:4000/. Install.
How do I get Helios back after I closed it? Press Shift, Shift, Ctrl, Shift on the page. The starter dialog returns with its two buttons. From the browser’s JavaScript console, require(['amber/helpers'], amber => amber.popupHelios()) opens Helios directly. Working in Helios.
Which Amber is running? In a workspace, print Smalltalk version. On the command line, amber with no arguments names the versions of the command and of Amber.
How do I get the newest Amber? For new projects, npm install -g @ambers/cli. For a project you have, npm update moves it within its minor version. A new minor version takes one install more. Upgrading a project.
What does the caret mean in "@ambers/lang": "^0.31.0"? It is a range: at least 0.31.0, and below 0.32.0. On a 0.x version the caret stops at the next minor release. package.json says what may be installed, not what is.
Working on the page
How do I read the value of an input field? Ask the element. With the DOM, (document querySelector: '#field1') value. With Silk, '#field1' asSilk element value. With jQuery, '#field1' asJQuery val. Amber and JavaScript.
How do I call a JavaScript function? Send it as a message. console log: 'hello' calls console.log, and for more than one argument only the first keyword names the function: Math max: 3 with: 7. Amber and JavaScript.
How do I fire and receive events between my own objects? With announcements. Keep an Announcer. A listener registers with anAnnouncer on: ItemAdded do: [ :ann | ... ], and the sender calls anAnnouncer announce: (ItemAdded new item: anItem). ItemAdded is a class of yours, with the slots the listener needs.
How do I add a method to String, or to another class of Amber? In the browser, select the class. Put the method into a protocol named after your package with a star in front, *HelloAmber. The method then belongs to your package and is committed with it. Working in Helios.
How do I use a JavaScript library from npm? Install it and write a name.amd.json that names its file. Run grunt devel, and import the module into your package, bound to a name. Libraries.
Should the .amd.json point at the minified file? Point at the readable build when the library ships one. Errors then show readable source, and grunt deploy minifies the bundle anyway. dayjs ships only its minified build at the top level, so its entry names that one.
When something goes wrong
Helios says “Commit failed”. amber serve writes where it was started. Start it in the project’s directory, or give it the directory with --base-path. Working in Helios.
My page stops loading after I changed a package’s imports. A wrong module name in the imports stops the package from loading, and Helios with it. Open src/YourPackage.js and remove the module from the requirejs list in the line that sets $pkg.isReady, and from $pkg.imports. Reload, fix the imports in Helios, and commit.
A method using an imported name says it “is not defined”. The name is bound when the package loads from its file. Commit the package and reload the page; then the method runs. Libraries.
grunt deploy prints “Cannot uglify file”. The project’s Gruntfile is from before 0.32. Change optimize: "uglify2" to "none" and add the terser step. Upgrading a project.
grunt devel stops with ENOENT. A file that the Gruntfile or an .amd.json names is not there, often after an npm uninstall. Remove the reference, or install the package again.
My test needs the browser and grunt test has none. Run it in Helios’ test runner, which runs the same tests in the page. Working in Helios.
Where to ask
The start page lists the chat, the mailing list and the issue trackers.