ansimax 1.0.0 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md ADDED
@@ -0,0 +1,274 @@
1
+ # Changelog
2
+
3
+ All notable changes to **ansimax** are documented in this file.
4
+ This project follows [Semantic Versioning](https://semver.org/).
5
+
6
+ ## [1.1.1] — bug fixes + improved examples
7
+
8
+ Patch release with two bug fixes from real-world testing of v1.1.0, plus
9
+ a cleaner set of examples covering every public API.
10
+
11
+ ### Fixed
12
+
13
+ - **`box()` no longer crashes with object padding.** Previously, calling
14
+ `box(text, { padding: { x: 2, y: 1 } })` threw `RangeError: Invalid
15
+ array length` because the code assumed `padding` was always a number.
16
+ Now non-numeric padding falls back to the default (`1`) gracefully.
17
+ The fix also covers `NaN`, `Infinity`, strings, and other malformed
18
+ input.
19
+ - **`components.menu()` cursor restoration on abrupt exit.** Previously,
20
+ killing the process while a menu was active (Ctrl+C, kill signal)
21
+ left the terminal cursor hidden because the cleanup handler only ran
22
+ through the normal menu lifecycle. Now `SIGINT`, `SIGTERM`, and
23
+ `exit` events trigger an emergency cursor restoration, so the terminal
24
+ is always left in a sane state.
25
+
26
+ ### Changed — Examples
27
+
28
+ - Replaced all examples in `/examples` with a clean set covering every
29
+ public API:
30
+ - `01-quick-smoke.ts` — verifies major imports
31
+ - `02-colors-gradients.ts` — color fns, gradients, `colorPresets`
32
+ - `03-ascii-banners.ts` — banners + 6 box styles + dividers
33
+ - `04-trees.ts` — builder + plain-data + 4 styles + algorithms
34
+ - `05-components.ts` — tables, badges, status, timeline, etc.
35
+ - `06-pixel-art.ts` — sprites + canvas + transforms
36
+ - `07-animations.ts` — typewriter, fade, slide, pulse, wave, glitch
37
+ - `08-loaders.ts` — spinners + tasks + countdown
38
+ - `09-themes.ts` — 8 themes + listeners + isolation
39
+ - `10-everything.ts` — comprehensive showcase
40
+ - `all-in-one.mjs` — ESM (`import`) version, no TypeScript
41
+ - `all-in-one.cjs` — CommonJS (`require`) version, no TypeScript
42
+ - All examples now import from `'ansimax'` (npm registry) instead of
43
+ `'../src/index.js'`, making them copy-pasteable into user projects.
44
+ - READMEs updated with animations + loaders preview GIFs in the
45
+ header, and an `all-ansimax.gif` showcase near the footer.
46
+
47
+ ### Notes
48
+
49
+ - No API changes — `1.1.1` is a drop-in replacement for `1.1.0`.
50
+ - No new dependencies — still zero runtime deps.
51
+ - All 1848 tests still pass.
52
+
53
+ ---
54
+
55
+ ## [1.1.0] — comprehensive hardening + new features
56
+
57
+ A massive robustness pass across every module, plus a new `trees` module,
58
+ new API surfaces, and broader test coverage (~1700+ tests across 16 suites).
59
+
60
+ **Backwards compatibility:** 100% preserved. All existing APIs work
61
+ identically — only defensive validation, new features, and bug fixes.
62
+
63
+ ---
64
+
65
+ ### Added — Trees (`trees/index.ts`) — NEW MODULE
66
+
67
+ Hierarchical text renderer inspired by Rich's `Tree`.
68
+
69
+ - **Builder API** — `tree('root').add('child').add('grandchild')`. `addLeaf()` returns the parent for fluent sibling-adds.
70
+ - **Plain-data API** — `renderTree({ label, children: [...] })` accepts any plain JS object.
71
+ - **4 visual styles** — `'normal'`, `'rounded'` (╰─), `'heavy'` (┣━), `'ascii'` (`+--`). Per-node `style` override mixes styles in one tree.
72
+ - **Per-node colors** — `color: ColorFn` colorizes the label.
73
+ - **Depth-based palette** — `palette: [color1, color2, ...]` cycles colors per depth level. Per-node `color` overrides.
74
+ - **Guide-line colors** — `guideColor` colorizes the `├──`/`│`/`└──` chars separately from labels.
75
+ - **Per-node icons** — `icon: '📁'` renders before the label.
76
+ - **Multi-line labels** — extra lines align with proper continuation glyph. CRLF normalized to LF.
77
+ - **Collapsed subtrees** — `collapse: N` hides the first N children, shows `[+N hidden]`.
78
+ - **Max depth truncation** — `maxDepth` truncates deep trees, shows `[+N more]` markers.
79
+ - **Indent option** — pad the entire tree with N leading spaces.
80
+ - **`renderTreeStream(root, opts)`** — generator that yields one rendered line at a time.
81
+ - **`measureTree(root, opts)`** — `{ width, height }` for layout decisions.
82
+ - **`walkTree(root, visitor)`** — depth-first traversal with cycle detection.
83
+ - **`findInTree(root, predicate)`** — locate first matching node.
84
+ - **`countNodes(root)`** — total node count.
85
+ - **`mapTree(root, fn)`** — transform every node, returns new tree (input untouched).
86
+ - **`filterTree(root, predicate, opts?)`** — keep matching nodes with optional `prune` mode.
87
+ - **Cycle detection** — `walkTree` / `mapTree` throw a clear error on circular references instead of stack overflow.
88
+ - **Strict validation** — non-string labels coerced, null/array root rejected.
89
+
90
+ ### Added — Configuration (`configure.ts`)
91
+
92
+ - **`onConfigKeyChange(key, listener)`** — subscribe to changes of a specific config key only. Listener fires with `(newValue, oldValue)`.
93
+ - **`pauseListeners()`/`resumeListeners()`** — batch multiple updates without flooding subscribers; resume flushes a single notification.
94
+ - **`withConfig(overrides, fn)`** — temporarily override config for a sync or async block, restoring previous state automatically (even on throw).
95
+ - **`strict` mode** — `configure(opts, { strict: true })` rejects unknown keys with `RangeError`; useful for catching typos in config files.
96
+ - **`DEFAULTS` exported** — `Object.freeze`d, accessible to consumers as `CONFIG_DEFAULTS`.
97
+ - **No-op detection** — `configure({})` or setting unchanged values no longer fires listeners.
98
+ - **Soft theme fallback** — uses `themes.tryUse` instead of `themes.use` so configure() doesn't throw on themes registered later.
99
+ - **Validation hardening** — `null`/array opts rejected, empty-string `theme`/`locale`/`asciiFont` rejected.
100
+
101
+ ### Added — Colors (`colors/index.ts`)
102
+
103
+ - **Adaptive escape cache** — `_fgEscCache` / `_bgEscCache` packed-RGB keyed, bounded LRU (512 entries). Gradient animations now 10–50× faster on repeated colors.
104
+ - **`clearColorCache()`** exported for tests and post-level-change cleanup.
105
+ - **`registerPreset(name, stops)`** — register custom gradient presets accessible via `color.<name>`.
106
+ - **`listPresets()`** — runtime list of available presets.
107
+ - **Reserved-preset guard** — registering presets with names like `bold`, `red`, `gradient` throws with a clear conflict message.
108
+ - **Text coercion** — `color.red(42)` now returns `"\x1b[31m42\x1b[0m"` (chalk/kleur compatibility).
109
+ - **NaN/Infinity-safe RGB** — `Infinity → 255`, `-Infinity → 0`, `NaN → 0` in `clampRgb`/`clamp256`.
110
+ - **`compose` filters non-functions** — `compose(red, null, bold)` works (null silently ignored).
111
+ - **`compose` swallows extractor errors** — user fns that throw on `extractOpen` skipped.
112
+ - **`gradient` single-stop colors statically** — consistent with CSS `linear-gradient` UX.
113
+ - **`gradient` defensive** — null/undefined/empty stops return text unchanged. Non-string text coerced. Grapheme iteration preserves emoji.
114
+ - **Bare `\x1b` literal in gradient** — malformed ANSI doesn't corrupt output.
115
+
116
+ ### Added — Themes (`themes/index.ts`)
117
+
118
+ - **Per-instance isolation** — `createTheme()` instances have their own registry. Registering a theme on one no longer leaks into others. Critical for multi-tenant SSR.
119
+ - **`tryUse(name)`** — tolerant theme switch returning `boolean` instead of throwing.
120
+ - **`onChange(listener)`** — subscribe to theme changes, returns unsubscribe. Errors swallowed.
121
+ - **`unregister(name)`** — remove themes, throws if removing the active one.
122
+ - **Background color helpers** — `bgPrimary`, `bgSecondary`, `bgAccent`, `bgSuccess`, `bgWarning`, `bgError`, `bgInfo`, `bgMuted`, `bgSurface`.
123
+ - **`success` color with fallback** — built-ins define it; user themes without `success` fall back to `accent`.
124
+ - **`style(name)` dynamic accessor** — `theme.style('primary')(text)` for config-driven styling. Identity fn for unknown names (no throw).
125
+ - **HEX_RE consistent** — `#` optional, matches colors module.
126
+ - **Strict validation** — `register()` rejects non-string/empty names, null/array defs, non-array gradient, short gradient (< 2 stops).
127
+ - **`BannerOpts` interface** — explicit type instead of fragile `Omit<Parameters<...>>` derivation.
128
+
129
+ ### Added — Animations (`animations/index.ts`)
130
+
131
+ - **Crash-safe cursor restore** — `exit/SIGINT/SIGTERM` handlers force-restore cursor even on uncaught exceptions.
132
+ - **Reference-counted `hideCursor`/`showCursor`** — concurrent animations don't reveal the cursor early.
133
+ - **`animate.delay(ms)` helper** — compatible with `sequence`/`chain`. Pause respecting signal.
134
+ - **`animate.parallel({ timeout })`** — race steps against a timeout to prevent hangs.
135
+ - **`animate.parallel` swallows per-step errors** — one failing step doesn't reject the whole Promise.all.
136
+ - **Signal propagation** — parallel steps receive the parent signal.
137
+ - **`wave` with single color** — renders statically with that color (better UX than skip).
138
+ - **`wave` with empty palette** — renders plain.
139
+ - **`reveal` with `steps` option** — scales with text length by default (`Math.min(60, Math.max(10, len*2))`).
140
+ - **`pulse`/`glitch` final write use `safeWriteAsync`** — backpressure-aware.
141
+ - **`safeWriteAsync`/`safeWrite`** wrappers swallow stream errors.
142
+ - **Hooks errors swallowed** — `onFrame`/`onDone`/`onAbort` errors don't break the loop.
143
+
144
+ ### Added — ASCII (`ascii/index.ts`)
145
+
146
+ - **Strict input validation** — `ensureString()` throws `TypeError` with clear messages for non-string text.
147
+ - **`ensureFontMap` validates type** — rejects null/array/non-object font maps.
148
+ - **`hasFont(name)`** — check if a font is registered without throwing.
149
+ - **`measure(text, font?, letterSpacing?)`** — get `{ width, height }` without paying full render cost.
150
+ - **`stream(text, { signal })`** — pre-aborted yields nothing; aborted mid-stream stops at next poll.
151
+ - **Cache key uses `\u0001` separator** — eliminates collision risk from font names containing `|`.
152
+ - **Grapheme iteration** in `renderFont` — preserves surrogate pairs and emoji.
153
+ - **`box`/`divider`/`logo` defensive** against -Infinity from `Math.max([])`, width 0, empty text.
154
+ - **`colorEachVisibleChar` bare `\x1b` literal** — non-CSI escapes emitted instead of consumed.
155
+
156
+ ### Added — Loaders (`loaders/index.ts`)
157
+
158
+ - **`spin` coerces non-string text/prefix/suffix**.
159
+ - **`spin` clamps NaN interval** to default 80.
160
+ - **`progress` clamps NaN/Infinity percent** to 0.
161
+ - **`progress` empty-char fallback**.
162
+ - **`countdown(NaN)` → 0**, negative → 0.
163
+ - **`tasks(non-array)` → `[]`** instead of crash.
164
+
165
+ ### Added — Frames (`frames/index.ts`)
166
+
167
+ - **Reference-counted cursor** — concurrent `play()` + `live()` + animations safe.
168
+ - **`registerCrashHandlers()`** — restore cursor on exit/SIGINT/SIGTERM.
169
+ - **`resetFramesCursorCount()`** exported for tests.
170
+ - **`play(non-array)`** — no-op controller instead of crash.
171
+ - **`play({ repeat: 0 })`** — explicit infinite loop.
172
+ - **`play({ repeat: -N })`** — negative now falls back to 1 (was infinite — dangerous on bad input).
173
+ - **`fps` capped at 60** — prevents CPU saturation with `fps: 9999`.
174
+ - **`generate` swallows per-frame errors** — one bad frame doesn't poison the sequence.
175
+ - **`generate` coerces non-string returns**.
176
+ - **`morph(steps=1)` clamps to 2** — avoids division by zero.
177
+ - **All presets defensive** — width=0 OK, NaN fallback, empty char fallback.
178
+ - **`live` with stop() idempotent** — multiple stops safe via `wasRunning` flag.
179
+
180
+ ### Added — Components (`components/index.ts`)
181
+
182
+ - **`progressBar(NaN/Infinity)` → 0%** — defensive numeric inputs.
183
+ - **`progressBar` with single-stop gradient** — colors statically (consistent with `gradient()` UX).
184
+ - **`badge` SGR codes validated** — NaN fg/bg falls back to defaults.
185
+ - **`table(non-array)` → `''`**, filters non-array rows, coerces non-string cells.
186
+ - **`columns(cols<1)` clamps to default** — no longer throws.
187
+ - **`columns(non-array)` → `''`**.
188
+ - **`timeline(non-array)` → `''`**, coerces event labels.
189
+ - **`section(NaN width)` falls back to terminal cols**.
190
+ - **`status({ icon: '' })` omits icon** — coherent with `icon: null`.
191
+ - **`menu([])` returns `MENU_CANCELLED`** instead of throwing (safer for runtime data).
192
+ - **`menu(non-array)` → `MENU_CANCELLED`**.
193
+ - **`menu` cleanup symmetric** — every path that hides cursor also restores it.
194
+ - **`menu` `safeResolve` prevents double-resolve** races.
195
+
196
+ ### Added — Images (`images/index.ts`)
197
+
198
+ - **All numeric inputs clamped** — `MAX_DIMENSION = 10000` prevents OOM on `Infinity`.
199
+ - **`renderPixelArt(non-array)` → `''`** instead of crash.
200
+ - **`ensurePixelGrid`** filters malformed rows.
201
+ - **`flipHorizontal`/`flipVertical`/`rotate90` defensive** — non-array input returns `[]`.
202
+ - **`gradientRect` validates colors array** — clear errors for empty/all-invalid.
203
+ - **`gradientRect` single-stop renders solid fill** — better UX.
204
+ - **`gradientRect(Infinity width)` clamps** to MAX_DIMENSION.
205
+ - **`createCanvas(NaN/0)` → 1×1**.
206
+ - **`createCanvas(Infinity)`** clamps to MAX_DIMENSION.
207
+ - **`canvas.set/get` reject non-finite coords** as no-op.
208
+ - **`canvas.drawRect/Circle/Sprite` defensive** against NaN, negative dims, non-array sprites.
209
+ - **`canvas.pixels` getter returns deep clone** — callers can't mutate canvas state.
210
+ - **`canvas.print` with try/catch** — stream torn down doesn't crash.
211
+ - **ANSI cache LRU bounded** at 1024 entries — survives massive color counts.
212
+ - **`Pixel` and `PixelGrid` exported** for typed consumers.
213
+
214
+ ### Added — Utils (`utils/ansi.ts`)
215
+
216
+ - **`OSC`, `ST`, `BEL` constants** exported.
217
+ - **`setTitle(text)`** — set terminal window title (OSC 2). Control chars stripped.
218
+ - **`link(text, url)`** — clickable hyperlink (OSC 8). Supported in iTerm2, Terminal.app, WezTerm, Kitty, modern xterm.
219
+ - **`bell()`** — terminal bell.
220
+ - **`cursor.position()`** — query position (CSI 6n).
221
+ - **`cursor.nextLine()`/`prevLine()`** — line-aware navigation.
222
+ - **`screen.clearAll()`** — alias for `clear()`.
223
+ - **`DEFAULT_TERM_COLS = 80`, `DEFAULT_TERM_ROWS = 24`** exported.
224
+ - **`writeAsync({ timeout })`** option — prevents infinite hangs on broken streams.
225
+ - **`OutputBuffer.pushIf(cond, str)`** — conditional append.
226
+ - **`detectColorSupport`** improved — TERM truecolor/24bit detection, 256 substring match, rxvt support, try/catch around `os.release()`.
227
+ - **All numeric inputs clamped** — `cursor.up(NaN)` → min=1, `fgRgb(Infinity, ...)` → 0.
228
+ - **`ensureString` coercion** — all writes accept any input.
229
+ - **`sleep(NaN/negative)` clamped** to 0.
230
+
231
+ ### Added — Utils (`utils/helpers.ts`)
232
+
233
+ - **`once(fn)`** — invoke a function exactly once.
234
+ - **`escapeRegex(str)`** — escape regex metacharacters.
235
+ - **`safeJson(value, indent?)`** — JSON.stringify handling BigInt and circular references.
236
+ - **`padBoth(str, width, ch?)`** — pad both sides equally, Unicode-aware.
237
+ - **`nextTick(cb)`** — `setImmediate` fallback to `setTimeout(0)`.
238
+ - **`memoize` with `{ keyFn }` option** — multi-argument memoization.
239
+ - **`onResize` with implicit throttle (50ms default)** — coalesces rapid resize events.
240
+ - **`debounce` with `maxWait` option** — guarantees invocation within window.
241
+ - **`diffLines` with `type: 'added' | 'removed' | 'changed'`** — richer damage tracking.
242
+ - **`gradientColor` auto-clamps `t`** — values outside [0,1] clamped automatically. NaN → 0.
243
+ - **`stripAnsi`/`visibleLen` defensive** against non-string inputs.
244
+ - **`termSize` validates** cols/rows > 0.
245
+
246
+ ---
247
+
248
+ ### Test infrastructure
249
+
250
+ - **~1700+ tests across 16 suites**, all green.
251
+ - Coverage: ~98% statements, ~95% branches, ~99% functions, ~99% lines.
252
+ - All test files use `FORCE_COLOR=3` + `resetColorSupportCache()` in `beforeEach` for isolation.
253
+ - New test isolation helpers exported: `resetCursorRefCount`, `resetFramesCursorCount`, `resetLoaderCursorCount`, `clearAnsiCache`, `clearThemeColorCache`, `clearColorCache`, `clearRenderCache`, `resetConfig`.
254
+
255
+ ### Examples
256
+
257
+ 6 production-grade examples in `/examples`:
258
+
259
+ - `01-cli-installer.ts` — npm-create style installer (banner + hierarchical tasks + status icons + summary box).
260
+ - `02-live-dashboard.ts` — real-time dashboard (frames.live + service table + gradient bars + onResize + SIGINT cleanup).
261
+ - `03-pixel-art-game.ts` — bouncing rocket sprite (canvas + alpha blending + sunset gradient + FPS counter + drift-corrected loop).
262
+ - `04-interactive-deploy.ts` — interactive menu + multi-select + loader.multi + createTheme + onConfigChange.
263
+ - `05-tree-visualizations.ts` — filesystem + dependency + JSON + decision trees (4 scenarios, walk + measure bonus).
264
+ - `06-everything-together.ts` — comprehensive showcase touching every module (NEW).
265
+
266
+ ---
267
+
268
+ ## [1.0.0] — initial release
269
+
270
+ - Core modules: `color`, `animate`, `ascii`, `loader`, `frames`, `components`, `themes`, `images`, `configure`.
271
+ - TypeScript types exported.
272
+ - Adaptive color rendering (NO_COLOR / FORCE_COLOR / TTY detection).
273
+ - AbortSignal support across all blocking APIs.
274
+ - 750+ tests, 85%+ coverage.
package/LICENSE CHANGED
@@ -1,21 +1,201 @@
1
- MIT License
2
-
3
- Copyright (c) 2025 Brashkie
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.