|
| 1 | + |
| 2 | + |
| 3 | +# Built-in Libraries |
| 4 | + |
| 5 | +This document lists the standard libraries that are pre-integrated into @codebase and available for use in your extensions and projects. |
| 6 | + |
| 7 | +## Icon Libraries |
| 8 | + |
| 9 | +### Font Awesome |
| 10 | +Font Awesome provides scalable vector icons that can be customized with CSS. |
| 11 | + |
| 12 | +**Import:** |
| 13 | +Font Awesome is globally available |
| 14 | + |
| 15 | +```js |
| 16 | +// Add a Font Awesome icon to an element |
| 17 | +element.innerHTML = '<i class="fas fa-save"></i>'; |
| 18 | +``` |
| 19 | + |
| 20 | + |
| 21 | +### Devicons |
| 22 | +Developer-focused icons for programming languages and development tools. |
| 23 | + |
| 24 | +**Import:** |
| 25 | +Devicons are available globally. |
| 26 | + |
| 27 | +```js |
| 28 | +// Add a Devicon to an element |
| 29 | +element.innerHTML = '<i class="devicon-javascript-plain"></i>'; |
| 30 | +``` |
| 31 | + |
| 32 | + |
| 33 | +### Octicons |
| 34 | +GitHub's icon set. |
| 35 | + |
| 36 | +**Import:** |
| 37 | +Octicons are available globally. |
| 38 | + |
| 39 | +```js |
| 40 | +// Add an Octicon to an element |
| 41 | +element.innerHTML = '<i class="octicon octicon-mark-github"></i>'; |
| 42 | +``` |
| 43 | + |
| 44 | +## Template Engines |
| 45 | + |
| 46 | +### Mustache |
| 47 | +Logic-less templates. |
| 48 | + |
| 49 | +**Import:** |
| 50 | +Mustache is available globally. |
| 51 | + |
| 52 | +```js |
| 53 | +const Mustache = brackets.getModule("thirdparty/mustache/mustache"); |
| 54 | +// example |
| 55 | +const template = "Hello {{name}}!"; |
| 56 | +const data = { name: "World" }; |
| 57 | +const output = Mustache.render(template, data); |
| 58 | +``` |
| 59 | + |
| 60 | + |
| 61 | +## Utility Libraries |
| 62 | + |
| 63 | +### Lodash |
| 64 | +A modern JavaScript utility library delivering modularity, performance & extras. |
| 65 | + |
| 66 | +**Import:** |
| 67 | +Lodash is available globally. |
| 68 | + |
| 69 | +```js |
| 70 | +const _ = brackets.getModule("thirdparty/lodash"); |
| 71 | +``` |
| 72 | + |
| 73 | + |
| 74 | +### Marked |
| 75 | +A markdown parser and compiler. |
| 76 | + |
| 77 | +**Import:** |
| 78 | +Marked is available globally. |
| 79 | + |
| 80 | +```js |
| 81 | +const marked = brackets.getModule('thirdparty/marked.min'); |
| 82 | +const html = marked("# I am using __markdown__."); |
| 83 | +``` |
| 84 | + |
| 85 | + |
| 86 | +## Phoenix-specific Libraries |
| 87 | + |
| 88 | +These libraries are available through the Phoenix.libs namespace: |
| 89 | + |
| 90 | +### LRU Cache |
| 91 | +Least Recently Used (LRU) cache implementation. |
| 92 | + |
| 93 | +**Import:** |
| 94 | +```js |
| 95 | +const { LRUCache } = Phoenix.libs; |
| 96 | +// example |
| 97 | +const cache = new LRUCache(100); // Create cache with max 100 items |
| 98 | +cache.set('key', 'value'); |
| 99 | +const value = cache.get('key'); |
| 100 | +``` |
| 101 | + |
| 102 | + |
| 103 | +### Highlight.js |
| 104 | +Syntax highlighting for code. |
| 105 | + |
| 106 | +**Import:** |
| 107 | + |
| 108 | +```js |
| 109 | +const { hljs } = Phoenix.libs; |
| 110 | +// see hilight js docs for usage |
| 111 | +``` |
| 112 | + |
| 113 | + |
| 114 | +### iconv |
| 115 | +Character encoding conversion. |
| 116 | + |
| 117 | +**Import:** |
| 118 | +```js |
| 119 | +const { iconv } = Phoenix.libs; |
| 120 | +// Example |
| 121 | +const buffer = iconv.encode("Hello", 'utf8'); |
| 122 | +const text = iconv.decode(buffer, 'utf8'); |
| 123 | +``` |
| 124 | + |
| 125 | +### picomatch |
| 126 | +Glob matching and pattern matching. |
| 127 | + |
| 128 | +**Import:** |
| 129 | +```js |
| 130 | +const { picomatch } = Phoenix.libs; |
| 131 | +// Example |
| 132 | +const isMatch = picomatch('.js'); |
| 133 | +console.log(isMatch('file.js')); // true |
| 134 | +console.log(isMatch('file.css')); // false |
| 135 | +``` |
| 136 | + |
| 137 | + |
| 138 | + |
| 139 | +## Notes |
| 140 | + |
| 141 | +- All libraries are pre-loaded when your extension starts up |
| 142 | +- Some libraries are available globally through the `window` object |
| 143 | +- Phoenix-specific libraries are accessed through `Phoenix.libs` |
| 144 | +- Version information for each library can be found in the package dependencies |
0 commit comments