This file replaces the old wiki page.
See INTERNALS.md for more about the structure of the code.
By contributing to TabFern, you license your contribution for use under CC-BY-SA 3.0, or any later version, at the option of the person using your contribution. See LICENSE.md for the license text and more details.
Please do not use any code or other content from Stack Overflow or any other Stack Exchange Web site. Explanation follows.
In 2019, Stack Exchange (SE) went through a relicensing process. SE has not provided information I need about licenses to SE-hosted content. I would like to avoid introducing any ambiguity into the TabFern code base if at all possible. Thank you for your understanding!
- Install Git.
- If you have never used git before, there are lots of tutorials online. I found Think Like a Git very helpful. Remember that whatever you do on your local copy won't mess up anyone else, so you can relax :) .
- Install node.js v10+.
- Install npm v6+. It comes with node.js on some systems and is a separate package on others.
- At a command line,
npm install -g npx
. - Fork this repo and clone your fork to your local machine.
- Update 2021-12-11 The default branch is called
main
(notmaster
).
- Update 2021-12-11 The default branch is called
We use a Brunch-based workflow. See
below for why. Developing on the main
branch involves:
- At a command prompt (
cmd
orbash
, whichever works),cd
to the directory where your fork is. - Create a new branch (e.g.,
git checkout -b mybranch origin/main
) - Run
npm install
. This will download all the other packages TabFern and its build process use. - Run
npx brunch w
. This will buildapp/
and the other directories in the branch intopublic/
. It will also leavebrunch
running. (To build but not leavebrunch
running, saynpx brunch b
.) - Load the
public/
directory as an unpacked extension.- In Chrome, go to
chrome://extensions
. Turn on "Developer Mode" in the upper right. Click "Load unpacked" and navigate to thepublic/
directory. Click "Select folder." - For Firefox, see the Firefox wiki page.
- In Chrome, go to
- Hack away! As you make changes,
brunch
will automatically rebuild the files inpublic/
. - After you make changes to any files, refresh the TabFern or settings window
to see them.
- If you change anything in
manifest.json
,var/
,brunch-config.js
, orapp/bg
, you will probably need to reload the extension. In Chrome, go tochrome://extensions
and click the circular arrow in TabFern's box.
- If you change anything in
If you want to make a .zip
, e.g., to try installing from a different folder,
say npm run zip
. The output will be in webstore-<VERSION>.zip
.
-
A tweaked version of Brunch builds the plugin into public/. The tweaks are here.
-
If you get a warning that says:
Browserslist: caniuse-lite is outdated. Please run next command
npm update
run
npx browserslist@latest --update-db
.npm update
won't actually help. Thanks to Andrey Sitnik for this answer.
Two reasons:
- It permits us to use npm packages much more easily. (It also permits more easily keeping those packages up to date!)
- It gives us flexibility to adjust the build for other targets, such as Firefox (#100).
This workflow takes a bit of getting used to, but works fairly well.
This section includes instructions for some specific tasks.
A good example is this commit.
-
Decide what type of setting it is. Currently TF divides Booleans (checkboxes) from everything else.
-
Edit
app/common/setting-definitions.js
to add the data storage and code interface to the setting:-
In the "Names of settings" section, go to the end of the "Booleans" or "Strings", depending on the type (boolean or other, respectively).
-
For booleans, add a paragraph following this template:
_NAM.CFG_POPUP_ON_STARTUP = 'SETTING-NAME'; _DEF[_NAM.CFG_POPUP_ON_STARTUP] = DEFAULT; _VAL[_NAM.CFG_POPUP_ON_STARTUP] = _vbool;
-
For other, add a paragraph following this template:
_NAM.CFGS_THEME_NAME = 'SETTING-NAME'; _DEF[_NAM.CFGS_THEME_NAME] = DEFAULT; _VAL[_NAM.CFGS_THEME_NAME] = (v)=>{ CODE
};
CODE
is a validator. It should check the given input and return a valid value for the setting, orundefined
to use the default. -
In the above paragraphs:
DEFAULT
must betrue
orfalse
for booleans, or a string for others.SETTING-NAME
should be a name that is all lowercase ASCII plus hyphens.
-
-
Edit
app/settings/manifest.js
to add the user interface to the setting:- In the "Settings" section, find the tab to which you want to add the
setting. It will be listed as a value of the
tab
field. - Scroll down to the point at which you want to add the setting. This
should be after the last setting in that tab unless there is a
compelling reason to do otherwise. Settings appear in the interface
in the order given in the
setting_definitions
array. - Copy and paste one of the
{ }
blocks, each of which is a setting. Pick one that matches the type of UI control you want (e.g.,type: checkbox
ortype: text
). See here for more documentation of the available options. - Edit the values appropriately.
- In the "Settings" section, find the tab to which you want to add the
setting. It will be listed as a value of the
- If you add a name ending with
id
(in any case), and it's not all upper-case, please spell itId
rather thanID
orid
. That will help avoid bugs like #304. Thanks!
The following dev dependencies are listed in package.json
but not used
directly by TF itself. They are listed to increase the minimum required
version satisfying an indirect dependency. If you add such a dependency to
package.json
, please also add it here.
- acorn
- archiver
- fstream
- lodash
- minimist
- mixin-deep
- path-parse
- set-value
- tar