@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.
- package/dist/hooks/transform-index-html.d.ts +22 -18
- package/dist/index.js +381 -264
- package/dist/lib/assets/index.d.ts +40 -0
- package/package.json +4 -4
|
@@ -1,30 +1,34 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Vite transformIndexHtml() hook
|
|
3
3
|
*
|
|
4
|
-
* Injects
|
|
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
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
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
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
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
|
|
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
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
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
|
-
*
|
|
32
|
+
* - **PostHog cross-origin iframe recorder (build only).**
|
|
29
33
|
*/
|
|
30
|
-
export declare function transformIndexHtmlHook(context: PluginContext): HtmlTagDescriptor[]
|
|
34
|
+
export declare function transformIndexHtmlHook(context: PluginContext): Promise<HtmlTagDescriptor[]>;
|