tencil 0.3.2 → 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.
package/dist/react.d.mts CHANGED
@@ -1,13 +1,20 @@
1
+ import { t as TencilCloudOptions } from "./cloud-Ez2olqK0.mjs";
1
2
  //#region src/integrations/react.d.ts
2
3
  /**
3
4
  * Loads the Tencil overlay in development from the daemon on the machine
4
- * serving the page (`npx tencil start`). Renders nothing in production;
5
- * without a running daemon the script simply doesn't load.
5
+ * serving the page (`npx tencil start`); without a running daemon the script
6
+ * simply doesn't load.
7
+ *
8
+ * Outside development it renders nothing, unless TENCIL_CLOUD is set for a
9
+ * preview deployment: then it loads the overlay from Tencil Cloud. That needs
10
+ * the env at render time, so keep `<Tencil />` in a server component (the root
11
+ * layout or `_document`).
6
12
  *
7
13
  * <body>{children}<Tencil /></body>
8
14
  */
9
- export declare function Tencil({ port }: {
15
+ export declare function Tencil({ port, cloud }: {
10
16
  port?: number;
17
+ cloud?: TencilCloudOptions;
11
18
  }): import("react").DetailedReactHTMLElement<{
12
19
  id: string;
13
20
  dangerouslySetInnerHTML: {
package/dist/react.mjs CHANGED
@@ -1,18 +1,33 @@
1
+ import { n as cloudLoader, r as resolveCloudBuild } from "./cloud-CiwIrP1h.mjs";
1
2
  import { n as overlayLoader, t as DEFAULT_DAEMON_PORT } from "./loader-BevujQ44.mjs";
2
3
  import { createElement } from "react";
3
4
  //#region src/integrations/react.ts
5
+ let warned = false;
4
6
  /**
5
7
  * Loads the Tencil overlay in development from the daemon on the machine
6
- * serving the page (`npx tencil start`). Renders nothing in production;
7
- * without a running daemon the script simply doesn't load.
8
+ * serving the page (`npx tencil start`); without a running daemon the script
9
+ * simply doesn't load.
10
+ *
11
+ * Outside development it renders nothing, unless TENCIL_CLOUD is set for a
12
+ * preview deployment: then it loads the overlay from Tencil Cloud. That needs
13
+ * the env at render time, so keep `<Tencil />` in a server component (the root
14
+ * layout or `_document`).
8
15
  *
9
16
  * <body>{children}<Tencil /></body>
10
17
  */
11
- function Tencil({ port = DEFAULT_DAEMON_PORT }) {
12
- if (process.env.NODE_ENV !== "development") return null;
18
+ function Tencil({ port = DEFAULT_DAEMON_PORT, cloud }) {
19
+ if (process.env.NODE_ENV === "development") return script(overlayLoader(port));
20
+ const resolved = resolveCloudBuild(typeof process === "undefined" ? {} : process.env, cloud);
21
+ if (resolved.kind === "refused" && !warned) {
22
+ warned = true;
23
+ console.warn(`[tencil] Not loading Tencil Cloud. ${resolved.reason}`);
24
+ }
25
+ return resolved.kind === "on" ? script(cloudLoader(resolved)) : null;
26
+ }
27
+ function script(code) {
13
28
  return createElement("script", {
14
29
  id: "tencil-loader",
15
- dangerouslySetInnerHTML: { __html: overlayLoader(port) }
30
+ dangerouslySetInnerHTML: { __html: code }
16
31
  });
17
32
  }
18
33
  //#endregion