@molecule/app-e2e-preview 1.0.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/LICENSE ADDED
@@ -0,0 +1,115 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work.
38
+
39
+ "Derivative Works" shall mean any work, whether in Source or Object
40
+ form, that is based on (or derived from) the Work and for which the
41
+ editorial revisions, annotations, elaborations, or other modifications
42
+ represent, as a whole, an original work of authorship.
43
+
44
+ "Contribution" shall mean any work of authorship, including the
45
+ original version of the Work and any modifications or additions
46
+ to that Work, that is intentionally submitted to the Licensor for
47
+ inclusion in the Work by the copyright owner or by an individual or
48
+ Legal Entity authorized to submit on behalf of the copyright owner.
49
+
50
+ "Contributor" shall mean Licensor and any individual or Legal Entity
51
+ on behalf of whom a Contribution has been received by the Licensor and
52
+ subsequently incorporated within the Work.
53
+
54
+ 2. Grant of Copyright License. Subject to the terms and conditions of
55
+ this License, each Contributor hereby grants to You a perpetual,
56
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
57
+ copyright license to reproduce, prepare Derivative Works of,
58
+ publicly display, publicly perform, sublicense, and distribute the
59
+ Work and such Derivative Works in Source or Object form.
60
+
61
+ 3. Grant of Patent License. Subject to the terms and conditions of
62
+ this License, each Contributor hereby grants to You a perpetual,
63
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
64
+ patent license to make, have made, use, offer to sell, sell, import,
65
+ and otherwise transfer the Work.
66
+
67
+ 4. Redistribution. You may reproduce and distribute copies of the
68
+ Work or Derivative Works thereof in any medium, with or without
69
+ modifications, and in Source or Object form, provided that You
70
+ meet the following conditions:
71
+
72
+ (a) You must give any other recipients of the Work or
73
+ Derivative Works a copy of this License; and
74
+
75
+ (b) You must cause any modified files to carry prominent notices
76
+ stating that You changed the files; and
77
+
78
+ (c) You must retain, in the Source form of any Derivative Works
79
+ that You distribute, all copyright, patent, trademark, and
80
+ attribution notices from the Source form of the Work,
81
+ excluding those notices that do not pertain to any part of
82
+ the Derivative Works; and
83
+
84
+ (d) If the Work includes a "NOTICE" text file as part of its
85
+ distribution, then any Derivative Works that You distribute must
86
+ include a readable copy of the attribution notices contained
87
+ within such NOTICE file.
88
+
89
+ 5. Submission of Contributions.
90
+
91
+ 6. Trademarks. This License does not grant permission to use the trade
92
+ names, trademarks, service marks, or product names of the Licensor.
93
+
94
+ 7. Disclaimer of Warranty. Unless required by applicable law or
95
+ agreed to in writing, Licensor provides the Work on an "AS IS" BASIS,
96
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND.
97
+
98
+ 8. Limitation of Liability. In no event and under no legal theory shall
99
+ any Contributor be liable to You for damages.
100
+
101
+ 9. Accepting Warranty or Additional Liability.
102
+
103
+ Copyright 2026 Molecule Dev, Inc.
104
+
105
+ Licensed under the Apache License, Version 2.0 (the "License");
106
+ you may not use this file except in compliance with the License.
107
+ You may obtain a copy of the License at
108
+
109
+ http://www.apache.org/licenses/LICENSE-2.0
110
+
111
+ Unless required by applicable law or agreed to in writing, software
112
+ distributed under the License is distributed on an "AS IS" BASIS,
113
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
114
+ See the License for the specific language governing permissions and
115
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,26 @@
1
+ # @molecule/app-e2e-preview
2
+
3
+ Drives the live IDE preview page as a Playwright-shaped page over a same-origin WebSocket through the dev server — no browser binary in the sandbox
4
+
5
+ ## Type
6
+
7
+ `provider`
8
+
9
+ ## Implements
10
+
11
+ `@molecule/app-e2e`
12
+
13
+ ## Injection Notes
14
+
15
+ ### Requirements
16
+
17
+ - None
18
+
19
+ ### Post-Injection Steps
20
+
21
+ - Run `npm install` to install dependencies
22
+ - Run `npm run build` to compile
23
+
24
+ ### Known Limitations
25
+
26
+ - None yet
@@ -0,0 +1,14 @@
1
+ /**
2
+ * The page client: a small script the Vite plugin injects into every
3
+ * dev/preview document. It opens a same-origin WebSocket back to the hub,
4
+ * runs `evaluate` requests, navigates on request, relays viewport requests to
5
+ * the IDE that frames it, and forwards console output, errors and dialogs.
6
+ *
7
+ * Plain ES5-flavoured JavaScript in a string: it must run in whatever the
8
+ * previewed app runs in, and it must never depend on the app's bundler.
9
+ *
10
+ * @module
11
+ */
12
+ /** The client script's source, ready to serve as `text/javascript`. */
13
+ export declare const E2E_PREVIEW_CLIENT_SCRIPT: string;
14
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,uEAAuE;AACvE,eAAO,MAAM,yBAAyB,QAmIrC,CAAA"}
package/dist/client.js ADDED
@@ -0,0 +1,146 @@
1
+ /**
2
+ * The page client: a small script the Vite plugin injects into every
3
+ * dev/preview document. It opens a same-origin WebSocket back to the hub,
4
+ * runs `evaluate` requests, navigates on request, relays viewport requests to
5
+ * the IDE that frames it, and forwards console output, errors and dialogs.
6
+ *
7
+ * Plain ES5-flavoured JavaScript in a string: it must run in whatever the
8
+ * previewed app runs in, and it must never depend on the app's bundler.
9
+ *
10
+ * @module
11
+ */
12
+ import { E2E_WS_PATH } from './types.js';
13
+ /** The client script's source, ready to serve as `text/javascript`. */
14
+ export const E2E_PREVIEW_CLIENT_SCRIPT = `;(function () {
15
+ if (window.__molE2EClient) return
16
+ var PATH = ${JSON.stringify(E2E_WS_PATH)}
17
+ var proto = location.protocol === 'https:' ? 'wss://' : 'ws://'
18
+ var pageId = (window.crypto && crypto.randomUUID) ? crypto.randomUUID() : String(Date.now()) + '-' + String(Math.random()).slice(2)
19
+ var ws = null
20
+ var backoff = 500
21
+ var leaving = false
22
+ var safe = function (value) {
23
+ if (value === undefined) return null
24
+ try {
25
+ return JSON.parse(JSON.stringify(value, function (k, v) { return typeof v === 'function' ? undefined : v }))
26
+ } catch (e) {
27
+ return String(value)
28
+ }
29
+ }
30
+ var send = function (obj) {
31
+ try { if (ws && ws.readyState === 1) ws.send(JSON.stringify(obj)) } catch (e) {}
32
+ }
33
+ var describe = function (args) {
34
+ var out = []
35
+ for (var i = 0; i < args.length; i++) {
36
+ var a = args[i]
37
+ if (typeof a === 'string') out.push(a)
38
+ else if (a instanceof Error) out.push(a.stack || a.message || String(a))
39
+ else { try { out.push(JSON.stringify(a)) } catch (e) { out.push(String(a)) } }
40
+ }
41
+ return out.join(' ')
42
+ }
43
+ var sameOrigin = function (url) {
44
+ var u = new URL(url, location.href)
45
+ if ((u.hostname === 'localhost' || u.hostname === '127.0.0.1' || u.hostname === '0.0.0.0') && u.host !== location.host) {
46
+ return location.origin + u.pathname + u.search + u.hash
47
+ }
48
+ return u.href
49
+ }
50
+ var handle = function (msg) {
51
+ var id = msg.id
52
+ var reply = function (obj) { obj.id = id; obj.href = location.href; send(obj) }
53
+ try {
54
+ if (msg.op === 'evaluate') {
55
+ var fn = new Function('return (' + msg.source + ')')()
56
+ Promise.resolve(fn(msg.arg)).then(function (value) {
57
+ reply({ ok: true, value: safe(value) })
58
+ }, function (e) {
59
+ reply({ ok: false, error: (e && e.stack) || String(e) })
60
+ })
61
+ } else if (msg.op === 'goto') {
62
+ var target = sameOrigin(msg.url)
63
+ reply({ ok: true, navigating: true, target: target })
64
+ leaving = true
65
+ if (target === location.href) location.reload()
66
+ else location.assign(target)
67
+ } else if (msg.op === 'reload') {
68
+ reply({ ok: true, navigating: true })
69
+ leaving = true
70
+ location.reload()
71
+ } else if (msg.op === 'history') {
72
+ reply({ ok: true, navigating: true })
73
+ history.go(msg.delta)
74
+ } else if (msg.op === 'viewport') {
75
+ try { window.parent.postMessage({ type: 'molecule:viewport', id: id, width: msg.width, height: msg.height }, '*') } catch (e) {}
76
+ var started = Date.now()
77
+ var check = function () {
78
+ if (Math.abs(innerWidth - msg.width) <= 2 || Date.now() - started > 1500) {
79
+ reply({ ok: true, value: { width: innerWidth, height: innerHeight, framed: window.parent !== window } })
80
+ } else setTimeout(check, 50)
81
+ }
82
+ setTimeout(check, 50)
83
+ } else if (msg.op === 'ping') {
84
+ reply({ ok: true, value: 'pong' })
85
+ } else {
86
+ reply({ ok: false, error: 'unknown op: ' + msg.op })
87
+ }
88
+ } catch (e) {
89
+ reply({ ok: false, error: (e && e.stack) || String(e) })
90
+ }
91
+ }
92
+ var hello = function () {
93
+ send({ hello: true, id: pageId, href: location.href, title: document.title, readyState: document.readyState, innerWidth: innerWidth, innerHeight: innerHeight, hidden: document.hidden, framed: window.parent !== window })
94
+ }
95
+ var connect = function () {
96
+ if (leaving) return
97
+ try { ws = new WebSocket(proto + location.host + PATH + '?role=page&id=' + encodeURIComponent(pageId)) } catch (e) { setTimeout(connect, backoff); return }
98
+ ws.onopen = function () { backoff = 500; hello() }
99
+ ws.onmessage = function (ev) {
100
+ var msg = null
101
+ try { msg = JSON.parse(ev.data) } catch (e) { return }
102
+ if (msg && msg.op) handle(msg)
103
+ }
104
+ ws.onclose = function () { if (!leaving) { backoff = Math.min(backoff * 2, 5000); setTimeout(connect, backoff) } }
105
+ ws.onerror = function () {}
106
+ }
107
+ var levels = ['log', 'info', 'warn', 'error', 'debug']
108
+ for (var i = 0; i < levels.length; i++) (function (level) {
109
+ var orig = console[level]
110
+ console[level] = function () {
111
+ try { send({ event: 'console', type: level === 'warn' ? 'warning' : level, text: describe(arguments) }) } catch (e) {}
112
+ return orig && orig.apply(console, arguments)
113
+ }
114
+ })(levels[i])
115
+ window.addEventListener('error', function (e) {
116
+ send({ event: 'pageerror', message: (e.error && e.error.message) || e.message || 'Error', stack: e.error && e.error.stack, url: e.filename, lineNumber: e.lineno, columnNumber: e.colno })
117
+ })
118
+ window.addEventListener('unhandledrejection', function (e) {
119
+ var r = e.reason
120
+ send({ event: 'pageerror', message: (r && r.message) || String(r), stack: r && r.stack })
121
+ })
122
+ var dialogs = ['alert', 'confirm', 'prompt']
123
+ for (var d = 0; d < dialogs.length; d++) (function (kind) {
124
+ window[kind] = function (message, defaultValue) {
125
+ send({ event: 'dialog', type: kind, message: String(message === undefined ? '' : message), defaultValue: defaultValue === undefined ? '' : String(defaultValue) })
126
+ if (kind === 'confirm') return true
127
+ if (kind === 'prompt') return defaultValue === undefined ? '' : String(defaultValue)
128
+ return undefined
129
+ }
130
+ })(dialogs[d])
131
+ var navigated = function () { send({ event: 'navigated', href: location.href, title: document.title }) }
132
+ window.addEventListener('popstate', navigated)
133
+ window.addEventListener('hashchange', navigated)
134
+ var wrapHistory = function (name) {
135
+ var orig = history[name]
136
+ history[name] = function () { var r = orig.apply(this, arguments); setTimeout(navigated, 0); return r }
137
+ }
138
+ wrapHistory('pushState')
139
+ wrapHistory('replaceState')
140
+ document.addEventListener('visibilitychange', function () { send({ event: 'visibility', hidden: document.hidden, href: location.href }) })
141
+ window.addEventListener('pagehide', function () { leaving = true; try { if (ws) ws.close() } catch (e) {} })
142
+ window.__molE2EClient = { pageId: pageId, version: 1 }
143
+ connect()
144
+ })()
145
+ `;
146
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAExC,uEAAuE;AACvE,MAAM,CAAC,MAAM,yBAAyB,GAAG;;eAE1B,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiIzC,CAAA"}
@@ -0,0 +1,77 @@
1
+ /**
2
+ * E2E bond that drives the LIVE PREVIEW — the page the molecule.dev IDE is
3
+ * already showing, in the person's own browser — as a Playwright-shaped page.
4
+ * No browser binary in the sandbox, nothing to download: the browser that
5
+ * renders the preview is the browser that runs the test.
6
+ *
7
+ * Three small parts:
8
+ *
9
+ * 1. A Vite plugin ({@link molE2EPreviewPlugin}) every scaffolded app carries.
10
+ * In `vite` dev and `vite preview` it serves a tiny page client, injects it
11
+ * into each document, and attaches a WebSocket hub to the dev server.
12
+ * `vite build` output is untouched.
13
+ * 2. The page client, which opens a same-origin WebSocket back to that hub
14
+ * (through whatever proxy serves the preview), runs `evaluate` requests,
15
+ * navigates on request, asks the framing IDE to resize on
16
+ * `setViewportSize`, and forwards console output, errors and dialogs.
17
+ * 3. The driver ({@link provider}), which the test runner uses from the same
18
+ * machine as the dev server: it connects to the hub as `role=driver`
19
+ * (loopback only, with the hub's token) and turns one connected page into
20
+ * `@molecule/app-e2e`'s Playwright-shaped `Page`.
21
+ *
22
+ * @example
23
+ * ```ts
24
+ * // e2e/bonds.ts (scaffolded)
25
+ * import { resolveE2EProviderName, setProvider } from '@molecule/app-e2e'
26
+ * import { provider as playwright } from '@molecule/app-e2e-playwright'
27
+ * import { provider as preview } from '@molecule/app-e2e-preview'
28
+ *
29
+ * setProvider(resolveE2EProviderName() === 'preview' ? preview : playwright)
30
+ *
31
+ * // vite-preview-bridge-plugin.ts (scaffolded) — the plugin rides the existing molecule plugin
32
+ * import { molE2EPreviewPlugin } from '@molecule/app-e2e-preview/vite'
33
+ *
34
+ * // any script — measure the live page without a test runner
35
+ * import { connectPreview } from '@molecule/app-e2e-preview'
36
+ * const page = await connectPreview()
37
+ * await page.setViewportSize({ width: 390, height: 844 })
38
+ * console.log(await page.locator('article p').first().evaluate((el) => getComputedStyle(el).fontSize))
39
+ * await page.close()
40
+ * ```
41
+ *
42
+ * @remarks
43
+ * - **Someone must be looking.** The renderer is a browser tab showing the
44
+ * preview. `connect()` waits (30s by default) for a page to be connected
45
+ * and then fails with a message saying to open the preview in the IDE or
46
+ * in any tab. Any connected viewer will do — a desktop tab keeps working
47
+ * while a phone sleeps. The IDE holds a screen wake lock during builds and
48
+ * re-delivers commands when a hidden tab wakes.
49
+ * - **Discovery.** The driver tries `MOL_E2E_PREVIEW_URL`, then ports
50
+ * `MOL_E2E_PREVIEW_PORT`, 5173 (the sandbox preview port), `VITE_PORT`,
51
+ * 3000, reading each hub's token from `MOL_E2E_TOKEN` or the file the hub
52
+ * writes in the OS temp dir. Only loopback drivers with the token are
53
+ * accepted, so a preview URL never becomes a way to run code in someone
54
+ * else's tab.
55
+ * - **URLs.** `page.goto('/path')` navigates the previewed page relative to
56
+ * ITS origin; an absolute `http://localhost:<port>/path` is rewritten to the
57
+ * same path there, so specs written for a local base URL run unchanged.
58
+ * - **Viewport.** `page.setViewportSize` posts `molecule:viewport` to the
59
+ * framing IDE, which resizes the frame; in a plain tab the size cannot
60
+ * change and the call throws (the configured project viewport is applied
61
+ * with a warning instead of a failure).
62
+ * - **What is not here** is listed in `@molecule/app-e2e`'s docs — screenshots,
63
+ * network interception, element handles, iframes — each method throws with
64
+ * the alternative; `@molecule/app-e2e-playwright` runs the same spec with
65
+ * real browsers when you need them.
66
+ * - Imported (non-Vite) apps get the hub only if their dev server can host
67
+ * it; today the plugin covers every Vite-served app, which is every
68
+ * molecule scaffold.
69
+ *
70
+ * @module
71
+ */
72
+ export { E2E_PREVIEW_CLIENT_SCRIPT } from './client.js';
73
+ export { connectPreview, listPreviewPages, provider } from './provider.js';
74
+ export { attachE2EHub, type E2EHub } from './server.js';
75
+ export * from './types.js';
76
+ export { injectE2EClientTag, molE2EPreviewPlugin, type MolE2EPreviewPluginOptions } from './vite.js';
77
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsEG;AAEH,OAAO,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAA;AACvD,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAC1E,OAAO,EAAE,YAAY,EAAE,KAAK,MAAM,EAAE,MAAM,aAAa,CAAA;AACvD,cAAc,YAAY,CAAA;AAC1B,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,KAAK,0BAA0B,EAAE,MAAM,WAAW,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,77 @@
1
+ /**
2
+ * E2E bond that drives the LIVE PREVIEW — the page the molecule.dev IDE is
3
+ * already showing, in the person's own browser — as a Playwright-shaped page.
4
+ * No browser binary in the sandbox, nothing to download: the browser that
5
+ * renders the preview is the browser that runs the test.
6
+ *
7
+ * Three small parts:
8
+ *
9
+ * 1. A Vite plugin ({@link molE2EPreviewPlugin}) every scaffolded app carries.
10
+ * In `vite` dev and `vite preview` it serves a tiny page client, injects it
11
+ * into each document, and attaches a WebSocket hub to the dev server.
12
+ * `vite build` output is untouched.
13
+ * 2. The page client, which opens a same-origin WebSocket back to that hub
14
+ * (through whatever proxy serves the preview), runs `evaluate` requests,
15
+ * navigates on request, asks the framing IDE to resize on
16
+ * `setViewportSize`, and forwards console output, errors and dialogs.
17
+ * 3. The driver ({@link provider}), which the test runner uses from the same
18
+ * machine as the dev server: it connects to the hub as `role=driver`
19
+ * (loopback only, with the hub's token) and turns one connected page into
20
+ * `@molecule/app-e2e`'s Playwright-shaped `Page`.
21
+ *
22
+ * @example
23
+ * ```ts
24
+ * // e2e/bonds.ts (scaffolded)
25
+ * import { resolveE2EProviderName, setProvider } from '@molecule/app-e2e'
26
+ * import { provider as playwright } from '@molecule/app-e2e-playwright'
27
+ * import { provider as preview } from '@molecule/app-e2e-preview'
28
+ *
29
+ * setProvider(resolveE2EProviderName() === 'preview' ? preview : playwright)
30
+ *
31
+ * // vite-preview-bridge-plugin.ts (scaffolded) — the plugin rides the existing molecule plugin
32
+ * import { molE2EPreviewPlugin } from '@molecule/app-e2e-preview/vite'
33
+ *
34
+ * // any script — measure the live page without a test runner
35
+ * import { connectPreview } from '@molecule/app-e2e-preview'
36
+ * const page = await connectPreview()
37
+ * await page.setViewportSize({ width: 390, height: 844 })
38
+ * console.log(await page.locator('article p').first().evaluate((el) => getComputedStyle(el).fontSize))
39
+ * await page.close()
40
+ * ```
41
+ *
42
+ * @remarks
43
+ * - **Someone must be looking.** The renderer is a browser tab showing the
44
+ * preview. `connect()` waits (30s by default) for a page to be connected
45
+ * and then fails with a message saying to open the preview in the IDE or
46
+ * in any tab. Any connected viewer will do — a desktop tab keeps working
47
+ * while a phone sleeps. The IDE holds a screen wake lock during builds and
48
+ * re-delivers commands when a hidden tab wakes.
49
+ * - **Discovery.** The driver tries `MOL_E2E_PREVIEW_URL`, then ports
50
+ * `MOL_E2E_PREVIEW_PORT`, 5173 (the sandbox preview port), `VITE_PORT`,
51
+ * 3000, reading each hub's token from `MOL_E2E_TOKEN` or the file the hub
52
+ * writes in the OS temp dir. Only loopback drivers with the token are
53
+ * accepted, so a preview URL never becomes a way to run code in someone
54
+ * else's tab.
55
+ * - **URLs.** `page.goto('/path')` navigates the previewed page relative to
56
+ * ITS origin; an absolute `http://localhost:<port>/path` is rewritten to the
57
+ * same path there, so specs written for a local base URL run unchanged.
58
+ * - **Viewport.** `page.setViewportSize` posts `molecule:viewport` to the
59
+ * framing IDE, which resizes the frame; in a plain tab the size cannot
60
+ * change and the call throws (the configured project viewport is applied
61
+ * with a warning instead of a failure).
62
+ * - **What is not here** is listed in `@molecule/app-e2e`'s docs — screenshots,
63
+ * network interception, element handles, iframes — each method throws with
64
+ * the alternative; `@molecule/app-e2e-playwright` runs the same spec with
65
+ * real browsers when you need them.
66
+ * - Imported (non-Vite) apps get the hub only if their dev server can host
67
+ * it; today the plugin covers every Vite-served app, which is every
68
+ * molecule scaffold.
69
+ *
70
+ * @module
71
+ */
72
+ export { E2E_PREVIEW_CLIENT_SCRIPT } from './client.js';
73
+ export { connectPreview, listPreviewPages, provider } from './provider.js';
74
+ export { attachE2EHub } from './server.js';
75
+ export * from './types.js';
76
+ export { injectE2EClientTag, molE2EPreviewPlugin } from './vite.js';
77
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsEG;AAEH,OAAO,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAA;AACvD,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAC1E,OAAO,EAAE,YAAY,EAAe,MAAM,aAAa,CAAA;AACvD,cAAc,YAAY,CAAA;AAC1B,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAmC,MAAM,WAAW,CAAA"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * The driver: connects to the hub from inside the sandbox (or any machine
3
+ * running the dev server), picks a connected preview page, and exposes it as
4
+ * an `E2ETransport` for the core's `createEvaluatePage()`.
5
+ *
6
+ * @module
7
+ */
8
+ import type { Page } from '@playwright/test';
9
+ import { type E2EProvider } from '@molecule/app-e2e';
10
+ import { type PagePeer, type PreviewConnectOptions } from './types.js';
11
+ /** The bond: `setProvider(provider)` in your `e2e/bonds.ts`. */
12
+ export declare const provider: E2EProvider;
13
+ /** Open the live preview as a Playwright-shaped page from any script (`node scripts/check.mjs`). */
14
+ export declare const connectPreview: (options?: PreviewConnectOptions) => Promise<Page>;
15
+ /** The preview pages currently connected to the hub. */
16
+ export declare const listPreviewPages: (options?: PreviewConnectOptions) => Promise<PagePeer[]>;
17
+ //# sourceMappingURL=provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAMH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AAG5C,OAAO,EAGL,KAAK,WAAW,EAIjB,MAAM,mBAAmB,CAAA;AAG1B,OAAO,EAGL,KAAK,QAAQ,EACb,KAAK,qBAAqB,EAE3B,MAAM,YAAY,CAAA;AAkanB,gEAAgE;AAChE,eAAO,MAAM,QAAQ,EAAE,WAMtB,CAAA;AAED,oGAAoG;AACpG,eAAO,MAAM,cAAc,GAAI,UAAS,qBAA0B,KAAG,OAAO,CAAC,IAAI,CACtD,CAAA;AAE3B,wDAAwD;AACxD,eAAO,MAAM,gBAAgB,GAC3B,UAAS,qBAA0B,KAClC,OAAO,CAAC,QAAQ,EAAE,CAQpB,CAAA"}