@hearthscale/app-ui 0.0.0-stage → 0.2.0
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/LICENSE +25 -0
- package/README.md +167 -2
- package/dist/CLASSES.md +574 -0
- package/dist/TOKENS.md +413 -0
- package/dist/chunks/chunk-E3RFTBRS.js +332 -0
- package/dist/editor.d.ts +32 -0
- package/dist/editor.js +69 -0
- package/dist/fonts/InterVariable.woff2 +0 -0
- package/dist/fonts/JetBrainsMono-Bold.woff2 +0 -0
- package/dist/fonts/JetBrainsMono-Medium.woff2 +0 -0
- package/dist/fonts/JetBrainsMono-Regular.woff2 +0 -0
- package/dist/fonts/JetBrainsMono-SemiBold.woff2 +0 -0
- package/dist/fonts/OFL.txt +92 -0
- package/dist/index.d.ts +745 -0
- package/dist/index.js +1499 -0
- package/dist/markdown.d.ts +25 -0
- package/dist/markdown.js +365 -0
- package/dist/remixicon/License +201 -0
- package/dist/remixicon/remixicon.css +3229 -0
- package/dist/remixicon/remixicon.woff2 +0 -0
- package/dist/ui.css +12023 -0
- package/package.json +82 -3
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
|
|
3
|
+
/** What a reply's links reach. */
|
|
4
|
+
interface MarkdownLinks {
|
|
5
|
+
/** A web address or a `hearthscale:` link the reply links to. */
|
|
6
|
+
open(href: string): void;
|
|
7
|
+
/** A file of the reply's turn named by its name: a picture's address
|
|
8
|
+
* and what opening it does at the press that opened it, or null for no
|
|
9
|
+
* such file. */
|
|
10
|
+
file(name: string): {
|
|
11
|
+
picture: string | Promise<string> | null;
|
|
12
|
+
open(at: HTMLElement): void;
|
|
13
|
+
} | null;
|
|
14
|
+
}
|
|
15
|
+
/** A reply's text as the transcript draws it. @category Chat */
|
|
16
|
+
declare const Markdown: react.NamedExoticComponent<{
|
|
17
|
+
children: string;
|
|
18
|
+
links: MarkdownLinks;
|
|
19
|
+
/** How the reply shows while it is still arriving: its words as they
|
|
20
|
+
* come, or a finished block at a time. */
|
|
21
|
+
streaming?: "tokens" | "blocks";
|
|
22
|
+
}>;
|
|
23
|
+
|
|
24
|
+
export { Markdown };
|
|
25
|
+
export type { MarkdownLinks };
|
package/dist/markdown.js
ADDED
|
@@ -0,0 +1,365 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CopyGlyph
|
|
3
|
+
} from "./chunks/chunk-E3RFTBRS.js";
|
|
4
|
+
|
|
5
|
+
// ../ui/dist/chat/markdown.js
|
|
6
|
+
import { jsx as _jsx5, Fragment as _Fragment } from "react/jsx-runtime";
|
|
7
|
+
import { Children, createContext as createContext2, isValidElement, memo, useContext as useContext2, useEffect as useEffect5, useMemo, useState as useState5 } from "react";
|
|
8
|
+
import ReactMarkdown, { defaultUrlTransform } from "react-markdown";
|
|
9
|
+
import remarkGfm from "remark-gfm";
|
|
10
|
+
|
|
11
|
+
// ../ui/dist/Chart.js
|
|
12
|
+
import { jsx as _jsx3 } from "react/jsx-runtime";
|
|
13
|
+
import { useEffect as useEffect3, useRef as useRef3, useState as useState3 } from "react";
|
|
14
|
+
|
|
15
|
+
// ../ui/dist/CodeBlock.js
|
|
16
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
17
|
+
|
|
18
|
+
// ../ui/dist/copy.js
|
|
19
|
+
import { useEffect, useRef, useState } from "react";
|
|
20
|
+
|
|
21
|
+
// ../ui/dist/motion/motion.js
|
|
22
|
+
function tokenMs(el, token) {
|
|
23
|
+
const value = getComputedStyle(el).getPropertyValue(token).trim();
|
|
24
|
+
return value.endsWith("ms") ? parseFloat(value) : parseFloat(value) * 1e3;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// ../ui/dist/copy.js
|
|
28
|
+
function useCopy() {
|
|
29
|
+
const [copied, setCopied] = useState(false);
|
|
30
|
+
const timer = useRef(void 0);
|
|
31
|
+
useEffect(() => () => clearTimeout(timer.current), []);
|
|
32
|
+
const copy = (what, press) => {
|
|
33
|
+
const hold = tokenMs(press, "--dur-copied");
|
|
34
|
+
const written = typeof what === "string" ? navigator.clipboard.writeText(what) : what();
|
|
35
|
+
void written.then(() => {
|
|
36
|
+
clearTimeout(timer.current);
|
|
37
|
+
setCopied(true);
|
|
38
|
+
timer.current = setTimeout(() => setCopied(false), hold);
|
|
39
|
+
}, () => {
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
return { copied, copy };
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// ../ui/dist/CodeBlock.js
|
|
46
|
+
function CodeBlock({ code, language, reason }) {
|
|
47
|
+
const { copied, copy } = useCopy();
|
|
48
|
+
return _jsxs("div", { className: "hs-code-block", children: [_jsxs("div", { className: "hs-code-head", children: [_jsx("span", { className: "hs-code-language", children: language ?? "code" }), reason && _jsx("span", { className: "hs-code-reason", children: reason }), _jsxs("button", { type: "button", onClick: (e) => copy(code.replace(/\n$/, ""), e.currentTarget), className: "hs-code-copy", children: [_jsx(CopyGlyph, { size: 11 }), copied ? "Copied" : "Copy"] })] }), _jsx("pre", { className: "hs-code-pre", children: code })] });
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// ../ui/dist/ThemeRoot.js
|
|
52
|
+
import { jsx as _jsx2, jsxs as _jsxs2 } from "react/jsx-runtime";
|
|
53
|
+
import { createContext, useContext, useEffect as useEffect2, useRef as useRef2, useState as useState2 } from "react";
|
|
54
|
+
var SchemeContext = createContext(null);
|
|
55
|
+
var LookContext = createContext("");
|
|
56
|
+
function useLook() {
|
|
57
|
+
return useContext(LookContext);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// ../ui/dist/Chart.js
|
|
61
|
+
function chrome(element) {
|
|
62
|
+
const style = getComputedStyle(element);
|
|
63
|
+
const token = (name) => style.getPropertyValue(name).trim();
|
|
64
|
+
const ink = token("--mut");
|
|
65
|
+
const line = token("--cardb");
|
|
66
|
+
const font = token("--font-app");
|
|
67
|
+
return {
|
|
68
|
+
title: { color: token("--text"), subtitleColor: ink, font, subtitleFont: font },
|
|
69
|
+
axis: {
|
|
70
|
+
domainColor: line,
|
|
71
|
+
gridColor: token("--line"),
|
|
72
|
+
tickColor: line,
|
|
73
|
+
labelColor: ink,
|
|
74
|
+
titleColor: ink
|
|
75
|
+
},
|
|
76
|
+
legend: { labelColor: ink, titleColor: ink },
|
|
77
|
+
style: { "guide-label": { font }, "guide-title": { font } }
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
function Chart({ spec }) {
|
|
81
|
+
const host = useRef3(null);
|
|
82
|
+
const [reason, setReason] = useState3(null);
|
|
83
|
+
const look = useLook();
|
|
84
|
+
useEffect3(() => {
|
|
85
|
+
const element = host.current;
|
|
86
|
+
if (!element)
|
|
87
|
+
return;
|
|
88
|
+
let live = true;
|
|
89
|
+
let view = null;
|
|
90
|
+
setReason(null);
|
|
91
|
+
void (async () => {
|
|
92
|
+
try {
|
|
93
|
+
const [vega, vegaLite, { expressionInterpreter }] = await Promise.all([
|
|
94
|
+
import("vega"),
|
|
95
|
+
import("vega-lite"),
|
|
96
|
+
import("vega-interpreter")
|
|
97
|
+
]);
|
|
98
|
+
const compiled = vegaLite.compile(JSON.parse(spec)).spec;
|
|
99
|
+
if (!live)
|
|
100
|
+
return;
|
|
101
|
+
const runtime = vega.parse(compiled, chrome(element), { ast: true });
|
|
102
|
+
const created = new vega.View(runtime, {
|
|
103
|
+
renderer: "svg",
|
|
104
|
+
container: element,
|
|
105
|
+
expr: expressionInterpreter
|
|
106
|
+
});
|
|
107
|
+
created.background("transparent");
|
|
108
|
+
await created.runAsync();
|
|
109
|
+
if (!live) {
|
|
110
|
+
created.finalize();
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
view = created;
|
|
114
|
+
} catch (error) {
|
|
115
|
+
if (live)
|
|
116
|
+
setReason(error instanceof Error ? error.message : String(error));
|
|
117
|
+
}
|
|
118
|
+
})();
|
|
119
|
+
return () => {
|
|
120
|
+
live = false;
|
|
121
|
+
view?.finalize();
|
|
122
|
+
element.replaceChildren();
|
|
123
|
+
};
|
|
124
|
+
}, [spec, look]);
|
|
125
|
+
if (reason !== null)
|
|
126
|
+
return _jsx3(CodeBlock, { code: spec, language: "vega-lite", reason });
|
|
127
|
+
return _jsx3("div", { ref: host, className: "hs-chart" });
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// ../ui/dist/Diagram.js
|
|
131
|
+
import { jsx as _jsx4 } from "react/jsx-runtime";
|
|
132
|
+
import { useEffect as useEffect4, useRef as useRef4, useState as useState4 } from "react";
|
|
133
|
+
var counter = 0;
|
|
134
|
+
function Diagram({ source }) {
|
|
135
|
+
const host = useRef4(null);
|
|
136
|
+
const [svg, setSvg] = useState4(null);
|
|
137
|
+
const [reason, setReason] = useState4(null);
|
|
138
|
+
const look = useLook();
|
|
139
|
+
useEffect4(() => {
|
|
140
|
+
const element = host.current;
|
|
141
|
+
if (!element)
|
|
142
|
+
return;
|
|
143
|
+
let live = true;
|
|
144
|
+
setSvg(null);
|
|
145
|
+
setReason(null);
|
|
146
|
+
const token = (name) => getComputedStyle(element).getPropertyValue(name).trim();
|
|
147
|
+
void (async () => {
|
|
148
|
+
try {
|
|
149
|
+
const [{ default: mermaid }, { default: DOMPurify }] = await Promise.all([
|
|
150
|
+
import("mermaid"),
|
|
151
|
+
import("dompurify")
|
|
152
|
+
]);
|
|
153
|
+
mermaid.initialize({
|
|
154
|
+
startOnLoad: false,
|
|
155
|
+
securityLevel: "strict",
|
|
156
|
+
suppressErrorRendering: true,
|
|
157
|
+
// Labels are SVG text, not HTML in a `foreignObject`: the sanitiser
|
|
158
|
+
// allows the SVG vocabulary only, and drops HTML inside SVG whole.
|
|
159
|
+
htmlLabels: false,
|
|
160
|
+
theme: "base",
|
|
161
|
+
fontFamily: token("--font-app"),
|
|
162
|
+
themeVariables: {
|
|
163
|
+
background: token("--card"),
|
|
164
|
+
primaryColor: token("--win"),
|
|
165
|
+
primaryTextColor: token("--text"),
|
|
166
|
+
primaryBorderColor: token("--cardb"),
|
|
167
|
+
secondaryColor: token("--hov"),
|
|
168
|
+
tertiaryColor: token("--card"),
|
|
169
|
+
lineColor: token("--mut"),
|
|
170
|
+
textColor: token("--text")
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
counter += 1;
|
|
174
|
+
const rendered = await mermaid.render(`hs-diagram-${counter}`, source);
|
|
175
|
+
if (!live)
|
|
176
|
+
return;
|
|
177
|
+
setSvg(DOMPurify.sanitize(rendered.svg, {
|
|
178
|
+
USE_PROFILES: { svg: true, svgFilters: true },
|
|
179
|
+
ADD_ATTR: ["dominant-baseline"]
|
|
180
|
+
}));
|
|
181
|
+
} catch (error) {
|
|
182
|
+
if (live)
|
|
183
|
+
setReason(error instanceof Error ? error.message : String(error));
|
|
184
|
+
}
|
|
185
|
+
})();
|
|
186
|
+
return () => {
|
|
187
|
+
live = false;
|
|
188
|
+
};
|
|
189
|
+
}, [source, look]);
|
|
190
|
+
if (reason !== null)
|
|
191
|
+
return _jsx4(CodeBlock, { code: source, language: "mermaid", reason });
|
|
192
|
+
return _jsx4("div", { ref: host, className: "hs-diagram", dangerouslySetInnerHTML: svg === null ? void 0 : { __html: svg } });
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// ../ui/dist/chat/markdown-incremental.js
|
|
196
|
+
function hasDefinitions(node) {
|
|
197
|
+
return node.type === "definition" || node.type === "footnoteDefinition" || "children" in node && node.children.some((child) => hasDefinitions(child));
|
|
198
|
+
}
|
|
199
|
+
function shiftPositions(node, offset, lines) {
|
|
200
|
+
if (node.position) {
|
|
201
|
+
for (const point of [node.position.start, node.position.end]) {
|
|
202
|
+
if (point.offset !== void 0)
|
|
203
|
+
point.offset += offset;
|
|
204
|
+
point.line += lines;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
if ("children" in node) {
|
|
208
|
+
for (const child of node.children)
|
|
209
|
+
shiftPositions(child, offset, lines);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
function incrementalParser(parse) {
|
|
213
|
+
let cached;
|
|
214
|
+
return (source, file) => {
|
|
215
|
+
if (source.includes("\r") || source.includes("\uFEFF"))
|
|
216
|
+
return parse(source, file);
|
|
217
|
+
const prefix = cached && source.startsWith(cached.source) ? cached : void 0;
|
|
218
|
+
let root;
|
|
219
|
+
if (prefix) {
|
|
220
|
+
root = parse(source.slice(prefix.offset), file);
|
|
221
|
+
if (hasDefinitions(root))
|
|
222
|
+
return parse(source, file);
|
|
223
|
+
shiftPositions(root, prefix.offset, prefix.line - 1);
|
|
224
|
+
if (root.position)
|
|
225
|
+
root.position.start = { line: 1, column: 1, offset: 0 };
|
|
226
|
+
root.children.unshift(...structuredClone(prefix.children));
|
|
227
|
+
} else {
|
|
228
|
+
root = parse(source, file);
|
|
229
|
+
if (hasDefinitions(root))
|
|
230
|
+
return root;
|
|
231
|
+
}
|
|
232
|
+
for (let index = root.children.length - 1; index >= 0; index--) {
|
|
233
|
+
const node = root.children[index];
|
|
234
|
+
if (node?.type !== "code")
|
|
235
|
+
continue;
|
|
236
|
+
const start = node.position?.start.offset;
|
|
237
|
+
const end = node.position?.end.offset;
|
|
238
|
+
if (start === void 0 || end === void 0)
|
|
239
|
+
continue;
|
|
240
|
+
if (prefix && end < prefix.offset)
|
|
241
|
+
break;
|
|
242
|
+
const value = source.slice(start, end);
|
|
243
|
+
const opening = /^ {0,3}(`{3,}|~{3,})[^\n]*\n/.exec(value)?.[1];
|
|
244
|
+
if (!opening)
|
|
245
|
+
continue;
|
|
246
|
+
const lastLine = value.slice(value.lastIndexOf("\n") + 1);
|
|
247
|
+
const closing = new RegExp(`^ {0,3}${opening[0]}{${opening.length},}[ \\t]*$`);
|
|
248
|
+
const separator = /^\n[ \t]*\n/.exec(source.slice(end))?.[0];
|
|
249
|
+
if (!closing.test(lastLine) || !separator)
|
|
250
|
+
continue;
|
|
251
|
+
const offset = end + separator.length;
|
|
252
|
+
cached = {
|
|
253
|
+
source: source.slice(0, offset),
|
|
254
|
+
offset,
|
|
255
|
+
line: node.position.end.line + 2,
|
|
256
|
+
children: structuredClone(root.children.slice(0, index + 1))
|
|
257
|
+
};
|
|
258
|
+
break;
|
|
259
|
+
}
|
|
260
|
+
return root;
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
function incrementalMarkdown() {
|
|
264
|
+
let parser;
|
|
265
|
+
return function() {
|
|
266
|
+
const original = this.parser;
|
|
267
|
+
if (!original)
|
|
268
|
+
return;
|
|
269
|
+
parser ??= incrementalParser((source, file) => original(source, file));
|
|
270
|
+
const parseDocument = parser;
|
|
271
|
+
let documentParsed = false;
|
|
272
|
+
this.parser = (source, file) => {
|
|
273
|
+
if (documentParsed)
|
|
274
|
+
return original(source, file);
|
|
275
|
+
documentParsed = true;
|
|
276
|
+
return parseDocument(source, file);
|
|
277
|
+
};
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
// ../ui/dist/chat/markdown.js
|
|
282
|
+
function fenceText(children) {
|
|
283
|
+
return Children.toArray(children).map((child) => typeof child === "string" ? child : "").join("").replace(/\n$/, "");
|
|
284
|
+
}
|
|
285
|
+
function nameOf(target) {
|
|
286
|
+
try {
|
|
287
|
+
return decodeURIComponent(target.replace(/^\.\//, ""));
|
|
288
|
+
} catch {
|
|
289
|
+
return target;
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
function FilePicture({ src, alt, onOpen }) {
|
|
293
|
+
const [known, setKnown] = useState5(typeof src === "string" ? src : null);
|
|
294
|
+
useEffect5(() => {
|
|
295
|
+
if (typeof src === "string")
|
|
296
|
+
return;
|
|
297
|
+
let live = true;
|
|
298
|
+
void src.then((url) => {
|
|
299
|
+
if (live)
|
|
300
|
+
setKnown(url);
|
|
301
|
+
}, () => void 0);
|
|
302
|
+
return () => {
|
|
303
|
+
live = false;
|
|
304
|
+
};
|
|
305
|
+
}, [src]);
|
|
306
|
+
return known ? _jsx5("button", { type: "button", className: "hs-md-picture", "aria-label": `Show ${alt}`, onClick: (e) => onOpen(e.currentTarget), children: _jsx5("img", { src: known, alt }) }) : null;
|
|
307
|
+
}
|
|
308
|
+
var APP_LINK = /^hearthscale:/i;
|
|
309
|
+
var keptUrl = (url) => APP_LINK.test(url) ? url : defaultUrlTransform(url);
|
|
310
|
+
var MarkdownState = createContext2(null);
|
|
311
|
+
function useMarkdownState() {
|
|
312
|
+
const state = useContext2(MarkdownState);
|
|
313
|
+
if (!state)
|
|
314
|
+
throw new Error("a part of a reply is drawn outside its Markdown");
|
|
315
|
+
return state;
|
|
316
|
+
}
|
|
317
|
+
var PARTS = {
|
|
318
|
+
pre: function MarkdownFence({ children }) {
|
|
319
|
+
const { streaming } = useMarkdownState();
|
|
320
|
+
const code = Children.toArray(children).find(isValidElement);
|
|
321
|
+
if (!code)
|
|
322
|
+
return null;
|
|
323
|
+
const source = fenceText(code.props.children);
|
|
324
|
+
const language = /language-([\w-]+)/.exec(code.props.className ?? "")?.[1];
|
|
325
|
+
if (language === "mermaid" && !streaming)
|
|
326
|
+
return _jsx5(Diagram, { source });
|
|
327
|
+
if (language === "vega-lite" && !streaming)
|
|
328
|
+
return _jsx5(Chart, { spec: source });
|
|
329
|
+
return _jsx5(CodeBlock, { code: source, ...language && { language } });
|
|
330
|
+
},
|
|
331
|
+
a: function MarkdownLink({ href, children: words }) {
|
|
332
|
+
const { links } = useMarkdownState();
|
|
333
|
+
const target = href ?? "";
|
|
334
|
+
const file = /^[a-z][a-z0-9+.-]*:/i.test(target) ? null : links.file(nameOf(target));
|
|
335
|
+
const web = /^https?:\/\//i.test(target);
|
|
336
|
+
const linked = web || APP_LINK.test(target);
|
|
337
|
+
if (!file && !linked)
|
|
338
|
+
return _jsx5(_Fragment, { children: words });
|
|
339
|
+
return _jsx5("a", { href: web ? target : void 0, className: "hs-md-link", onClick: (event) => {
|
|
340
|
+
event.preventDefault();
|
|
341
|
+
if (file)
|
|
342
|
+
file.open(event.currentTarget);
|
|
343
|
+
else if (linked)
|
|
344
|
+
links.open(target);
|
|
345
|
+
}, children: words });
|
|
346
|
+
},
|
|
347
|
+
img: function MarkdownPicture({ src, alt }) {
|
|
348
|
+
const { links } = useMarkdownState();
|
|
349
|
+
const target = typeof src === "string" ? src : "";
|
|
350
|
+
const file = /^[a-z][a-z0-9+.-]*:/i.test(target) ? null : links.file(nameOf(target));
|
|
351
|
+
return file?.picture ? _jsx5(FilePicture, { src: file.picture, alt: alt ?? "", onOpen: file.open }) : _jsx5("span", { className: "hs-md-missing", children: alt || nameOf(target) });
|
|
352
|
+
}
|
|
353
|
+
};
|
|
354
|
+
var WHOLE = [remarkGfm];
|
|
355
|
+
var FENCED = /(?:^|\n) {0,3}(?:`{3}|~{3})/;
|
|
356
|
+
var Markdown = memo(function Markdown2({ children, links, streaming }) {
|
|
357
|
+
const arriving = streaming !== void 0;
|
|
358
|
+
const incremental = arriving && FENCED.test(children);
|
|
359
|
+
const plugins = useMemo(() => incremental ? [remarkGfm, incrementalMarkdown()] : WHOLE, [incremental]);
|
|
360
|
+
const state = useMemo(() => ({ links, streaming: arriving }), [links, arriving]);
|
|
361
|
+
return _jsx5("div", { className: "hs-md hs-assistant-text", "data-streaming": streaming, children: _jsx5(MarkdownState.Provider, { value: state, children: _jsx5(ReactMarkdown, { remarkPlugins: plugins, components: PARTS, urlTransform: keptUrl, children }) }) });
|
|
362
|
+
});
|
|
363
|
+
export {
|
|
364
|
+
Markdown
|
|
365
|
+
};
|
|
@@ -0,0 +1,201 @@
|
|
|
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.
|