@scenar/cli 0.2.0 → 0.3.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/example-bundle/assets/index-BLQ14SEo.js +147 -0
- package/example-bundle/assets/logo-f-5LjVqJ.png +0 -0
- package/example-bundle/assets/style-Dnzx_jUO.css +1 -0
- package/example-bundle/embed.js +1 -0
- package/example-bundle/index.html +13 -0
- package/example-bundle/pack-manifest.json +42 -0
- package/example-bundle/scenario.json +9 -0
- package/package.json +6 -5
- package/src/__tests__/embed-loader.test.ts +29 -0
- package/src/__tests__/embed-snippet.test.ts +48 -1
- package/src/__tests__/pack-generate-embed-entry.test.ts +59 -6
- package/src/__tests__/try-command.test.ts +21 -0
- package/src/commands/publish.d.ts.map +1 -1
- package/src/commands/publish.js +3 -1
- package/src/commands/publish.js.map +1 -1
- package/src/commands/publish.ts +5 -1
- package/src/commands/serve.d.ts.map +1 -1
- package/src/commands/serve.js +2 -0
- package/src/commands/serve.js.map +1 -1
- package/src/commands/serve.ts +4 -0
- package/src/commands/try.d.ts +3 -0
- package/src/commands/try.d.ts.map +1 -0
- package/src/commands/try.js +99 -0
- package/src/commands/try.js.map +1 -0
- package/src/commands/try.ts +122 -0
- package/src/deploy/embed-snippet.d.ts +16 -0
- package/src/deploy/embed-snippet.d.ts.map +1 -1
- package/src/deploy/embed-snippet.js +27 -0
- package/src/deploy/embed-snippet.js.map +1 -1
- package/src/deploy/embed-snippet.ts +28 -0
- package/src/index.d.ts.map +1 -1
- package/src/index.js +2 -0
- package/src/index.js.map +1 -1
- package/src/index.ts +2 -0
- package/src/pack/embed-loader.d.ts +18 -0
- package/src/pack/embed-loader.d.ts.map +1 -0
- package/src/pack/embed-loader.js +25 -0
- package/src/pack/embed-loader.js.map +1 -0
- package/src/pack/embed-loader.ts +27 -0
- package/src/pack/generate-embed-entry.d.ts +11 -0
- package/src/pack/generate-embed-entry.d.ts.map +1 -1
- package/src/pack/generate-embed-entry.js +81 -10
- package/src/pack/generate-embed-entry.js.map +1 -1
- package/src/pack/generate-embed-entry.ts +81 -10
- package/src/pack/run-pack.d.ts.map +1 -1
- package/src/pack/run-pack.js +6 -0
- package/src/pack/run-pack.js.map +1 -1
- package/src/pack/run-pack.ts +7 -0
- package/src/publish/run-publish.d.ts +2 -0
- package/src/publish/run-publish.d.ts.map +1 -1
- package/src/publish/run-publish.js +3 -2
- package/src/publish/run-publish.js.map +1 -1
- package/src/publish/run-publish.ts +5 -2
- package/src/serve/run-serve.d.ts +2 -0
- package/src/serve/run-serve.d.ts.map +1 -1
- package/src/serve/run-serve.js +3 -2
- package/src/serve/run-serve.js.map +1 -1
- package/src/serve/run-serve.ts +5 -2
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
2
|
+
import { platform } from "node:process";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
import { dirname, resolve } from "node:path";
|
|
5
|
+
import { stat } from "node:fs/promises";
|
|
6
|
+
import { Command } from "commander";
|
|
7
|
+
import { runServe } from "../serve/run-serve.js";
|
|
8
|
+
import type { BundleServerHandle } from "../serve/static-server.js";
|
|
9
|
+
|
|
10
|
+
/** Vite's preview port — the conventional "serve a built site" port. */
|
|
11
|
+
const DEFAULT_PORT = 4173;
|
|
12
|
+
|
|
13
|
+
/** Bind to loopback by default; a preview is a single-developer tool. */
|
|
14
|
+
const DEFAULT_HOST = "localhost";
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* The example bundle that ships with the CLI. It's generated at build time
|
|
18
|
+
* (`pack examples/welcome-tour --out dist/example-bundle`, see package.json) and
|
|
19
|
+
* published as part of dist/, so it's present for npx consumers. This module
|
|
20
|
+
* compiles to dist/src/commands/try.js, so the bundle sits two levels up.
|
|
21
|
+
*/
|
|
22
|
+
const EXAMPLE_BUNDLE_DIR = resolve(dirname(fileURLToPath(import.meta.url)), "../../example-bundle");
|
|
23
|
+
|
|
24
|
+
interface TryOptions {
|
|
25
|
+
port?: string;
|
|
26
|
+
host?: string;
|
|
27
|
+
open?: boolean;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function registerTryCommand(program: Command): void {
|
|
31
|
+
program
|
|
32
|
+
.command("try")
|
|
33
|
+
.description(
|
|
34
|
+
"Serve the bundled welcome-tour example locally — no app required.\n\n" +
|
|
35
|
+
"Boots the example embed that ships with the CLI on\n" +
|
|
36
|
+
"http://localhost:4173 (override with --port/--host) and prints a\n" +
|
|
37
|
+
"ready-to-paste <iframe> snippet, then stays running until Ctrl+C.\n\n" +
|
|
38
|
+
"This is the fastest way to see what a Scenar embed looks like before\n" +
|
|
39
|
+
"wiring up your own app. To build a tour from your components, see\n" +
|
|
40
|
+
"`scenar preview`; to host one, see `scenar publish`.",
|
|
41
|
+
)
|
|
42
|
+
.option("--port <number>", `port to listen on (default: ${DEFAULT_PORT})`, String(DEFAULT_PORT))
|
|
43
|
+
.option("--host <host>", `host/interface to bind (default: ${DEFAULT_HOST})`, DEFAULT_HOST)
|
|
44
|
+
.option("--open", "open the embed in your default browser")
|
|
45
|
+
.action(async (options: TryOptions) => {
|
|
46
|
+
try {
|
|
47
|
+
const port = Number(options.port);
|
|
48
|
+
if (!Number.isInteger(port) || port < 0 || port > 65535) {
|
|
49
|
+
throw new Error(`invalid --port "${options.port}"; expected an integer between 0 and 65535.`);
|
|
50
|
+
}
|
|
51
|
+
const host = options.host ?? DEFAULT_HOST;
|
|
52
|
+
|
|
53
|
+
const bundle = await stat(EXAMPLE_BUNDLE_DIR).catch(() => null);
|
|
54
|
+
if (!bundle || !bundle.isDirectory()) {
|
|
55
|
+
throw new Error(
|
|
56
|
+
"the bundled example is missing. If you installed @scenar/cli from npm, " +
|
|
57
|
+
"reinstall it; if you're running from source, run `pnpm build` first.",
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
let result;
|
|
62
|
+
try {
|
|
63
|
+
result = await runServe({ bundleDir: EXAMPLE_BUNDLE_DIR, port, host });
|
|
64
|
+
} catch (error) {
|
|
65
|
+
if (isAddrInUse(error)) {
|
|
66
|
+
throw new Error(
|
|
67
|
+
`port ${port} is already in use. Stop the other process or pass --port <number>.`,
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
throw error;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
process.stderr.write(`\n\x1b[32m✓\x1b[0m Serving the welcome-tour example at ${result.url}\n`);
|
|
74
|
+
process.stderr.write("\n Embed snippet (paste into any page):\n\n");
|
|
75
|
+
process.stderr.write(`${indent(result.snippet)}\n`);
|
|
76
|
+
process.stderr.write("\n Press Ctrl+C to stop.\n");
|
|
77
|
+
|
|
78
|
+
if (options.open) {
|
|
79
|
+
openInBrowser(result.url);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
await runUntilInterrupted(result.handle);
|
|
83
|
+
} catch (error) {
|
|
84
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
85
|
+
process.stderr.write(`\x1b[31mError:\x1b[0m ${msg}\n`);
|
|
86
|
+
process.exitCode = 1;
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/** Block until SIGINT/SIGTERM, then close the server cleanly. */
|
|
92
|
+
function runUntilInterrupted(handle: BundleServerHandle): Promise<void> {
|
|
93
|
+
return new Promise<void>((resolvePromise) => {
|
|
94
|
+
const shutdown = () => {
|
|
95
|
+
process.stderr.write("\nStopping...\n");
|
|
96
|
+
void handle.close().finally(() => resolvePromise());
|
|
97
|
+
};
|
|
98
|
+
process.once("SIGINT", shutdown);
|
|
99
|
+
process.once("SIGTERM", shutdown);
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/** Best-effort: launch the OS default browser. Failures are silent (non-fatal). */
|
|
104
|
+
function openInBrowser(url: string): void {
|
|
105
|
+
const command = platform === "darwin" ? "open" : platform === "win32" ? "start" : "xdg-open";
|
|
106
|
+
try {
|
|
107
|
+
const child = spawn(command, [url], { stdio: "ignore", detached: true, shell: platform === "win32" });
|
|
108
|
+
child.on("error", () => {});
|
|
109
|
+
child.unref();
|
|
110
|
+
} catch {
|
|
111
|
+
// Opening a browser is a convenience; never fail the command over it.
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
function isAddrInUse(error: unknown): boolean {
|
|
116
|
+
return typeof error === "object" && error !== null && (error as { code?: string }).code === "EADDRINUSE";
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/** Indent every line by two spaces (for nesting a block under a heading). */
|
|
120
|
+
function indent(block: string): string {
|
|
121
|
+
return block.replace(/^/gm, " ");
|
|
122
|
+
}
|
|
@@ -24,4 +24,20 @@ export interface EmbedSnippetInput {
|
|
|
24
24
|
* Pure function — returns the snippet string; the caller decides where to print.
|
|
25
25
|
*/
|
|
26
26
|
export declare function buildEmbedSnippet(input: EmbedSnippetInput): string;
|
|
27
|
+
/**
|
|
28
|
+
* Build the *enhanced* embed snippet — the optional `<scenar-embed>` loader of
|
|
29
|
+
* DD-002/DD-005. A single `<script>` registers the custom element (the bundle's
|
|
30
|
+
* sibling `embed.js`, copied in by `scenar pack`), and the tag then auto-fits to
|
|
31
|
+
* the embed's reported size and syncs the host's light/dark theme. No viewport
|
|
32
|
+
* math is needed in the snippet: the element adopts the embed's exact aspect
|
|
33
|
+
* ratio from its first `resize`, falling back to the recorded baseline until then.
|
|
34
|
+
*
|
|
35
|
+
* The loader URL is resolved as `embed.js` relative to the embed URL, so it
|
|
36
|
+
* points at the copy that ships inside the bundle (works on GitHub Pages, a
|
|
37
|
+
* local `serve`, or any static host). Attribute values are escaped, since the
|
|
38
|
+
* snippet is copy-pasted into third-party HTML.
|
|
39
|
+
*
|
|
40
|
+
* Pure function — returns the snippet string; the caller decides where to print.
|
|
41
|
+
*/
|
|
42
|
+
export declare function buildEnhancedEmbedSnippet(input: EmbedSnippetInput): string;
|
|
27
43
|
//# sourceMappingURL=embed-snippet.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"embed-snippet.d.ts","sourceRoot":"","sources":["../../../src/deploy/embed-snippet.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAEpD,4CAA4C;AAC5C,MAAM,WAAW,iBAAiB;IAChC,2EAA2E;IAC3E,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,+EAA+E;IAC/E,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,+EAA+E;IAC/E,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,iBAAiB,GAAG,MAAM,CAelE"}
|
|
1
|
+
{"version":3,"file":"embed-snippet.d.ts","sourceRoot":"","sources":["../../../src/deploy/embed-snippet.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAEpD,4CAA4C;AAC5C,MAAM,WAAW,iBAAiB;IAChC,2EAA2E;IAC3E,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,+EAA+E;IAC/E,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,+EAA+E;IAC/E,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,iBAAiB,GAAG,MAAM,CAelE;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,iBAAiB,GAAG,MAAM,CAW1E"}
|
|
@@ -29,6 +29,33 @@ export function buildEmbedSnippet(input) {
|
|
|
29
29
|
`</div>`,
|
|
30
30
|
].join("\n");
|
|
31
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* Build the *enhanced* embed snippet — the optional `<scenar-embed>` loader of
|
|
34
|
+
* DD-002/DD-005. A single `<script>` registers the custom element (the bundle's
|
|
35
|
+
* sibling `embed.js`, copied in by `scenar pack`), and the tag then auto-fits to
|
|
36
|
+
* the embed's reported size and syncs the host's light/dark theme. No viewport
|
|
37
|
+
* math is needed in the snippet: the element adopts the embed's exact aspect
|
|
38
|
+
* ratio from its first `resize`, falling back to the recorded baseline until then.
|
|
39
|
+
*
|
|
40
|
+
* The loader URL is resolved as `embed.js` relative to the embed URL, so it
|
|
41
|
+
* points at the copy that ships inside the bundle (works on GitHub Pages, a
|
|
42
|
+
* local `serve`, or any static host). Attribute values are escaped, since the
|
|
43
|
+
* snippet is copy-pasted into third-party HTML.
|
|
44
|
+
*
|
|
45
|
+
* Pure function — returns the snippet string; the caller decides where to print.
|
|
46
|
+
*/
|
|
47
|
+
export function buildEnhancedEmbedSnippet(input) {
|
|
48
|
+
const { embedUrl } = input;
|
|
49
|
+
const title = input.title ?? "Scenar embed";
|
|
50
|
+
const loaderUrl = new URL("embed.js", embedUrl).toString();
|
|
51
|
+
return [
|
|
52
|
+
`<script type="module" src="${escapeAttr(loaderUrl)}"></script>`,
|
|
53
|
+
`<scenar-embed`,
|
|
54
|
+
` src="${escapeAttr(embedUrl)}"`,
|
|
55
|
+
` title="${escapeAttr(title)}"`,
|
|
56
|
+
`></scenar-embed>`,
|
|
57
|
+
].join("\n");
|
|
58
|
+
}
|
|
32
59
|
/** Escape a string for safe interpolation into a double-quoted HTML attribute. */
|
|
33
60
|
function escapeAttr(value) {
|
|
34
61
|
return value
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"embed-snippet.js","sourceRoot":"","sources":["../../../src/deploy/embed-snippet.ts"],"names":[],"mappings":"AAYA;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAAwB;IACxD,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;IACr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I,CAAC,CAAC;AACf,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,yBAAyB,CAAC,KAAwB;IAChE,MAAM,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;IAC3B,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,IAAI,cAAc,CAAC;IAC5C,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC,QAAQ,EAAE,CAAC;IAC3D,OAAO;QACL,8BAA8B,UAAU,CAAC,SAAS,CAAC,aAAa;QAChE,eAAe;QACf,UAAU,UAAU,CAAC,QAAQ,CAAC,GAAG;QACjC,YAAY,UAAU,CAAC,KAAK,CAAC,GAAG;QAChC,kBAAkB;KACnB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC;AAED,kFAAkF;AAClF,SAAS,UAAU,CAAC,KAAa;IAC/B,OAAO,KAAK;SACT,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC;SACtB,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC;SACvB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC;SACrB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;AAC3B,CAAC"}
|
|
@@ -42,6 +42,34 @@ export function buildEmbedSnippet(input: EmbedSnippetInput): string {
|
|
|
42
42
|
].join("\n");
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
+
/**
|
|
46
|
+
* Build the *enhanced* embed snippet — the optional `<scenar-embed>` loader of
|
|
47
|
+
* DD-002/DD-005. A single `<script>` registers the custom element (the bundle's
|
|
48
|
+
* sibling `embed.js`, copied in by `scenar pack`), and the tag then auto-fits to
|
|
49
|
+
* the embed's reported size and syncs the host's light/dark theme. No viewport
|
|
50
|
+
* math is needed in the snippet: the element adopts the embed's exact aspect
|
|
51
|
+
* ratio from its first `resize`, falling back to the recorded baseline until then.
|
|
52
|
+
*
|
|
53
|
+
* The loader URL is resolved as `embed.js` relative to the embed URL, so it
|
|
54
|
+
* points at the copy that ships inside the bundle (works on GitHub Pages, a
|
|
55
|
+
* local `serve`, or any static host). Attribute values are escaped, since the
|
|
56
|
+
* snippet is copy-pasted into third-party HTML.
|
|
57
|
+
*
|
|
58
|
+
* Pure function — returns the snippet string; the caller decides where to print.
|
|
59
|
+
*/
|
|
60
|
+
export function buildEnhancedEmbedSnippet(input: EmbedSnippetInput): string {
|
|
61
|
+
const { embedUrl } = input;
|
|
62
|
+
const title = input.title ?? "Scenar embed";
|
|
63
|
+
const loaderUrl = new URL("embed.js", embedUrl).toString();
|
|
64
|
+
return [
|
|
65
|
+
`<script type="module" src="${escapeAttr(loaderUrl)}"></script>`,
|
|
66
|
+
`<scenar-embed`,
|
|
67
|
+
` src="${escapeAttr(embedUrl)}"`,
|
|
68
|
+
` title="${escapeAttr(title)}"`,
|
|
69
|
+
`></scenar-embed>`,
|
|
70
|
+
].join("\n");
|
|
71
|
+
}
|
|
72
|
+
|
|
45
73
|
/** Escape a string for safe interpolation into a double-quoted HTML attribute. */
|
|
46
74
|
function escapeAttr(value: string): string {
|
|
47
75
|
return value
|
package/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAWpC,wBAAgB,aAAa,IAAI,OAAO,CAmBvC;AAED,wBAAgB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,IAAI,CAGxC"}
|
package/src/index.js
CHANGED
|
@@ -5,6 +5,7 @@ import { registerPreviewCommand } from "./commands/preview.js";
|
|
|
5
5
|
import { registerRenderCommand } from "./commands/render.js";
|
|
6
6
|
import { registerPackCommand } from "./commands/pack.js";
|
|
7
7
|
import { registerServeCommand } from "./commands/serve.js";
|
|
8
|
+
import { registerTryCommand } from "./commands/try.js";
|
|
8
9
|
import { registerPublishCommand } from "./commands/publish.js";
|
|
9
10
|
import { registerDeployCommand } from "./commands/deploy.js";
|
|
10
11
|
export function createProgram() {
|
|
@@ -19,6 +20,7 @@ export function createProgram() {
|
|
|
19
20
|
registerPreviewCommand(program);
|
|
20
21
|
registerPackCommand(program);
|
|
21
22
|
registerServeCommand(program);
|
|
23
|
+
registerTryCommand(program);
|
|
22
24
|
registerPublishCommand(program);
|
|
23
25
|
registerDeployCommand(program);
|
|
24
26
|
return program;
|
package/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAE7D,MAAM,UAAU,aAAa;IAC3B,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;IAE9B,OAAO;SACJ,IAAI,CAAC,QAAQ,CAAC;SACd,WAAW,CAAC,8FAA8F,CAAC;SAC3G,OAAO,CAAC,OAAO,CAAC,CAAC;IAEpB,uBAAuB,CAAC,OAAO,CAAC,CAAC;IACjC,sBAAsB,C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AAuB,CAAC,OAAO,CAAC,CAAC;IACjC,sBAAsB,CAAC,OAAO,CAAC,CAAC;IAChC,qBAAqB,CAAC,OAAO,CAAC,CAAC;IAC/B,sBAAsB,CAAC,OAAO,CAAC,CAAC;IAChC,mBAAmB,CAAC,OAAO,CAAC,CAAC;IAC7B,oBAAoB,CAAC,OAAO,CAAC,CAAC;IAC9B,kBAAkB,CAAC,OAAO,CAAC,CAAC;IAC5B,sBAAsB,CAAC,OAAO,CAAC,CAAC;IAChC,qBAAqB,CAAC,OAAO,CAAC,CAAC;IAE/B,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,MAAM,UAAU,GAAG,CAAC,IAAc;IAChC,MAAM,OAAO,GAAG,aAAa,EAAE,CAAC;IAChC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;AACtB,CAAC"}
|
package/src/index.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { registerPreviewCommand } from "./commands/preview.js";
|
|
|
5
5
|
import { registerRenderCommand } from "./commands/render.js";
|
|
6
6
|
import { registerPackCommand } from "./commands/pack.js";
|
|
7
7
|
import { registerServeCommand } from "./commands/serve.js";
|
|
8
|
+
import { registerTryCommand } from "./commands/try.js";
|
|
8
9
|
import { registerPublishCommand } from "./commands/publish.js";
|
|
9
10
|
import { registerDeployCommand } from "./commands/deploy.js";
|
|
10
11
|
|
|
@@ -22,6 +23,7 @@ export function createProgram(): Command {
|
|
|
22
23
|
registerPreviewCommand(program);
|
|
23
24
|
registerPackCommand(program);
|
|
24
25
|
registerServeCommand(program);
|
|
26
|
+
registerTryCommand(program);
|
|
25
27
|
registerPublishCommand(program);
|
|
26
28
|
registerDeployCommand(program);
|
|
27
29
|
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The loader artifact's name inside the bundle — a sibling of `index.html`. The
|
|
3
|
+
* enhanced `<scenar-embed>` snippet references it as `embed.js` relative to the
|
|
4
|
+
* embed URL, so `serve`/`publish` carry it automatically with no change to the
|
|
5
|
+
* publish-flow bundle contract.
|
|
6
|
+
*/
|
|
7
|
+
export declare const EMBED_LOADER_FILE = "embed.js";
|
|
8
|
+
/**
|
|
9
|
+
* Copy `@scenar/embed`'s prebuilt loader (its `./loader` export → the IIFE
|
|
10
|
+
* `embed.global.js`) into the bundle as {@link EMBED_LOADER_FILE}.
|
|
11
|
+
*
|
|
12
|
+
* The artifact is resolved through the package export rather than a hard-coded
|
|
13
|
+
* path, so it works the same in the workspace (symlinked) and in a published
|
|
14
|
+
* install. `@scenar/cli` depends on `@scenar/embed`, so it is always present and
|
|
15
|
+
* built before the CLI (and thus before `pack` runs).
|
|
16
|
+
*/
|
|
17
|
+
export declare function copyEmbedLoader(outDir: string): Promise<void>;
|
|
18
|
+
//# sourceMappingURL=embed-loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"embed-loader.d.ts","sourceRoot":"","sources":["../../../src/pack/embed-loader.ts"],"names":[],"mappings":"AAIA;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,aAAa,CAAC;AAI5C;;;;;;;;GAQG;AACH,wBAAsB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAGnE"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
import { copyFile } from "node:fs/promises";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
/**
|
|
5
|
+
* The loader artifact's name inside the bundle — a sibling of `index.html`. The
|
|
6
|
+
* enhanced `<scenar-embed>` snippet references it as `embed.js` relative to the
|
|
7
|
+
* embed URL, so `serve`/`publish` carry it automatically with no change to the
|
|
8
|
+
* publish-flow bundle contract.
|
|
9
|
+
*/
|
|
10
|
+
export const EMBED_LOADER_FILE = "embed.js";
|
|
11
|
+
const requireFromHere = createRequire(import.meta.url);
|
|
12
|
+
/**
|
|
13
|
+
* Copy `@scenar/embed`'s prebuilt loader (its `./loader` export → the IIFE
|
|
14
|
+
* `embed.global.js`) into the bundle as {@link EMBED_LOADER_FILE}.
|
|
15
|
+
*
|
|
16
|
+
* The artifact is resolved through the package export rather than a hard-coded
|
|
17
|
+
* path, so it works the same in the workspace (symlinked) and in a published
|
|
18
|
+
* install. `@scenar/cli` depends on `@scenar/embed`, so it is always present and
|
|
19
|
+
* built before the CLI (and thus before `pack` runs).
|
|
20
|
+
*/
|
|
21
|
+
export async function copyEmbedLoader(outDir) {
|
|
22
|
+
const loaderPath = requireFromHere.resolve("@scenar/embed/loader");
|
|
23
|
+
await copyFile(loaderPath, join(outDir, EMBED_LOADER_FILE));
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=embed-loader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"embed-loader.js","sourceRoot":"","sources":["../../../src/pack/embed-loader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,UAAU,CAAC;AAE5C,MAAM,eAAe,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAEvD;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,MAAc;IAClD,MAAM,UAAU,GAAG,eAAe,CAAC,OAAO,CAAC,sBAAsB,CAAC,CAAC;IACnE,MAAM,QAAQ,CAAC,UAAU,EAAE,IAAI,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC,CAAC;AAC9D,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
import { copyFile } from "node:fs/promises";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The loader artifact's name inside the bundle — a sibling of `index.html`. The
|
|
7
|
+
* enhanced `<scenar-embed>` snippet references it as `embed.js` relative to the
|
|
8
|
+
* embed URL, so `serve`/`publish` carry it automatically with no change to the
|
|
9
|
+
* publish-flow bundle contract.
|
|
10
|
+
*/
|
|
11
|
+
export const EMBED_LOADER_FILE = "embed.js";
|
|
12
|
+
|
|
13
|
+
const requireFromHere = createRequire(import.meta.url);
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Copy `@scenar/embed`'s prebuilt loader (its `./loader` export → the IIFE
|
|
17
|
+
* `embed.global.js`) into the bundle as {@link EMBED_LOADER_FILE}.
|
|
18
|
+
*
|
|
19
|
+
* The artifact is resolved through the package export rather than a hard-coded
|
|
20
|
+
* path, so it works the same in the workspace (symlinked) and in a published
|
|
21
|
+
* install. `@scenar/cli` depends on `@scenar/embed`, so it is always present and
|
|
22
|
+
* built before the CLI (and thus before `pack` runs).
|
|
23
|
+
*/
|
|
24
|
+
export async function copyEmbedLoader(outDir: string): Promise<void> {
|
|
25
|
+
const loaderPath = requireFromHere.resolve("@scenar/embed/loader");
|
|
26
|
+
await copyFile(loaderPath, join(outDir, EMBED_LOADER_FILE));
|
|
27
|
+
}
|
|
@@ -30,6 +30,17 @@ export interface EmbedEntryInput {
|
|
|
30
30
|
* @scenar/react theme + styles so the bundle is self-contained, and scopes the
|
|
31
31
|
* tree with `SCENAR_CLASS` + `DemoViewport` exactly as the authoring surfaces do.
|
|
32
32
|
*
|
|
33
|
+
* Interactions: the entry wires the full host-side interaction system —
|
|
34
|
+
* `useStepInteractions` + `<Cursor>` + `<ViewportTransformLayer>` — so packed
|
|
35
|
+
* embeds run the same narration-synced cursor moves, clicks, typing, hovers,
|
|
36
|
+
* drags, scrolls, and viewport transitions as the in-app player. (`ScenarioPlayer`
|
|
37
|
+
* itself owns none of this; the host must wire it, per DemoViewport's contract.)
|
|
38
|
+
*
|
|
39
|
+
* Theme: the embed reads `?theme` from its own URL and applies the `dark` class
|
|
40
|
+
* alongside `SCENAR_CLASS` when `theme=dark` (matching the `.scenar.dark` token
|
|
41
|
+
* selector). The default is light, so existing embeds are unaffected; a host can
|
|
42
|
+
* theme-sync simply by framing `…/?theme=dark`.
|
|
43
|
+
*
|
|
33
44
|
* Pure function, no side effects — the caller writes the result to disk.
|
|
34
45
|
*/
|
|
35
46
|
export declare function generateEmbedEntry(input: EmbedEntryInput): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-embed-entry.d.ts","sourceRoot":"","sources":["../../../src/pack/generate-embed-entry.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,MAAM,WAAW,eAAe;IAC9B,mEAAmE;IACnE,WAAW,EAAE,MAAM,CAAC;IACpB,yDAAyD;IACzD,cAAc,EAAE,MAAM,CAAC;IACvB,gEAAgE;IAChE,UAAU,EAAE,MAAM,CAAC;IACnB,+DAA+D;IAC/D,YAAY,EAAE,OAAO,CAAC;IACtB,+DAA+D;IAC/D,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,sEAAsE;IACtE,cAAc,EAAE,MAAM,CAAC;IACvB,4DAA4D;IAC5D,WAAW,EAAE,MAAM,CAAC;CACrB;AAED
|
|
1
|
+
{"version":3,"file":"generate-embed-entry.d.ts","sourceRoot":"","sources":["../../../src/pack/generate-embed-entry.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,MAAM,WAAW,eAAe;IAC9B,mEAAmE;IACnE,WAAW,EAAE,MAAM,CAAC;IACpB,yDAAyD;IACzD,cAAc,EAAE,MAAM,CAAC;IACvB,gEAAgE;IAChE,UAAU,EAAE,MAAM,CAAC;IACnB,+DAA+D;IAC/D,YAAY,EAAE,OAAO,CAAC;IACtB,+DAA+D;IAC/D,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,sEAAsE;IACtE,cAAc,EAAE,MAAM,CAAC;IACvB,4DAA4D;IAC5D,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,eAAe,GAAG,MAAM,CAiJjE;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,MAAM,CAgBnF"}
|
|
@@ -9,6 +9,17 @@ import { posix } from "node:path";
|
|
|
9
9
|
* @scenar/react theme + styles so the bundle is self-contained, and scopes the
|
|
10
10
|
* tree with `SCENAR_CLASS` + `DemoViewport` exactly as the authoring surfaces do.
|
|
11
11
|
*
|
|
12
|
+
* Interactions: the entry wires the full host-side interaction system —
|
|
13
|
+
* `useStepInteractions` + `<Cursor>` + `<ViewportTransformLayer>` — so packed
|
|
14
|
+
* embeds run the same narration-synced cursor moves, clicks, typing, hovers,
|
|
15
|
+
* drags, scrolls, and viewport transitions as the in-app player. (`ScenarioPlayer`
|
|
16
|
+
* itself owns none of this; the host must wire it, per DemoViewport's contract.)
|
|
17
|
+
*
|
|
18
|
+
* Theme: the embed reads `?theme` from its own URL and applies the `dark` class
|
|
19
|
+
* alongside `SCENAR_CLASS` when `theme=dark` (matching the `.scenar.dark` token
|
|
20
|
+
* selector). The default is light, so existing embeds are unaffected; a host can
|
|
21
|
+
* theme-sync simply by framing `…/?theme=dark`.
|
|
22
|
+
*
|
|
12
23
|
* Pure function, no side effects — the caller writes the result to disk.
|
|
13
24
|
*/
|
|
14
25
|
export function generateEmbedEntry(input) {
|
|
@@ -17,11 +28,24 @@ export function generateEmbedEntry(input) {
|
|
|
17
28
|
const renderImport = toPosix(input.renderFilePath).replace(/\.[^.]+$/, "");
|
|
18
29
|
const lines = [];
|
|
19
30
|
// --- Imports ---
|
|
31
|
+
// React hooks drive the host-side interaction system (the same one the
|
|
32
|
+
// in-app player wires): step tracking, cursor target, ripple/drag flags, and
|
|
33
|
+
// the viewport transform. Without these, the embed would render content but
|
|
34
|
+
// silently drop every cursor move and mid-step interaction.
|
|
35
|
+
lines.push(`import { useCallback, useRef, useState } from "react";`);
|
|
20
36
|
lines.push(`import { createRoot } from "react-dom/client";`);
|
|
21
|
-
const reactImports =
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
37
|
+
const reactImports = [
|
|
38
|
+
"ScenarioPlayer",
|
|
39
|
+
"DemoViewport",
|
|
40
|
+
"SCENAR_CLASS",
|
|
41
|
+
"Cursor",
|
|
42
|
+
"useStepInteractions",
|
|
43
|
+
"ViewportTransformLayer",
|
|
44
|
+
"VIEWPORT_TRANSFORM_IDENTITY",
|
|
45
|
+
];
|
|
46
|
+
if (input.hasNarration)
|
|
47
|
+
reactImports.push("useNarrationManifest");
|
|
48
|
+
lines.push(`import { ${reactImports.join(", ")} } from "@scenar/react";`);
|
|
25
49
|
lines.push(`import "@scenar/react/theme.css";`);
|
|
26
50
|
lines.push(`import "@scenar/react/styles.css";`);
|
|
27
51
|
lines.push(`import { renderStep } from ${JSON.stringify(renderImport)};`);
|
|
@@ -54,26 +78,73 @@ export function generateEmbedEntry(input) {
|
|
|
54
78
|
lines.push(``);
|
|
55
79
|
lines.push(`const _resolveManifestUrl = () => "./narration/manifest.json";`);
|
|
56
80
|
}
|
|
81
|
+
// --- Theme: opt-in dark via ?theme=dark (default light; backward-compatible) ---
|
|
82
|
+
// Read once at module load from the embed's own URL. `theme=dark` adds the
|
|
83
|
+
// `dark` class next to SCENAR_CLASS so the `.scenar.dark` tokens apply; any
|
|
84
|
+
// other value (including absent) renders light, preserving prior behavior.
|
|
85
|
+
lines.push(``);
|
|
86
|
+
lines.push(`const _theme = (() => {`);
|
|
87
|
+
lines.push(` try { return new URLSearchParams(window.location.search).get("theme"); }`);
|
|
88
|
+
lines.push(` catch { return null; }`);
|
|
89
|
+
lines.push(`})();`);
|
|
90
|
+
lines.push(`const _rootClass = _theme === "dark" ? SCENAR_CLASS + " dark" : SCENAR_CLASS;`);
|
|
57
91
|
// --- App tree ---
|
|
92
|
+
// The structure mirrors the in-app demo wiring exactly (see DemoViewport's
|
|
93
|
+
// contract and ViewportTransformLayer's "Cursor must be a sibling" invariant):
|
|
94
|
+
// DemoViewport(containerRef)
|
|
95
|
+
// └ ViewportTransformLayer(transform)
|
|
96
|
+
// └ ScenarioPlayer(embed, onStepChange)
|
|
97
|
+
// └ Cursor(target, containerRef) ← sibling, not a child
|
|
98
|
+
// `useStepInteractions` reads the current step's `interactions` and drives the
|
|
99
|
+
// cursor / ripple / drag / viewport state, synced to narration duration.
|
|
100
|
+
const manifestExpr = input.hasNarration ? "_manifest" : "undefined";
|
|
58
101
|
lines.push(``);
|
|
59
102
|
lines.push(`function _App() {`);
|
|
60
103
|
if (input.hasNarration) {
|
|
61
104
|
lines.push(` const _manifest = useNarrationManifest(${JSON.stringify(input.scenarioId)}, _resolveManifestUrl);`);
|
|
62
105
|
}
|
|
106
|
+
lines.push(` const _containerRef = useRef<HTMLDivElement>(null);`);
|
|
107
|
+
lines.push(` const [_stepIndex, _setStepIndex] = useState(0);`);
|
|
108
|
+
lines.push(` const [_cursorTarget, _setCursorTarget] = useState<string | undefined>(undefined);`);
|
|
109
|
+
lines.push(` const [_showRipple, _setShowRipple] = useState(true);`);
|
|
110
|
+
lines.push(` const [_dragging, _setDragging] = useState(false);`);
|
|
111
|
+
lines.push(` const [_viewport, _setViewport] = useState(VIEWPORT_TRANSFORM_IDENTITY);`);
|
|
112
|
+
lines.push(``);
|
|
113
|
+
// Reset the cursor when the step changes so a prior step's target never
|
|
114
|
+
// lingers; the new step's interactions re-set it at their scheduled time.
|
|
115
|
+
lines.push(` const _handleStepChange = useCallback((_data: any, index: number) => {`);
|
|
116
|
+
lines.push(` _setStepIndex(index);`);
|
|
117
|
+
lines.push(` _setCursorTarget(undefined);`);
|
|
118
|
+
lines.push(` }, []);`);
|
|
119
|
+
lines.push(``);
|
|
120
|
+
lines.push(` useStepInteractions({`);
|
|
121
|
+
lines.push(` stepIndex: _stepIndex,`);
|
|
122
|
+
lines.push(` narrationManifest: ${manifestExpr},`);
|
|
123
|
+
lines.push(` containerRef: _containerRef,`);
|
|
124
|
+
lines.push(` setCursorTarget: _setCursorTarget,`);
|
|
125
|
+
lines.push(` setShowRipple: _setShowRipple,`);
|
|
126
|
+
lines.push(` setDragging: _setDragging,`);
|
|
127
|
+
lines.push(` setViewportTransform: _setViewport,`);
|
|
128
|
+
lines.push(` steps: _steps,`);
|
|
129
|
+
lines.push(` });`);
|
|
130
|
+
lines.push(``);
|
|
63
131
|
lines.push(` const _bundle = {`);
|
|
64
132
|
lines.push(` id: ${JSON.stringify(input.scenarioId)},`);
|
|
65
133
|
lines.push(` steps: _steps,`);
|
|
66
|
-
lines.push(` narrationManifest: ${
|
|
134
|
+
lines.push(` narrationManifest: ${manifestExpr},`);
|
|
67
135
|
lines.push(` };`);
|
|
68
136
|
const open = input.providersPath ? `<_Providers>` : ``;
|
|
69
137
|
const close = input.providersPath ? `</_Providers>` : ``;
|
|
70
138
|
lines.push(` return (`);
|
|
71
|
-
lines.push(` <div className={
|
|
139
|
+
lines.push(` <div className={_rootClass}>`);
|
|
72
140
|
lines.push(` ${open}`);
|
|
73
|
-
lines.push(` <DemoViewport canonicalWidth={${input.canonicalWidth}} shellHeight={${input.shellHeight}}>`);
|
|
74
|
-
lines.push(` <
|
|
75
|
-
lines.push(` {
|
|
76
|
-
lines.push(`
|
|
141
|
+
lines.push(` <DemoViewport containerRef={_containerRef} canonicalWidth={${input.canonicalWidth}} shellHeight={${input.shellHeight}}>`);
|
|
142
|
+
lines.push(` <ViewportTransformLayer transform={_viewport}>`);
|
|
143
|
+
lines.push(` <ScenarioPlayer bundle={_bundle} embed onStepChange={_handleStepChange}>`);
|
|
144
|
+
lines.push(` {(data: any, stepIndex: number) => renderStep(data, stepIndex)}`);
|
|
145
|
+
lines.push(` </ScenarioPlayer>`);
|
|
146
|
+
lines.push(` </ViewportTransformLayer>`);
|
|
147
|
+
lines.push(` <Cursor target={_cursorTarget} containerRef={_containerRef} showRipple={_showRipple} isDragging={_dragging} />`);
|
|
77
148
|
lines.push(` </DemoViewport>`);
|
|
78
149
|
lines.push(` ${close}`);
|
|
79
150
|
lines.push(` </div>`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-embed-entry.js","sourceRoot":"","sources":["../../../src/pack/generate-embed-entry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAyBlC
|
|
1
|
+
{"version":3,"file":"generate-embed-entry.js","sourceRoot":"","sources":["../../../src/pack/generate-embed-entry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAyBlC;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,UAAU,kBAAkB,CAAC,KAAsB;IACvD,MAAM,YAAY,GAAG,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;IAChD,MAAM,WAAW,GAAG,GAAG,YAAY,QAAQ,CAAC;IAC5C,MAAM,YAAY,GAAG,OAAO,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;IAE3E,MAAM,KAAK,GAAa,EAAE,CAAC;IAE3B,kBAAkB;IAClB,uEAAuE;IACvE,6EAA6E;IAC7E,4EAA4E;IAC5E,4DAA4D;IAC5D,KAAK,CAAC,IAAI,CAAC,wDAAwD,CAAC,CAAC;IACrE,KAAK,CAAC,IAAI,CAAC,gDAAgD,CAAC,CAAC;IAC7D,MAAM,YAAY,GAAG;QACnB,gBAAgB;QAChB,cAAc;QACd,cAAc;QACd,QAAQ;QACR,qBAAqB;QACrB,wBAAwB;QACxB,6BAA6B;KAC9B,CAAC;IACF,IAAI,KAAK,CAAC,YAAY;QAAE,YAAY,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;IAClE,KAAK,CAAC,IAAI,CAAC,YAAY,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,0BAA0B,CAAC,CAAC;IAC1E,KAA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