Spec v1.2, Logosmental-based design direction and tokens, pnpm monorepo (apps/demo, packages/data|features|i18n|db/seed), student + admin screens in 4 locales, simulated ArifPay checkout on the real order state machine, artifact inline/check tools, domain rule checks and UI audit fixes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
30 lines
3.1 KiB
JavaScript
30 lines
3.1 KiB
JavaScript
// In-memory stand-in for the artifact runtime (window.claude), for local screenshots only.
|
|
(() => {
|
|
const SEED = window.__SEED__ || {}; const store = new Map(Object.entries(SEED).filter(([, v]) => v)); const subs = new Set();
|
|
const merge = (a, b) => { const o = { ...(a || {}) }; for (const [k, v] of Object.entries(b)) o[k] = v && typeof v === 'object' && !Array.isArray(v) && o[k] && typeof o[k] === 'object' ? merge(o[k], v) : v; return o; };
|
|
const snapDoc = (p) => ({ id: p.split('/').pop(), exists: store.has(p), data: () => store.get(p), metadata: {} });
|
|
const notify = () => setTimeout(() => subs.forEach((f) => f()), 0);
|
|
const query = (col, ord, lim) => ({
|
|
where: () => query(col, ord, lim), orderBy: (f, d = 'asc') => query(col, [f, d], lim), limit: (n) => query(col, ord, n),
|
|
get: async () => snapQ(), onSnapshot(next) { const f = () => next(snapQ()); subs.add(f); setTimeout(f, 30); return () => subs.delete(f); },
|
|
doc: (id = Math.random().toString(36).slice(2)) => docRef(col + '/' + id), path: col,
|
|
});
|
|
function snapQ() { return null; }
|
|
const docRef = (p) => ({ id: p.split('/').pop(), path: p, get: async () => snapDoc(p),
|
|
set: async (d) => { store.set(p, JSON.parse(JSON.stringify(d))); notify(); }, update: async (d) => { store.set(p, merge(store.get(p), JSON.parse(JSON.stringify(d)))); notify(); },
|
|
delete: async () => { store.delete(p); notify(); }, onSnapshot(next) { const f = () => next(snapDoc(p)); subs.add(f); setTimeout(f, 30); return () => subs.delete(f); },
|
|
collection: (c) => collection(p + '/' + c) });
|
|
function collection(col, ord, lim) {
|
|
const q = query(col, ord, lim);
|
|
const run = () => { let docs = [...store.keys()].filter((k) => k.startsWith(col + '/') && k.split('/').length === col.split('/').length + 1).map(snapDoc);
|
|
if (ord) docs.sort((a, b) => String(a.data()[ord[0]] ?? '').localeCompare(String(b.data()[ord[0]] ?? '')) * (ord[1] === 'desc' ? -1 : 1));
|
|
if (lim) docs = docs.slice(0, lim); return { docs, size: docs.length, empty: !docs.length, docChanges: () => [], metadata: {} }; };
|
|
return { ...q, orderBy: (f, d = 'asc') => collection(col, [f, d], lim), limit: (n) => collection(col, ord, n), get: async () => run(),
|
|
onSnapshot(next) { const f = () => next(run()); subs.add(f); setTimeout(f, 30); return () => subs.delete(f); }, add: async (d) => { const r = docRef(col + '/' + Math.random().toString(36).slice(2)); await r.set(d); return r; } };
|
|
}
|
|
const ME = window.__ME__ || { id: 'u_reviewer', name: 'Kirubel', isOwner: true, canEdit: true };
|
|
const user = { me: async () => ({ ...ME, avatarUrl: '', color: '#888', email: null }), id: async () => ME.id, isOwner: async () => ME.isOwner, canEdit: async () => ME.canEdit, can: async () => null, profiles: async (ids) => Object.fromEntries([].concat(ids).map((i) => [i, { id: i, name: i === ME.id ? ME.name : 'Admin', avatarUrl: '', color: '#888', email: null, isMe: i === ME.id, guest: false }])) };
|
|
const ns = { db: { doc: docRef, collection }, user, comments: { openComposer: async () => ({ opened: true }) }, downloads: { save: async () => ({ saved: true }) }, assets: null };
|
|
window.claude = { use: async (n) => ns[n] ?? null };
|
|
})();
|