@lionlang/ui 0.0.0-stage → 0.2.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/dist/types.mjs ADDED
@@ -0,0 +1,79 @@
1
+ //#region src/types.ts
2
+ /**
3
+ * Pure JSON-serializable UI node types returned by `ui/*` Lion functions.
4
+ * Every UI tree is ordinary Lion data — evaluable in memory with zero DOM
5
+ * dependency, diffable as JSON, and safe to stream across Web Workers or HTTP.
6
+ */
7
+ const UI_KINDS = [
8
+ "stack",
9
+ "row",
10
+ "grid",
11
+ "split",
12
+ "section",
13
+ "card",
14
+ "hero",
15
+ "tabs",
16
+ "accordion",
17
+ "divider",
18
+ "heading",
19
+ "text",
20
+ "badge",
21
+ "metric",
22
+ "kv",
23
+ "list",
24
+ "link",
25
+ "alert",
26
+ "table",
27
+ "progress",
28
+ "code",
29
+ "chart",
30
+ "graph",
31
+ "timeline",
32
+ "diff",
33
+ "source",
34
+ "input",
35
+ "textarea",
36
+ "number",
37
+ "slider",
38
+ "select",
39
+ "toggle",
40
+ "checkbox",
41
+ "button",
42
+ "why",
43
+ "proof"
44
+ ];
45
+ const UI_KIND_SET = new Set(UI_KINDS);
46
+ /** Returns true when a value is a well-formed Lion UI node. */
47
+ const isUiNode = (value) => {
48
+ if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
49
+ const record = value;
50
+ return typeof record.$ui === "string" && UI_KIND_SET.has(record.$ui) && typeof record.props === "object" && record.props !== null && !Array.isArray(record.props) && Array.isArray(record.children);
51
+ };
52
+ /** Returns true when an argument is a plain props record (not a UI node). */
53
+ const isPropsRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value) && !("$ui" in value);
54
+ /**
55
+ * Flattens nested child arrays (such as results of `array/map` or `find`) and
56
+ * skips `null`, `undefined`, and `false` (so `cond` branches that return nothing
57
+ * compose cleanly).
58
+ */
59
+ const normalizeChildren = (items) => {
60
+ const out = [];
61
+ const visit = (item) => {
62
+ if (item === null || item === void 0 || item === false) return;
63
+ if (Array.isArray(item)) {
64
+ for (const nested of item) visit(nested);
65
+ return;
66
+ }
67
+ if (isUiNode(item) || typeof item === "string" || typeof item === "number" || typeof item === "boolean") {
68
+ out.push(item);
69
+ return;
70
+ }
71
+ out.push(String(item));
72
+ };
73
+ for (const item of items) visit(item);
74
+ return out;
75
+ };
76
+ //#endregion
77
+ export { UI_KINDS, isPropsRecord, isUiNode, normalizeChildren };
78
+
79
+ //# sourceMappingURL=types.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.mjs","names":[],"sources":["../src/types.ts"],"sourcesContent":["/**\n * Pure JSON-serializable UI node types returned by `ui/*` Lion functions.\n * Every UI tree is ordinary Lion data — evaluable in memory with zero DOM\n * dependency, diffable as JSON, and safe to stream across Web Workers or HTTP.\n */\n\nexport const UI_KINDS = [\n \"stack\",\n \"row\",\n \"grid\",\n \"split\",\n \"section\",\n \"card\",\n \"hero\",\n \"tabs\",\n \"accordion\",\n \"divider\",\n \"heading\",\n \"text\",\n \"badge\",\n \"metric\",\n \"kv\",\n \"list\",\n \"link\",\n \"alert\",\n \"table\",\n \"progress\",\n \"code\",\n \"chart\",\n \"graph\",\n \"timeline\",\n \"diff\",\n \"source\",\n \"input\",\n \"textarea\",\n \"number\",\n \"slider\",\n \"select\",\n \"toggle\",\n \"checkbox\",\n \"button\",\n \"why\",\n \"proof\",\n] as const;\n\nexport type UiKind = (typeof UI_KINDS)[number];\n\nexport type UiChild = UiNode | string | number | boolean;\n\nexport type UiProps = Readonly<Record<string, unknown>>;\n\nexport interface UiNode {\n readonly $ui: UiKind;\n readonly children: readonly UiChild[];\n readonly props: UiProps;\n}\n\nconst UI_KIND_SET: ReadonlySet<string> = new Set(UI_KINDS);\n\n/** Returns true when a value is a well-formed Lion UI node. */\nexport const isUiNode = (value: unknown): value is UiNode => {\n if (typeof value !== \"object\" || value === null || Array.isArray(value)) {\n return false;\n }\n const record = value as Record<string, unknown>;\n return (\n typeof record.$ui === \"string\" &&\n UI_KIND_SET.has(record.$ui) &&\n typeof record.props === \"object\" &&\n record.props !== null &&\n !Array.isArray(record.props) &&\n Array.isArray(record.children)\n );\n};\n\n/** Returns true when an argument is a plain props record (not a UI node). */\nexport const isPropsRecord = (value: unknown): value is UiProps =>\n typeof value === \"object\" &&\n value !== null &&\n !Array.isArray(value) &&\n !(\"$ui\" in value);\n\n/**\n * Flattens nested child arrays (such as results of `array/map` or `find`) and\n * skips `null`, `undefined`, and `false` (so `cond` branches that return nothing\n * compose cleanly).\n */\nexport const normalizeChildren = (\n items: readonly unknown[]\n): readonly UiChild[] => {\n const out: UiChild[] = [];\n const visit = (item: unknown) => {\n if (item === null || item === undefined || item === false) {\n return;\n }\n if (Array.isArray(item)) {\n for (const nested of item) {\n visit(nested);\n }\n return;\n }\n if (\n isUiNode(item) ||\n typeof item === \"string\" ||\n typeof item === \"number\" ||\n typeof item === \"boolean\"\n ) {\n out.push(item);\n return;\n }\n out.push(String(item));\n };\n for (const item of items) {\n visit(item);\n }\n return out;\n};\n"],"mappings":";;;;;;AAMA,MAAa,WAAW;CACtB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;AAcD,MAAM,cAAmC,IAAI,IAAI,SAAS;;AAG1D,MAAa,YAAY,UAAoC;AAC3D,KAAI,OAAO,UAAU,YAAY,UAAU,QAAQ,MAAM,QAAQ,MAAM,CACrE,QAAO;CAET,MAAM,SAAS;AACf,QACE,OAAO,OAAO,QAAQ,YACtB,YAAY,IAAI,OAAO,IAAI,IAC3B,OAAO,OAAO,UAAU,YACxB,OAAO,UAAU,QACjB,CAAC,MAAM,QAAQ,OAAO,MAAM,IAC5B,MAAM,QAAQ,OAAO,SAAS;;;AAKlC,MAAa,iBAAiB,UAC5B,OAAO,UAAU,YACjB,UAAU,QACV,CAAC,MAAM,QAAQ,MAAM,IACrB,EAAE,SAAS;;;;;;AAOb,MAAa,qBACX,UACuB;CACvB,MAAM,MAAiB,EAAE;CACzB,MAAM,SAAS,SAAkB;AAC/B,MAAI,SAAS,QAAQ,SAAS,KAAA,KAAa,SAAS,MAClD;AAEF,MAAI,MAAM,QAAQ,KAAK,EAAE;AACvB,QAAK,MAAM,UAAU,KACnB,OAAM,OAAO;AAEf;;AAEF,MACE,SAAS,KAAK,IACd,OAAO,SAAS,YAChB,OAAO,SAAS,YAChB,OAAO,SAAS,WAChB;AACA,OAAI,KAAK,KAAK;AACd;;AAEF,MAAI,KAAK,OAAO,KAAK,CAAC;;AAExB,MAAK,MAAM,QAAQ,MACjB,OAAM,KAAK;AAEb,QAAO"}
package/package.json CHANGED
@@ -1,6 +1,47 @@
1
1
  {
2
2
  "name": "@lionlang/ui",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.2.0",
4
+ "type": "module",
5
+ "description": "Declarative, interactive, and streaming UI bindings and DOM renderer for Lion.",
6
+ "license": "MIT",
7
+ "author": "Andrue Anderson <andrueanderson.cs@gmail.com>",
8
+ "homepage": "https://lionlang.dev",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/andrueandersoncs/lion.git",
12
+ "directory": "packages/ui"
13
+ },
14
+ "publishConfig": {
15
+ "access": "public"
16
+ },
17
+ "exports": {
18
+ ".": "./dist/index.mjs",
19
+ "./artifact": "./dist/artifact.mjs",
20
+ "./browser-runtime": "./dist/browser-runtime.mjs",
21
+ "./dom": "./dist/dom.mjs",
22
+ "./types": "./dist/types.mjs",
23
+ "./package.json": "./package.json"
24
+ },
25
+ "files": [
26
+ "dist",
27
+ "src/styles.css"
28
+ ],
29
+ "scripts": {
30
+ "test": "vitest run",
31
+ "typecheck": "tsc --noEmit",
32
+ "build": "tsdown"
33
+ },
34
+ "dependencies": {
35
+ "@lionlang/core": "0.24.0",
36
+ "effect": "4.1.2"
37
+ },
38
+ "devDependencies": {
39
+ "@effect/vitest": "4.1.2",
40
+ "@types/bun": "latest",
41
+ "tsdown": "^0.21.10",
42
+ "vitest": "^5.0.1"
43
+ },
44
+ "peerDependencies": {
45
+ "typescript": "^6.0.2"
46
+ }
47
+ }