@leaders-tech/schemio-playground 0.1.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/README.md +69 -0
- package/embed-dist/chunks/SchemioPlaygroundMount-DdNsPNrS.js +28212 -0
- package/embed-dist/schemio-playground.js +58 -0
- package/package.json +79 -0
- package/schemio-playground.d.ts +18 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
const s = ":host{color:#e2e8f0;display:block;font-family:Segoe UI,Helvetica Neue,sans-serif}*{box-sizing:border-box}.schemio-playground{background:#0f172a;border:1px solid #334155;border-radius:18px;padding:20px}.schemio-playground__header,.schemio-playground__debugger-title{align-items:start;display:flex;gap:16px;justify-content:space-between}.schemio-playground h2,.schemio-playground h3,.schemio-playground h4,.schemio-playground p{margin:0}.schemio-playground h2{font-size:1.25rem}.schemio-playground h3{font-size:1rem}.schemio-playground h4{color:#cbd5e1;font-size:.78rem;letter-spacing:.08em;text-transform:uppercase}.schemio-playground__header p,.schemio-playground__debugger-title p,.schemio-playground__storage{color:#94a3b8;font-size:.88rem;margin-top:4px}.schemio-playground__reset{background:#1e293b;border:1px solid #475569;border-radius:9px;color:#f8fafc;cursor:pointer;font:inherit;padding:8px 10px}.schemio-playground__reset:hover{background:#334155}.schemio-playground__editor{border:1px solid #334155;border-radius:12px;margin-top:18px;overflow:hidden}.schemio-playground__diagnostics,.schemio-playground__debugger{background:#172033;border-radius:12px;margin-top:16px;padding:14px}.schemio-playground__diagnostics ul{color:#fecaca;margin:10px 0 0;padding-left:20px}.schemio-playground__success{color:#86efac;font-size:.9rem;margin-top:8px!important}.schemio-playground__blocked{color:#cbd5e1;margin-top:14px!important}.schemio-playground__signals{display:grid;gap:14px;grid-template-columns:repeat(2,minmax(0,1fr));margin-top:14px}.schemio-playground__signal-list{display:flex;flex-wrap:wrap;gap:8px;margin-top:9px}.schemio-playground__bit{align-items:center;background:#020617;border:1px solid #334155;border-radius:9px;color:#f8fafc;display:flex;flex-direction:column;font:inherit;min-width:72px;padding:8px 12px}button.schemio-playground__bit{cursor:pointer}.schemio-playground__bit--on{background:#34d399;border-color:#6ee7b7;color:#052e2b}.schemio-playground__bit span{font-size:.75rem;opacity:.72}.schemio-playground__bit strong{font-size:1.3rem}.schemio-playground__output{background:#111827}.schemio-playground__storage{margin-top:14px!important}@media(max-width:600px){.schemio-playground{border-radius:12px;padding:14px}.schemio-playground__header,.schemio-playground__debugger-title{flex-direction:column}.schemio-playground__signals{grid-template-columns:1fr}}", a = `scheme (a b) xor (out):
|
|
2
|
+
local either both not_both
|
|
3
|
+
(a b) or (either)
|
|
4
|
+
(a b) and (both)
|
|
5
|
+
(both) not (not_both)
|
|
6
|
+
(either not_both) and (out)
|
|
7
|
+
end
|
|
8
|
+
`;
|
|
9
|
+
function d(n) {
|
|
10
|
+
const e = n.querySelector(':scope > script[type="text/plain"]');
|
|
11
|
+
return e?.textContent ? e.textContent.replace(/^\s*\n/, "").trimEnd() + `
|
|
12
|
+
` : a;
|
|
13
|
+
}
|
|
14
|
+
function l(n) {
|
|
15
|
+
return Array.from(document.querySelectorAll("schemio-playground")).indexOf(n);
|
|
16
|
+
}
|
|
17
|
+
class c extends HTMLElement {
|
|
18
|
+
cleanup = null;
|
|
19
|
+
host = null;
|
|
20
|
+
observer = null;
|
|
21
|
+
loaded = !1;
|
|
22
|
+
connectedCallback() {
|
|
23
|
+
if (this.loaded)
|
|
24
|
+
return;
|
|
25
|
+
if (!this.shadowRoot) {
|
|
26
|
+
const r = this.attachShadow({ mode: "open" }), t = document.createElement("style");
|
|
27
|
+
t.textContent = s, this.host = document.createElement("div"), r.append(t, this.host);
|
|
28
|
+
}
|
|
29
|
+
const e = this.host;
|
|
30
|
+
e.textContent = "Loading Schemio playground…";
|
|
31
|
+
const o = () => {
|
|
32
|
+
this.loaded || (this.loaded = !0, this.observer?.disconnect(), this.mount(e));
|
|
33
|
+
};
|
|
34
|
+
this.getBoundingClientRect().top <= window.innerHeight + 320 || !("IntersectionObserver" in window) ? o() : (this.observer = new IntersectionObserver((r) => {
|
|
35
|
+
r.some((t) => t.isIntersecting) && o();
|
|
36
|
+
}, { rootMargin: "320px" }), this.observer.observe(this));
|
|
37
|
+
}
|
|
38
|
+
disconnectedCallback() {
|
|
39
|
+
this.observer?.disconnect(), this.observer = null, this.cleanup?.(), this.cleanup = null, this.loaded = !1;
|
|
40
|
+
}
|
|
41
|
+
async mount(e) {
|
|
42
|
+
try {
|
|
43
|
+
const { mountSchemioPlayground: o } = await import("./chunks/SchemioPlaygroundMount-DdNsPNrS.js"), i = this.getAttribute("storage-key") ?? `schemio-playground:${window.location.pathname}:${this.id || l(this)}`;
|
|
44
|
+
this.cleanup = o(e, {
|
|
45
|
+
initialSource: d(this),
|
|
46
|
+
storageKey: i,
|
|
47
|
+
persist: this.getAttribute("storage") !== "off",
|
|
48
|
+
readOnly: this.hasAttribute("readonly"),
|
|
49
|
+
onSourceChange: (r, t) => {
|
|
50
|
+
this.dispatchEvent(new CustomEvent("schemio-change", { bubbles: !0, composed: !0, detail: { source: r, isValid: t } }));
|
|
51
|
+
}
|
|
52
|
+
}).unmount;
|
|
53
|
+
} catch (o) {
|
|
54
|
+
e.textContent = "Schemio playground could not load. Please reload the page.", console.error("Could not load the Schemio playground.", o);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
customElements.get("schemio-playground") || customElements.define("schemio-playground", c);
|
package/package.json
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@leaders-tech/schemio-playground",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "A lazy-loaded web component with a Schemio editor and live logic-scheme debugger.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"types": "./schemio-playground.d.ts",
|
|
9
|
+
"import": "./embed-dist/schemio-playground.js"
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
"types": "./schemio-playground.d.ts",
|
|
13
|
+
"files": [
|
|
14
|
+
"embed-dist",
|
|
15
|
+
"README.md",
|
|
16
|
+
"schemio-playground.d.ts"
|
|
17
|
+
],
|
|
18
|
+
"sideEffects": true,
|
|
19
|
+
"engines": {
|
|
20
|
+
"node": ">=20"
|
|
21
|
+
},
|
|
22
|
+
"repository": {
|
|
23
|
+
"type": "git",
|
|
24
|
+
"url": "git+https://github.com/leaders-tech/scheme.git",
|
|
25
|
+
"directory": "frontend"
|
|
26
|
+
},
|
|
27
|
+
"homepage": "https://github.com/leaders-tech/scheme#readme",
|
|
28
|
+
"bugs": {
|
|
29
|
+
"url": "https://github.com/leaders-tech/scheme/issues"
|
|
30
|
+
},
|
|
31
|
+
"publishConfig": {
|
|
32
|
+
"access": "public"
|
|
33
|
+
},
|
|
34
|
+
"scripts": {
|
|
35
|
+
"dev": "vite",
|
|
36
|
+
"build": "tsc -b && vite build",
|
|
37
|
+
"build:playground": "tsc -b && vite build --config vite.playground.config.ts",
|
|
38
|
+
"preview": "vite preview",
|
|
39
|
+
"test": "vitest run",
|
|
40
|
+
"test:watch": "vitest",
|
|
41
|
+
"test:e2e": "npm run build:playground && playwright test",
|
|
42
|
+
"test:e2e:docker": "sh ./scripts/test-e2e-docker.sh",
|
|
43
|
+
"pack:check": "npm run build:playground && npm pack --dry-run",
|
|
44
|
+
"format": "prettier --write ."
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@codemirror/autocomplete": "^6.20.1",
|
|
48
|
+
"@codemirror/lang-javascript": "^6.2.5",
|
|
49
|
+
"@codemirror/language": "^6.12.3",
|
|
50
|
+
"@codemirror/state": "^6.6.0",
|
|
51
|
+
"@codemirror/theme-one-dark": "^6.1.3",
|
|
52
|
+
"@codemirror/view": "^6.41.0",
|
|
53
|
+
"@eslint/js": "^9.34.0",
|
|
54
|
+
"@playwright/test": "^1.55.0",
|
|
55
|
+
"@tailwindcss/vite": "^4.1.13",
|
|
56
|
+
"@testing-library/jest-dom": "^6.8.0",
|
|
57
|
+
"@testing-library/react": "^16.3.0",
|
|
58
|
+
"@testing-library/user-event": "^14.6.1",
|
|
59
|
+
"@types/node": "^24.3.0",
|
|
60
|
+
"@types/react": "^19.1.12",
|
|
61
|
+
"@types/react-dom": "^19.1.9",
|
|
62
|
+
"@uiw/react-codemirror": "^4.25.9",
|
|
63
|
+
"@vitejs/plugin-react": "^5.0.2",
|
|
64
|
+
"eslint": "^9.34.0",
|
|
65
|
+
"eslint-plugin-react-hooks": "^5.2.0",
|
|
66
|
+
"eslint-plugin-react-refresh": "^0.4.20",
|
|
67
|
+
"jsdom": "^27.0.0",
|
|
68
|
+
"prettier": "^3.6.2",
|
|
69
|
+
"react": "^19.1.1",
|
|
70
|
+
"react-dom": "^19.1.1",
|
|
71
|
+
"react-router-dom": "^7.8.2",
|
|
72
|
+
"tailwindcss": "^4.1.13",
|
|
73
|
+
"typescript": "^5.9.2",
|
|
74
|
+
"typescript-eslint": "^8.41.0",
|
|
75
|
+
"vite": "^7.1.3",
|
|
76
|
+
"vite-plugin-pwa": "^1.0.3",
|
|
77
|
+
"vitest": "^3.2.4"
|
|
78
|
+
}
|
|
79
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/* This file describes the browser-facing Schemio playground package.
|
|
2
|
+
Edit it when the custom element's public tag or event details change.
|
|
3
|
+
Copy it when another web-component package needs a small TypeScript API. */
|
|
4
|
+
|
|
5
|
+
export type SchemioChangeDetail = {
|
|
6
|
+
source: string;
|
|
7
|
+
isValid: boolean;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
declare global {
|
|
11
|
+
interface HTMLElementTagNameMap {
|
|
12
|
+
"schemio-playground": HTMLElement;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
interface HTMLElementEventMap {
|
|
16
|
+
"schemio-change": CustomEvent<SchemioChangeDetail>;
|
|
17
|
+
}
|
|
18
|
+
}
|