@moloodev/cli 0.3.0 → 0.5.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.
@@ -1,12 +0,0 @@
1
- import { createRoot } from "react-dom/client";
2
- import { DevHostApp } from "./dev-host-app";
3
- import { createDevHostController } from "./dev-host-client";
4
-
5
- const config = typeof window === "undefined" ? undefined : window.__MOLOO_DEV_HOST__;
6
- if (config) {
7
- document.documentElement.classList.add("dark");
8
- const container = document.createElement("div");
9
- container.id = "moloo-dev-host";
10
- document.body.replaceChildren(container);
11
- createRoot(container).render(<DevHostApp controller={createDevHostController(config)} />);
12
- }
package/src/dev-host.css DELETED
@@ -1,19 +0,0 @@
1
- @import "@moloodev/ui/fonts.css";
2
- @import "tailwindcss";
3
- @import "tw-animate-css";
4
- @import "shadcn/tailwind.css";
5
- @import "@moloodev/ui/styles.css";
6
- @import "@moloodev/ui/typeset.css";
7
- @import "@moloodev/ui/moloo.css";
8
-
9
- @custom-variant dark (&:is(.dark *));
10
-
11
- html,
12
- body {
13
- height: 100%;
14
- margin: 0;
15
- overflow: hidden;
16
- font-family: var(--font-sans);
17
- background: var(--background);
18
- color: var(--foreground);
19
- }
package/src/view-page.ts DELETED
@@ -1,57 +0,0 @@
1
- import { connectEditorView, type EditorView } from "@moloodev/editor-sdk/view";
2
-
3
- export type HandshakePageDeps = {
4
- readonly search: string;
5
- readonly editorId: string;
6
- postMessage(
7
- message: unknown,
8
- targetOrigin: string,
9
- transfer: readonly MessagePort[],
10
- ): void;
11
- createChannel(): MessageChannel;
12
- setHandshake(value: string): void;
13
- };
14
-
15
- /** Handshake only. The dataset records `ok` or the failure code from the existing channel. */
16
- export function startHandshakePage(deps: HandshakePageDeps): EditorView {
17
- const view = connectEditorView({
18
- parent: singleParent(deps.search),
19
- editorId: deps.editorId,
20
- postMessage: deps.postMessage,
21
- createChannel: deps.createChannel,
22
- });
23
- void view.handshake.then((result) => {
24
- deps.setHandshake(result.ok ? "ok" : result.code);
25
- });
26
- return view;
27
- }
28
-
29
- function singleParent(search: string): string | null {
30
- const values = new URLSearchParams(search).getAll("parent");
31
- if (values.length !== 1) return null;
32
- const parent = values[0];
33
- if (parent === undefined || parent.length === 0) return null;
34
- return parent;
35
- }
36
-
37
- function wireWindow(): void {
38
- if (typeof document === "undefined") return;
39
- const root = document.documentElement;
40
- startHandshakePage({
41
- search: window.location.search,
42
- editorId: root.dataset.editorId ?? "",
43
- postMessage(message, targetOrigin, transfer) {
44
- const ports: Transferable[] = [];
45
- for (const port of transfer) ports.push(port);
46
- window.parent.postMessage(message, targetOrigin, ports);
47
- },
48
- createChannel() {
49
- return new MessageChannel();
50
- },
51
- setHandshake(value) {
52
- root.dataset.handshake = value;
53
- },
54
- });
55
- }
56
-
57
- wireWindow();