diff --git a/markdown/bitburner.md b/markdown/bitburner.md index 5e29657ff..c655ca2a3 100644 --- a/markdown/bitburner.md +++ b/markdown/bitburner.md @@ -84,7 +84,7 @@ | [Player](./bitburner.player.md) | | | [ProcessInfo](./bitburner.processinfo.md) | A single process on a server. | | [Product](./bitburner.product.md) | Product in a warehouse | -| [ReactElement](./bitburner.reactelement.md) | A stand-in for the real React.ReactElement, which API-extractor doesn't know about. Don't try to create one of these by hand; use React.createElement(). | +| [ReactElement](./bitburner.reactelement.md) | A stand-in for the real React.ReactElement. Use React.createElement to make these. See [creating an element without jsx](https://react.dev/reference/react/createElement#creating-an-element-without-jsx) from the official React documentation. | | [RecentScript](./bitburner.recentscript.md) | | | [ReputationFormulas](./bitburner.reputationformulas.md) | Reputation formulas | | [ResetInfo](./bitburner.resetinfo.md) | Various info about resets | @@ -125,6 +125,7 @@ | [FilenameOrPID](./bitburner.filenameorpid.md) | | | [NSEnums](./bitburner.nsenums.md) | | | [PortData](./bitburner.portdata.md) | | +| [ReactNode](./bitburner.reactnode.md) |
A stand-in for the real React.ReactNode. A [ReactElement](./bitburner.reactelement.md) is rendered dynamically with React. number and string are displayed directly. boolean, null, and undefined are ignored and not rendered. An array of ReactNodes will display all members of that array sequentially.
Use React.createElement to make the ReactElement type, see [creating an element without jsx](https://react.dev/reference/react/createElement#creating-an-element-without-jsx) from the official React documentation.
| | [ScriptArg](./bitburner.scriptarg.md) | | | [SleeveBladeburnerTask](./bitburner.sleevebladeburnertask.md) | | | [SleeveClassTask](./bitburner.sleeveclasstask.md) | | diff --git a/markdown/bitburner.ns.md b/markdown/bitburner.ns.md index 1c50a938f..aea80c386 100644 --- a/markdown/bitburner.ns.md +++ b/markdown/bitburner.ns.md @@ -137,6 +137,7 @@ export async function main(ns) { | [peek(portNumber)](./bitburner.ns.peek.md) | Get a copy of the data from a port without popping it. | | [print(args)](./bitburner.ns.print.md) | Prints one or more values or variables to the script’s logs. | | [printf(format, args)](./bitburner.ns.printf.md) | Prints a formatted string to the script’s logs. | +| [printRaw(node)](./bitburner.ns.printraw.md) | Prints a ReactNode to the script logs. | | [prompt(txt, options)](./bitburner.ns.prompt.md) | Prompt the player with an input modal. | | [ps(host)](./bitburner.ns.ps.md) | List running scripts on a server. | | [purchaseServer(hostname, ram)](./bitburner.ns.purchaseserver.md) | Purchase a server. | @@ -163,6 +164,7 @@ export async function main(ns) { | [toast(msg, variant, duration)](./bitburner.ns.toast.md) | Queue a toast (bottom-right notification). | | [tprint(args)](./bitburner.ns.tprint.md) | Prints one or more values or variables to the Terminal. | | [tprintf(format, values)](./bitburner.ns.tprintf.md) | Prints a raw value or a variable to the Terminal. | +| [tprintRaw(node)](./bitburner.ns.tprintraw.md) | Prints a ReactNode to the terminal. | | [tryWritePort(portNumber, data)](./bitburner.ns.trywriteport.md) | Attempt to write to a port. | | [upgradePurchasedServer(hostname, ram)](./bitburner.ns.upgradepurchasedserver.md) | Upgrade a purchased server's RAM. | | [vsprintf(format, args)](./bitburner.ns.vsprintf.md) | Format a string with an array of arguments. | diff --git a/markdown/bitburner.ns.printraw.md b/markdown/bitburner.ns.printraw.md new file mode 100644 index 000000000..8e81a7d9c --- /dev/null +++ b/markdown/bitburner.ns.printraw.md @@ -0,0 +1,30 @@ + + +[Home](./index.md) > [bitburner](./bitburner.md) > [NS](./bitburner.ns.md) > [printRaw](./bitburner.ns.printraw.md) + +## NS.printRaw() method + +Prints a ReactNode to the script logs. + +**Signature:** + +```typescript +printRaw(node: ReactNode): void; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| node | [ReactNode](./bitburner.reactnode.md) | The react node to be printed. | + +**Returns:** + +void + +## Remarks + +RAM cost: 0 GB + +See [ReactNode](./bitburner.reactnode.md) type for the acceptable values. + diff --git a/markdown/bitburner.ns.settitle.md b/markdown/bitburner.ns.settitle.md index cc777850e..e015a95c7 100644 --- a/markdown/bitburner.ns.settitle.md +++ b/markdown/bitburner.ns.settitle.md @@ -9,14 +9,14 @@ Set the title of the tail window of a script. **Signature:** ```typescript -setTitle(title: string | ReactElement, pid?: number): void; +setTitle(title: string | ReactNode, pid?: number): void; ``` ## Parameters | Parameter | Type | Description | | --- | --- | --- | -| title | string \| [ReactElement](./bitburner.reactelement.md) | | +| title | string \| [ReactNode](./bitburner.reactnode.md) | | | pid | number | _(Optional)_ Optional. PID of the script having its tail closed. If omitted, the current script is used. | **Returns:** @@ -35,5 +35,5 @@ If the pid is unspecified, it will modify the current script’s logs. Otherwise, the pid argument can be used to change the logs from another script. -It is possible to pass a React Element instead of a string. Get these by calling React.createElement() with appropriate parameters. You should either know or be willing to learn about the React UI library if you go down this route, and there will likely be rough edges. +It is possible to pass any React Node instead of a string. See [ReactElement](./bitburner.reactelement.md) and [ReactNode](./bitburner.reactnode.md) types for additional info. diff --git a/markdown/bitburner.ns.tprintraw.md b/markdown/bitburner.ns.tprintraw.md new file mode 100644 index 000000000..e39682e53 --- /dev/null +++ b/markdown/bitburner.ns.tprintraw.md @@ -0,0 +1,30 @@ + + +[Home](./index.md) > [bitburner](./bitburner.md) > [NS](./bitburner.ns.md) > [tprintRaw](./bitburner.ns.tprintraw.md) + +## NS.tprintRaw() method + +Prints a ReactNode to the terminal. + +**Signature:** + +```typescript +tprintRaw(node: ReactNode): void; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| node | [ReactNode](./bitburner.reactnode.md) | The react node to be printed. | + +**Returns:** + +void + +## Remarks + +RAM cost: 0 GB + +See [ReactNode](./bitburner.reactnode.md) type for the acceptable values. + diff --git a/markdown/bitburner.reactelement.md b/markdown/bitburner.reactelement.md index 44141fc32..abb71adee 100644 --- a/markdown/bitburner.reactelement.md +++ b/markdown/bitburner.reactelement.md @@ -4,7 +4,7 @@ ## ReactElement interface -A stand-in for the real React.ReactElement, which API-extractor doesn't know about. Don't try to create one of these by hand; use React.createElement(). +A stand-in for the real React.ReactElement. Use React.createElement to make these. See [creating an element without jsx](https://react.dev/reference/react/createElement#creating-an-element-without-jsx) from the official React documentation. **Signature:** diff --git a/markdown/bitburner.reactnode.md b/markdown/bitburner.reactnode.md new file mode 100644 index 000000000..c75458052 --- /dev/null +++ b/markdown/bitburner.reactnode.md @@ -0,0 +1,17 @@ + + +[Home](./index.md) > [bitburner](./bitburner.md) > [ReactNode](./bitburner.reactnode.md) + +## ReactNode type + +A stand-in for the real React.ReactNode. A [ReactElement](./bitburner.reactelement.md) is rendered dynamically with React. number and string are displayed directly. boolean, null, and undefined are ignored and not rendered. An array of ReactNodes will display all members of that array sequentially. + +Use React.createElement to make the ReactElement type, see [creating an element without jsx](https://react.dev/reference/react/createElement#creating-an-element-without-jsx) from the official React documentation. + +**Signature:** + +```typescript +type ReactNode = ReactElement | string | number | null | undefined | boolean | ReactNode[]; +``` +**References:** [ReactElement](./bitburner.reactelement.md), [ReactNode](./bitburner.reactnode.md) + diff --git a/src/NetscriptFunctions.ts b/src/NetscriptFunctions.ts index ea84049c0..534b36664 100644 --- a/src/NetscriptFunctions.ts +++ b/src/NetscriptFunctions.ts @@ -1767,6 +1767,12 @@ export const ns: InternalAPI