wuira 0.1.1 → 0.1.2

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 CHANGED
@@ -195,6 +195,8 @@ An empty fragment creates no native frame. Only empty fragments are currently su
195
195
 
196
196
  `console.log/info/warn/error` use a global WoW console polyfill. Output goes to the local chat window, never to other players. The addon uses no Node.js runtime or stdin/stdout. `console.error` does not throw. Arguments are formatted with Lua `tostring`; objects are not deeply inspected. The CLI uses its own Node.js terminal console.
197
197
 
198
+ Importing `wuira` installs the global console polyfill automatically. The shared TypeScript config loads its global declarations and uses Node16 module resolution for package exports; DOM typings are not required. `wuira.Mount` accepts a `Cell`, no value, or a function returning `Cell | void`, so addons without a visual tree can simply log and return.
199
+
198
200
  ## Build and distribution
199
201
 
200
202
  `wuira build` transpiles through `tsconfig.json`. It writes a standalone addon directory containing individual Lua modules, a loader, a startup file, and `<addonName>.toc`. The default output directory is `dist/`. The addon name lives in `wuira.config.mjs`; Interface version and other metadata live in `addon.toc.in`. The default Interface version, 16001, targets the Forever playground.
@@ -2,10 +2,12 @@
2
2
  "$schema": "https://raw.githubusercontent.com/TypeScriptToLua/TypeScriptToLua/master/tsconfig-schema.json",
3
3
  "compilerOptions": {
4
4
  "target": "ESNext",
5
+ "module": "Node16",
6
+ "moduleResolution": "Node16",
5
7
  "lib": [
6
8
  "ESNext"
7
9
  ],
8
- "types": [],
10
+ "types": ["wuira/console-polyfill"],
9
11
  "jsx": "react",
10
12
  "jsxFactory": "UI.createElement",
11
13
  "jsxFragmentFactory": "UI.Fragment",
package/lib/index.d.ts CHANGED
@@ -1,4 +1,6 @@
1
1
  /// <reference path="./platform/forever.d.ts" />
2
+ import "./console-polyfill";
2
3
  export { wuira } from "./wuira";
3
4
  export { UI } from "./ui/primitives/jsx";
4
5
  export type { Element, Component } from "./ui/primitives/jsx";
6
+ export type { Cell } from "./ui/Cell";
package/lib/index.lua CHANGED
@@ -1,5 +1,6 @@
1
1
  --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
2
  local ____exports = {}
3
+ require("console-polyfill")
3
4
  do
4
5
  local ____wuira = require("wuira")
5
6
  ____exports.wuira = ____wuira.wuira
package/lib/ui/Cell.d.ts CHANGED
@@ -3,6 +3,9 @@ import type { Decorations } from "./decorations/Decorations";
3
3
  import type { Position } from "../types/Position";
4
4
  import type { Spacing } from "../types/Spacing";
5
5
  export type Size = number | "inherit";
6
+ /** Common visual descriptor accepted by the mounting API. */
7
+ export interface Cell extends Element {
8
+ }
6
9
  export type CellProps = {
7
10
  width: Size;
8
11
  height: Size;
@@ -18,4 +21,4 @@ export interface ICell extends Element {
18
21
  }
19
22
  export declare function Cell(props: Partial<CellProps> & {
20
23
  child?: Element;
21
- }, child?: Element): Element;
24
+ }, child?: Element): Cell;
package/lib/ui/Cell.lua CHANGED
@@ -2,6 +2,7 @@
2
2
  local ____exports = {}
3
3
  local ____jsx = require("ui.primitives.jsx")
4
4
  local UI = ____jsx.UI
5
+ --- Common visual descriptor accepted by the mounting API.
5
6
  function ____exports.Cell(self, props, child)
6
7
  return UI:createElement("cell", props, props.child or child or ({}))
7
8
  end
package/lib/wuira.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- import type { Element } from "./ui/primitives/jsx";
1
+ import type { Cell } from "./ui/Cell";
2
2
  import type { Anchor } from "./types/Position";
3
3
  /** Public entry point for mounting JSX UI trees. */
4
4
  export declare class wuira {
5
5
  private constructor();
6
- static Mount(frame: Element | (() => Element), anchor?: Anchor, parent?: wuiraNativeFrame): wuiraNativeFrame | undefined;
6
+ static Mount(frame: Cell | void | (() => Cell | void), anchor?: Anchor, parent?: wuiraNativeFrame): wuiraNativeFrame | undefined;
7
7
  static Unmount(frame: wuiraNativeFrame): void;
8
8
  }
package/lib/wuira.lua CHANGED
@@ -18,8 +18,14 @@ wuira.name = "wuira"
18
18
  function wuira.prototype.____constructor(self)
19
19
  end
20
20
  function wuira.Mount(self, frame, anchor, parent)
21
- local view = type(frame) == "function" and frame(nil) or frame
22
- if view.kind == "empty" then
21
+ local ____temp_0
22
+ if type(frame) == "function" then
23
+ ____temp_0 = frame(nil)
24
+ else
25
+ ____temp_0 = frame
26
+ end
27
+ local view = ____temp_0
28
+ if view == nil or view.kind == "empty" then
23
29
  return nil
24
30
  end
25
31
  return mount(nil, view, parent, anchor)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wuira",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "author": {
5
5
  "name": "Kerim Cetinbas",
6
6
  "email": "a.cetinbas@icloud.com"
@@ -1,9 +1,7 @@
1
- import "wuira/console-polyfill";
2
- import { UI, wuira } from "wuira";
1
+ import { wuira } from "wuira";
3
2
 
4
3
  function App() {
5
4
  console.log("{{addonName}} loaded");
6
- return <></>;
7
5
  }
8
6
 
9
7
  wuira.Mount(App);