@dotgui/embed 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 ADDED
@@ -0,0 +1,82 @@
1
+ # @dotgui/embed
2
+
3
+ Render `.gui` files anywhere in the browser. A thin layer over [`@dotgui/kit`](../kit)'s
4
+ renderer — one CDN script, **zero dependencies** for the consumer.
5
+
6
+ ```html
7
+ <script src="https://cdn.dotgui.com/gui-embed.js"></script>
8
+ ```
9
+
10
+ One element does everything: **`<gui-embed>`**. It's the explicit "render a gui here"
11
+ declaration. The file comes from an inner `<script type="application/gui">` (inline)
12
+ or a `src` (external). No chrome by default; add booleans for the widget.
13
+
14
+ ## Render a file
15
+
16
+ ```html
17
+ <!-- inline content — parser-safe carrier -->
18
+ <gui-embed>
19
+ <script type="application/gui">
20
+ <gui> … </gui>
21
+ </script>
22
+ </gui-embed>
23
+
24
+ <!-- external file -->
25
+ <gui-embed src="hero.gui"></gui-embed>
26
+ ```
27
+
28
+ Inline content lives in a `<script type="application/gui">` because script content is
29
+ raw text the HTML parser never touches — so a full `.gui` survives verbatim, including
30
+ tags that collide with HTML void elements (`<col>`, `<img>`). The script is also the
31
+ source of truth: edit it, re-render; copy/download emits it unchanged.
32
+
33
+ `src` is fetched, unzipped, assets resolved to `blob:` URLs, and rendered — never shown
34
+ raw.
35
+
36
+ ## Standalone vs widget — same tag, just attributes
37
+
38
+ ```html
39
+ <!-- standalone preview: no chrome, sizes to the file's native size -->
40
+ <gui-embed> <script type="application/gui">…</script> </gui-embed>
41
+
42
+ <!-- widget: fixed canvas, controls, dot grid -->
43
+ <gui-embed src="hero.gui" style="width:360px;height:460px"
44
+ zoom download copy mode-switch grid></gui-embed>
45
+ ```
46
+
47
+ **Sizing (CSS):**
48
+ - No CSS → sizes to the file's native dimensions, like an inline SVG.
49
+ - Width only → height follows the file's aspect ratio.
50
+ - Width + height → fixed canvas; the file is placed center-center, scaled to fit.
51
+
52
+ **Controls (individual booleans — present = on):**
53
+
54
+ | attr | default | effect |
55
+ |---|---|---|
56
+ | `zoom` | on | scroll/pinch-zoom + drag-pan, and a "Fit" reset button |
57
+ | `grid` | on | dot-grid canvas background (the dotgui surface) |
58
+ | `download` | off | download the `.gui` file |
59
+ | `copy` | off | copy the `.guix` markup to the clipboard |
60
+ | `mode-switch` | off | mode dropdown — only when the file declares >1 mode |
61
+
62
+ Default render mode comes from the file (RFC-0037 `<modes>`). Theme the grid with
63
+ `--gui-embed-bg`, `--gui-embed-dot`, `--gui-embed-dot-gap`.
64
+
65
+ ## Programmatic use
66
+
67
+ The CDN build self-installs. As a module:
68
+
69
+ ```js
70
+ import { install } from '@dotgui/embed'
71
+ install() // registers <gui-embed>
72
+ ```
73
+
74
+ ## Build
75
+
76
+ ```sh
77
+ bun run build # → dist/gui-embed.js (IIFE, CDN) + dist/gui-embed.esm.js
78
+ bun run typecheck
79
+ ```
80
+
81
+ Everything (`@dotgui/kit` render + parser + package, panzoom, fflate) is bundled into
82
+ one self-contained file. Demo: `embed/demo/index.html`.