@bastani/atomic 0.9.20-alpha.4 → 0.9.20-alpha.6
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/CHANGELOG.md +60 -0
- package/README.md +37 -0
- package/dist/builtin/intercom/CHANGELOG.md +16 -0
- package/dist/builtin/intercom/broker/broker.ts +110 -39
- package/dist/builtin/intercom/broker/client.ts +8 -1
- package/dist/builtin/intercom/index.bundle.mjs +61 -2
- package/dist/builtin/intercom/live-route-refusal.ts +69 -0
- package/dist/builtin/intercom/package.json +2 -2
- package/dist/builtin/intercom/recoverable-disconnect.ts +16 -4
- package/dist/builtin/intercom/skills/intercom/SKILL.md +43 -12
- package/dist/builtin/intercom/types.ts +3 -1
- package/dist/builtin/mcp/package.json +2 -2
- package/dist/builtin/subagents/CHANGELOG.md +18 -0
- package/dist/builtin/subagents/README.md +2 -0
- package/dist/builtin/subagents/agents/code-simplifier.md +1 -1
- package/dist/builtin/subagents/agents/codebase-analyzer.md +1 -1
- package/dist/builtin/subagents/agents/codebase-online-researcher.md +3 -3
- package/dist/builtin/subagents/agents/debugger.md +7 -5
- package/dist/builtin/subagents/agents/worker.md +4 -2
- package/dist/builtin/subagents/package.json +3 -3
- package/dist/builtin/subagents/skills/agent-browser/SKILL.md +56 -0
- package/dist/builtin/subagents/skills/cua-driver/BROWSER.md +494 -0
- package/dist/builtin/subagents/skills/cua-driver/EMBEDDING.md +578 -0
- package/dist/builtin/subagents/skills/cua-driver/LINUX.md +364 -0
- package/dist/builtin/subagents/skills/cua-driver/MACOS.md +509 -0
- package/dist/builtin/subagents/skills/cua-driver/README.md +113 -0
- package/dist/builtin/subagents/skills/cua-driver/RECORDING.md +162 -0
- package/dist/builtin/subagents/skills/cua-driver/SKILL.md +1105 -0
- package/dist/builtin/subagents/skills/cua-driver/WINDOWS.md +866 -0
- package/dist/builtin/subagents/skills/subagent/SKILL.md +32 -8
- package/dist/builtin/subagents/src/extension/index.bundle.mjs +7 -4
- package/dist/builtin/web-access/package.json +2 -2
- package/dist/builtin/workflows/CHANGELOG.md +43 -0
- package/dist/builtin/workflows/README.md +4 -2
- package/dist/builtin/workflows/builtin/adversarial-verification.js +3 -3
- package/dist/builtin/workflows/builtin/{chunk-1dydq7w3.js → chunk-2hzrv5y8.js} +202 -45
- package/dist/builtin/workflows/builtin/{chunk-n4yxrsm9.js → chunk-3tx8ry44.js} +3 -2
- package/dist/builtin/workflows/builtin/{chunk-n8g2da69.js → chunk-5724b0cf.js} +1 -1
- package/dist/builtin/workflows/builtin/{chunk-scgprmdj.js → chunk-7n51c5gh.js} +1 -1
- package/dist/builtin/workflows/builtin/{chunk-9y0f90rd.js → chunk-9z3ztr2a.js} +1 -1
- package/dist/builtin/workflows/builtin/{chunk-vt9zgr9d.js → chunk-deq63d9p.js} +4 -4
- package/dist/builtin/workflows/builtin/{chunk-k18g9me8.js → chunk-dxjxtgmp.js} +1 -1
- package/dist/builtin/workflows/builtin/{chunk-kf5xpbkz.js → chunk-ffdrv23t.js} +1 -1
- package/dist/builtin/workflows/builtin/{chunk-119kxb28.js → chunk-hmt5w62g.js} +72 -45
- package/dist/builtin/workflows/builtin/{chunk-hnbbb5r0.js → chunk-jngsbbpm.js} +4 -4
- package/dist/builtin/workflows/builtin/{chunk-d1xqh1rd.js → chunk-njmf5ze7.js} +1 -1
- package/dist/builtin/workflows/builtin/{chunk-sn5mchnx.js → chunk-vn0wb31x.js} +1 -1
- package/dist/builtin/workflows/builtin/classify-and-act.js +3 -3
- package/dist/builtin/workflows/builtin/fan-out-and-synthesize.js +3 -3
- package/dist/builtin/workflows/builtin/generate-and-filter.js +3 -3
- package/dist/builtin/workflows/builtin/goal.js +4 -4
- package/dist/builtin/workflows/builtin/index.d.ts +1 -1
- package/dist/builtin/workflows/builtin/index.js +12 -12
- package/dist/builtin/workflows/builtin/loop-until-done.js +3 -3
- package/dist/builtin/workflows/builtin/open-claude-design.d.ts +1 -1
- package/dist/builtin/workflows/builtin/open-claude-design.js +3 -3
- package/dist/builtin/workflows/builtin/ralph.js +4 -4
- package/dist/builtin/workflows/builtin/steering-context.js +1 -1
- package/dist/builtin/workflows/builtin/tournament.js +3 -3
- package/dist/builtin/workflows/package.json +2 -2
- package/dist/builtin/workflows/skills/impeccable/SKILL.md +18 -11
- package/dist/builtin/workflows/skills/impeccable/reference/adapt.md +1 -1
- package/dist/builtin/workflows/skills/impeccable/reference/adapt.native.md +1 -1
- package/dist/builtin/workflows/skills/impeccable/reference/animate.md +1 -1
- package/dist/builtin/workflows/skills/impeccable/reference/audit.md +5 -5
- package/dist/builtin/workflows/skills/impeccable/reference/audit.native.md +6 -6
- package/dist/builtin/workflows/skills/impeccable/reference/bolder.md +2 -2
- package/dist/builtin/workflows/skills/impeccable/reference/clarify.md +1 -1
- package/dist/builtin/workflows/skills/impeccable/reference/colorize.md +1 -1
- package/dist/builtin/workflows/skills/impeccable/reference/craft-floor.md +0 -6
- package/dist/builtin/workflows/skills/impeccable/reference/critique.md +19 -41
- package/dist/builtin/workflows/skills/impeccable/reference/degraded/asset-producer.md +11 -65
- package/dist/builtin/workflows/skills/impeccable/reference/degraded/documenter.md +3 -3
- package/dist/builtin/workflows/skills/impeccable/reference/degraded/finish-reviewer.md +4 -4
- package/dist/builtin/workflows/skills/impeccable/reference/degraded/manual-edit-applier.md +1 -1
- package/dist/builtin/workflows/skills/impeccable/reference/delight.md +1 -1
- package/dist/builtin/workflows/skills/impeccable/reference/distill.md +2 -2
- package/dist/builtin/workflows/skills/impeccable/reference/doctor.md +4 -4
- package/dist/builtin/workflows/skills/impeccable/reference/document.md +4 -4
- package/dist/builtin/workflows/skills/impeccable/reference/extract.md +1 -1
- package/dist/builtin/workflows/skills/impeccable/reference/harden.md +1 -1
- package/dist/builtin/workflows/skills/impeccable/reference/hooks.md +21 -21
- package/dist/builtin/workflows/skills/impeccable/reference/init.md +8 -8
- package/dist/builtin/workflows/skills/impeccable/reference/layout.md +2 -2
- package/dist/builtin/workflows/skills/impeccable/reference/live-setup.md +10 -8
- package/dist/builtin/workflows/skills/impeccable/reference/live.md +39 -38
- package/dist/builtin/workflows/skills/impeccable/reference/new-work.md +48 -21
- package/dist/builtin/workflows/skills/impeccable/reference/onboard.md +1 -1
- package/dist/builtin/workflows/skills/impeccable/reference/optimize.md +1 -1
- package/dist/builtin/workflows/skills/impeccable/reference/overdrive.md +1 -1
- package/dist/builtin/workflows/skills/impeccable/reference/polish.md +11 -3
- package/dist/builtin/workflows/skills/impeccable/reference/quieter.md +2 -2
- package/dist/builtin/workflows/skills/impeccable/reference/routing.md +13 -7
- package/dist/builtin/workflows/skills/impeccable/reference/typeset.md +2 -2
- package/dist/builtin/workflows/skills/impeccable/reference/visualize.md +13 -19
- package/dist/builtin/workflows/skills/impeccable/scripts/VERSION +1 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/data/font-index-failures.json +121 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/data/font-index.json +1 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/impeccable +212 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/impeccable.cmd +218 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/live-browser-dom.js +21 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/live-browser-ignores.js +242 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/live-browser-session.js +25 -4
- package/dist/builtin/workflows/skills/impeccable/scripts/live-browser.js +666 -197
- package/dist/builtin/workflows/skills/research-codebase/SKILL.md +1 -1
- package/dist/builtin/workflows/src/extension/index.bundle.mjs +352 -117
- package/dist/builtin/workflows/src/index.js +1403 -1218
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +15 -4
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/file-processor.d.ts +1 -1
- package/dist/cli/file-processor.d.ts.map +1 -1
- package/dist/cli/file-processor.js.map +1 -1
- package/dist/core/agent-session-auto-compaction.d.ts.map +1 -1
- package/dist/core/agent-session-auto-compaction.js +40 -12
- package/dist/core/agent-session-auto-compaction.js.map +1 -1
- package/dist/core/agent-session-bash.d.ts.map +1 -1
- package/dist/core/agent-session-bash.js +9 -8
- package/dist/core/agent-session-bash.js.map +1 -1
- package/dist/core/agent-session-boundaries.d.ts +68 -0
- package/dist/core/agent-session-boundaries.d.ts.map +1 -0
- package/dist/core/agent-session-boundaries.js +334 -0
- package/dist/core/agent-session-boundaries.js.map +1 -0
- package/dist/core/agent-session-compaction.js +1 -1
- package/dist/core/agent-session-compaction.js.map +1 -1
- package/dist/core/agent-session-events.d.ts.map +1 -1
- package/dist/core/agent-session-events.js +27 -13
- package/dist/core/agent-session-events.js.map +1 -1
- package/dist/core/agent-session-export.d.ts.map +1 -1
- package/dist/core/agent-session-export.js +16 -20
- package/dist/core/agent-session-export.js.map +1 -1
- package/dist/core/agent-session-message-queue.d.ts.map +1 -1
- package/dist/core/agent-session-message-queue.js +3 -2
- package/dist/core/agent-session-message-queue.js.map +1 -1
- package/dist/core/agent-session-methods.d.ts +30 -4
- package/dist/core/agent-session-methods.d.ts.map +1 -1
- package/dist/core/agent-session-methods.js.map +1 -1
- package/dist/core/agent-session-persistent-custom-messages.d.ts.map +1 -1
- package/dist/core/agent-session-persistent-custom-messages.js +2 -1
- package/dist/core/agent-session-persistent-custom-messages.js.map +1 -1
- package/dist/core/agent-session-prompt.d.ts.map +1 -1
- package/dist/core/agent-session-prompt.js +93 -25
- package/dist/core/agent-session-prompt.js.map +1 -1
- package/dist/core/agent-session-retry.d.ts.map +1 -1
- package/dist/core/agent-session-retry.js +4 -9
- package/dist/core/agent-session-retry.js.map +1 -1
- package/dist/core/agent-session-runtime.js +1 -1
- package/dist/core/agent-session-runtime.js.map +1 -1
- package/dist/core/agent-session-tool-hooks.d.ts.map +1 -1
- package/dist/core/agent-session-tool-hooks.js +15 -5
- package/dist/core/agent-session-tool-hooks.js.map +1 -1
- package/dist/core/agent-session-tree.d.ts.map +1 -1
- package/dist/core/agent-session-tree.js +2 -3
- package/dist/core/agent-session-tree.js.map +1 -1
- package/dist/core/agent-session-types.d.ts +6 -0
- package/dist/core/agent-session-types.d.ts.map +1 -1
- package/dist/core/agent-session-types.js.map +1 -1
- package/dist/core/agent-session.d.ts +15 -2
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +17 -1
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
- package/dist/core/compaction/branch-summarization.js +1 -0
- package/dist/core/compaction/branch-summarization.js.map +1 -1
- package/dist/core/compaction/compaction-boundary.d.ts.map +1 -1
- package/dist/core/compaction/compaction-boundary.js +11 -6
- package/dist/core/compaction/compaction-boundary.js.map +1 -1
- package/dist/core/compaction/compaction.d.ts +3 -1
- package/dist/core/compaction/compaction.d.ts.map +1 -1
- package/dist/core/compaction/compaction.js +37 -0
- package/dist/core/compaction/compaction.js.map +1 -1
- package/dist/core/crash-log.d.ts +6 -0
- package/dist/core/crash-log.d.ts.map +1 -0
- package/dist/core/crash-log.js +69 -0
- package/dist/core/crash-log.js.map +1 -0
- package/dist/core/execution-model-router.d.ts +3 -0
- package/dist/core/execution-model-router.d.ts.map +1 -1
- package/dist/core/execution-model-router.js +45 -16
- package/dist/core/execution-model-router.js.map +1 -1
- package/dist/core/export-html/template-js/tree-filter-render.js +6 -1
- package/dist/core/export-html/template.js +6 -1
- package/dist/core/extensions/agent-events.d.ts +69 -3
- package/dist/core/extensions/agent-events.d.ts.map +1 -1
- package/dist/core/extensions/agent-events.js.map +1 -1
- package/dist/core/extensions/api-types.d.ts +5 -3
- package/dist/core/extensions/api-types.d.ts.map +1 -1
- package/dist/core/extensions/api-types.js.map +1 -1
- package/dist/core/extensions/event-results.d.ts +3 -0
- package/dist/core/extensions/event-results.d.ts.map +1 -1
- package/dist/core/extensions/event-results.js.map +1 -1
- package/dist/core/extensions/event-types.d.ts +2 -2
- package/dist/core/extensions/event-types.d.ts.map +1 -1
- package/dist/core/extensions/event-types.js.map +1 -1
- package/dist/core/extensions/index.d.ts +1 -1
- package/dist/core/extensions/index.d.ts.map +1 -1
- package/dist/core/extensions/index.js.map +1 -1
- package/dist/core/extensions/provider-types.d.ts +2 -0
- package/dist/core/extensions/provider-types.d.ts.map +1 -1
- package/dist/core/extensions/provider-types.js.map +1 -1
- package/dist/core/extensions/runner-events.d.ts +16 -2
- package/dist/core/extensions/runner-events.d.ts.map +1 -1
- package/dist/core/extensions/runner-events.js +98 -5
- package/dist/core/extensions/runner-events.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +3 -2
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +4 -1
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js.map +1 -1
- package/dist/core/messages.d.ts +10 -0
- package/dist/core/messages.d.ts.map +1 -1
- package/dist/core/messages.js +57 -0
- package/dist/core/messages.js.map +1 -1
- package/dist/core/model-config.d.ts +52 -0
- package/dist/core/model-config.d.ts.map +1 -1
- package/dist/core/model-config.js +16 -0
- package/dist/core/model-config.js.map +1 -1
- package/dist/core/model-resolver-defaults.d.ts.map +1 -1
- package/dist/core/model-resolver-defaults.js +2 -1
- package/dist/core/model-resolver-defaults.js.map +1 -1
- package/dist/core/model-routing-task.d.ts +1 -1
- package/dist/core/model-routing-task.d.ts.map +1 -1
- package/dist/core/model-routing-task.js +4 -3
- package/dist/core/model-routing-task.js.map +1 -1
- package/dist/core/prompt-templates-async.d.ts +2 -2
- package/dist/core/prompt-templates-async.d.ts.map +1 -1
- package/dist/core/prompt-templates-async.js +57 -29
- package/dist/core/prompt-templates-async.js.map +1 -1
- package/dist/core/prompt-templates.d.ts +6 -1
- package/dist/core/prompt-templates.d.ts.map +1 -1
- package/dist/core/prompt-templates.js +61 -35
- package/dist/core/prompt-templates.js.map +1 -1
- package/dist/core/provider-composer-internal.d.ts +1 -0
- package/dist/core/provider-composer-internal.d.ts.map +1 -1
- package/dist/core/provider-composer-internal.js +19 -0
- package/dist/core/provider-composer-internal.js.map +1 -1
- package/dist/core/resource-loader-assets.d.ts.map +1 -1
- package/dist/core/resource-loader-assets.js +6 -6
- package/dist/core/resource-loader-assets.js.map +1 -1
- package/dist/core/sdk.js +3 -2
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-manager-core.d.ts +10 -3
- package/dist/core/session-manager-core.d.ts.map +1 -1
- package/dist/core/session-manager-core.js +65 -7
- package/dist/core/session-manager-core.js.map +1 -1
- package/dist/core/session-manager-entries.d.ts +4 -1
- package/dist/core/session-manager-entries.d.ts.map +1 -1
- package/dist/core/session-manager-entries.js +8 -0
- package/dist/core/session-manager-entries.js.map +1 -1
- package/dist/core/session-manager-history.d.ts +16 -1
- package/dist/core/session-manager-history.d.ts.map +1 -1
- package/dist/core/session-manager-history.js +105 -42
- package/dist/core/session-manager-history.js.map +1 -1
- package/dist/core/session-manager-types.d.ts +30 -3
- package/dist/core/session-manager-types.d.ts.map +1 -1
- package/dist/core/session-manager-types.js.map +1 -1
- package/dist/core/session-manager.d.ts +2 -2
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +1 -1
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/structured-output/index.d.ts +0 -1
- package/dist/core/structured-output/index.d.ts.map +1 -1
- package/dist/core/structured-output/index.js +3 -15
- package/dist/core/structured-output/index.js.map +1 -1
- package/dist/core/structured-output/jev-client.d.ts +4 -8
- package/dist/core/structured-output/jev-client.d.ts.map +1 -1
- package/dist/core/structured-output/jev-client.js +36 -32
- package/dist/core/structured-output/jev-client.js.map +1 -1
- package/dist/core/structured-output/jev.d.ts.map +1 -1
- package/dist/core/structured-output/jev.js +4 -12
- package/dist/core/structured-output/jev.js.map +1 -1
- package/dist/core/structured-output/types.d.ts +0 -2
- package/dist/core/structured-output/types.d.ts.map +1 -1
- package/dist/core/structured-output/types.js.map +1 -1
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +2 -1
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tools/read.d.ts +4 -0
- package/dist/core/tools/read.d.ts.map +1 -1
- package/dist/core/tools/read.js +5 -1
- package/dist/core/tools/read.js.map +1 -1
- package/dist/index-extensions.d.ts +1 -1
- package/dist/index-extensions.d.ts.map +1 -1
- package/dist/index-extensions.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/main-app-mode.d.ts +1 -1
- package/dist/main-app-mode.d.ts.map +1 -1
- package/dist/main-app-mode.js +3 -2
- package/dist/main-app-mode.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +1 -1
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/components/chat-message-renderer.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-message-renderer.js +4 -0
- package/dist/modes/interactive/components/chat-message-renderer.js.map +1 -1
- package/dist/modes/interactive/components/tree-selector-content.d.ts.map +1 -1
- package/dist/modes/interactive/components/tree-selector-content.js +6 -0
- package/dist/modes/interactive/components/tree-selector-content.js.map +1 -1
- package/dist/modes/interactive/components/tree-selector-model.d.ts.map +1 -1
- package/dist/modes/interactive/components/tree-selector-model.js +1 -0
- package/dist/modes/interactive/components/tree-selector-model.js.map +1 -1
- package/dist/modes/interactive/interactive-agent-events.js +17 -1
- package/dist/modes/interactive/interactive-agent-events.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-helpers.d.ts +1 -0
- package/dist/modes/interactive/interactive-mode-helpers.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-helpers.js +16 -0
- package/dist/modes/interactive/interactive-mode-helpers.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-surface.d.ts +1 -0
- package/dist/modes/interactive/interactive-mode-surface.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-surface.js.map +1 -1
- package/dist/modes/interactive/interactive-process-lifecycle.js +13 -1
- package/dist/modes/interactive/interactive-process-lifecycle.js.map +1 -1
- package/dist/modes/interactive/interactive-session-runtime.js +5 -1
- package/dist/modes/interactive/interactive-session-runtime.js.map +1 -1
- package/dist/utils/mime.js +1 -1
- package/dist/utils/mime.js.map +1 -1
- package/dist/utils/tool-result-images.d.ts +3 -1
- package/dist/utils/tool-result-images.d.ts.map +1 -1
- package/dist/utils/tool-result-images.js +4 -1
- package/dist/utils/tool-result-images.js.map +1 -1
- package/docs/compaction.md +5 -1
- package/docs/computer-use.md +123 -73
- package/docs/extensions/events.md +75 -7
- package/docs/extensions.md +6 -2
- package/docs/getting-started/first-session.md +3 -2
- package/docs/getting-started/installation.md +6 -2
- package/docs/intercom/operations.md +13 -1
- package/docs/intercom.md +7 -2
- package/docs/models/evals.md +68 -82
- package/docs/models/model-selection.md +11 -7
- package/docs/models/reference.md +30 -2
- package/docs/packages.md +2 -0
- package/docs/prompt-templates.md +1 -0
- package/docs/providers.md +8 -2
- package/docs/quickstart.md +1 -1
- package/docs/sdk/reference.md +1 -2
- package/docs/sdk/structured-decisions.md +10 -9
- package/docs/sdk.md +13 -2
- package/docs/session-format.md +17 -2
- package/docs/settings.md +1 -1
- package/docs/skills.md +3 -1
- package/docs/subagents/reference.md +6 -6
- package/docs/subagents.md +8 -2
- package/docs/usage.md +2 -0
- package/docs/windows.md +1 -1
- package/docs/workflows/api-reference.md +5 -4
- package/docs/workflows/authoring.md +191 -0
- package/docs/workflows/builtins.md +2 -2
- package/docs/workflows/operations.md +10 -4
- package/docs/workflows/reliable-design.md +12 -1
- package/docs/workflows/verification.md +27 -14
- package/npm-shrinkwrap.json +69 -69
- package/package.json +8 -8
- package/dist/builtin/subagents/skills/playwright-cli/SKILL.md +0 -420
- package/dist/builtin/subagents/skills/playwright-cli/references/element-attributes.md +0 -23
- package/dist/builtin/subagents/skills/playwright-cli/references/playwright-tests.md +0 -39
- package/dist/builtin/subagents/skills/playwright-cli/references/request-mocking.md +0 -87
- package/dist/builtin/subagents/skills/playwright-cli/references/running-code.md +0 -241
- package/dist/builtin/subagents/skills/playwright-cli/references/session-management.md +0 -225
- package/dist/builtin/subagents/skills/playwright-cli/references/storage-state.md +0 -275
- package/dist/builtin/subagents/skills/playwright-cli/references/test-generation.md +0 -433
- package/dist/builtin/subagents/skills/playwright-cli/references/tracing.md +0 -139
- package/dist/builtin/subagents/skills/playwright-cli/references/video-recording.md +0 -143
- package/dist/builtin/workflows/skills/impeccable/agents/impeccable_asset_producer.toml +0 -94
- package/dist/builtin/workflows/skills/impeccable/agents/impeccable_documenter.toml +0 -27
- package/dist/builtin/workflows/skills/impeccable/agents/impeccable_finish_reviewer.toml +0 -41
- package/dist/builtin/workflows/skills/impeccable/agents/impeccable_manual_edit_applier.toml +0 -95
- package/dist/builtin/workflows/skills/impeccable/agents/openai.yaml +0 -4
- package/dist/builtin/workflows/skills/impeccable/scripts/concept-seed.mjs +0 -695
- package/dist/builtin/workflows/skills/impeccable/scripts/context-signals.mjs +0 -325
- package/dist/builtin/workflows/skills/impeccable/scripts/context.mjs +0 -1503
- package/dist/builtin/workflows/skills/impeccable/scripts/critique-storage.mjs +0 -222
- package/dist/builtin/workflows/skills/impeccable/scripts/detect-csp.mjs +0 -198
- package/dist/builtin/workflows/skills/impeccable/scripts/detect.mjs +0 -21
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/browser/injected/index.mjs +0 -2073
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/cli/main.mjs +0 -432
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/design-system.mjs +0 -1121
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/detect-antipatterns-browser.js +0 -8746
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/detect-antipatterns.mjs +0 -51
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/engines/browser/detect-url.mjs +0 -376
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/engines/regex/detect-text.mjs +0 -1168
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/engines/static-html/css-cascade.mjs +0 -1192
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/engines/static-html/detect-html.mjs +0 -290
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/engines/visual/screenshot-contrast.mjs +0 -189
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/findings.mjs +0 -18
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/node/file-system.mjs +0 -213
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/profile/profiler.mjs +0 -166
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/registry/antipatterns.mjs +0 -617
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/rules/checks.mjs +0 -5534
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/shared/color.mjs +0 -588
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/shared/constants.mjs +0 -112
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/shared/fonts.mjs +0 -30
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/shared/inline-ignores.mjs +0 -148
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/shared/page.mjs +0 -35
- package/dist/builtin/workflows/skills/impeccable/scripts/doctor.mjs +0 -338
- package/dist/builtin/workflows/skills/impeccable/scripts/embed-prompt.mjs +0 -270
- package/dist/builtin/workflows/skills/impeccable/scripts/generate-image.mjs +0 -277
- package/dist/builtin/workflows/skills/impeccable/scripts/hook-admin.mjs +0 -783
- package/dist/builtin/workflows/skills/impeccable/scripts/hook-lib.mjs +0 -2305
- package/dist/builtin/workflows/skills/impeccable/scripts/hook.mjs +0 -78
- package/dist/builtin/workflows/skills/impeccable/scripts/lib/artifact-schema.mjs +0 -93
- package/dist/builtin/workflows/skills/impeccable/scripts/lib/composition-catalog.mjs +0 -200
- package/dist/builtin/workflows/skills/impeccable/scripts/lib/concept-catalog.mjs +0 -395
- package/dist/builtin/workflows/skills/impeccable/scripts/lib/design-parser.mjs +0 -925
- package/dist/builtin/workflows/skills/impeccable/scripts/lib/impeccable-config.mjs +0 -640
- package/dist/builtin/workflows/skills/impeccable/scripts/lib/impeccable-paths.mjs +0 -137
- package/dist/builtin/workflows/skills/impeccable/scripts/lib/is-generated.mjs +0 -72
- package/dist/builtin/workflows/skills/impeccable/scripts/lib/open-system-browser.mjs +0 -57
- package/dist/builtin/workflows/skills/impeccable/scripts/lib/provider.mjs +0 -5
- package/dist/builtin/workflows/skills/impeccable/scripts/lib/roll-selection.mjs +0 -369
- package/dist/builtin/workflows/skills/impeccable/scripts/lib/staleness-deep.mjs +0 -483
- package/dist/builtin/workflows/skills/impeccable/scripts/lib/staleness-notice.mjs +0 -169
- package/dist/builtin/workflows/skills/impeccable/scripts/lib/staleness.mjs +0 -528
- package/dist/builtin/workflows/skills/impeccable/scripts/lib/surface-briefs.mjs +0 -151
- package/dist/builtin/workflows/skills/impeccable/scripts/lib/target-args.mjs +0 -42
- package/dist/builtin/workflows/skills/impeccable/scripts/lib/target-slug.mjs +0 -33
- package/dist/builtin/workflows/skills/impeccable/scripts/lib/template-extensions.mjs +0 -146
- package/dist/builtin/workflows/skills/impeccable/scripts/live/accept-css.mjs +0 -617
- package/dist/builtin/workflows/skills/impeccable/scripts/live/accept-verify.mjs +0 -71
- package/dist/builtin/workflows/skills/impeccable/scripts/live/browser-script-parts.mjs +0 -77
- package/dist/builtin/workflows/skills/impeccable/scripts/live/completion.mjs +0 -28
- package/dist/builtin/workflows/skills/impeccable/scripts/live/event-validation.mjs +0 -199
- package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/astro.mjs +0 -47
- package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/detect-utils.mjs +0 -157
- package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/index.mjs +0 -143
- package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/journal.mjs +0 -205
- package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/nextjs.mjs +0 -49
- package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/nuxt.mjs +0 -170
- package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/script-src.mjs +0 -26
- package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/static-html.mjs +0 -26
- package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/sveltekit.mjs +0 -71
- package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/tag-strategy.mjs +0 -247
- package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/tanstack-start.mjs +0 -70
- package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/vite-generic.mjs +0 -42
- package/dist/builtin/workflows/skills/impeccable/scripts/live/generation-preflight.mjs +0 -149
- package/dist/builtin/workflows/skills/impeccable/scripts/live/insert-ui.mjs +0 -458
- package/dist/builtin/workflows/skills/impeccable/scripts/live/instructions.mjs +0 -169
- package/dist/builtin/workflows/skills/impeccable/scripts/live/manual-apply.mjs +0 -939
- package/dist/builtin/workflows/skills/impeccable/scripts/live/manual-edit-routes.mjs +0 -357
- package/dist/builtin/workflows/skills/impeccable/scripts/live/manual-edits-buffer.mjs +0 -152
- package/dist/builtin/workflows/skills/impeccable/scripts/live/poll-lanes.mjs +0 -14
- package/dist/builtin/workflows/skills/impeccable/scripts/live/roots.mjs +0 -670
- package/dist/builtin/workflows/skills/impeccable/scripts/live/session-store.mjs +0 -563
- package/dist/builtin/workflows/skills/impeccable/scripts/live/source-lock.mjs +0 -105
- package/dist/builtin/workflows/skills/impeccable/scripts/live/source-search.mjs +0 -105
- package/dist/builtin/workflows/skills/impeccable/scripts/live/svelte-ast.mjs +0 -969
- package/dist/builtin/workflows/skills/impeccable/scripts/live/svelte-component.mjs +0 -1401
- package/dist/builtin/workflows/skills/impeccable/scripts/live/sveltekit-adapter.mjs +0 -314
- package/dist/builtin/workflows/skills/impeccable/scripts/live/tanstack-adapter.mjs +0 -280
- package/dist/builtin/workflows/skills/impeccable/scripts/live/ui-surfaces.mjs +0 -75
- package/dist/builtin/workflows/skills/impeccable/scripts/live/vocabulary.mjs +0 -171
- package/dist/builtin/workflows/skills/impeccable/scripts/live-accept.mjs +0 -961
- package/dist/builtin/workflows/skills/impeccable/scripts/live-commit-manual-edits.mjs +0 -1244
- package/dist/builtin/workflows/skills/impeccable/scripts/live-complete.mjs +0 -107
- package/dist/builtin/workflows/skills/impeccable/scripts/live-copy-edit-agent.mjs +0 -800
- package/dist/builtin/workflows/skills/impeccable/scripts/live-discard-manual-edits.mjs +0 -51
- package/dist/builtin/workflows/skills/impeccable/scripts/live-inject.mjs +0 -515
- package/dist/builtin/workflows/skills/impeccable/scripts/live-insert.mjs +0 -292
- package/dist/builtin/workflows/skills/impeccable/scripts/live-manual-edit-evidence.mjs +0 -371
- package/dist/builtin/workflows/skills/impeccable/scripts/live-poll.mjs +0 -427
- package/dist/builtin/workflows/skills/impeccable/scripts/live-resume.mjs +0 -123
- package/dist/builtin/workflows/skills/impeccable/scripts/live-server.mjs +0 -1675
- package/dist/builtin/workflows/skills/impeccable/scripts/live-status.mjs +0 -71
- package/dist/builtin/workflows/skills/impeccable/scripts/live-target.mjs +0 -30
- package/dist/builtin/workflows/skills/impeccable/scripts/live-wrap.mjs +0 -927
- package/dist/builtin/workflows/skills/impeccable/scripts/live.mjs +0 -365
- package/dist/builtin/workflows/skills/impeccable/scripts/palette.mjs +0 -628
- package/dist/builtin/workflows/skills/impeccable/scripts/pin.mjs +0 -224
- package/dist/builtin/workflows/skills/impeccable/scripts/serve-question.mjs +0 -1540
- package/dist/builtin/workflows/skills/impeccable/scripts/surface-brief.mjs +0 -74
|
@@ -121,6 +121,10 @@
|
|
|
121
121
|
let hoveredElement = null;
|
|
122
122
|
let selectedElement = null;
|
|
123
123
|
let currentSessionId = null;
|
|
124
|
+
// Advances when the user begins configuring a fresh edit, before that edit
|
|
125
|
+
// has a server session id. Deferred recovery captures this revision so an
|
|
126
|
+
// older accept/discard can never reload over a replacement configuration.
|
|
127
|
+
let liveInteractionRevision = 0;
|
|
124
128
|
let expectedVariants = 0;
|
|
125
129
|
let arrivedVariants = 0;
|
|
126
130
|
let visibleVariant = 0;
|
|
@@ -188,6 +192,9 @@
|
|
|
188
192
|
// when the real accept result arrives or a new session starts.
|
|
189
193
|
let awaitingAcceptResult = null;
|
|
190
194
|
let variantObserver = null;
|
|
195
|
+
const discardedFrameworkWrapperWatchers = new Map();
|
|
196
|
+
const handledRuntimeWrapperWatchers = new Map();
|
|
197
|
+
const handledRuntimeWrapperReloadSessions = new Set();
|
|
191
198
|
let variantSelectionInFlight = false;
|
|
192
199
|
let variantSelectionPromise = null;
|
|
193
200
|
let recoveringEmptyCycling = false;
|
|
@@ -208,6 +215,7 @@
|
|
|
208
215
|
const SCROLL_ANCHOR_LOCK_ID = 'impeccable-scroll-anchor-lock';
|
|
209
216
|
const VARIANT_STATE_STYLE_ID = 'impeccable-variant-state';
|
|
210
217
|
const DISCARD_STATE_STYLE_ID = 'impeccable-discard-state';
|
|
218
|
+
const HANDLED_WRAPPER_RELOAD_KEY = PREFIX + '-handled-wrapper-reload';
|
|
211
219
|
|
|
212
220
|
// Dedicated key for scroll position - SEPARATE from LS_KEY so that
|
|
213
221
|
// saveSession's state updates don't clobber a carefully-captured scrollY.
|
|
@@ -270,6 +278,7 @@
|
|
|
270
278
|
desc,
|
|
271
279
|
rectIsUsableAnchor,
|
|
272
280
|
makeFrozenAnchor,
|
|
281
|
+
hasFrameworkHmrOwnership,
|
|
273
282
|
id8,
|
|
274
283
|
cssId,
|
|
275
284
|
liveUiRoot,
|
|
@@ -2034,6 +2043,16 @@
|
|
|
2034
2043
|
syncSteerQueueHint();
|
|
2035
2044
|
}
|
|
2036
2045
|
|
|
2046
|
+
function beginNewLiveConfiguration() {
|
|
2047
|
+
liveInteractionRevision += 1;
|
|
2048
|
+
setLiveState('CONFIGURING');
|
|
2049
|
+
}
|
|
2050
|
+
|
|
2051
|
+
function deferredRecoverySuperseded(sessionId, recoveryRevision) {
|
|
2052
|
+
return liveInteractionRevision !== recoveryRevision
|
|
2053
|
+
|| !!(currentSessionId && currentSessionId !== sessionId);
|
|
2054
|
+
}
|
|
2055
|
+
|
|
2037
2056
|
/** Element used to position the floating bar / shader during a session. */
|
|
2038
2057
|
function resolveBarAnchor() {
|
|
2039
2058
|
if (svelteComponentSession?.sessionId === currentSessionId && (state === 'GENERATING' || state === 'CYCLING')) {
|
|
@@ -2041,7 +2060,7 @@
|
|
|
2041
2060
|
if (anchor) return anchor;
|
|
2042
2061
|
}
|
|
2043
2062
|
if (currentSessionId && (state === 'GENERATING' || state === 'CYCLING')) {
|
|
2044
|
-
const wrapper =
|
|
2063
|
+
const wrapper = findVariantsWrapper(currentSessionId);
|
|
2045
2064
|
if (wrapper) {
|
|
2046
2065
|
const variantCount = wrapper.querySelectorAll('[data-impeccable-variant]:not([data-impeccable-variant="original"])').length;
|
|
2047
2066
|
if (variantCount > 0 && visibleVariant > 0) {
|
|
@@ -2112,14 +2131,14 @@
|
|
|
2112
2131
|
|
|
2113
2132
|
function isInsertGeneratingSession() {
|
|
2114
2133
|
if (state !== 'GENERATING' || !currentSessionId) return false;
|
|
2115
|
-
const wrapper =
|
|
2134
|
+
const wrapper = findVariantsWrapper(currentSessionId);
|
|
2116
2135
|
return !!wrapper && wrapper.dataset.impeccableMode === 'insert';
|
|
2117
2136
|
}
|
|
2118
2137
|
|
|
2119
2138
|
/** Recreate the dotted placeholder if Astro/Vite HMR removed it mid-generation. */
|
|
2120
2139
|
function ensureInsertPlaceholder() {
|
|
2121
2140
|
if (!isInsertGeneratingSession()) return placeholderElement;
|
|
2122
|
-
const wrapper =
|
|
2141
|
+
const wrapper = findVariantsWrapper(currentSessionId);
|
|
2123
2142
|
const variantCount = wrapper.querySelectorAll('[data-impeccable-variant]:not([data-impeccable-variant="original"])').length;
|
|
2124
2143
|
if (variantCount > 0) return placeholderElement;
|
|
2125
2144
|
if (placeholderElement && document.body.contains(placeholderElement)) return placeholderElement;
|
|
@@ -3137,7 +3156,7 @@
|
|
|
3137
3156
|
|| svelteComponentSession.wrapperEl
|
|
3138
3157
|
|| null;
|
|
3139
3158
|
}
|
|
3140
|
-
const wrapper =
|
|
3159
|
+
const wrapper = findVariantsWrapper(currentSessionId);
|
|
3141
3160
|
if (!wrapper) return null;
|
|
3142
3161
|
return wrapper.querySelector('[data-impeccable-variant="' + visibleVariant + '"]');
|
|
3143
3162
|
}
|
|
@@ -4881,7 +4900,7 @@
|
|
|
4881
4900
|
return Object.values(svelteComponentSession.paramsByVariant || {})
|
|
4882
4901
|
.reduce((total, params) => total + (Array.isArray(params) ? params.length : 0), 0);
|
|
4883
4902
|
}
|
|
4884
|
-
const wrapper =
|
|
4903
|
+
const wrapper = findVariantsWrapper(currentSessionId);
|
|
4885
4904
|
if (!wrapper) return 0;
|
|
4886
4905
|
return [...wrapper.querySelectorAll('[data-impeccable-variant]:not([data-impeccable-variant="original"])')]
|
|
4887
4906
|
.reduce((total, variant) => total + parseVariantParams(variant).length, 0);
|
|
@@ -4902,6 +4921,13 @@
|
|
|
4902
4921
|
saveSession();
|
|
4903
4922
|
}
|
|
4904
4923
|
|
|
4924
|
+
function completeParameterGenerationIfReady() {
|
|
4925
|
+
if (expectedVariants <= 0 || arrivedVariants < expectedVariants) return;
|
|
4926
|
+
if (parameterGenerationState === 'pending' || parameterGenerationState === 'loading') {
|
|
4927
|
+
completeParameterPublication();
|
|
4928
|
+
}
|
|
4929
|
+
}
|
|
4930
|
+
|
|
4905
4931
|
function toggleTunePopover() {
|
|
4906
4932
|
if (pendingApplyInFlight) { showManualApplyBusyToast(); return; }
|
|
4907
4933
|
if (tuneOpen) { closeTunePopover(); return; }
|
|
@@ -4978,7 +5004,7 @@
|
|
|
4978
5004
|
scheduleCyclingBarSync(sessionId, num);
|
|
4979
5005
|
return true;
|
|
4980
5006
|
}
|
|
4981
|
-
const wrapper =
|
|
5007
|
+
const wrapper = findVariantsWrapper(sessionId);
|
|
4982
5008
|
if (!wrapper) return false;
|
|
4983
5009
|
updateVariantStateStylesheet(sessionId, num);
|
|
4984
5010
|
// Unconditional refresh - covers first-reveal (no-op if state isn't
|
|
@@ -5029,7 +5055,7 @@
|
|
|
5029
5055
|
&& el.parentElement
|
|
5030
5056
|
&& document.body.contains(el)
|
|
5031
5057
|
&& !own(el)
|
|
5032
|
-
&& !el.closest?.('[data-impeccable-variants]');
|
|
5058
|
+
&& !el.closest?.('[data-impeccable-variants],[data-impeccable-carbonize]');
|
|
5033
5059
|
}
|
|
5034
5060
|
|
|
5035
5061
|
function elementMatchesOriginalMarkup(liveEl, origContent) {
|
|
@@ -5301,10 +5327,6 @@
|
|
|
5301
5327
|
if (session) session.styleEl = null;
|
|
5302
5328
|
}
|
|
5303
5329
|
|
|
5304
|
-
function scopeCssToSveltePreview(css, sessionId) {
|
|
5305
|
-
const prefix = '[data-impeccable-variants="' + String(sessionId).replace(/\\/g, '\\\\').replace(/"/g, '\\"') + '"] ';
|
|
5306
|
-
return scopeCssBlock(String(css || ''), prefix).trim();
|
|
5307
|
-
}
|
|
5308
5330
|
|
|
5309
5331
|
function scopeCssBlock(css, prefix) {
|
|
5310
5332
|
let out = '';
|
|
@@ -5798,9 +5820,10 @@
|
|
|
5798
5820
|
return;
|
|
5799
5821
|
}
|
|
5800
5822
|
setLiveState('CYCLING');
|
|
5823
|
+
hideShaderOverlay();
|
|
5801
5824
|
showOrUpdateCyclingBar();
|
|
5802
5825
|
saveSession();
|
|
5803
|
-
|
|
5826
|
+
completeParameterGenerationIfReady();
|
|
5804
5827
|
return;
|
|
5805
5828
|
}
|
|
5806
5829
|
|
|
@@ -5888,7 +5911,7 @@
|
|
|
5888
5911
|
refreshParamsPanel();
|
|
5889
5912
|
positionBar();
|
|
5890
5913
|
saveSession();
|
|
5891
|
-
|
|
5914
|
+
completeParameterGenerationIfReady();
|
|
5892
5915
|
console.log('[impeccable] Mounted ' + arrivedVariants + ' ' + manifest.framework + ' component variants.');
|
|
5893
5916
|
} catch (err) {
|
|
5894
5917
|
console.error('[impeccable] Failed to mount component-preview variants:', err);
|
|
@@ -6190,6 +6213,137 @@
|
|
|
6190
6213
|
showToast('The previous live session no longer matches the source file, so it was discarded. Pick an element to start fresh.', 6000);
|
|
6191
6214
|
}
|
|
6192
6215
|
|
|
6216
|
+
function isJsxSourceFile(filePath) {
|
|
6217
|
+
return /\.[cm]?[jt]sx$/i.test(String(filePath || ''));
|
|
6218
|
+
}
|
|
6219
|
+
|
|
6220
|
+
function sourceHasSessionWrapper(text, sessionId) {
|
|
6221
|
+
const src = String(text || '');
|
|
6222
|
+
return src.indexOf('data-impeccable-variants="' + sessionId + '"') !== -1
|
|
6223
|
+
|| src.indexOf("data-impeccable-variants='" + sessionId + "'") !== -1
|
|
6224
|
+
|| src.indexOf('impeccable-variants-start ' + sessionId) !== -1;
|
|
6225
|
+
}
|
|
6226
|
+
|
|
6227
|
+
/**
|
|
6228
|
+
* Orphan probe for JSX targets (#439 + #454). An unmounted wrapper and a
|
|
6229
|
+
* wrapper deleted from source look identical in the DOM, and only the second
|
|
6230
|
+
* is an orphan, so the DOM alone cannot decide. #454 forbids parsing or
|
|
6231
|
+
* injecting raw JSX; reading the file as plain text and matching the session
|
|
6232
|
+
* marker honors that, because no DOM is ever built from what comes back.
|
|
6233
|
+
* Marker present means the component is simply not mounted right now (a
|
|
6234
|
+
* closed modal, another route) and the variant observer keeps waiting.
|
|
6235
|
+
* Marker absent after the same retry budget the HTML path uses means the
|
|
6236
|
+
* file was edited out from under the session, which no reload, HMR push, or
|
|
6237
|
+
* server restart can repair, so the session self-discards and hands the
|
|
6238
|
+
* surface back to the picker.
|
|
6239
|
+
*/
|
|
6240
|
+
function probeJsxWrapperForOrphan(filePath, sessionId, opts) {
|
|
6241
|
+
const attempt = opts._orphanAttempt || 0;
|
|
6242
|
+
const url = 'http://localhost:' + PORT + '/source?token=' + TOKEN + '&path=' + encodeURIComponent(filePath);
|
|
6243
|
+
const stillActive = () => sessionId === currentSessionId && (state === 'GENERATING' || state === 'CYCLING');
|
|
6244
|
+
const retryLater = () => {
|
|
6245
|
+
setTimeout(() => {
|
|
6246
|
+
if (!stillActive()) return;
|
|
6247
|
+
injectVariantsFromSource(filePath, sessionId, { ...opts, _orphanAttempt: attempt + 1 });
|
|
6248
|
+
}, COMPLETED_SOURCE_FALLBACK_RETRY_MS);
|
|
6249
|
+
};
|
|
6250
|
+
// Discarding is durable (the session moves to the discarded phase and the
|
|
6251
|
+
// picker replaces it), so it needs evidence that the wrapper is gone: a
|
|
6252
|
+
// read that answers without the marker, or a 404 (the file itself was
|
|
6253
|
+
// renamed or deleted). Either kind retries on the shared budget first.
|
|
6254
|
+
// A read that fails for any other reason (the server briefly away, a
|
|
6255
|
+
// transient fetch error) says nothing about the wrapper; after the budget
|
|
6256
|
+
// the session is kept, the user told, and the next event retries.
|
|
6257
|
+
const onNoWrapper = (reason) => {
|
|
6258
|
+
if (!stillActive()) return;
|
|
6259
|
+
if (attempt < COMPLETED_SOURCE_FALLBACK_RETRIES) { retryLater(); return; }
|
|
6260
|
+
discardOrphanedSession(reason);
|
|
6261
|
+
};
|
|
6262
|
+
const onUnreadable = (detail) => {
|
|
6263
|
+
if (!stillActive()) return;
|
|
6264
|
+
if (attempt < COMPLETED_SOURCE_FALLBACK_RETRIES) { retryLater(); return; }
|
|
6265
|
+
console.warn('[impeccable] Could not read source to check the variant wrapper; keeping the session: ' + detail);
|
|
6266
|
+
showToast('Could not read the source file to check this session; it stays open and is checked again on the next event.', 5500);
|
|
6267
|
+
};
|
|
6268
|
+
fetch(url)
|
|
6269
|
+
.then(r => { if (!r.ok) throw new Error('source read failed: ' + r.status); return r.text(); })
|
|
6270
|
+
.then(text => {
|
|
6271
|
+
if (!stillActive()) return;
|
|
6272
|
+
if (sourceHasSessionWrapper(text, sessionId)) return;
|
|
6273
|
+
onNoWrapper('variant wrapper missing from source');
|
|
6274
|
+
})
|
|
6275
|
+
.catch(err => {
|
|
6276
|
+
const detail = err && err.message ? err.message : 'fetch failed';
|
|
6277
|
+
if (/source read failed: 404$/.test(detail)) {
|
|
6278
|
+
onNoWrapper('source file missing (404) while checking for the variant wrapper');
|
|
6279
|
+
return;
|
|
6280
|
+
}
|
|
6281
|
+
onUnreadable(detail);
|
|
6282
|
+
});
|
|
6283
|
+
}
|
|
6284
|
+
|
|
6285
|
+
function completeSourceInjection(wrapper, sessionId, opts) {
|
|
6286
|
+
recoveryWaitingForAnchor = false;
|
|
6287
|
+
if (pendingVariantAnchorRetryObserver) {
|
|
6288
|
+
pendingVariantAnchorRetryObserver.disconnect();
|
|
6289
|
+
pendingVariantAnchorRetryObserver = null;
|
|
6290
|
+
}
|
|
6291
|
+
|
|
6292
|
+
const previousVisibleVariant = currentSessionId === sessionId ? visibleVariant : 0;
|
|
6293
|
+
const variants = wrapper.querySelectorAll('[data-impeccable-variant]:not([data-impeccable-variant="original"])');
|
|
6294
|
+
arrivedVariants = variants.length;
|
|
6295
|
+
expectedVariants = parseInt(wrapper.dataset.impeccableVariantCount || arrivedVariants);
|
|
6296
|
+
if (arrivedVariants <= 0) {
|
|
6297
|
+
if (state === 'GENERATING') {
|
|
6298
|
+
// Mid-generation the source legitimately holds a scaffold wrapper
|
|
6299
|
+
// with no variants yet (the server-side preflight wraps before the
|
|
6300
|
+
// agent writes). Tearing the session down here would destroy an
|
|
6301
|
+
// in-flight generation; stay in GENERATING — the variant observer
|
|
6302
|
+
// is armed and the server re-delivers a missed `done`.
|
|
6303
|
+
if (!opts.generationCompleted) {
|
|
6304
|
+
console.log('[impeccable] Source has scaffold but no variants yet; still generating.');
|
|
6305
|
+
return;
|
|
6306
|
+
}
|
|
6307
|
+
// Generation finished, yet the read shows only the scaffold: the
|
|
6308
|
+
// source view is stale and no further event will fire. Re-read a
|
|
6309
|
+
// few times before surfacing recovery — a single silent return
|
|
6310
|
+
// here would strand the tab in GENERATING forever.
|
|
6311
|
+
const attempt = opts.attempt || 0;
|
|
6312
|
+
if (attempt < COMPLETED_SOURCE_FALLBACK_RETRIES) {
|
|
6313
|
+
console.log('[impeccable] Generation is done but source shows no variants yet; retrying read ('
|
|
6314
|
+
+ (attempt + 1) + '/' + COMPLETED_SOURCE_FALLBACK_RETRIES + ').');
|
|
6315
|
+
setTimeout(() => {
|
|
6316
|
+
if (state !== 'GENERATING' || currentSessionId !== sessionId) return;
|
|
6317
|
+
if (arrivedVariants > 0) return;
|
|
6318
|
+
injectVariantsFromSource(opts.filePath, sessionId, { ...opts, attempt: attempt + 1 });
|
|
6319
|
+
}, COMPLETED_SOURCE_FALLBACK_RETRY_MS);
|
|
6320
|
+
return;
|
|
6321
|
+
}
|
|
6322
|
+
}
|
|
6323
|
+
recoverEmptyCycling('source-fallback-empty');
|
|
6324
|
+
return;
|
|
6325
|
+
}
|
|
6326
|
+
const saved = loadSession();
|
|
6327
|
+
const savedVisibleVariant = saved && saved.id === sessionId ? saved.visible : 0;
|
|
6328
|
+
visibleVariant = previousVisibleVariant > 0 && previousVisibleVariant <= arrivedVariants
|
|
6329
|
+
? previousVisibleVariant
|
|
6330
|
+
: (savedVisibleVariant > 0 && savedVisibleVariant <= arrivedVariants ? savedVisibleVariant : 1);
|
|
6331
|
+
showVariantInDOM(sessionId, visibleVariant);
|
|
6332
|
+
|
|
6333
|
+
selectedElement = pickVariantContent(wrapper, visibleVariant) || wrapper.parentElement;
|
|
6334
|
+
|
|
6335
|
+
setLiveState('CYCLING');
|
|
6336
|
+
recoveryWaitingForAnchor = false;
|
|
6337
|
+
hideShaderOverlay();
|
|
6338
|
+
showOrUpdateCyclingBar();
|
|
6339
|
+
disableInlineEdit();
|
|
6340
|
+
refreshParamsPanel();
|
|
6341
|
+
positionBar();
|
|
6342
|
+
saveSession();
|
|
6343
|
+
completeParameterGenerationIfReady();
|
|
6344
|
+
console.log('[impeccable] Injected ' + arrivedVariants + ' variants from source file.');
|
|
6345
|
+
}
|
|
6346
|
+
|
|
6193
6347
|
/**
|
|
6194
6348
|
* No-HMR fallback: fetch the raw source file from the live server,
|
|
6195
6349
|
* parse it, extract the variant wrapper, and inject it into the live DOM.
|
|
@@ -6207,14 +6361,46 @@
|
|
|
6207
6361
|
return;
|
|
6208
6362
|
}
|
|
6209
6363
|
rememberSessionFileMeta({ file: filePath });
|
|
6364
|
+
if (isJsxSourceFile(filePath)) {
|
|
6365
|
+
const liveWrapper = findVariantsWrapper(sessionId);
|
|
6366
|
+
if (liveWrapper && liveWrapper.querySelector('[data-impeccable-variant]:not([data-impeccable-variant="original"])')) {
|
|
6367
|
+
completeSourceInjection(liveWrapper, sessionId, { ...opts, filePath });
|
|
6368
|
+
return;
|
|
6369
|
+
}
|
|
6370
|
+
// #454: never fetch/parse JSX. Missing wrap waits for mount (closed
|
|
6371
|
+
// modal / other route). Insert scaffolds stay for late HMR. A replace
|
|
6372
|
+
// scaffold with no variants after retries is a failed generation.
|
|
6373
|
+
if (opts.generationCompleted && sessionId === currentSessionId) {
|
|
6374
|
+
const attempt = opts.attempt || 0;
|
|
6375
|
+
if (attempt < COMPLETED_SOURCE_FALLBACK_RETRIES) {
|
|
6376
|
+
setTimeout(() => {
|
|
6377
|
+
if (state !== 'GENERATING' || currentSessionId !== sessionId) return;
|
|
6378
|
+
injectVariantsFromSource(filePath, sessionId, { ...opts, attempt: attempt + 1 });
|
|
6379
|
+
}, COMPLETED_SOURCE_FALLBACK_RETRY_MS);
|
|
6380
|
+
return;
|
|
6381
|
+
}
|
|
6382
|
+
if (!liveWrapper) {
|
|
6383
|
+
showToast(
|
|
6384
|
+
"Variants ready. If the picked element isn't visible, retrace the path that revealed it - they'll appear automatically.",
|
|
6385
|
+
15000,
|
|
6386
|
+
);
|
|
6387
|
+
return;
|
|
6388
|
+
}
|
|
6389
|
+
if (liveWrapper.dataset.impeccableMode !== 'insert') {
|
|
6390
|
+
recoverEmptyCycling('source-fallback-empty');
|
|
6391
|
+
}
|
|
6392
|
+
return;
|
|
6393
|
+
}
|
|
6394
|
+
if (opts.orphanDiscard && !liveWrapper && sessionId === currentSessionId) {
|
|
6395
|
+
probeJsxWrapperForOrphan(filePath, sessionId, opts);
|
|
6396
|
+
}
|
|
6397
|
+
return;
|
|
6398
|
+
}
|
|
6210
6399
|
const url = 'http://localhost:' + PORT + '/source?token=' + TOKEN + '&path=' + encodeURIComponent(filePath);
|
|
6211
6400
|
fetch(url)
|
|
6212
6401
|
.then(r => { if (!r.ok) throw new Error(r.status); return r.text(); })
|
|
6213
6402
|
.then(html => {
|
|
6214
6403
|
const parser = new DOMParser();
|
|
6215
|
-
let srcWrapper = null;
|
|
6216
|
-
|
|
6217
|
-
// Full-file parse works for HTML/JSX; Astro/Vue sources need marker extraction.
|
|
6218
6404
|
const startMark = '<!-- impeccable-variants-start ' + sessionId + ' -->';
|
|
6219
6405
|
const endMark = '<!-- impeccable-variants-end ' + sessionId + ' -->';
|
|
6220
6406
|
const startIdx = html.indexOf(startMark);
|
|
@@ -6222,8 +6408,8 @@
|
|
|
6222
6408
|
const block = startIdx !== -1 && endIdx !== -1 && endIdx > startIdx
|
|
6223
6409
|
? html.slice(startIdx + startMark.length, endIdx).trim()
|
|
6224
6410
|
: html;
|
|
6225
|
-
const doc = parser.parseFromString(
|
|
6226
|
-
srcWrapper = doc.querySelector('[data-impeccable-variants="' + sessionId + '"]');
|
|
6411
|
+
const doc = parser.parseFromString(block, 'text/html');
|
|
6412
|
+
const srcWrapper = doc.querySelector('[data-impeccable-variants="' + sessionId + '"]');
|
|
6227
6413
|
if (!srcWrapper) {
|
|
6228
6414
|
console.warn('[impeccable] Variant wrapper not found in source file.');
|
|
6229
6415
|
// A resumed cycling session whose wrapper is gone from source is an
|
|
@@ -6248,93 +6434,33 @@
|
|
|
6248
6434
|
return;
|
|
6249
6435
|
}
|
|
6250
6436
|
|
|
6251
|
-
const
|
|
6252
|
-
const wrapper = srcWrapper.cloneNode(true);
|
|
6253
|
-
|
|
6254
|
-
// Wrapper already in DOM (wrap HMR landed, variant insert did not).
|
|
6255
|
-
const existingWrapper = document.querySelector('[data-impeccable-variants="' + sessionId + '"]');
|
|
6437
|
+
const existingWrapper = findVariantsWrapper(sessionId);
|
|
6256
6438
|
if (existingWrapper) {
|
|
6439
|
+
const wrapper = srcWrapper.cloneNode(true);
|
|
6257
6440
|
existingWrapper.parentElement.replaceChild(wrapper, existingWrapper);
|
|
6258
|
-
|
|
6259
|
-
|
|
6260
|
-
if (!origContent) return;
|
|
6261
|
-
|
|
6262
|
-
const liveEl = resolveLiveInjectionAnchor(origContent.outerHTML);
|
|
6263
|
-
if (!liveEl) {
|
|
6264
|
-
console.warn('[impeccable] Could not find original element in live DOM.');
|
|
6265
|
-
enterRecoveryWaitingForAnchor({
|
|
6266
|
-
filePath,
|
|
6267
|
-
sessionId,
|
|
6268
|
-
srcWrapper,
|
|
6269
|
-
checkpointReason: 'variant_anchor_missing',
|
|
6270
|
-
trackScroll: false,
|
|
6271
|
-
});
|
|
6272
|
-
return;
|
|
6273
|
-
}
|
|
6274
|
-
|
|
6275
|
-
liveEl.parentElement.replaceChild(wrapper, liveEl);
|
|
6276
|
-
}
|
|
6277
|
-
recoveryWaitingForAnchor = false;
|
|
6278
|
-
if (pendingVariantAnchorRetryObserver) {
|
|
6279
|
-
pendingVariantAnchorRetryObserver.disconnect();
|
|
6280
|
-
pendingVariantAnchorRetryObserver = null;
|
|
6441
|
+
completeSourceInjection(wrapper, sessionId, { ...opts, filePath });
|
|
6442
|
+
return;
|
|
6281
6443
|
}
|
|
6282
6444
|
|
|
6283
|
-
|
|
6284
|
-
|
|
6285
|
-
|
|
6286
|
-
|
|
6287
|
-
|
|
6288
|
-
if (
|
|
6289
|
-
|
|
6290
|
-
|
|
6291
|
-
|
|
6292
|
-
|
|
6293
|
-
|
|
6294
|
-
|
|
6295
|
-
|
|
6296
|
-
|
|
6297
|
-
return;
|
|
6298
|
-
}
|
|
6299
|
-
// Generation finished, yet the read shows only the scaffold: the
|
|
6300
|
-
// source view is stale and no further event will fire. Re-read a
|
|
6301
|
-
// few times before surfacing recovery — a single silent return
|
|
6302
|
-
// here would strand the tab in GENERATING forever.
|
|
6303
|
-
const attempt = opts.attempt || 0;
|
|
6304
|
-
if (attempt < COMPLETED_SOURCE_FALLBACK_RETRIES) {
|
|
6305
|
-
console.log('[impeccable] Generation is done but source shows no variants yet; retrying read ('
|
|
6306
|
-
+ (attempt + 1) + '/' + COMPLETED_SOURCE_FALLBACK_RETRIES + ').');
|
|
6307
|
-
setTimeout(() => {
|
|
6308
|
-
if (state !== 'GENERATING' || currentSessionId !== sessionId) return;
|
|
6309
|
-
if (arrivedVariants > 0) return;
|
|
6310
|
-
injectVariantsFromSource(filePath, sessionId, { ...opts, attempt: attempt + 1 });
|
|
6311
|
-
}, COMPLETED_SOURCE_FALLBACK_RETRY_MS);
|
|
6312
|
-
return;
|
|
6313
|
-
}
|
|
6314
|
-
}
|
|
6315
|
-
recoverEmptyCycling('source-fallback-empty');
|
|
6445
|
+
const wrapper = srcWrapper.cloneNode(true);
|
|
6446
|
+
const origContent = srcWrapper.querySelector('[data-impeccable-variant="original"] > :first-child');
|
|
6447
|
+
if (!origContent) return;
|
|
6448
|
+
|
|
6449
|
+
const liveEl = resolveLiveInjectionAnchor(origContent.outerHTML);
|
|
6450
|
+
if (!liveEl) {
|
|
6451
|
+
console.warn('[impeccable] Could not find original element in live DOM.');
|
|
6452
|
+
enterRecoveryWaitingForAnchor({
|
|
6453
|
+
filePath,
|
|
6454
|
+
sessionId,
|
|
6455
|
+
srcWrapper,
|
|
6456
|
+
checkpointReason: 'variant_anchor_missing',
|
|
6457
|
+
trackScroll: false,
|
|
6458
|
+
});
|
|
6316
6459
|
return;
|
|
6317
6460
|
}
|
|
6318
|
-
const saved = loadSession();
|
|
6319
|
-
const savedVisibleVariant = saved && saved.id === sessionId ? saved.visible : 0;
|
|
6320
|
-
visibleVariant = previousVisibleVariant > 0 && previousVisibleVariant <= arrivedVariants
|
|
6321
|
-
? previousVisibleVariant
|
|
6322
|
-
: (savedVisibleVariant > 0 && savedVisibleVariant <= arrivedVariants ? savedVisibleVariant : 1);
|
|
6323
|
-
showVariantInDOM(sessionId, visibleVariant);
|
|
6324
|
-
|
|
6325
|
-
// Update selectedElement to the visible variant's content
|
|
6326
|
-
selectedElement = pickVariantContent(wrapper, visibleVariant) || wrapper.parentElement;
|
|
6327
6461
|
|
|
6328
|
-
|
|
6329
|
-
|
|
6330
|
-
hideShaderOverlay();
|
|
6331
|
-
showOrUpdateCyclingBar();
|
|
6332
|
-
disableInlineEdit();
|
|
6333
|
-
refreshParamsPanel();
|
|
6334
|
-
positionBar();
|
|
6335
|
-
saveSession();
|
|
6336
|
-
if (parameterGenerationState === 'loading') completeParameterPublication();
|
|
6337
|
-
console.log('[impeccable] Injected ' + arrivedVariants + ' variants from source file.');
|
|
6462
|
+
liveEl.parentElement.replaceChild(wrapper, liveEl);
|
|
6463
|
+
completeSourceInjection(wrapper, sessionId, { ...opts, filePath });
|
|
6338
6464
|
})
|
|
6339
6465
|
.catch(err => {
|
|
6340
6466
|
console.error('[impeccable] Failed to fetch source:', err);
|
|
@@ -6342,44 +6468,6 @@
|
|
|
6342
6468
|
});
|
|
6343
6469
|
}
|
|
6344
6470
|
|
|
6345
|
-
function normalizeSourceFallbackBlock(block, filePath) {
|
|
6346
|
-
if (!/\.[cm]?[jt]sx$/i.test(String(filePath || ''))) return block;
|
|
6347
|
-
return String(block)
|
|
6348
|
-
.replace(
|
|
6349
|
-
/<style\b([^>]*)>\s*\{\s*`([\s\S]*?)`\s*\}\s*<\/style>/g,
|
|
6350
|
-
(_match, attrs, css) => '<style' + attrs + '>' + css + '</style>',
|
|
6351
|
-
)
|
|
6352
|
-
.replace(/\bclassName\s*=\s*\{\s*`([^`]*?)`\s*\}/g, (_match, value) => {
|
|
6353
|
-
const literalClasses = value.replace(/\$\{[^}]*\}/g, ' ').replace(/\s+/g, ' ').trim();
|
|
6354
|
-
return literalClasses ? 'class="' + escapeHtml(literalClasses) + '"' : '';
|
|
6355
|
-
})
|
|
6356
|
-
.replace(/\bclassName\s*=/g, 'class=')
|
|
6357
|
-
.replace(/\sstyle=\{\{([\s\S]*?)\}\}/g, (_match, body) => {
|
|
6358
|
-
const css = jsxStyleObjectToCss(body);
|
|
6359
|
-
return css ? ' style="' + escapeHtml(css) + '"' : '';
|
|
6360
|
-
});
|
|
6361
|
-
}
|
|
6362
|
-
|
|
6363
|
-
function jsxStyleObjectToCss(body) {
|
|
6364
|
-
const declarations = [];
|
|
6365
|
-
const re = /(["'][^"']+["']|[A-Za-z_$][\w$-]*)\s*:\s*(?:"([^"]*)"|'([^']*)'|(-?\d+(?:\.\d+)?))/g;
|
|
6366
|
-
let match;
|
|
6367
|
-
while ((match = re.exec(String(body || '')))) {
|
|
6368
|
-
const prop = jsxStylePropToCss(match[1]);
|
|
6369
|
-
const value = match[2] ?? match[3] ?? match[4] ?? '';
|
|
6370
|
-
if (!prop || value === '') continue;
|
|
6371
|
-
declarations.push(prop + ': ' + value);
|
|
6372
|
-
}
|
|
6373
|
-
return declarations.join('; ');
|
|
6374
|
-
}
|
|
6375
|
-
|
|
6376
|
-
function jsxStylePropToCss(prop) {
|
|
6377
|
-
let out = String(prop || '').trim().replace(/^["']|["']$/g, '');
|
|
6378
|
-
if (!out) return '';
|
|
6379
|
-
if (out.startsWith('--')) return out;
|
|
6380
|
-
return out.replace(/[A-Z]/g, (ch) => '-' + ch.toLowerCase());
|
|
6381
|
-
}
|
|
6382
|
-
|
|
6383
6471
|
function buildSvelteExpressionTextMap(sourceOriginal, liveOriginal) {
|
|
6384
6472
|
const map = new Map();
|
|
6385
6473
|
if (!sourceOriginal || !liveOriginal) return map;
|
|
@@ -6503,7 +6591,7 @@
|
|
|
6503
6591
|
if (anchor && !anchor.__impeccableFrozenAnchor) selectedElement = anchor;
|
|
6504
6592
|
return;
|
|
6505
6593
|
}
|
|
6506
|
-
const wrapper =
|
|
6594
|
+
const wrapper = findVariantsWrapper(currentSessionId);
|
|
6507
6595
|
if (!wrapper) return;
|
|
6508
6596
|
const visEl = pickVariantContent(wrapper, visibleVariant);
|
|
6509
6597
|
if (visEl) selectedElement = visEl;
|
|
@@ -6513,7 +6601,7 @@
|
|
|
6513
6601
|
if (svelteComponentSession?.sessionId === sessionId && svelteComponentSession.mountedVariant > 0) {
|
|
6514
6602
|
return svelteComponentSession.mountedVariant;
|
|
6515
6603
|
}
|
|
6516
|
-
const wrapper =
|
|
6604
|
+
const wrapper = findVariantsWrapper(sessionId);
|
|
6517
6605
|
if (!wrapper) return 0;
|
|
6518
6606
|
const variants = wrapper.querySelectorAll('[data-impeccable-variant]:not([data-impeccable-variant="original"])');
|
|
6519
6607
|
for (const variant of variants) {
|
|
@@ -6605,19 +6693,99 @@
|
|
|
6605
6693
|
document.getElementById(VARIANT_STATE_STYLE_ID)?.remove();
|
|
6606
6694
|
}
|
|
6607
6695
|
|
|
6696
|
+
function discardStateStyleId(sessionId) {
|
|
6697
|
+
return DISCARD_STATE_STYLE_ID + '-' + sessionId;
|
|
6698
|
+
}
|
|
6699
|
+
|
|
6608
6700
|
function showOriginalDuringDiscard(sessionId) {
|
|
6609
6701
|
if (!sessionId) return;
|
|
6610
|
-
let styleEl = document.getElementById(
|
|
6702
|
+
let styleEl = document.getElementById(discardStateStyleId(sessionId));
|
|
6611
6703
|
if (!styleEl) {
|
|
6612
6704
|
styleEl = document.createElement('style');
|
|
6613
|
-
styleEl.id =
|
|
6705
|
+
styleEl.id = discardStateStyleId(sessionId);
|
|
6614
6706
|
(document.head || document.documentElement).appendChild(styleEl);
|
|
6615
6707
|
}
|
|
6708
|
+
styleEl.dataset.impeccableDiscardSession = sessionId;
|
|
6616
6709
|
const wrapper = '[data-impeccable-variants="' + sessionId + '"]';
|
|
6617
6710
|
styleEl.textContent = wrapper + ' > [data-impeccable-variant]:not([data-impeccable-variant="original"]) { display:none !important; }\n'
|
|
6618
6711
|
+ wrapper + ' > [data-impeccable-variant="original"] { display:block !important; }';
|
|
6619
6712
|
}
|
|
6620
6713
|
|
|
6714
|
+
function removeDiscardStateStylesheet(sessionId) {
|
|
6715
|
+
if (!sessionId) return;
|
|
6716
|
+
document.getElementById(discardStateStyleId(sessionId))?.remove();
|
|
6717
|
+
}
|
|
6718
|
+
|
|
6719
|
+
/**
|
|
6720
|
+
* Every wrapper a discard has to unwind. A target inside a `.map()` renders
|
|
6721
|
+
* one wrapper per item, so the hide, the release, and the existence checks
|
|
6722
|
+
* all have to speak about the same set.
|
|
6723
|
+
*/
|
|
6724
|
+
function discardedWrappers(sessionId) {
|
|
6725
|
+
if (!sessionId) return [];
|
|
6726
|
+
return [...document.querySelectorAll('[data-impeccable-variants="' + sessionId + '"]')];
|
|
6727
|
+
}
|
|
6728
|
+
|
|
6729
|
+
function releaseDiscardedStaticWrapper(wrapper) {
|
|
6730
|
+
if (!wrapper) return;
|
|
6731
|
+
const orig = wrapper.querySelector('[data-impeccable-variant="original"]');
|
|
6732
|
+
const content = orig?.firstElementChild;
|
|
6733
|
+
if (content && wrapper.parentElement) {
|
|
6734
|
+
wrapper.parentElement.replaceChild(content, wrapper);
|
|
6735
|
+
return;
|
|
6736
|
+
}
|
|
6737
|
+
wrapper.remove();
|
|
6738
|
+
}
|
|
6739
|
+
|
|
6740
|
+
/**
|
|
6741
|
+
* Undo the discard hide on every wrapper it covered. Releasing only the
|
|
6742
|
+
* first match left the other mapped items sitting at display:none with
|
|
6743
|
+
* their original content never restored, on exactly the static and
|
|
6744
|
+
* missed-HMR flows this fallback exists for.
|
|
6745
|
+
*/
|
|
6746
|
+
function releaseDiscardedStaticWrappers(sessionId, wrappers) {
|
|
6747
|
+
removeDiscardStateStylesheet(sessionId);
|
|
6748
|
+
const set = wrappers && wrappers.length ? wrappers : discardedWrappers(sessionId);
|
|
6749
|
+
for (const wrapper of set) releaseDiscardedStaticWrapper(wrapper);
|
|
6750
|
+
}
|
|
6751
|
+
|
|
6752
|
+
function watchForDiscardedFrameworkWrapperRemoval(sessionId) {
|
|
6753
|
+
if (!sessionId || !document.body) return;
|
|
6754
|
+
if (discardedFrameworkWrapperWatchers.has(sessionId)) return;
|
|
6755
|
+
const selector = '[data-impeccable-variants="' + sessionId + '"]';
|
|
6756
|
+
let observer = null;
|
|
6757
|
+
let timer = null;
|
|
6758
|
+
const stopWatching = function() {
|
|
6759
|
+
observer?.disconnect();
|
|
6760
|
+
if (timer) clearTimeout(timer);
|
|
6761
|
+
discardedFrameworkWrapperWatchers.delete(sessionId);
|
|
6762
|
+
};
|
|
6763
|
+
const finishIfGone = function() {
|
|
6764
|
+
if (document.querySelector(selector)) return false;
|
|
6765
|
+
removeDiscardStateStylesheet(sessionId);
|
|
6766
|
+
stopWatching();
|
|
6767
|
+
return true;
|
|
6768
|
+
};
|
|
6769
|
+
if (finishIfGone()) return;
|
|
6770
|
+
observer = new MutationObserver(finishIfGone);
|
|
6771
|
+
observer.observe(document.body, { childList: true, subtree: true });
|
|
6772
|
+
const resolveStillMounted = function() {
|
|
6773
|
+
if (finishIfGone()) return;
|
|
6774
|
+
const replacementActive = !!currentSessionId
|
|
6775
|
+
|| (state !== 'IDLE' && state !== 'PICKING');
|
|
6776
|
+
if (replacementActive) {
|
|
6777
|
+
timer = setTimeout(resolveStillMounted, 12000);
|
|
6778
|
+
discardedFrameworkWrapperWatchers.get(sessionId).timer = timer;
|
|
6779
|
+
return;
|
|
6780
|
+
}
|
|
6781
|
+
removeDiscardStateStylesheet(sessionId);
|
|
6782
|
+
stopWatching();
|
|
6783
|
+
location.reload();
|
|
6784
|
+
};
|
|
6785
|
+
timer = setTimeout(resolveStillMounted, 12000);
|
|
6786
|
+
discardedFrameworkWrapperWatchers.set(sessionId, { observer, timer });
|
|
6787
|
+
}
|
|
6788
|
+
|
|
6621
6789
|
function resolveScrollLockAnchorTop() {
|
|
6622
6790
|
const anchor = resolveBarAnchor();
|
|
6623
6791
|
if (!anchor?.isConnected) return null;
|
|
@@ -6761,6 +6929,42 @@
|
|
|
6761
6929
|
// MutationObserver for progressive variant reveal
|
|
6762
6930
|
//
|
|
6763
6931
|
|
|
6932
|
+
// A session id can have more than one wrapper in the DOM: the target may sit
|
|
6933
|
+
// inside a `.map()` callback (the wrapper renders once per item), or the
|
|
6934
|
+
// agent may have relocated the wrapper out of the shared primitive live-wrap
|
|
6935
|
+
// scaffolded into. A plain first match can then pin an empty scaffold while
|
|
6936
|
+
// the real variants sit in a later wrapper, which strands the session at
|
|
6937
|
+
// 0/N and leaves the bar, the params panel, and accept all reading the
|
|
6938
|
+
// wrong element. Prefer a wrapper that actually holds variants. With zero
|
|
6939
|
+
// or one match this is exactly the querySelector it replaces.
|
|
6940
|
+
//
|
|
6941
|
+
// Every lookup of the ACTIVE session's wrapper goes through here. The
|
|
6942
|
+
// remaining raw `[data-impeccable-variants=...]` uses are deliberate: bare
|
|
6943
|
+
// existence checks, selector strings for stylesheets and observers (which
|
|
6944
|
+
// want to cover every match), `querySelectorAll` sweeps, and the parsed
|
|
6945
|
+
// source document, which is not this document.
|
|
6946
|
+
function pickPopulatedVariantsWrapper(selector) {
|
|
6947
|
+
const matches = document.querySelectorAll(selector);
|
|
6948
|
+
if (matches.length < 2) return matches[0] || null;
|
|
6949
|
+
for (const candidate of matches) {
|
|
6950
|
+
if (candidate.querySelector('[data-impeccable-variant]:not([data-impeccable-variant="original"])')) {
|
|
6951
|
+
return candidate;
|
|
6952
|
+
}
|
|
6953
|
+
}
|
|
6954
|
+
return matches[0];
|
|
6955
|
+
}
|
|
6956
|
+
|
|
6957
|
+
/** The wrapper holding `sessionId`'s variants, or null without an id. */
|
|
6958
|
+
function findVariantsWrapper(sessionId) {
|
|
6959
|
+
if (!sessionId) return null;
|
|
6960
|
+
return pickPopulatedVariantsWrapper('[data-impeccable-variants="' + sessionId + '"]');
|
|
6961
|
+
}
|
|
6962
|
+
|
|
6963
|
+
/** Any live variant wrapper, for the resume paths that have no id yet. */
|
|
6964
|
+
function findAnyVariantsWrapper() {
|
|
6965
|
+
return pickPopulatedVariantsWrapper('[data-impeccable-variants]');
|
|
6966
|
+
}
|
|
6967
|
+
|
|
6764
6968
|
function startVariantObserver(sessionId) {
|
|
6765
6969
|
let updating = false; // re-entrancy guard
|
|
6766
6970
|
|
|
@@ -6790,7 +6994,7 @@
|
|
|
6790
6994
|
}
|
|
6791
6995
|
if (!dominated) return;
|
|
6792
6996
|
|
|
6793
|
-
const wrapper =
|
|
6997
|
+
const wrapper = findVariantsWrapper(sessionId);
|
|
6794
6998
|
if (!wrapper) return;
|
|
6795
6999
|
|
|
6796
7000
|
const variants = wrapper.querySelectorAll('[data-impeccable-variant]:not([data-impeccable-variant="original"])');
|
|
@@ -6840,6 +7044,7 @@
|
|
|
6840
7044
|
|
|
6841
7045
|
const expected = parseInt(wrapper.dataset.impeccableVariantCount || '0');
|
|
6842
7046
|
if (expected > 0) expectedVariants = expected;
|
|
7047
|
+
completeParameterGenerationIfReady();
|
|
6843
7048
|
|
|
6844
7049
|
if (arrivedVariants > 0) {
|
|
6845
7050
|
setLiveState('CYCLING');
|
|
@@ -6998,6 +7203,7 @@
|
|
|
6998
7203
|
if (arrivedVariants >= expectedVariants && expectedVariants > 0) {
|
|
6999
7204
|
if (state === 'GENERATING') {
|
|
7000
7205
|
setLiveState('CYCLING');
|
|
7206
|
+
hideShaderOverlay();
|
|
7001
7207
|
showOrUpdateCyclingBar();
|
|
7002
7208
|
disableInlineEdit();
|
|
7003
7209
|
refreshParamsPanel();
|
|
@@ -7058,6 +7264,7 @@
|
|
|
7058
7264
|
pendingAcceptedSession = null;
|
|
7059
7265
|
awaitingAcceptResult = null;
|
|
7060
7266
|
setLiveState('CYCLING');
|
|
7267
|
+
hideShaderOverlay();
|
|
7061
7268
|
updateBarContent('cycling');
|
|
7062
7269
|
showToast('Could not complete accept cleanup. Try Accept again.', 5000);
|
|
7063
7270
|
break;
|
|
@@ -7331,7 +7538,7 @@
|
|
|
7331
7538
|
hideInsertLine();
|
|
7332
7539
|
configureKind = 'insert';
|
|
7333
7540
|
selectedElement = placeholder;
|
|
7334
|
-
|
|
7541
|
+
beginNewLiveConfiguration();
|
|
7335
7542
|
hideHighlight();
|
|
7336
7543
|
clearAnnotations();
|
|
7337
7544
|
showAnnotOverlay(placeholder);
|
|
@@ -7349,7 +7556,7 @@
|
|
|
7349
7556
|
e.preventDefault();
|
|
7350
7557
|
e.stopPropagation();
|
|
7351
7558
|
selectedElement = hoveredElement;
|
|
7352
|
-
|
|
7559
|
+
beginNewLiveConfiguration();
|
|
7353
7560
|
showHighlight(selectedElement);
|
|
7354
7561
|
clearAnnotations();
|
|
7355
7562
|
showAnnotOverlay(selectedElement);
|
|
@@ -7526,7 +7733,7 @@
|
|
|
7526
7733
|
} else if (e.key === 'Enter') {
|
|
7527
7734
|
e.preventDefault();
|
|
7528
7735
|
selectedElement = hoveredElement;
|
|
7529
|
-
|
|
7736
|
+
beginNewLiveConfiguration();
|
|
7530
7737
|
showHighlight(selectedElement);
|
|
7531
7738
|
clearAnnotations();
|
|
7532
7739
|
showAnnotOverlay(selectedElement);
|
|
@@ -7627,7 +7834,6 @@
|
|
|
7627
7834
|
if (editBadgeEl && editBadgeEl.style.display !== 'none') renderEditBadge('idle-disabled');
|
|
7628
7835
|
showBar('generating');
|
|
7629
7836
|
saveSession();
|
|
7630
|
-
sendCheckpoint('generate_started');
|
|
7631
7837
|
writeScrollY(window.scrollY);
|
|
7632
7838
|
if (variantObserver) variantObserver.disconnect();
|
|
7633
7839
|
variantObserver = startVariantObserver(currentSessionId);
|
|
@@ -7709,7 +7915,6 @@
|
|
|
7709
7915
|
showBar('generating');
|
|
7710
7916
|
startScrollTracking();
|
|
7711
7917
|
saveSession();
|
|
7712
|
-
sendCheckpoint('generate_started');
|
|
7713
7918
|
writeScrollY(window.scrollY);
|
|
7714
7919
|
if (variantObserver) variantObserver.disconnect();
|
|
7715
7920
|
variantObserver = startVariantObserver(currentSessionId);
|
|
@@ -8031,7 +8236,8 @@
|
|
|
8031
8236
|
// rasterization from delaying the fetch itself.
|
|
8032
8237
|
if (!hasAnnotations) {
|
|
8033
8238
|
basePayload.clientSentAt = Date.now();
|
|
8034
|
-
await sendEvent(basePayload);
|
|
8239
|
+
const created = await sendEvent(basePayload);
|
|
8240
|
+
if (created?.ok && currentSessionId === basePayload.id) sendCheckpoint('generate_started');
|
|
8035
8241
|
}
|
|
8036
8242
|
|
|
8037
8243
|
let screenshotPath;
|
|
@@ -8072,7 +8278,10 @@
|
|
|
8072
8278
|
// is semantic input. Plain requests were already dispatched above.
|
|
8073
8279
|
if (hasAnnotations) {
|
|
8074
8280
|
basePayload.clientSentAt = Date.now();
|
|
8075
|
-
sendEvent(screenshotPath ? { ...basePayload, screenshotPath } : basePayload);
|
|
8281
|
+
const created = await sendEvent(screenshotPath ? { ...basePayload, screenshotPath } : basePayload);
|
|
8282
|
+
// Capture/upload can take seconds. Progress before this acknowledgment
|
|
8283
|
+
// refers to an unknown session and would clear our own active work.
|
|
8284
|
+
if (created?.ok && currentSessionId === basePayload.id) sendCheckpoint('generate_started');
|
|
8076
8285
|
}
|
|
8077
8286
|
}
|
|
8078
8287
|
|
|
@@ -8160,6 +8369,15 @@ void main() {
|
|
|
8160
8369
|
// matches the original off-white risograph paper.
|
|
8161
8370
|
const SHADER_PAPER_FALLBACK = [0.975, 0.965, 0.955];
|
|
8162
8371
|
let shaderState = null; // { canvas, gl, program, texture, rafId, startTime }
|
|
8372
|
+
// showShaderOverlay is async: it appends its canvas, then awaits
|
|
8373
|
+
// createImageBitmap and the GL setup before it publishes shaderState. A
|
|
8374
|
+
// teardown that landed inside that window found shaderState still null,
|
|
8375
|
+
// returned, and then watched the construction publish itself over a session
|
|
8376
|
+
// that had already left GENERATING, with no teardown left to run. That is
|
|
8377
|
+
// the generating loader frozen over a page that already cycles (issue #719).
|
|
8378
|
+
// Every teardown bumps this epoch; a construction abandons its own canvas as
|
|
8379
|
+
// soon as it sees the epoch move.
|
|
8380
|
+
let shaderEpoch = 0;
|
|
8163
8381
|
|
|
8164
8382
|
// The element's effective background tone, used as the uniform halftone
|
|
8165
8383
|
// ground so content dissolves into dots over it. Unlike resolveCanvasBackground
|
|
@@ -8306,14 +8524,28 @@ void main() {
|
|
|
8306
8524
|
});
|
|
8307
8525
|
}
|
|
8308
8526
|
|
|
8527
|
+
/** Drop a shader node no shaderState owns (an abandoned construction). */
|
|
8528
|
+
function removeStrayShaderNode() {
|
|
8529
|
+
const stray = uiGetById(PREFIX + '-shader');
|
|
8530
|
+
if (stray) stray.remove();
|
|
8531
|
+
}
|
|
8532
|
+
|
|
8309
8533
|
function hideShaderOverlay() {
|
|
8310
|
-
|
|
8534
|
+
// Bump first, unconditionally: this is what tells an in-flight
|
|
8535
|
+
// showShaderOverlay to abandon itself rather than publish over a session
|
|
8536
|
+
// that has already moved on.
|
|
8537
|
+
shaderEpoch += 1;
|
|
8538
|
+
if (!shaderState) {
|
|
8539
|
+
removeStrayShaderNode();
|
|
8540
|
+
return;
|
|
8541
|
+
}
|
|
8311
8542
|
if (shaderState.rafId) cancelAnimationFrame(shaderState.rafId);
|
|
8312
8543
|
if (shaderState.canvas) shaderState.canvas.remove();
|
|
8313
8544
|
if (shaderState.objectUrl) URL.revokeObjectURL(shaderState.objectUrl);
|
|
8314
8545
|
const lose = shaderState.gl?.getExtension?.('WEBGL_lose_context');
|
|
8315
8546
|
try { lose?.loseContext(); } catch {}
|
|
8316
8547
|
shaderState = null;
|
|
8548
|
+
removeStrayShaderNode();
|
|
8317
8549
|
}
|
|
8318
8550
|
|
|
8319
8551
|
function showShaderBitmapFallback(canvas, blob) {
|
|
@@ -8338,6 +8570,16 @@ void main() {
|
|
|
8338
8570
|
async function showShaderOverlay(el, blob, rect, paper) {
|
|
8339
8571
|
hideShaderOverlay();
|
|
8340
8572
|
if (!blob || !el) return;
|
|
8573
|
+
// hideShaderOverlay just bumped the epoch, so this run owns it until the
|
|
8574
|
+
// next teardown. Every step past an await re-checks before it publishes.
|
|
8575
|
+
const epoch = shaderEpoch;
|
|
8576
|
+
const abandoned = (node, gl) => {
|
|
8577
|
+
if (epoch === shaderEpoch) return false;
|
|
8578
|
+
node.remove();
|
|
8579
|
+
const lose = gl?.getExtension?.('WEBGL_lose_context');
|
|
8580
|
+
try { lose?.loseContext(); } catch {}
|
|
8581
|
+
return true;
|
|
8582
|
+
};
|
|
8341
8583
|
const canvas = document.createElement('canvas');
|
|
8342
8584
|
canvas.id = PREFIX + '-shader';
|
|
8343
8585
|
const dpr = Math.min(window.devicePixelRatio || 1, 2);
|
|
@@ -8360,6 +8602,7 @@ void main() {
|
|
|
8360
8602
|
if (!gl) {
|
|
8361
8603
|
// WebGL unavailable: use the captured bitmap as a background overlay so
|
|
8362
8604
|
// the user still sees something meaningful during generation.
|
|
8605
|
+
if (abandoned(canvas, null)) return;
|
|
8363
8606
|
showShaderBitmapFallback(canvas, blob);
|
|
8364
8607
|
return;
|
|
8365
8608
|
}
|
|
@@ -8399,16 +8642,22 @@ void main() {
|
|
|
8399
8642
|
}
|
|
8400
8643
|
|
|
8401
8644
|
// Upload the screenshot as a texture
|
|
8645
|
+
if (abandoned(canvas, gl)) return;
|
|
8402
8646
|
let bitmap;
|
|
8403
8647
|
try {
|
|
8404
8648
|
bitmap = await createImageBitmap(blob);
|
|
8405
8649
|
} catch (err) {
|
|
8406
8650
|
console.warn('[impeccable] shader bitmap decode failed:', err);
|
|
8651
|
+
if (abandoned(canvas, gl)) return;
|
|
8407
8652
|
const lose = gl.getExtension?.('WEBGL_lose_context');
|
|
8408
8653
|
try { lose?.loseContext(); } catch {}
|
|
8409
8654
|
showShaderBitmapFallback(canvas, blob);
|
|
8410
8655
|
return;
|
|
8411
8656
|
}
|
|
8657
|
+
if (abandoned(canvas, gl)) {
|
|
8658
|
+
if (bitmap.close) bitmap.close();
|
|
8659
|
+
return;
|
|
8660
|
+
}
|
|
8412
8661
|
texture = gl.createTexture();
|
|
8413
8662
|
gl.bindTexture(gl.TEXTURE_2D, texture);
|
|
8414
8663
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
|
|
@@ -8427,6 +8676,7 @@ void main() {
|
|
|
8427
8676
|
const paperRgb = paper || resolvePaperRgb(el);
|
|
8428
8677
|
const reduced = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
|
|
8429
8678
|
|
|
8679
|
+
if (abandoned(canvas, gl)) return;
|
|
8430
8680
|
shaderState = { canvas, gl, program, texture, rafId: 0, startTime: performance.now(), reduced };
|
|
8431
8681
|
function frame() {
|
|
8432
8682
|
if (!shaderState) return;
|
|
@@ -8463,7 +8713,7 @@ void main() {
|
|
|
8463
8713
|
clientSentAt: Date.now(),
|
|
8464
8714
|
};
|
|
8465
8715
|
if (!currentSessionId || arrivedVariants === 0) return;
|
|
8466
|
-
const acceptWrapper =
|
|
8716
|
+
const acceptWrapper = findVariantsWrapper(currentSessionId);
|
|
8467
8717
|
if (Object.keys(paramsCurrentValues).length > 0) {
|
|
8468
8718
|
acceptPayload.paramValues = { ...paramsCurrentValues };
|
|
8469
8719
|
}
|
|
@@ -8506,6 +8756,7 @@ void main() {
|
|
|
8506
8756
|
.catch(() => {
|
|
8507
8757
|
if (pendingAcceptedSession?.id === acceptedSessionId) pendingAcceptedSession = null;
|
|
8508
8758
|
setLiveState('CYCLING');
|
|
8759
|
+
hideShaderOverlay();
|
|
8509
8760
|
showOrUpdateCyclingBar();
|
|
8510
8761
|
showToast('Could not confirm accept with the live server. Session kept for recovery; try Accept again.', 5000);
|
|
8511
8762
|
});
|
|
@@ -8531,6 +8782,7 @@ void main() {
|
|
|
8531
8782
|
}
|
|
8532
8783
|
|
|
8533
8784
|
function scheduleAcceptCleanup(accepted) {
|
|
8785
|
+
const recoveryRevision = liveInteractionRevision;
|
|
8534
8786
|
queueMicrotask(function() {
|
|
8535
8787
|
if (pendingAcceptedSession?.id !== accepted?.id) return;
|
|
8536
8788
|
// Svelte previews live in an adapter-owned mount rather than in source
|
|
@@ -8547,14 +8799,16 @@ void main() {
|
|
|
8547
8799
|
// races. Static servers still need a fallback, but it must not keep Live
|
|
8548
8800
|
// in SAVING or block the user's next pick.
|
|
8549
8801
|
if (!accepted?.isSvelteComponent) {
|
|
8802
|
+
watchForHandledRuntimeWrapper(accepted?.id, recoveryRevision);
|
|
8550
8803
|
setTimeout(function() {
|
|
8551
|
-
if (
|
|
8804
|
+
if (deferredRecoverySuperseded(accepted?.id, recoveryRevision)) return;
|
|
8805
|
+
if (!acceptedDomAlreadyClean(accepted)) ensureAcceptedDomClean(accepted, recoveryRevision);
|
|
8552
8806
|
}, 1200);
|
|
8553
8807
|
}
|
|
8554
8808
|
}
|
|
8555
8809
|
|
|
8556
8810
|
function snapshotAcceptedVariantDom(sessionId, variantId) {
|
|
8557
|
-
const wrapper =
|
|
8811
|
+
const wrapper = findVariantsWrapper(sessionId);
|
|
8558
8812
|
const accepted = wrapper?.querySelector?.('[data-impeccable-variant="' + variantId + '"]');
|
|
8559
8813
|
const root = accepted?.firstElementChild || null;
|
|
8560
8814
|
return {
|
|
@@ -8581,13 +8835,27 @@ void main() {
|
|
|
8581
8835
|
&& matches.every((el) => !el.closest('[data-impeccable-variants],[data-impeccable-variant],[data-impeccable-carbonize]'));
|
|
8582
8836
|
}
|
|
8583
8837
|
|
|
8584
|
-
function ensureAcceptedDomClean(pending) {
|
|
8838
|
+
function ensureAcceptedDomClean(pending, recoveryRevision) {
|
|
8839
|
+
// Background cleanup for an accepted session must never mutate or reload
|
|
8840
|
+
// a newer comparison the user has already started.
|
|
8841
|
+
if (deferredRecoverySuperseded(pending?.id, recoveryRevision)) return;
|
|
8585
8842
|
if (acceptedDomAlreadyClean(pending)) return;
|
|
8586
8843
|
const sessionId = pending?.id;
|
|
8587
8844
|
const variantId = pending?.variant;
|
|
8588
8845
|
const wrappers = findAcceptedRuntimeWrappers(sessionId);
|
|
8846
|
+
if (hasFrameworkHmrOwnership(wrappers[0] || pending?.parentElement)) {
|
|
8847
|
+
// Vite can coalesce rapid scaffold/carbonize writes and leave the last
|
|
8848
|
+
// framework-owned preview tree mounted even though source is clean. Give
|
|
8849
|
+
// HMR another grace window, then reload from clean source rather than
|
|
8850
|
+
// violating reconciler ownership with a manual DOM mutation.
|
|
8851
|
+
setTimeout(function() {
|
|
8852
|
+
if (deferredRecoverySuperseded(pending?.id, recoveryRevision)) return;
|
|
8853
|
+
if (!acceptedDomAlreadyClean(pending)) location.reload();
|
|
8854
|
+
}, 2000);
|
|
8855
|
+
return;
|
|
8856
|
+
}
|
|
8589
8857
|
if (wrappers.length === 0) {
|
|
8590
|
-
restoreAcceptedDomFromSnapshot(pending);
|
|
8858
|
+
restoreAcceptedDomFromSnapshot(pending, recoveryRevision);
|
|
8591
8859
|
return;
|
|
8592
8860
|
}
|
|
8593
8861
|
for (const wrapper of wrappers) {
|
|
@@ -8604,7 +8872,7 @@ void main() {
|
|
|
8604
8872
|
}
|
|
8605
8873
|
wrapper.remove();
|
|
8606
8874
|
}
|
|
8607
|
-
if (!acceptedDomAlreadyClean(pending)) restoreAcceptedDomFromSnapshot(pending);
|
|
8875
|
+
if (!acceptedDomAlreadyClean(pending)) restoreAcceptedDomFromSnapshot(pending, recoveryRevision);
|
|
8608
8876
|
}
|
|
8609
8877
|
|
|
8610
8878
|
function findAcceptedRuntimeWrappers(sessionId) {
|
|
@@ -8615,17 +8883,17 @@ void main() {
|
|
|
8615
8883
|
])];
|
|
8616
8884
|
}
|
|
8617
8885
|
|
|
8618
|
-
function restoreAcceptedDomFromSnapshot(pending) {
|
|
8886
|
+
function restoreAcceptedDomFromSnapshot(pending, recoveryRevision) {
|
|
8619
8887
|
if (acceptedDomAlreadyClean(pending)) return;
|
|
8620
8888
|
if (!pending?.acceptedHtml) {
|
|
8621
|
-
reloadAfterMissingAcceptedDom(pending);
|
|
8889
|
+
reloadAfterMissingAcceptedDom(pending, recoveryRevision);
|
|
8622
8890
|
return;
|
|
8623
8891
|
}
|
|
8624
8892
|
const parent = pending.parentElement?.isConnected
|
|
8625
8893
|
? pending.parentElement
|
|
8626
8894
|
: (pending.parentSelector ? document.querySelector(pending.parentSelector) : null);
|
|
8627
8895
|
if (!parent) {
|
|
8628
|
-
reloadAfterMissingAcceptedDom(pending);
|
|
8896
|
+
reloadAfterMissingAcceptedDom(pending, recoveryRevision);
|
|
8629
8897
|
return;
|
|
8630
8898
|
}
|
|
8631
8899
|
const template = document.createElement('template');
|
|
@@ -8634,10 +8902,11 @@ void main() {
|
|
|
8634
8902
|
? pending.nextSibling
|
|
8635
8903
|
: null;
|
|
8636
8904
|
parent.insertBefore(template.content, anchor);
|
|
8637
|
-
if (!acceptedDomAlreadyClean(pending)) reloadAfterMissingAcceptedDom(pending);
|
|
8905
|
+
if (!acceptedDomAlreadyClean(pending)) reloadAfterMissingAcceptedDom(pending, recoveryRevision);
|
|
8638
8906
|
}
|
|
8639
8907
|
|
|
8640
|
-
function reloadAfterMissingAcceptedDom(pending) {
|
|
8908
|
+
function reloadAfterMissingAcceptedDom(pending, recoveryRevision) {
|
|
8909
|
+
if (deferredRecoverySuperseded(pending?.id, recoveryRevision)) return;
|
|
8641
8910
|
if (acceptedDomAlreadyClean(pending)) return;
|
|
8642
8911
|
if (pending?.id && document.querySelector('[data-impeccable-variants="' + pending.id + '"]')) return;
|
|
8643
8912
|
location.reload();
|
|
@@ -8666,7 +8935,7 @@ void main() {
|
|
|
8666
8935
|
}
|
|
8667
8936
|
|
|
8668
8937
|
function commitAcceptedVariantToDom(sessionId, variantId) {
|
|
8669
|
-
const wrapper =
|
|
8938
|
+
const wrapper = findVariantsWrapper(sessionId);
|
|
8670
8939
|
if (!wrapper) return false;
|
|
8671
8940
|
const accepted = wrapper.querySelector('[data-impeccable-variant="' + variantId + '"]');
|
|
8672
8941
|
if (!accepted || !accepted.firstElementChild) return false;
|
|
@@ -8894,7 +9163,7 @@ void main() {
|
|
|
8894
9163
|
}
|
|
8895
9164
|
|
|
8896
9165
|
function restoreFromActiveSessions(activeSessions, reason) {
|
|
8897
|
-
const wrapper =
|
|
9166
|
+
const wrapper = findAnyVariantsWrapper();
|
|
8898
9167
|
if (wrapper && !isFrameworkComponentPreviewMode(wrapper.dataset.impeccablePreview)) return false;
|
|
8899
9168
|
if (svelteComponentSession?.sessionId === currentSessionId) return false;
|
|
8900
9169
|
return restoreSessionWithoutWrapper(reason || 'sse_connected', activeSessions);
|
|
@@ -8987,14 +9256,15 @@ void main() {
|
|
|
8987
9256
|
return sessionState.isHandled(id);
|
|
8988
9257
|
}
|
|
8989
9258
|
|
|
8990
|
-
function clearHandled() {
|
|
8991
|
-
sessionState.clearHandled();
|
|
9259
|
+
function clearHandled(sessionId) {
|
|
9260
|
+
sessionState.clearHandled(sessionId);
|
|
8992
9261
|
}
|
|
8993
9262
|
|
|
8994
9263
|
function cleanup(options) {
|
|
8995
9264
|
const restoreOriginal = options?.restoreOriginal === true;
|
|
8996
9265
|
const instantChrome = options?.instantChrome === true;
|
|
8997
9266
|
const cleanupSessionId = currentSessionId;
|
|
9267
|
+
const cleanupRevision = liveInteractionRevision;
|
|
8998
9268
|
clearMountErrorCard();
|
|
8999
9269
|
lastReportedMountFailure = null;
|
|
9000
9270
|
if (svelteComponentSession?.sessionId === cleanupSessionId) {
|
|
@@ -9006,25 +9276,55 @@ void main() {
|
|
|
9006
9276
|
// reconciler later tries to remove a wrapper we already removed.
|
|
9007
9277
|
// Schedule a 2s fallback that does the manual swap only if HMR hasn't
|
|
9008
9278
|
// replaced the wrapper by then (keeps static-server / no-HMR flows alive).
|
|
9009
|
-
|
|
9010
|
-
|
|
9279
|
+
// Every match, not the first: a target inside a `.map()` renders one
|
|
9280
|
+
// wrapper per item, and hiding only one leaves the rest of the
|
|
9281
|
+
// discarded variants on screen.
|
|
9282
|
+
const discardWrappers = discardedWrappers(cleanupSessionId);
|
|
9283
|
+
if (discardWrappers.length > 0) {
|
|
9011
9284
|
if (restoreOriginal) showOriginalDuringDiscard(cleanupSessionId);
|
|
9012
|
-
else
|
|
9285
|
+
else for (const discardWrapper of discardWrappers) discardWrapper.style.display = 'none';
|
|
9013
9286
|
}
|
|
9014
9287
|
setTimeout(function() {
|
|
9015
|
-
|
|
9016
|
-
if (!cleanupSessionId)
|
|
9017
|
-
|
|
9018
|
-
|
|
9019
|
-
|
|
9020
|
-
|
|
9021
|
-
|
|
9022
|
-
|
|
9023
|
-
|
|
9024
|
-
|
|
9288
|
+
const recoverySuperseded = deferredRecoverySuperseded(cleanupSessionId, cleanupRevision);
|
|
9289
|
+
if (!cleanupSessionId) {
|
|
9290
|
+
removeDiscardStateStylesheet();
|
|
9291
|
+
return;
|
|
9292
|
+
}
|
|
9293
|
+
const lateWrappers = discardedWrappers(cleanupSessionId);
|
|
9294
|
+
if (lateWrappers.length === 0) {
|
|
9295
|
+
removeDiscardStateStylesheet(cleanupSessionId);
|
|
9296
|
+
return;
|
|
9297
|
+
}
|
|
9298
|
+
// Duplicates all render from one source element, so HMR ownership is
|
|
9299
|
+
// uniform across them; the first is a fair witness for the set.
|
|
9300
|
+
const lateWrapper = lateWrappers[0];
|
|
9301
|
+
if (recoverySuperseded) {
|
|
9302
|
+
if (hasFrameworkHmrOwnership(lateWrapper)) {
|
|
9303
|
+
watchForDiscardedFrameworkWrapperRemoval(cleanupSessionId);
|
|
9304
|
+
} else {
|
|
9305
|
+
releaseDiscardedStaticWrappers(cleanupSessionId, lateWrappers);
|
|
9025
9306
|
}
|
|
9307
|
+
return;
|
|
9026
9308
|
}
|
|
9027
|
-
lateWrapper
|
|
9309
|
+
if (hasFrameworkHmrOwnership(lateWrapper)) {
|
|
9310
|
+
// As on accept, never restructure framework-owned DOM. If HMR missed
|
|
9311
|
+
// the final source rewrite, reload once after a grace window so the
|
|
9312
|
+
// discarded source becomes authoritative without a reconciler race.
|
|
9313
|
+
setTimeout(function() {
|
|
9314
|
+
const staleWrappers = discardedWrappers(cleanupSessionId);
|
|
9315
|
+
if (deferredRecoverySuperseded(cleanupSessionId, cleanupRevision)) {
|
|
9316
|
+
if (staleWrappers.length === 0) removeDiscardStateStylesheet(cleanupSessionId);
|
|
9317
|
+
else watchForDiscardedFrameworkWrapperRemoval(cleanupSessionId);
|
|
9318
|
+
return;
|
|
9319
|
+
}
|
|
9320
|
+
removeDiscardStateStylesheet(cleanupSessionId);
|
|
9321
|
+
// A reload restores every wrapper's original at once, so there is
|
|
9322
|
+
// nothing per-wrapper to do here.
|
|
9323
|
+
if (staleWrappers.length > 0) location.reload();
|
|
9324
|
+
}, 2000);
|
|
9325
|
+
return;
|
|
9326
|
+
}
|
|
9327
|
+
releaseDiscardedStaticWrappers(cleanupSessionId, lateWrappers);
|
|
9028
9328
|
}, 2000);
|
|
9029
9329
|
}
|
|
9030
9330
|
hideBar(instantChrome);
|
|
@@ -9107,12 +9407,127 @@ void main() {
|
|
|
9107
9407
|
// Resume an active variant session after HMR/page reload.
|
|
9108
9408
|
// If a [data-impeccable-variants] wrapper exists in the DOM, the agent wrote
|
|
9109
9409
|
// variants before HMR fired. Pick up where we left off.
|
|
9110
|
-
function
|
|
9111
|
-
|
|
9410
|
+
function handledWrapperReloadKey(sessionId) {
|
|
9411
|
+
return HANDLED_WRAPPER_RELOAD_KEY + ':' + sessionId;
|
|
9412
|
+
}
|
|
9413
|
+
|
|
9414
|
+
function clearHandledWrapperReloadStamp(sessionId) {
|
|
9415
|
+
try {
|
|
9416
|
+
if (sessionId) {
|
|
9417
|
+
sessionStorage.removeItem(handledWrapperReloadKey(sessionId));
|
|
9418
|
+
const legacy = sessionStorage.getItem(HANDLED_WRAPPER_RELOAD_KEY) || '';
|
|
9419
|
+
if (legacy === sessionId || legacy.startsWith(sessionId + ':')) {
|
|
9420
|
+
sessionStorage.removeItem(HANDLED_WRAPPER_RELOAD_KEY);
|
|
9421
|
+
}
|
|
9422
|
+
return;
|
|
9423
|
+
}
|
|
9424
|
+
sessionStorage.removeItem(HANDLED_WRAPPER_RELOAD_KEY);
|
|
9425
|
+
for (let i = sessionStorage.length - 1; i >= 0; i--) {
|
|
9426
|
+
const key = sessionStorage.key(i);
|
|
9427
|
+
if (key?.startsWith(HANDLED_WRAPPER_RELOAD_KEY + ':')) sessionStorage.removeItem(key);
|
|
9428
|
+
}
|
|
9429
|
+
} catch {}
|
|
9430
|
+
}
|
|
9431
|
+
|
|
9432
|
+
function scheduleHandledRuntimeWrapperReload(wrapper, recoveryRevision = liveInteractionRevision) {
|
|
9433
|
+
const sessionId = wrapper?.dataset?.impeccableVariants
|
|
9434
|
+
|| wrapper?.dataset?.impeccableCarbonize;
|
|
9435
|
+
if (!sessionId || !isSessionHandled(sessionId)) return false;
|
|
9436
|
+
if (deferredRecoverySuperseded(sessionId, recoveryRevision)) return true;
|
|
9437
|
+
|
|
9438
|
+
if (handledRuntimeWrapperReloadSessions.has(sessionId)) return true;
|
|
9439
|
+
let reloadAttempts = 0;
|
|
9440
|
+
try {
|
|
9441
|
+
reloadAttempts = Number(sessionStorage.getItem(handledWrapperReloadKey(sessionId))) || 0;
|
|
9442
|
+
if (reloadAttempts >= 2) return true;
|
|
9443
|
+
sessionStorage.setItem(handledWrapperReloadKey(sessionId), String(reloadAttempts + 1));
|
|
9444
|
+
} catch {}
|
|
9445
|
+
handledRuntimeWrapperReloadSessions.add(sessionId);
|
|
9446
|
+
|
|
9447
|
+
// A framework refresh can replace the variants tree with an intermediate
|
|
9448
|
+
// carbonize tree and reload the page, cancelling the original accept timer.
|
|
9449
|
+
// Let the file-side cleanup settle, then reload once from authoritative
|
|
9450
|
+
// source. The sessionStorage stamp prevents a stale dev-server response
|
|
9451
|
+
// from turning this recovery into a reload loop.
|
|
9452
|
+
setTimeout(function() {
|
|
9453
|
+
if (deferredRecoverySuperseded(sessionId, recoveryRevision)) {
|
|
9454
|
+
clearHandledWrapperReloadStamp(sessionId);
|
|
9455
|
+
handledRuntimeWrapperReloadSessions.delete(sessionId);
|
|
9456
|
+
return;
|
|
9457
|
+
}
|
|
9458
|
+
const staleWrapper = document.querySelector(
|
|
9459
|
+
'[data-impeccable-variants="' + sessionId + '"],'
|
|
9460
|
+
+ '[data-impeccable-carbonize="' + sessionId + '"]',
|
|
9461
|
+
);
|
|
9462
|
+
if (staleWrapper) location.reload();
|
|
9463
|
+
else {
|
|
9464
|
+
clearHandledWrapperReloadStamp(sessionId);
|
|
9465
|
+
handledRuntimeWrapperReloadSessions.delete(sessionId);
|
|
9466
|
+
}
|
|
9467
|
+
}, 3000);
|
|
9468
|
+
return true;
|
|
9469
|
+
}
|
|
9470
|
+
|
|
9471
|
+
function watchForHandledRuntimeWrapper(sessionId, recoveryRevision = liveInteractionRevision) {
|
|
9472
|
+
if (!sessionId || !document.body) return;
|
|
9473
|
+
const existing = handledRuntimeWrapperWatchers.get(sessionId);
|
|
9474
|
+
existing?.observer.disconnect();
|
|
9475
|
+
if (existing?.timer) clearTimeout(existing.timer);
|
|
9476
|
+
|
|
9477
|
+
const findHandledWrapper = function() {
|
|
9478
|
+
const wrapper = document.querySelector(
|
|
9479
|
+
'[data-impeccable-variants="' + sessionId + '"],'
|
|
9480
|
+
+ '[data-impeccable-carbonize="' + sessionId + '"]',
|
|
9481
|
+
);
|
|
9482
|
+
if (wrapper) scheduleHandledRuntimeWrapperReload(wrapper, recoveryRevision);
|
|
9483
|
+
};
|
|
9484
|
+
|
|
9485
|
+
// Vite can briefly render the clean accepted tree, then apply a delayed
|
|
9486
|
+
// carbonize refresh after the one-shot accept fallback has already passed.
|
|
9487
|
+
// Keep a bounded scout alive through that refresh window so a late stale
|
|
9488
|
+
// framework tree still reloads from the now-authoritative source.
|
|
9489
|
+
const observer = new MutationObserver(findHandledWrapper);
|
|
9490
|
+
observer.observe(document.body, { childList: true, subtree: true });
|
|
9491
|
+
const timer = setTimeout(function() {
|
|
9492
|
+
if (handledRuntimeWrapperWatchers.get(sessionId)?.observer !== observer) return;
|
|
9493
|
+
observer.disconnect();
|
|
9494
|
+
handledRuntimeWrapperWatchers.delete(sessionId);
|
|
9495
|
+
}, 12000);
|
|
9496
|
+
handledRuntimeWrapperWatchers.set(sessionId, { observer, timer });
|
|
9497
|
+
findHandledWrapper();
|
|
9498
|
+
}
|
|
9499
|
+
|
|
9500
|
+
function restoreSessionSupersedingHandledWrapper(runtimeWrapper) {
|
|
9501
|
+
const handledSessionId = runtimeWrapper?.dataset?.impeccableVariants
|
|
9502
|
+
|| runtimeWrapper?.dataset?.impeccableCarbonize;
|
|
9503
|
+
if (!handledSessionId || !isSessionHandled(handledSessionId)) return false;
|
|
9504
|
+
|
|
9505
|
+
// Accept releases the picker before carbonize finishes, so a replacement
|
|
9506
|
+
// generation can already be durable while the prior handled wrapper is
|
|
9507
|
+
// still mounted. Restore that newer session before the stale-wrapper
|
|
9508
|
+
// recovery path gets a chance to reload or consume its retry budget.
|
|
9509
|
+
const saved = loadSession();
|
|
9510
|
+
if (!saved?.id || saved.id === handledSessionId || isSessionHandled(saved.id)) return false;
|
|
9511
|
+
if (currentSessionId === saved.id) return true;
|
|
9512
|
+
return restoreSessionWithoutWrapper('browser_resumed_over_handled_wrapper');
|
|
9513
|
+
}
|
|
9514
|
+
|
|
9515
|
+
function resumeSession(recoveryRevision = liveInteractionRevision, opts = {}) {
|
|
9516
|
+
// Which path resumed matters in the journal: an init resume is a fresh
|
|
9517
|
+
// page load, the deferred-wrapper scout is a mid-page-load arrival. Both
|
|
9518
|
+
// used to log the same `browser_resumed`, which made issue #719 take a
|
|
9519
|
+
// DOM reconstruction to diagnose.
|
|
9520
|
+
const resumeReason = opts.reason || 'browser_resumed';
|
|
9521
|
+
const wrapper = findAnyVariantsWrapper();
|
|
9522
|
+
const runtimeWrapper = wrapper || document.querySelector('[data-impeccable-carbonize]');
|
|
9523
|
+
if (restoreSessionSupersedingHandledWrapper(runtimeWrapper)) return true;
|
|
9524
|
+
if (scheduleHandledRuntimeWrapperReload(runtimeWrapper, recoveryRevision)) return false;
|
|
9112
9525
|
if (!wrapper) {
|
|
9113
9526
|
if (restoreSessionWithoutWrapper('browser_resumed_without_wrapper')) return true;
|
|
9114
9527
|
clearSession();
|
|
9115
|
-
|
|
9528
|
+
// Keep the bounded handled-id history durable. A framework can hydrate a
|
|
9529
|
+
// completed wrapper well after initialization, and a later reload must
|
|
9530
|
+
// still recognize that wrapper as recovery work rather than resume it.
|
|
9116
9531
|
return false;
|
|
9117
9532
|
}
|
|
9118
9533
|
|
|
@@ -9132,7 +9547,7 @@ void main() {
|
|
|
9132
9547
|
wrapper.remove();
|
|
9133
9548
|
if (restoreSessionWithoutWrapper('browser_resumed_svelte_orphan_wrapper')) return true;
|
|
9134
9549
|
clearSession();
|
|
9135
|
-
clearHandled();
|
|
9550
|
+
clearHandled(sessionId);
|
|
9136
9551
|
return false;
|
|
9137
9552
|
}
|
|
9138
9553
|
|
|
@@ -9202,16 +9617,38 @@ void main() {
|
|
|
9202
9617
|
|
|
9203
9618
|
showBar(state === 'CYCLING' ? 'cycling' : 'generating');
|
|
9204
9619
|
startScrollTracking();
|
|
9205
|
-
//
|
|
9206
|
-
//
|
|
9207
|
-
//
|
|
9208
|
-
//
|
|
9209
|
-
|
|
9620
|
+
// A resume can BE the arrival, not just a re-entry after one. The server's
|
|
9621
|
+
// generation preflight runs live-wrap with --defer-source-write, so the
|
|
9622
|
+
// wrapper and every variant reach the DOM in one HMR batch, and the
|
|
9623
|
+
// deferred-wrapper scout (constructed at init) runs before the variant
|
|
9624
|
+
// MutationObserver (constructed at Go) on that batch. Finish the same
|
|
9625
|
+
// transition the observer would have finished. Without hideShaderOverlay
|
|
9626
|
+
// the generating shader stays frozen over the target and the session looks
|
|
9627
|
+
// stuck at GENERATING while the bar already cycles (issue #719).
|
|
9628
|
+
if (state === 'CYCLING') {
|
|
9629
|
+
recoveryWaitingForAnchor = false;
|
|
9630
|
+
hideShaderOverlay();
|
|
9631
|
+
if (isInsert) finalizeInsertSession();
|
|
9632
|
+
disableInlineEdit();
|
|
9633
|
+
// Build the params panel for the restored visible variant. Previously
|
|
9634
|
+
// this was missed on page-reload resume: showVariantInDOM above fires
|
|
9635
|
+
// refreshParamsPanel, but state was still IDLE at that moment so it
|
|
9636
|
+
// hid. Now that state is CYCLING, re-fire.
|
|
9637
|
+
refreshParamsPanel();
|
|
9638
|
+
}
|
|
9210
9639
|
saveSession();
|
|
9211
9640
|
if (arrivedVariants > 0 && arrivedVariants < expectedVariants) {
|
|
9212
9641
|
sendCheckpoint('variants_progress');
|
|
9213
9642
|
} else {
|
|
9214
|
-
queueCheckpoint(
|
|
9643
|
+
queueCheckpoint(resumeReason);
|
|
9644
|
+
// Only variants_progress and variants_ready count as publication
|
|
9645
|
+
// progress. When the resume is the arrival, the observer never gets to
|
|
9646
|
+
// report it (this function disconnects and re-creates it below, which
|
|
9647
|
+
// drops the records it had already queued for this same batch), so
|
|
9648
|
+
// without this the server never learns the variants were published.
|
|
9649
|
+
if (arrivedVariants > 0 && arrivedVariants >= expectedVariants && expectedVariants > 0) {
|
|
9650
|
+
sendCheckpoint('variants_ready');
|
|
9651
|
+
}
|
|
9215
9652
|
}
|
|
9216
9653
|
|
|
9217
9654
|
// Start observing for more variants AFTER initial setup
|
|
@@ -11138,10 +11575,36 @@ void main() {
|
|
|
11138
11575
|
const scanId = String(++detectScanSeq);
|
|
11139
11576
|
activeDetectScanId = scanId;
|
|
11140
11577
|
pendingDetectScanId = scanId;
|
|
11578
|
+
// Send the project's detector waivers with the scan so the overlay
|
|
11579
|
+
// filters the same findings the CLI and the edit hook do (issue #639).
|
|
11580
|
+
// live-browser-ignores.js resolves .impeccable config for this page:
|
|
11581
|
+
// ignoreRules suppress outright, wildcard ignoreValues suppress their
|
|
11582
|
+
// rule in the files they name, ignoreFiles that name the page skip the
|
|
11583
|
+
// scan wholesale, and the rest match on the finding's own value inside
|
|
11584
|
+
// the detector. Guarded twice: a stale cached live.js without the
|
|
11585
|
+
// resolver part still scans, and a resolver that throws must not brick
|
|
11586
|
+
// the detect toggle; both degrade to an unfiltered scan.
|
|
11587
|
+
const ignoresApi = window.__IMPECCABLE_LIVE_IGNORES__;
|
|
11588
|
+
let ignores = { disabledRules: [], disabledValues: [], skipScan: false };
|
|
11589
|
+
if (typeof ignoresApi?.resolveDetectIgnores === 'function') {
|
|
11590
|
+
try {
|
|
11591
|
+
ignores = ignoresApi.resolveDetectIgnores({
|
|
11592
|
+
ignores: window.__IMPECCABLE_PROJECT_IGNORES__,
|
|
11593
|
+
pathname: location.pathname,
|
|
11594
|
+
}) || ignores;
|
|
11595
|
+
} catch (e) {
|
|
11596
|
+
ignores = { disabledRules: [], disabledValues: [], skipScan: false };
|
|
11597
|
+
}
|
|
11598
|
+
}
|
|
11141
11599
|
window.postMessage({
|
|
11142
11600
|
source: 'impeccable-command',
|
|
11143
11601
|
action: 'scan',
|
|
11144
|
-
config: {
|
|
11602
|
+
config: {
|
|
11603
|
+
scanId,
|
|
11604
|
+
disabledRules: ignores.disabledRules || [],
|
|
11605
|
+
disabledValues: ignores.disabledValues || [],
|
|
11606
|
+
skipScan: ignores.skipScan === true,
|
|
11607
|
+
},
|
|
11145
11608
|
}, '*');
|
|
11146
11609
|
}
|
|
11147
11610
|
|
|
@@ -12489,22 +12952,28 @@ void main() {
|
|
|
12489
12952
|
connectSSE();
|
|
12490
12953
|
|
|
12491
12954
|
// Check for an active session to resume (variant wrapper already in DOM after HMR)
|
|
12492
|
-
|
|
12955
|
+
const resumed = resumeSession();
|
|
12956
|
+
if (!resumed) {
|
|
12493
12957
|
console.log('[impeccable] Live variant mode ready. Hover over elements to pick one.');
|
|
12494
|
-
|
|
12495
|
-
|
|
12496
|
-
|
|
12958
|
+
} else {
|
|
12959
|
+
console.log('[impeccable] Resumed active variant session ' + currentSessionId + ' (' + arrivedVariants + '/' + expectedVariants + ' variants).');
|
|
12960
|
+
}
|
|
12961
|
+
|
|
12962
|
+
// SvelteKit, React, and other frameworks may restore a durable session
|
|
12963
|
+
// before hydration adds its variant wrapper. Keep a deferred-wrapper scout
|
|
12964
|
+
// whenever init did not see a runtime wrapper, even if local/server state
|
|
12965
|
+
// was already restored successfully. Disconnect on the first wrapper hit.
|
|
12966
|
+
if (!resumed || !document.querySelector('[data-impeccable-variants],[data-impeccable-carbonize]')) {
|
|
12967
|
+
const deferredResumeRevision = liveInteractionRevision;
|
|
12497
12968
|
const scout = new MutationObserver(() => {
|
|
12498
|
-
const wrapper = document.querySelector('[data-impeccable-variants]');
|
|
12969
|
+
const wrapper = document.querySelector('[data-impeccable-variants],[data-impeccable-carbonize]');
|
|
12499
12970
|
if (!wrapper) return;
|
|
12500
12971
|
scout.disconnect();
|
|
12501
|
-
if (resumeSession()) {
|
|
12972
|
+
if (resumeSession(deferredResumeRevision, { reason: 'browser_resumed_deferred_wrapper' })) {
|
|
12502
12973
|
console.log('[impeccable] Resumed deferred session ' + currentSessionId + ' (post-hydration).');
|
|
12503
12974
|
}
|
|
12504
12975
|
});
|
|
12505
12976
|
scout.observe(document.body, { childList: true, subtree: true });
|
|
12506
|
-
} else {
|
|
12507
|
-
console.log('[impeccable] Resumed active variant session ' + currentSessionId + ' (' + arrivedVariants + '/' + expectedVariants + ' variants).');
|
|
12508
12977
|
}
|
|
12509
12978
|
|
|
12510
12979
|
if (state === 'IDLE' && (pickActive || insertActive)) setLiveState('PICKING');
|