修改ui样式,修改轮播图
This commit is contained in:
+1
-1
@@ -1,5 +1,5 @@
|
||||
node_modules/
|
||||
dist/
|
||||
/dist/
|
||||
dist.zip
|
||||
vibemake-dist/
|
||||
.DS_Store
|
||||
|
||||
+53
-28
@@ -266,22 +266,49 @@ kbd { font-family: var(--mono); font-size: 10.5px; padding: 1px 6px; border: 1px
|
||||
position: relative;
|
||||
aspect-ratio: 16 / 10;
|
||||
display: grid; place-items: center;
|
||||
background: radial-gradient(70% 80% at 50% 70%, color-mix(in srgb, var(--hue) 16%, #15181c), #0d0f12 75%);
|
||||
background: #14161a;
|
||||
border-bottom: 1px solid rgba(255, 255, 255, 0.06);
|
||||
overflow: hidden;
|
||||
}
|
||||
.pcard-media img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .5s, transform .6s cubic-bezier(.2, .7, .2, 1); }
|
||||
.pcard-media img { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; transition: opacity .5s; }
|
||||
.pcard-media img.pcard-backdrop {
|
||||
z-index: 0; object-fit: cover; transform: scale(1.06);
|
||||
filter: blur(4px);
|
||||
}
|
||||
.pcard-media img.pcard-foreground {
|
||||
inset: auto; top: 50%; left: 50%; z-index: 2;
|
||||
width: auto; height: auto; max-width: 100%; max-height: 100%;
|
||||
object-fit: contain; transform: translate(-50%, -50%);
|
||||
}
|
||||
.pcard-media.ready img { opacity: 1; }
|
||||
.pcard:hover .pcard-media img { transform: scale(1.05); }
|
||||
.pcard-ph { font-size: 44px; font-weight: 600; color: rgba(255, 255, 255, 0.06); }
|
||||
.pcard-media:not(.ready) .pcard-ph { animation: pulse 1.6s ease-in-out infinite; }
|
||||
.pcard-media:not(.ready)::after { content: ''; position: absolute; inset: 0; background: linear-gradient(100deg, transparent 30%, rgba(255, 255, 255, 0.045) 50%, transparent 70%) 0 0 / 250% 100%; animation: shimmer 1.6s linear infinite; }
|
||||
.pcard-media.failed::after { content: none; }
|
||||
.pcard-default { display: grid; justify-items: center; gap: 10px; color: color-mix(in srgb, var(--hue) 55%, rgba(255, 255, 255, 0.35)); }
|
||||
.pcard-default .ic { opacity: .7; }
|
||||
.pcard-default small { font-size: 12px; letter-spacing: .2em; color: rgba(255, 255, 255, 0.32); }
|
||||
.pcard-media.ready img.pcard-backdrop { opacity: 1; }
|
||||
.pcard:hover .pcard-media img.pcard-backdrop { transform: scale(1.08); }
|
||||
.pcard-loader {
|
||||
position: absolute; z-index: 2; top: 50%; left: 50%;
|
||||
width: 1.75em; height: 1.75em; margin: 0;
|
||||
transform: translate(-50%, -150%) translateZ(0);
|
||||
color: #5e343f;
|
||||
font-size: 8px;
|
||||
box-shadow: 0 1.75em 0 0 currentColor;
|
||||
border-radius: 50%;
|
||||
animation: pcard-load7 1.8s infinite ease-in-out;
|
||||
animation-fill-mode: both;
|
||||
animation-delay: -.16s;
|
||||
pointer-events: none;
|
||||
}
|
||||
.pcard-loader::before, .pcard-loader::after {
|
||||
content: ''; position: absolute; top: 0;
|
||||
width: 1.75em; height: 1.75em;
|
||||
border-radius: 50%;
|
||||
box-shadow: 0 1.75em 0 0 currentColor;
|
||||
animation: pcard-load7 1.8s infinite ease-in-out;
|
||||
animation-fill-mode: both;
|
||||
}
|
||||
.pcard-loader::before { left: -2.3em; animation-delay: -.32s; }
|
||||
.pcard-loader::after { left: 2.3em; }
|
||||
.pcard-media.ready .pcard-loader, .pcard-media.failed .pcard-loader { display: none; }
|
||||
.pcard.skel { pointer-events: none; --hue: #2a2f36; }
|
||||
.pcard.skel .pcard-media { background: #111418; }
|
||||
.pcard.skel .pcard-media { background: #14161a; }
|
||||
.sk { display: block; height: 12px; border-radius: 6px; background: linear-gradient(100deg, rgba(255,255,255,.045) 30%, rgba(255,255,255,.09) 50%, rgba(255,255,255,.045) 70%) 0 0 / 250% 100%; animation: shimmer 1.4s linear infinite; }
|
||||
.sk-title { height: 20px; margin: 4px 0 2px; }
|
||||
.sk-av { width: 22px; height: 22px; border-radius: 50%; flex: 0 0 auto; }
|
||||
@@ -289,7 +316,10 @@ kbd { font-family: var(--mono); font-size: 10.5px; padding: 1px 6px; border: 1px
|
||||
.ws-card.skel { pointer-events: none; }
|
||||
.ws-card.skel .ws-cover { background: linear-gradient(100deg, rgba(255,255,255,.03) 30%, rgba(255,255,255,.07) 50%, rgba(255,255,255,.03) 70%) 0 0 / 250% 100%; animation: shimmer 1.4s linear infinite; }
|
||||
@keyframes shimmer { from { background-position: 125% 0; } to { background-position: -125% 0; } }
|
||||
@keyframes pulse { 50% { opacity: .4; } }
|
||||
@keyframes pcard-load7 {
|
||||
0%, 80%, 100% { box-shadow: 0 1.75em 0 -.9em currentColor; }
|
||||
40% { box-shadow: 0 1.75em 0 0 currentColor; }
|
||||
}
|
||||
.pcard-rank { position: absolute; top: 16px; left: 16px; font-family: var(--mono); font-size: 12px; color: var(--text); padding: 3px 10px; border-radius: 999px; background: rgba(0, 0, 0, 0.45); backdrop-filter: blur(8px); border: 1px solid var(--line); }
|
||||
.pcard-body { display: flex; flex-direction: column; gap: 8px; padding: 20px 22px 20px; flex: 1; }
|
||||
.pcard-row { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--muted); }
|
||||
@@ -308,7 +338,7 @@ kbd { font-family: var(--mono); font-size: 10.5px; padding: 1px 6px; border: 1px
|
||||
.pcard-stats span { display: inline-flex; align-items: center; gap: 5px; }
|
||||
.pgrid.list { grid-template-columns: 1fr; gap: 16px; }
|
||||
.pcard.list { flex-direction: row; }
|
||||
.pcard.list .pcard-media { flex: 0 0 300px; aspect-ratio: auto; min-height: 170px; }
|
||||
.pcard.list .pcard-media { flex: 0 0 300px; align-self: flex-start; aspect-ratio: 16 / 10; min-height: 0; }
|
||||
|
||||
/* ---------- 讨论精选 ---------- */
|
||||
.quotes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 28px; }
|
||||
@@ -499,7 +529,7 @@ code, .md code { font-family: var(--mono); font-size: .86em; color: var(--accent
|
||||
.related { display: grid; gap: 12px; }
|
||||
.related a { display: flex; align-items: center; gap: 14px; padding: 8px; margin: -8px; border-radius: 14px; font-size: 14px; transition: background .2s; }
|
||||
.related a:hover { background: rgba(255, 255, 255, 0.04); }
|
||||
.related .thumb { position: relative; width: 64px; height: 48px; border-radius: 10px; overflow: hidden; background: var(--surface-2); flex: 0 0 auto; }
|
||||
.related .thumb { position: relative; width: 64px; height: 40px; border-radius: 10px; overflow: hidden; background: var(--surface-2); flex: 0 0 auto; }
|
||||
.related .thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
|
||||
.related small { display: block; font-size: 12px; color: var(--dim); }
|
||||
|
||||
@@ -548,7 +578,7 @@ code, .md code { font-family: var(--mono); font-size: .86em; color: var(--accent
|
||||
.loader:not(.error) #loader-text { display: none; }
|
||||
.loader.error .spinner { display: none; }
|
||||
.loader.error .loader-box { color: var(--danger); max-width: 420px; text-align: center; padding: 0 16px; }
|
||||
/* 切换模型时的小加载环:两段弧线反向旋转 */
|
||||
/* 其他页面继续使用原有的双弧加载环。 */
|
||||
.spinner { position: relative; width: 34px; height: 34px; }
|
||||
.spinner::before, .spinner::after { content: ''; position: absolute; inset: 0; border-radius: 50%; border: 1.5px solid transparent; }
|
||||
.spinner::before { border-top-color: var(--accent); animation: spin 0.9s cubic-bezier(.5, .1, .5, .9) infinite; }
|
||||
@@ -708,7 +738,7 @@ body.studio::before, body.studio::after { display: none; }
|
||||
.section { padding-top: 88px; }
|
||||
.pgrid, .quotes, .makers { grid-template-columns: 1fr; }
|
||||
.pcard.list { flex-direction: column; }
|
||||
.pcard.list .pcard-media { flex-basis: auto; aspect-ratio: 16 / 10; }
|
||||
.pcard.list .pcard-media { flex-basis: auto; align-self: stretch; aspect-ratio: 16 / 10; }
|
||||
.publish { padding: 32px 24px; border-radius: 22px; }
|
||||
.footer-grid { flex-direction: column; gap: 28px; }
|
||||
.footer-links { gap: 22px; }
|
||||
@@ -738,6 +768,10 @@ body.studio::before, body.studio::after { display: none; }
|
||||
}
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
* { transition: none !important; animation: none !important; }
|
||||
.pcard-loader, .pcard-loader::before, .pcard-loader::after {
|
||||
animation: none;
|
||||
box-shadow: 0 1.75em 0 0 currentColor;
|
||||
}
|
||||
}
|
||||
#trending { padding-top: 80px; }
|
||||
|
||||
@@ -866,7 +900,7 @@ body.studio::before, body.studio::after { display: none; }
|
||||
.ai-results { display: grid; gap: 6px; }
|
||||
.ai-result { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 14px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.02); transition: border-color .2s; }
|
||||
.ai-result:hover { border-color: rgba(255, 255, 255, 0.2); }
|
||||
.ai-thumb { width: 56px; height: 42px; border-radius: 9px; overflow: hidden; display: grid; place-items: center; background: var(--surface-2, #15181c); color: var(--dim); flex: 0 0 auto; }
|
||||
.ai-thumb { width: 56px; height: 35px; border-radius: 9px; overflow: hidden; display: grid; place-items: center; background: var(--surface-2, #15181c); color: var(--dim); flex: 0 0 auto; }
|
||||
.ai-thumb img { width: 100%; height: 100%; object-fit: cover; }
|
||||
.ai-result-txt { flex: 1; min-width: 0; display: grid; }
|
||||
.ai-result-txt b { font-size: 13.5px; color: var(--text); font-weight: 500; }
|
||||
@@ -920,7 +954,7 @@ body.studio::before, body.studio::after { display: none; }
|
||||
.ws-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; padding-bottom: 80px; }
|
||||
.ws-card { display: flex; gap: 14px; padding: 14px; border-radius: 18px; border: 1px solid var(--line); background: var(--surface); transition: border-color .2s, transform .2s; min-width: 0; }
|
||||
.ws-card:hover { border-color: rgba(255, 255, 255, 0.18); transform: translateY(-2px); }
|
||||
.ws-cover { flex: 0 0 auto; width: 88px; height: 66px; border-radius: 12px; overflow: hidden; display: grid; place-items: center; background: var(--surface-2); color: var(--dim); }
|
||||
.ws-cover { flex: 0 0 auto; width: 88px; height: 55px; border-radius: 12px; overflow: hidden; display: grid; place-items: center; background: var(--surface-2); color: var(--dim); }
|
||||
.ws-cover img { width: 100%; height: 100%; object-fit: cover; }
|
||||
.ws-card-body { flex: 1; min-width: 0; display: grid; gap: 6px; align-content: start; }
|
||||
.ws-card-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
|
||||
@@ -1011,7 +1045,7 @@ a.ws-badge:hover { color: var(--text); }
|
||||
.ws-set-body { padding: 20px; }
|
||||
.ws-set-body .form-note, .ws-set-body .form-msg { text-align: left; }
|
||||
.ws-cover-edit { display: flex; align-items: center; gap: 16px; }
|
||||
.ws-cover-edit .ws-cover { width: 128px; height: 96px; }
|
||||
.ws-cover-edit .ws-cover { width: 128px; height: 80px; }
|
||||
.ws-cover-btns { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
|
||||
.ws-set.danger { border-color: rgba(255, 107, 91, 0.3); }
|
||||
.ws-danger-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
|
||||
@@ -1165,12 +1199,3 @@ html.ai-locked, html.ai-locked body { overflow: hidden; }
|
||||
/* 不要向上伸出的伪元素:Safari 判断「贴顶导航」时看整个盒子,伸出去会被当成不在顶部,就不延伸颜色 */
|
||||
.nav::before { display: none; }
|
||||
}
|
||||
/* 封面:比例接近就铺满;否则完整显示原图,背后垫同一张图的模糊放大版填满卡片 */
|
||||
.pcard-media img { object-fit: contain; z-index: 1; }
|
||||
.pcard-media img.fill { object-fit: cover; }
|
||||
.pcard-media img.pcard-blur { object-fit: cover; z-index: 0; filter: blur(28px) saturate(1.2) brightness(.7); transform: scale(1.25); }
|
||||
.pcard:hover .pcard-media img { transform: none; }
|
||||
.pcard:hover .pcard-media img.fill { transform: scale(1.04); }
|
||||
.pcard:hover .pcard-media img.pcard-blur { transform: scale(1.25); }
|
||||
.pcard-media.ready img:not(.pcard-blur):not(.fill) { filter: drop-shadow(0 10px 24px rgba(0, 0, 0, 0.45)); }
|
||||
.ws-cover img, .ai-thumb img { object-fit: contain; }
|
||||
|
||||
+1
-1
@@ -76,7 +76,7 @@
|
||||
|
||||
<main class="container">
|
||||
<div class="result-count" id="count"></div>
|
||||
<div class="pgrid" id="results"><div class="pcard grid skel" aria-hidden="true"><div class="pcard-media"></div><div class="pcard-body"><i class="sk" style="width:28%"></i><i class="sk sk-title" style="width:62%"></i><i class="sk" style="width:92%"></i><i class="sk" style="width:70%"></i></div></div><div class="pcard grid skel" aria-hidden="true"><div class="pcard-media"></div><div class="pcard-body"><i class="sk" style="width:28%"></i><i class="sk sk-title" style="width:62%"></i><i class="sk" style="width:92%"></i><i class="sk" style="width:70%"></i></div></div><div class="pcard grid skel" aria-hidden="true"><div class="pcard-media"></div><div class="pcard-body"><i class="sk" style="width:28%"></i><i class="sk sk-title" style="width:62%"></i><i class="sk" style="width:92%"></i><i class="sk" style="width:70%"></i></div></div><div class="pcard grid skel" aria-hidden="true"><div class="pcard-media"></div><div class="pcard-body"><i class="sk" style="width:28%"></i><i class="sk sk-title" style="width:62%"></i><i class="sk" style="width:92%"></i><i class="sk" style="width:70%"></i></div></div><div class="pcard grid skel" aria-hidden="true"><div class="pcard-media"></div><div class="pcard-body"><i class="sk" style="width:28%"></i><i class="sk sk-title" style="width:62%"></i><i class="sk" style="width:92%"></i><i class="sk" style="width:70%"></i></div></div><div class="pcard grid skel" aria-hidden="true"><div class="pcard-media"></div><div class="pcard-body"><i class="sk" style="width:28%"></i><i class="sk sk-title" style="width:62%"></i><i class="sk" style="width:92%"></i><i class="sk" style="width:70%"></i></div></div></div>
|
||||
<div class="pgrid" id="results"><div class="pcard grid skel" aria-hidden="true"><div class="pcard-media"><span class="pcard-loader" aria-hidden="true"></span></div><div class="pcard-body"><i class="sk" style="width:28%"></i><i class="sk sk-title" style="width:62%"></i><i class="sk" style="width:92%"></i><i class="sk" style="width:70%"></i></div></div><div class="pcard grid skel" aria-hidden="true"><div class="pcard-media"><span class="pcard-loader" aria-hidden="true"></span></div><div class="pcard-body"><i class="sk" style="width:28%"></i><i class="sk sk-title" style="width:62%"></i><i class="sk" style="width:92%"></i><i class="sk" style="width:70%"></i></div></div><div class="pcard grid skel" aria-hidden="true"><div class="pcard-media"><span class="pcard-loader" aria-hidden="true"></span></div><div class="pcard-body"><i class="sk" style="width:28%"></i><i class="sk sk-title" style="width:62%"></i><i class="sk" style="width:92%"></i><i class="sk" style="width:70%"></i></div></div><div class="pcard grid skel" aria-hidden="true"><div class="pcard-media"><span class="pcard-loader" aria-hidden="true"></span></div><div class="pcard-body"><i class="sk" style="width:28%"></i><i class="sk sk-title" style="width:62%"></i><i class="sk" style="width:92%"></i><i class="sk" style="width:70%"></i></div></div><div class="pcard grid skel" aria-hidden="true"><div class="pcard-media"><span class="pcard-loader" aria-hidden="true"></span></div><div class="pcard-body"><i class="sk" style="width:28%"></i><i class="sk sk-title" style="width:62%"></i><i class="sk" style="width:92%"></i><i class="sk" style="width:70%"></i></div></div><div class="pcard grid skel" aria-hidden="true"><div class="pcard-media"><span class="pcard-loader" aria-hidden="true"></span></div><div class="pcard-body"><i class="sk" style="width:28%"></i><i class="sk sk-title" style="width:62%"></i><i class="sk" style="width:92%"></i><i class="sk" style="width:70%"></i></div></div></div>
|
||||
</main>
|
||||
|
||||
<script type="module" src="js/explore.js"></script>
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
// Community 后端接口封装。字段与《Community 前端接口对接文档》一致。
|
||||
// 所有请求走同域 /api(开发时由 scripts/dev-server.mjs 代理到后端,部署时由 nginx 反代)。
|
||||
import { store } from './layout.js';
|
||||
import { compressCoverImage } from './compress-cover.js';
|
||||
import { normalizeUrdfEntries } from './urdf-paths.js';
|
||||
|
||||
// 后端地址按访问的域名选择(静态网站部署,浏览器直接请求后端,后端需要允许这些前端域名跨域):
|
||||
// dev-vibemake.robotquan.com(及其他 dev-* 域名) → https://dev-vibemake-api.robotquan.com/api
|
||||
@@ -215,13 +217,15 @@ export const unpublishProject = (code) => request(`/workspace/projects/${enc(cod
|
||||
// ---------- 封面直传 OSS ----------
|
||||
export async function uploadCover(file, signal) {
|
||||
if (!LIMITS.coverTypes.includes(file.type)) throw new ApiError(400, 'BAD_REQUEST', '封面只支持 JPG / PNG / WebP');
|
||||
if (file.size <= 0) throw new ApiError(400, 'BAD_REQUEST', '封面文件为空');
|
||||
if (file.size > LIMITS.coverBytes) throw new ApiError(413, 'UPLOAD_TOO_LARGE', '封面不能超过 5 MB');
|
||||
const uploadFile = await compressCoverImage(file);
|
||||
const sig = await request('/uploads/project-covers/signature', {
|
||||
method: 'POST', body: { contentType: file.type, fileSize: file.size }, auth: 'required', signal,
|
||||
method: 'POST', body: { contentType: uploadFile.type, fileSize: uploadFile.size }, auth: 'required', signal,
|
||||
});
|
||||
const form = new FormData();
|
||||
for (const [k, v] of Object.entries(sig.formFields)) form.append(k, v);
|
||||
form.append('file', file); // 必须是最后一个字段
|
||||
form.append('file', uploadFile); // 必须是最后一个字段
|
||||
const res = await fetch(sig.uploadUrl, { method: 'POST', body: form, credentials: 'omit', signal });
|
||||
if (res.status !== 200) throw new ApiError(res.status, 'OSS_UPLOAD_FAILED', `封面上传失败:HTTP ${res.status}`);
|
||||
return sig.coverUrl;
|
||||
@@ -256,6 +260,7 @@ export function checkUrdfEntries(entries) {
|
||||
}
|
||||
|
||||
export async function uploadUrdf(code, entries, onProgress, signal) {
|
||||
entries = await normalizeUrdfEntries(entries);
|
||||
const problem = checkUrdfEntries(entries);
|
||||
if (problem) throw new ApiError(400, 'URDF_MAIN_FILE_INVALID', problem);
|
||||
const files = entries.map((e) => ({ relativePath: e.relativePath, sizeBytes: e.file.size }));
|
||||
|
||||
+18
-24
@@ -191,44 +191,38 @@ export function hydrateThumbnails(root, projects) {
|
||||
root.querySelectorAll('[data-thumb]').forEach((el) => {
|
||||
const p = projects.find((x) => x.id === el.dataset.thumb);
|
||||
if (!p) return;
|
||||
// 没有封面、没有 3D 模型或图片加载失败:展示默认图(接口文档:coverUrl 为 null 时展示前端默认图)
|
||||
const fallback = () => {
|
||||
el.innerHTML = `<span class="pcard-default">${icon('cube', 34)}<small>${esc(p.type || '')}</small></span>`;
|
||||
// 没有封面或缩略图加载失败时清空占位,不用默认图标冒充项目封面。
|
||||
const clearPlaceholder = () => {
|
||||
el.replaceChildren();
|
||||
el.classList.remove('ready');
|
||||
el.classList.add('failed');
|
||||
};
|
||||
thumbnail(p).then((url) => {
|
||||
// 图片完整下载、解码后再淡入;外部图片(GitHub 等)8 秒还没到就先显示默认图,到了再换上
|
||||
// 等图片下载、解码完成后再显示;慢速加载时继续显示封面 loading。
|
||||
const img = Object.assign(new Image(), { alt: p.name, decoding: 'async' });
|
||||
let shown = false;
|
||||
let timer;
|
||||
whenNear(el, () => { timer = setTimeout(() => { if (!shown) fallback(); }, 8000); });
|
||||
img.onload = () => {
|
||||
shown = true;
|
||||
clearTimeout(timer);
|
||||
el.innerHTML = '';
|
||||
// 比例和卡片(16:10)接近:直接铺满;差得多:完整显示原图,后面垫一层同一张图的模糊放大版,不留黑边
|
||||
const ratio = img.naturalWidth / img.naturalHeight / 1.6;
|
||||
if (ratio > 0.82 && ratio < 1.22) img.classList.add('fill');
|
||||
else {
|
||||
const bg = Object.assign(new Image(), { src: img.src, alt: '', className: 'pcard-blur' });
|
||||
bg.setAttribute('aria-hidden', 'true');
|
||||
el.append(bg);
|
||||
}
|
||||
el.append(img);
|
||||
const showImage = () => {
|
||||
const backdrop = Object.assign(new Image(), { alt: '', className: 'pcard-backdrop', decoding: 'async' });
|
||||
backdrop.setAttribute('aria-hidden', 'true');
|
||||
backdrop.src = img.src;
|
||||
img.className = 'pcard-foreground';
|
||||
el.replaceChildren(backdrop, img);
|
||||
el.classList.remove('failed');
|
||||
requestAnimationFrame(() => el.classList.add('ready'));
|
||||
};
|
||||
img.onerror = () => { clearTimeout(timer); fallback(); };
|
||||
img.onload = () => {
|
||||
if (typeof img.decode !== 'function') { showImage(); return; }
|
||||
img.decode().then(showImage, () => img.naturalWidth ? showImage() : clearPlaceholder());
|
||||
};
|
||||
img.onerror = clearPlaceholder;
|
||||
whenNear(el, () => { img.src = url; });
|
||||
}).catch(fallback);
|
||||
}).catch(clearPlaceholder);
|
||||
});
|
||||
}
|
||||
|
||||
// ---------- 骨架卡片:数据回来之前先占好位置,尺寸和真卡片一致,内容到了不会跳 ----------
|
||||
export function skeletonCards(n = 6, layout = 'grid') {
|
||||
return Array.from({ length: n }, () => `<div class="pcard ${layout} skel" aria-hidden="true">
|
||||
<div class="pcard-media"></div>
|
||||
<div class="pcard-media"><span class="pcard-loader" aria-hidden="true"></span></div>
|
||||
<div class="pcard-body">
|
||||
<i class="sk" style="width:28%"></i>
|
||||
<i class="sk sk-title" style="width:62%"></i>
|
||||
@@ -241,7 +235,7 @@ export function skeletonCards(n = 6, layout = 'grid') {
|
||||
export function projectCard(p, { rank, layout = 'grid' } = {}) {
|
||||
const href = `/project/?id=${encodeURIComponent(p.id)}`;
|
||||
return `<a class="pcard ${layout}" href="${href}" style="--hue:${esc(p.owner.color)}">
|
||||
<div class="pcard-media" data-thumb="${esc(p.id)}"><span class="pcard-ph">${esc(p.name.slice(0, 1))}</span></div>
|
||||
<div class="pcard-media" data-thumb="${esc(p.id)}"><span class="pcard-loader" aria-hidden="true"></span></div>
|
||||
${rank ? `<span class="pcard-rank">${String(rank).padStart(2, '0')}</span>` : ''}
|
||||
<div class="pcard-body">
|
||||
<div class="pcard-row"><span class="pcard-type">${esc(p.type)}</span></div>
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
const MAX_WIDTH = 768;
|
||||
const MAX_HEIGHT = 480;
|
||||
const TARGET_BYTES = 500 * 1024;
|
||||
const DEFAULT_QUALITY = 0.72;
|
||||
const FALLBACK_QUALITY = 0.62;
|
||||
|
||||
async function decodeImage(file) {
|
||||
if (typeof createImageBitmap === 'function') {
|
||||
try {
|
||||
const bitmap = await createImageBitmap(file, { imageOrientation: 'from-image' });
|
||||
return { source: bitmap, width: bitmap.width, height: bitmap.height, dispose: () => bitmap.close() };
|
||||
} catch {
|
||||
// Fall through to HTMLImageElement for browsers without ImageBitmap support.
|
||||
}
|
||||
}
|
||||
|
||||
const objectUrl = URL.createObjectURL(file);
|
||||
try {
|
||||
const image = await new Promise((resolve, reject) => {
|
||||
const element = new Image();
|
||||
element.onload = () => resolve(element);
|
||||
element.onerror = () => reject(new Error('无法读取封面图片'));
|
||||
element.src = objectUrl;
|
||||
});
|
||||
return {
|
||||
source: image,
|
||||
width: image.naturalWidth,
|
||||
height: image.naturalHeight,
|
||||
dispose: () => URL.revokeObjectURL(objectUrl),
|
||||
};
|
||||
} catch (error) {
|
||||
URL.revokeObjectURL(objectUrl);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
function canvasBlob(canvas, quality) {
|
||||
return new Promise((resolve) => canvas.toBlob(resolve, 'image/webp', quality));
|
||||
}
|
||||
|
||||
export async function compressCoverImage(file) {
|
||||
if (file.size <= 0 || file.size > 5 * 1024 * 1024) return file;
|
||||
|
||||
let decoded;
|
||||
try {
|
||||
decoded = await decodeImage(file);
|
||||
} catch {
|
||||
return file;
|
||||
}
|
||||
|
||||
try {
|
||||
if (decoded.width <= 0 || decoded.height <= 0) return file;
|
||||
const scale = Math.min(1, MAX_WIDTH / decoded.width, MAX_HEIGHT / decoded.height);
|
||||
const width = Math.max(1, Math.round(decoded.width * scale));
|
||||
const height = Math.max(1, Math.round(decoded.height * scale));
|
||||
const canvas = document.createElement('canvas');
|
||||
canvas.width = width;
|
||||
canvas.height = height;
|
||||
const context = canvas.getContext('2d');
|
||||
if (!context) return file;
|
||||
context.drawImage(decoded.source, 0, 0, width, height);
|
||||
|
||||
const candidates = [];
|
||||
const normal = await canvasBlob(canvas, DEFAULT_QUALITY);
|
||||
if (normal) candidates.push(normal);
|
||||
if (normal && normal.size > TARGET_BYTES) {
|
||||
const smaller = await canvasBlob(canvas, FALLBACK_QUALITY);
|
||||
if (smaller) candidates.push(smaller);
|
||||
}
|
||||
const smallest = candidates.sort((a, b) => a.size - b.size)[0];
|
||||
if (!smallest || smallest.type !== 'image/webp' || smallest.size >= file.size) return file;
|
||||
const name = file.name.replace(/\.[^.]+$/, '') || 'cover';
|
||||
return new File([smallest], `${name}.webp`, { type: 'image/webp', lastModified: file.lastModified });
|
||||
} catch {
|
||||
return file;
|
||||
} finally {
|
||||
decoded.dispose();
|
||||
}
|
||||
}
|
||||
+7
-3
@@ -8,6 +8,12 @@ import { renderShell, esc, fmt, avatar, icon, timeAgo, toast } from './layout.js
|
||||
renderShell('home');
|
||||
|
||||
const CYCLE_MS = 8000;
|
||||
const PROJECT_DETAIL_IDS = {
|
||||
'open-duck-mini': 'g62seg83j2sc',
|
||||
phantomx: 'm30d6pn3t24y',
|
||||
xlerobot: 'dsxz7erz8ccb',
|
||||
so101: '8tbq03ybjekw',
|
||||
};
|
||||
const $ = (id) => document.getElementById(id);
|
||||
const hero = $('hero');
|
||||
const loader = $('loader');
|
||||
@@ -63,9 +69,7 @@ async function go(i) {
|
||||
<span>更新于 ${timeAgo(p.updated)}</span>`}
|
||||
</div>
|
||||
<div class="hero-actions">
|
||||
${p.showcase
|
||||
? `<a class="btn btn-lg btn-light" href="${esc(p.robot.source?.repo || '#')}" target="_blank" rel="noopener">查看源项目</a>`
|
||||
: `<a class="btn btn-lg btn-light" href="/project/?id=${encodeURIComponent(p.id)}">查看项目</a>`}
|
||||
<a class="btn btn-lg btn-light" href="/project/?id=${encodeURIComponent(PROJECT_DETAIL_IDS[p.id] || p.id)}">查看项目</a>
|
||||
<a class="btn btn-lg" href="/studio/?robot=${encodeURIComponent(p.id)}">${icon('play', 14)}在线控制</a>
|
||||
</div>`;
|
||||
void copy.offsetWidth;
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
// (data/community.json + robots/),保留最早的完整样子作参考。
|
||||
import * as api from './api.js';
|
||||
import { normalizeRobot } from './registry.js';
|
||||
import { meshUrlCandidates } from './urdf-paths.js';
|
||||
|
||||
export const STATIC_HOSTS = ['127.0.0.1'];
|
||||
|
||||
@@ -101,6 +102,7 @@ function robotFromUrdf(p) {
|
||||
description: p.description,
|
||||
urdf: p.urdfMainUrl,
|
||||
resolveUrl,
|
||||
resolveMeshUrls: (url) => meshUrlCandidates(base, url),
|
||||
packages: () => base,
|
||||
archetype: 'generic', // 没有关节映射:演示时所有关节在限位内摆动
|
||||
source: { project: p.code },
|
||||
|
||||
@@ -0,0 +1,104 @@
|
||||
const dirname = (path) => path.includes('/') ? path.slice(0, path.lastIndexOf('/')) : '';
|
||||
|
||||
function normalize(path) {
|
||||
const out = [];
|
||||
for (const seg of path.split('/')) {
|
||||
if (!seg || seg === '.') continue;
|
||||
if (seg === '..') {
|
||||
if (!out.length) return null;
|
||||
out.pop();
|
||||
} else out.push(seg);
|
||||
}
|
||||
return out.join('/');
|
||||
}
|
||||
|
||||
function relative(fromDir, to) {
|
||||
const a = fromDir ? fromDir.split('/') : [];
|
||||
const b = to.split('/');
|
||||
while (a.length && b.length > 1 && a[0] === b[0]) { a.shift(); b.shift(); }
|
||||
return [...a.map(() => '..'), ...b].join('/') || '.';
|
||||
}
|
||||
|
||||
function localPath(filename, mainPath) {
|
||||
const value = String(filename).trim();
|
||||
const pkg = value.match(/^package:\/\/[^/]+\/(.*)$/i);
|
||||
if (pkg) return normalize(pkg[1]);
|
||||
if (/^https?:\/\//i.test(value) || /^(data|blob):/i.test(value)) return null;
|
||||
if (/^file:\/\//i.test(value)) return normalize(value.replace(/^file:\/+/i, ''));
|
||||
return normalize(value.startsWith('/') ? value.slice(1) : `${dirname(mainPath)}/${value}`);
|
||||
}
|
||||
|
||||
export function meshUrlCandidates(base, url) {
|
||||
const value = String(url);
|
||||
const root = String(base).replace(/\/+$/, '');
|
||||
const prefix = `${root}/`;
|
||||
if (!value.startsWith(prefix)) return [value];
|
||||
const path = value.slice(prefix.length).split(/[?#]/, 1)[0];
|
||||
const parts = path.split('/');
|
||||
if (parts.some((part) => !part || part === '.' || part === '..')) return [value];
|
||||
const resourceIndex = parts.findIndex((part, index) => index > 1 && (part === 'meshes' || part === 'qb_meshes'));
|
||||
const rootResource = parts[0] === 'robots' && resourceIndex > 1
|
||||
? `${root}/${parts.slice(resourceIndex).join('/')}`
|
||||
: null;
|
||||
// Older uploads can retain source directories that are absent from the OSS batch.
|
||||
const fallbacks = parts.slice(1, 9).map((_, i) => `${root}/${parts.slice(i + 1).join('/')}`);
|
||||
return [...new Set([rootResource, value, ...fallbacks].filter(Boolean))];
|
||||
}
|
||||
|
||||
// Resolve references against the uploaded file manifest. A unique suffix match
|
||||
// handles URDFs that retain their source workspace prefix after upload.
|
||||
export function resolveUrdfResourcePath(filename, mainPath, availablePaths) {
|
||||
const target = localPath(filename, mainPath);
|
||||
if (!target) return null;
|
||||
|
||||
const available = [...new Set(availablePaths.map(normalize).filter(Boolean))];
|
||||
let match = available.includes(target) ? target : null;
|
||||
if (!match) {
|
||||
const targetParts = target.split('/');
|
||||
let bestScore = 1;
|
||||
let best = [];
|
||||
for (const path of available) {
|
||||
const parts = path.split('/');
|
||||
let score = 0;
|
||||
while (score < targetParts.length && score < parts.length
|
||||
&& targetParts[targetParts.length - score - 1] === parts[parts.length - score - 1]) score++;
|
||||
if (score > bestScore) { bestScore = score; best = [path]; }
|
||||
else if (score === bestScore && score > 1) best.push(path);
|
||||
}
|
||||
if (bestScore > 1 && best.length === 1) match = best[0];
|
||||
else if (bestScore <= 1) {
|
||||
const basename = targetParts.at(-1);
|
||||
const sameName = available.filter((path) => path.split('/').at(-1) === basename);
|
||||
if (sameName.length === 1) match = sameName[0];
|
||||
}
|
||||
}
|
||||
|
||||
return match ? relative(dirname(mainPath), match) : null;
|
||||
}
|
||||
|
||||
export async function normalizeUrdfEntries(entries) {
|
||||
const main = entries.find((entry) => /\.urdf$/i.test(entry.relativePath));
|
||||
if (!main || typeof DOMParser === 'undefined' || typeof XMLSerializer === 'undefined' || typeof File === 'undefined') return entries;
|
||||
|
||||
const source = await main.file.text();
|
||||
const doc = new DOMParser().parseFromString(source, 'application/xml');
|
||||
if (doc.getElementsByTagName('parsererror').length) return entries;
|
||||
|
||||
const paths = entries.map((entry) => entry.relativePath);
|
||||
let changed = false;
|
||||
doc.querySelectorAll('mesh[filename], texture[filename]').forEach((node) => {
|
||||
const filename = node.getAttribute('filename');
|
||||
const resolved = resolveUrdfResourcePath(filename, main.relativePath, paths);
|
||||
if (resolved && resolved !== filename) {
|
||||
node.setAttribute('filename', resolved);
|
||||
changed = true;
|
||||
}
|
||||
});
|
||||
if (!changed) return entries;
|
||||
|
||||
const file = new File([new XMLSerializer().serializeToString(doc)], main.file.name, {
|
||||
type: main.file.type || 'application/xml',
|
||||
lastModified: main.file.lastModified,
|
||||
});
|
||||
return entries.map((entry) => entry === main ? { ...entry, file } : entry);
|
||||
}
|
||||
+24
-3
@@ -5,6 +5,8 @@ import { RoomEnvironment } from 'three/addons/environments/RoomEnvironment.js';
|
||||
import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';
|
||||
import { DRACOLoader } from 'three/addons/loaders/DRACOLoader.js';
|
||||
import { OBJLoader } from 'three/addons/loaders/OBJLoader.js';
|
||||
import { STLLoader } from 'three/addons/loaders/STLLoader.js';
|
||||
import { ColladaLoader } from 'three/addons/loaders/ColladaLoader.js';
|
||||
import URDFLoader from 'urdf-loader';
|
||||
import { URDFDragControls } from 'urdf-loader/src/URDFDragControls.js';
|
||||
import { MotionController } from './motion.js';
|
||||
@@ -320,7 +322,8 @@ export class RobotViewer extends EventTarget {
|
||||
const check = () => { if (model && pending === 0) resolve(model); };
|
||||
loader.loadMeshCb = (path, mgr, done) => {
|
||||
pending++;
|
||||
this.loadMesh(path, mgr, (mesh, err) => { done(mesh, err); pending--; queueMicrotask(check); }, loader);
|
||||
const candidates = config.resolveMeshUrls?.(path) || [path];
|
||||
this.loadMeshWithFallback(candidates, mgr, (mesh, err) => { done(mesh, err); pending--; queueMicrotask(check); });
|
||||
};
|
||||
loader.load(config.urdf, (m) => { model = m; queueMicrotask(check); }, undefined, reject);
|
||||
});
|
||||
@@ -364,7 +367,7 @@ export class RobotViewer extends EventTarget {
|
||||
return robot;
|
||||
}
|
||||
|
||||
loadMesh(path, manager, done, loader) {
|
||||
loadMesh(path, manager, done) {
|
||||
const ext = path.split(/[?#]/)[0].split('.').pop().toLowerCase();
|
||||
const fail = (err) => done(null, err);
|
||||
if (ext === 'glb' || ext === 'gltf') {
|
||||
@@ -376,11 +379,29 @@ export class RobotViewer extends EventTarget {
|
||||
}, undefined, fail);
|
||||
} else if (ext === 'obj') {
|
||||
new OBJLoader(manager).load(path, done, undefined, fail);
|
||||
} else if (ext === 'stl') {
|
||||
new STLLoader(manager).load(path, (geometry) => done(new THREE.Mesh(geometry, new THREE.MeshPhongMaterial())), undefined, fail);
|
||||
} else if (ext === 'dae') {
|
||||
new ColladaLoader(manager).load(path, (dae) => done(dae.scene), undefined, fail);
|
||||
} else {
|
||||
loader.defaultMeshLoader(path, manager, done);
|
||||
fail(new Error(`没有可用的网格加载器:${path}`));
|
||||
}
|
||||
}
|
||||
|
||||
loadMeshWithFallback(paths, manager, done) {
|
||||
const candidates = [...new Set(paths)].slice(0, 9);
|
||||
let index = 0;
|
||||
const attempt = (lastError) => {
|
||||
const path = candidates[index++];
|
||||
if (!path) { done(null, lastError); return; }
|
||||
this.loadMesh(path, manager, (mesh, err) => {
|
||||
if (err && index < candidates.length) attempt(err);
|
||||
else done(mesh, err);
|
||||
});
|
||||
};
|
||||
attempt();
|
||||
}
|
||||
|
||||
// 归一化尺寸、落地、居中,并按 view 配置摆相机
|
||||
frame(view) {
|
||||
const robot = this.robot;
|
||||
|
||||
+1
-1
@@ -773,7 +773,7 @@ async function renderSettings() {
|
||||
<span class="ws-cover-btns">
|
||||
<label class="btn btn-sm">选择图片<input type="file" accept="image/jpeg,image/png,image/webp" hidden id="ws-cover-file"></label>
|
||||
${p.coverUrl ? '<button type="button" class="btn btn-sm btn-ghost" data-nocover>移除封面</button>' : ''}
|
||||
<small class="muted">JPG / PNG / WebP,5 MB 以内</small>
|
||||
<small class="muted">JPG / PNG / WebP,原图 5 MB 以内,上传后自动优化</small>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { meshUrlCandidates, resolveUrdfResourcePath } from '../js/urdf-paths.js';
|
||||
|
||||
test('maps package references with a stale source directory prefix to uploaded paths', () => {
|
||||
assert.equal(
|
||||
resolveUrdfResourcePath(
|
||||
'package://example-robot-data/robots/asr_twodof_description/meshes/arm.stl',
|
||||
'robot.urdf',
|
||||
['meshes/arm.stl'],
|
||||
),
|
||||
'meshes/arm.stl',
|
||||
);
|
||||
});
|
||||
|
||||
test('rewrites a package reference relative to a nested URDF file', () => {
|
||||
assert.equal(
|
||||
resolveUrdfResourcePath('package://robot/meshes/body.stl', 'urdf/robot.urdf', ['meshes/body.stl']),
|
||||
'../meshes/body.stl',
|
||||
);
|
||||
});
|
||||
|
||||
test('uses uploaded paths to resolve ordinary relative references', () => {
|
||||
assert.equal(
|
||||
resolveUrdfResourcePath('../meshes/body.stl', 'urdf/robot.urdf', ['meshes/body.stl']),
|
||||
'../meshes/body.stl',
|
||||
);
|
||||
});
|
||||
|
||||
test('leaves ambiguous filename-only matches unchanged', () => {
|
||||
assert.equal(
|
||||
resolveUrdfResourcePath('package://robot/legacy/body.stl', 'robot.urdf', ['left/body.stl', 'right/body.stl']),
|
||||
null,
|
||||
);
|
||||
});
|
||||
|
||||
test('tries the resource-root URL first for stale robot source directory prefixes', () => {
|
||||
assert.deepEqual(
|
||||
meshUrlCandidates(
|
||||
'https://oss.example/batch',
|
||||
'https://oss.example/batch/robots/asr_twodof_description/meshes/arm.stl',
|
||||
),
|
||||
[
|
||||
'https://oss.example/batch/meshes/arm.stl',
|
||||
'https://oss.example/batch/robots/asr_twodof_description/meshes/arm.stl',
|
||||
'https://oss.example/batch/asr_twodof_description/meshes/arm.stl',
|
||||
'https://oss.example/batch/arm.stl',
|
||||
],
|
||||
);
|
||||
});
|
||||
|
||||
test('keeps normal package mesh URLs first', () => {
|
||||
assert.deepEqual(
|
||||
meshUrlCandidates('https://oss.example/batch', 'https://oss.example/batch/meshes/body.stl'),
|
||||
['https://oss.example/batch/meshes/body.stl', 'https://oss.example/batch/body.stl'],
|
||||
);
|
||||
});
|
||||
Vendored
+568
@@ -0,0 +1,568 @@
|
||||
DOMPurify
|
||||
Copyright 2024 Dr.-Ing. Mario Heiderich, Cure53
|
||||
|
||||
DOMPurify is free software; you can redistribute it and/or modify it under the
|
||||
terms of either:
|
||||
|
||||
a) the Apache License Version 2.0, or
|
||||
b) the Mozilla Public License Version 2.0
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
Mozilla Public License, version 2.0
|
||||
|
||||
1. Definitions
|
||||
|
||||
1.1. “Contributor”
|
||||
|
||||
means each individual or legal entity that creates, contributes to the
|
||||
creation of, or owns Covered Software.
|
||||
|
||||
1.2. “Contributor Version”
|
||||
|
||||
means the combination of the Contributions of others (if any) used by a
|
||||
Contributor and that particular Contributor’s Contribution.
|
||||
|
||||
1.3. “Contribution”
|
||||
|
||||
means Covered Software of a particular Contributor.
|
||||
|
||||
1.4. “Covered Software”
|
||||
|
||||
means Source Code Form to which the initial Contributor has attached the
|
||||
notice in Exhibit A, the Executable Form of such Source Code Form, and
|
||||
Modifications of such Source Code Form, in each case including portions
|
||||
thereof.
|
||||
|
||||
1.5. “Incompatible With Secondary Licenses”
|
||||
means
|
||||
|
||||
a. that the initial Contributor has attached the notice described in
|
||||
Exhibit B to the Covered Software; or
|
||||
|
||||
b. that the Covered Software was made available under the terms of version
|
||||
1.1 or earlier of the License, but not also under the terms of a
|
||||
Secondary License.
|
||||
|
||||
1.6. “Executable Form”
|
||||
|
||||
means any form of the work other than Source Code Form.
|
||||
|
||||
1.7. “Larger Work”
|
||||
|
||||
means a work that combines Covered Software with other material, in a separate
|
||||
file or files, that is not Covered Software.
|
||||
|
||||
1.8. “License”
|
||||
|
||||
means this document.
|
||||
|
||||
1.9. “Licensable”
|
||||
|
||||
means having the right to grant, to the maximum extent possible, whether at the
|
||||
time of the initial grant or subsequently, any and all of the rights conveyed by
|
||||
this License.
|
||||
|
||||
1.10. “Modifications”
|
||||
|
||||
means any of the following:
|
||||
|
||||
a. any file in Source Code Form that results from an addition to, deletion
|
||||
from, or modification of the contents of Covered Software; or
|
||||
|
||||
b. any new file in Source Code Form that contains any Covered Software.
|
||||
|
||||
1.11. “Patent Claims” of a Contributor
|
||||
|
||||
means any patent claim(s), including without limitation, method, process,
|
||||
and apparatus claims, in any patent Licensable by such Contributor that
|
||||
would be infringed, but for the grant of the License, by the making,
|
||||
using, selling, offering for sale, having made, import, or transfer of
|
||||
either its Contributions or its Contributor Version.
|
||||
|
||||
1.12. “Secondary License”
|
||||
|
||||
means either the GNU General Public License, Version 2.0, the GNU Lesser
|
||||
General Public License, Version 2.1, the GNU Affero General Public
|
||||
License, Version 3.0, or any later versions of those licenses.
|
||||
|
||||
1.13. “Source Code Form”
|
||||
|
||||
means the form of the work preferred for making modifications.
|
||||
|
||||
1.14. “You” (or “Your”)
|
||||
|
||||
means an individual or a legal entity exercising rights under this
|
||||
License. For legal entities, “You” includes any entity that controls, is
|
||||
controlled by, or is under common control with You. For purposes of this
|
||||
definition, “control” means (a) the power, direct or indirect, to cause
|
||||
the direction or management of such entity, whether by contract or
|
||||
otherwise, or (b) ownership of more than fifty percent (50%) of the
|
||||
outstanding shares or beneficial ownership of such entity.
|
||||
|
||||
|
||||
2. License Grants and Conditions
|
||||
|
||||
2.1. Grants
|
||||
|
||||
Each Contributor hereby grants You a world-wide, royalty-free,
|
||||
non-exclusive license:
|
||||
|
||||
a. under intellectual property rights (other than patent or trademark)
|
||||
Licensable by such Contributor to use, reproduce, make available,
|
||||
modify, display, perform, distribute, and otherwise exploit its
|
||||
Contributions, either on an unmodified basis, with Modifications, or as
|
||||
part of a Larger Work; and
|
||||
|
||||
b. under Patent Claims of such Contributor to make, use, sell, offer for
|
||||
sale, have made, import, and otherwise transfer either its Contributions
|
||||
or its Contributor Version.
|
||||
|
||||
2.2. Effective Date
|
||||
|
||||
The licenses granted in Section 2.1 with respect to any Contribution become
|
||||
effective for each Contribution on the date the Contributor first distributes
|
||||
such Contribution.
|
||||
|
||||
2.3. Limitations on Grant Scope
|
||||
|
||||
The licenses granted in this Section 2 are the only rights granted under this
|
||||
License. No additional rights or licenses will be implied from the distribution
|
||||
or licensing of Covered Software under this License. Notwithstanding Section
|
||||
2.1(b) above, no patent license is granted by a Contributor:
|
||||
|
||||
a. for any code that a Contributor has removed from Covered Software; or
|
||||
|
||||
b. for infringements caused by: (i) Your and any other third party’s
|
||||
modifications of Covered Software, or (ii) the combination of its
|
||||
Contributions with other software (except as part of its Contributor
|
||||
Version); or
|
||||
|
||||
c. under Patent Claims infringed by Covered Software in the absence of its
|
||||
Contributions.
|
||||
|
||||
This License does not grant any rights in the trademarks, service marks, or
|
||||
logos of any Contributor (except as may be necessary to comply with the
|
||||
notice requirements in Section 3.4).
|
||||
|
||||
2.4. Subsequent Licenses
|
||||
|
||||
No Contributor makes additional grants as a result of Your choice to
|
||||
distribute the Covered Software under a subsequent version of this License
|
||||
(see Section 10.2) or under the terms of a Secondary License (if permitted
|
||||
under the terms of Section 3.3).
|
||||
|
||||
2.5. Representation
|
||||
|
||||
Each Contributor represents that the Contributor believes its Contributions
|
||||
are its original creation(s) or it has sufficient rights to grant the
|
||||
rights to its Contributions conveyed by this License.
|
||||
|
||||
2.6. Fair Use
|
||||
|
||||
This License is not intended to limit any rights You have under applicable
|
||||
copyright doctrines of fair use, fair dealing, or other equivalents.
|
||||
|
||||
2.7. Conditions
|
||||
|
||||
Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted in
|
||||
Section 2.1.
|
||||
|
||||
|
||||
3. Responsibilities
|
||||
|
||||
3.1. Distribution of Source Form
|
||||
|
||||
All distribution of Covered Software in Source Code Form, including any
|
||||
Modifications that You create or to which You contribute, must be under the
|
||||
terms of this License. You must inform recipients that the Source Code Form
|
||||
of the Covered Software is governed by the terms of this License, and how
|
||||
they can obtain a copy of this License. You may not attempt to alter or
|
||||
restrict the recipients’ rights in the Source Code Form.
|
||||
|
||||
3.2. Distribution of Executable Form
|
||||
|
||||
If You distribute Covered Software in Executable Form then:
|
||||
|
||||
a. such Covered Software must also be made available in Source Code Form,
|
||||
as described in Section 3.1, and You must inform recipients of the
|
||||
Executable Form how they can obtain a copy of such Source Code Form by
|
||||
reasonable means in a timely manner, at a charge no more than the cost
|
||||
of distribution to the recipient; and
|
||||
|
||||
b. You may distribute such Executable Form under the terms of this License,
|
||||
or sublicense it under different terms, provided that the license for
|
||||
the Executable Form does not attempt to limit or alter the recipients’
|
||||
rights in the Source Code Form under this License.
|
||||
|
||||
3.3. Distribution of a Larger Work
|
||||
|
||||
You may create and distribute a Larger Work under terms of Your choice,
|
||||
provided that You also comply with the requirements of this License for the
|
||||
Covered Software. If the Larger Work is a combination of Covered Software
|
||||
with a work governed by one or more Secondary Licenses, and the Covered
|
||||
Software is not Incompatible With Secondary Licenses, this License permits
|
||||
You to additionally distribute such Covered Software under the terms of
|
||||
such Secondary License(s), so that the recipient of the Larger Work may, at
|
||||
their option, further distribute the Covered Software under the terms of
|
||||
either this License or such Secondary License(s).
|
||||
|
||||
3.4. Notices
|
||||
|
||||
You may not remove or alter the substance of any license notices (including
|
||||
copyright notices, patent notices, disclaimers of warranty, or limitations
|
||||
of liability) contained within the Source Code Form of the Covered
|
||||
Software, except that You may alter any license notices to the extent
|
||||
required to remedy known factual inaccuracies.
|
||||
|
||||
3.5. Application of Additional Terms
|
||||
|
||||
You may choose to offer, and to charge a fee for, warranty, support,
|
||||
indemnity or liability obligations to one or more recipients of Covered
|
||||
Software. However, You may do so only on Your own behalf, and not on behalf
|
||||
of any Contributor. You must make it absolutely clear that any such
|
||||
warranty, support, indemnity, or liability obligation is offered by You
|
||||
alone, and You hereby agree to indemnify every Contributor for any
|
||||
liability incurred by such Contributor as a result of warranty, support,
|
||||
indemnity or liability terms You offer. You may include additional
|
||||
disclaimers of warranty and limitations of liability specific to any
|
||||
jurisdiction.
|
||||
|
||||
4. Inability to Comply Due to Statute or Regulation
|
||||
|
||||
If it is impossible for You to comply with any of the terms of this License
|
||||
with respect to some or all of the Covered Software due to statute, judicial
|
||||
order, or regulation then You must: (a) comply with the terms of this License
|
||||
to the maximum extent possible; and (b) describe the limitations and the code
|
||||
they affect. Such description must be placed in a text file included with all
|
||||
distributions of the Covered Software under this License. Except to the
|
||||
extent prohibited by statute or regulation, such description must be
|
||||
sufficiently detailed for a recipient of ordinary skill to be able to
|
||||
understand it.
|
||||
|
||||
5. Termination
|
||||
|
||||
5.1. The rights granted under this License will terminate automatically if You
|
||||
fail to comply with any of its terms. However, if You become compliant,
|
||||
then the rights granted under this License from a particular Contributor
|
||||
are reinstated (a) provisionally, unless and until such Contributor
|
||||
explicitly and finally terminates Your grants, and (b) on an ongoing basis,
|
||||
if such Contributor fails to notify You of the non-compliance by some
|
||||
reasonable means prior to 60 days after You have come back into compliance.
|
||||
Moreover, Your grants from a particular Contributor are reinstated on an
|
||||
ongoing basis if such Contributor notifies You of the non-compliance by
|
||||
some reasonable means, this is the first time You have received notice of
|
||||
non-compliance with this License from such Contributor, and You become
|
||||
compliant prior to 30 days after Your receipt of the notice.
|
||||
|
||||
5.2. If You initiate litigation against any entity by asserting a patent
|
||||
infringement claim (excluding declaratory judgment actions, counter-claims,
|
||||
and cross-claims) alleging that a Contributor Version directly or
|
||||
indirectly infringes any patent, then the rights granted to You by any and
|
||||
all Contributors for the Covered Software under Section 2.1 of this License
|
||||
shall terminate.
|
||||
|
||||
5.3. In the event of termination under Sections 5.1 or 5.2 above, all end user
|
||||
license agreements (excluding distributors and resellers) which have been
|
||||
validly granted by You or Your distributors under this License prior to
|
||||
termination shall survive termination.
|
||||
|
||||
6. Disclaimer of Warranty
|
||||
|
||||
Covered Software is provided under this License on an “as is” basis, without
|
||||
warranty of any kind, either expressed, implied, or statutory, including,
|
||||
without limitation, warranties that the Covered Software is free of defects,
|
||||
merchantable, fit for a particular purpose or non-infringing. The entire
|
||||
risk as to the quality and performance of the Covered Software is with You.
|
||||
Should any Covered Software prove defective in any respect, You (not any
|
||||
Contributor) assume the cost of any necessary servicing, repair, or
|
||||
correction. This disclaimer of warranty constitutes an essential part of this
|
||||
License. No use of any Covered Software is authorized under this License
|
||||
except under this disclaimer.
|
||||
|
||||
7. Limitation of Liability
|
||||
|
||||
Under no circumstances and under no legal theory, whether tort (including
|
||||
negligence), contract, or otherwise, shall any Contributor, or anyone who
|
||||
distributes Covered Software as permitted above, be liable to You for any
|
||||
direct, indirect, special, incidental, or consequential damages of any
|
||||
character including, without limitation, damages for lost profits, loss of
|
||||
goodwill, work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses, even if such party shall have been
|
||||
informed of the possibility of such damages. This limitation of liability
|
||||
shall not apply to liability for death or personal injury resulting from such
|
||||
party’s negligence to the extent applicable law prohibits such limitation.
|
||||
Some jurisdictions do not allow the exclusion or limitation of incidental or
|
||||
consequential damages, so this exclusion and limitation may not apply to You.
|
||||
|
||||
8. Litigation
|
||||
|
||||
Any litigation relating to this License may be brought only in the courts of
|
||||
a jurisdiction where the defendant maintains its principal place of business
|
||||
and such litigation shall be governed by laws of that jurisdiction, without
|
||||
reference to its conflict-of-law provisions. Nothing in this Section shall
|
||||
prevent a party’s ability to bring cross-claims or counter-claims.
|
||||
|
||||
9. Miscellaneous
|
||||
|
||||
This License represents the complete agreement concerning the subject matter
|
||||
hereof. If any provision of this License is held to be unenforceable, such
|
||||
provision shall be reformed only to the extent necessary to make it
|
||||
enforceable. Any law or regulation which provides that the language of a
|
||||
contract shall be construed against the drafter shall not be used to construe
|
||||
this License against a Contributor.
|
||||
|
||||
|
||||
10. Versions of the License
|
||||
|
||||
10.1. New Versions
|
||||
|
||||
Mozilla Foundation is the license steward. Except as provided in Section
|
||||
10.3, no one other than the license steward has the right to modify or
|
||||
publish new versions of this License. Each version will be given a
|
||||
distinguishing version number.
|
||||
|
||||
10.2. Effect of New Versions
|
||||
|
||||
You may distribute the Covered Software under the terms of the version of
|
||||
the License under which You originally received the Covered Software, or
|
||||
under the terms of any subsequent version published by the license
|
||||
steward.
|
||||
|
||||
10.3. Modified Versions
|
||||
|
||||
If you create software not governed by this License, and you want to
|
||||
create a new license for such software, you may create and use a modified
|
||||
version of this License if you rename the license and remove any
|
||||
references to the name of the license steward (except to note that such
|
||||
modified license differs from this License).
|
||||
|
||||
10.4. Distributing Source Code Form that is Incompatible With Secondary Licenses
|
||||
If You choose to distribute Source Code Form that is Incompatible With
|
||||
Secondary Licenses under the terms of this version of the License, the
|
||||
notice described in Exhibit B of this License must be attached.
|
||||
|
||||
Exhibit A - Source Code Form License Notice
|
||||
|
||||
This Source Code Form is subject to the
|
||||
terms of the Mozilla Public License, v.
|
||||
2.0. If a copy of the MPL was not
|
||||
distributed with this file, You can
|
||||
obtain one at
|
||||
http://mozilla.org/MPL/2.0/.
|
||||
|
||||
If it is not possible or desirable to put the notice in a particular file, then
|
||||
You may include the notice in a location (such as a LICENSE file in a relevant
|
||||
directory) where a recipient would be likely to look for such a notice.
|
||||
|
||||
You may add additional accurate notices of copyright ownership.
|
||||
|
||||
Exhibit B - “Incompatible With Secondary Licenses” Notice
|
||||
|
||||
This Source Code Form is “Incompatible
|
||||
With Secondary Licenses”, as defined by
|
||||
the Mozilla Public License, v. 2.0.
|
||||
|
||||
Vendored
+1554
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user