@playcademy/vite-plugin 1.0.1-beta.4 → 1.1.0-beta.1

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.
@@ -1,30 +1,34 @@
1
1
  /**
2
2
  * Vite transformIndexHtml() hook
3
3
  *
4
- * Injects a PostHog session replay snippet into game HTML at build time.
5
- * This enables cross-origin iframe recording: the game iframe's PostHog
6
- * instance posts its recording data (DOM snapshots, console logs, network
7
- * requests) to the parent platform's PostHog instance, producing a single
8
- * unified session replay.
4
+ * Injects two independent snippets into game HTML `<head>`:
9
5
  *
10
- * The snippet loads before any game JS, so it captures the full boot
11
- * sequence including asset downloads and JS parse/execute timing even
12
- * if the game bundle never finishes loading.
6
+ * 1. **Dev only** the asset manifest (`self.__PLAYCADEMY_ASSET_MANIFEST`),
7
+ * read from the local bucket, so the SDK's `asset()` resolver works in
8
+ * `vite dev` as it does on the platform. In production the edge worker
9
+ * injects this itself, so we don't bake it into the build.
13
10
  *
14
- * Uses a named instance to avoid conflicting with any PostHog instance
15
- * a game developer may have initialized on the default `window.posthog`.
16
- *
17
- * Only injected in production builds.
11
+ * 2. **Build only** a PostHog session-replay snippet enabling cross-origin
12
+ * iframe recording: the game iframe's PostHog instance posts its recording
13
+ * data to the parent platform's instance for a single unified replay. It
14
+ * loads before any game JS (capturing the full boot sequence) and uses a
15
+ * named instance to avoid conflicting with the game's own `window.posthog`.
18
16
  */
19
17
  import type { HtmlTagDescriptor } from 'vite';
20
18
  import type { PluginContext } from '../types';
21
19
  /**
22
- * Transform index.html to inject PostHog cross-origin iframe recording.
20
+ * Transform index.html. Returns HTML tags Vite injects into `<head>`, before
21
+ * any game scripts in `<body>`.
22
+ *
23
+ * Two independent, build-only-vs-dev-only injections:
23
24
  *
24
- * Returns an array of HTML tag descriptors that Vite injects into the
25
- * built HTML. The script is placed in `<head>` so it loads before any
26
- * game scripts in `<body>`.
25
+ * - **Asset manifest (dev only).** Mirrors the SDK's `asset()` resolver against
26
+ * the local bucket so it works in `vite dev` the same as on the platform. We
27
+ * do NOT inject at build time: in production the edge worker injects the
28
+ * manifest into every HTML response itself, sourced from the deployed bucket.
29
+ * Baking a tag at build time would embed the developer's *local* bucket
30
+ * manifest into the deployed HTML — stale and competing with the worker's.
27
31
  *
28
- * Skipped when running the dev server (not a production build).
32
+ * - **PostHog cross-origin iframe recorder (build only).**
29
33
  */
30
- export declare function transformIndexHtmlHook(context: PluginContext): HtmlTagDescriptor[] | undefined;
34
+ export declare function transformIndexHtmlHook(context: PluginContext): Promise<HtmlTagDescriptor[]>;