quiver-cli 0.7.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +110 -45
- package/bin/quiver-cli.mjs +3 -1
- package/dist/cli.js +733 -499
- package/package.json +2 -2
- package/template/.agents/AGENTS.md +4 -3
- package/template/.agents/config.json +7 -0
- package/template/.agents/plugins/opencode/rtk.ts +34 -0
- package/template/.agents/skills/agent-browser/SKILL.md +1 -0
- package/template/.agents/skills/apps/skybridge/SKILL.md +4 -0
- package/template/.agents/skills/design/impeccable/SKILL.md +36 -118
- package/template/.agents/skills/design/impeccable/reference/adapt.md +1 -0
- package/template/.agents/skills/design/impeccable/reference/adapt.native.md +58 -0
- package/template/.agents/skills/design/impeccable/reference/android.md +40 -0
- package/template/.agents/skills/design/impeccable/reference/animate.md +73 -188
- package/template/.agents/skills/design/impeccable/reference/audit.md +12 -9
- package/template/.agents/skills/design/impeccable/reference/audit.native.md +139 -0
- package/template/.agents/skills/design/impeccable/reference/bolder.md +19 -101
- package/template/.agents/skills/design/impeccable/reference/clarify.md +59 -253
- package/template/.agents/skills/design/impeccable/reference/colorize.md +51 -222
- package/template/.agents/skills/design/impeccable/reference/craft-floor.md +42 -0
- package/template/.agents/skills/design/impeccable/reference/craft.md +3 -121
- package/template/.agents/skills/design/impeccable/reference/critique.md +44 -23
- package/template/.agents/skills/design/impeccable/reference/degraded/asset-producer.md +90 -0
- package/template/.agents/skills/design/impeccable/reference/degraded/documenter.md +24 -0
- package/template/.agents/skills/design/impeccable/reference/degraded/finish-reviewer.md +37 -0
- package/template/.agents/skills/design/impeccable/reference/degraded/manual-edit-applier.md +92 -0
- package/template/.agents/skills/design/impeccable/reference/delight.md +47 -279
- package/template/.agents/skills/design/impeccable/reference/distill.md +2 -2
- package/template/.agents/skills/design/impeccable/reference/doctor.md +53 -0
- package/template/.agents/skills/design/impeccable/reference/document.md +60 -73
- package/template/.agents/skills/design/impeccable/reference/harden.md +1 -12
- package/template/.agents/skills/design/impeccable/reference/hooks.md +20 -5
- package/template/.agents/skills/design/impeccable/reference/init.md +72 -119
- package/template/.agents/skills/design/impeccable/reference/ios.md +45 -0
- package/template/.agents/skills/design/impeccable/reference/layout.md +54 -131
- package/template/.agents/skills/design/impeccable/reference/live-setup.md +102 -0
- package/template/.agents/skills/design/impeccable/reference/live.md +116 -511
- package/template/.agents/skills/design/impeccable/reference/new-work.md +105 -0
- package/template/.agents/skills/design/impeccable/reference/{product.md → operate.md} +6 -5
- package/template/.agents/skills/design/impeccable/reference/optimize.md +4 -4
- package/template/.agents/skills/design/impeccable/reference/overdrive.md +1 -4
- package/template/.agents/skills/design/impeccable/reference/polish.md +68 -212
- package/template/.agents/skills/design/impeccable/reference/quieter.md +3 -3
- package/template/.agents/skills/design/impeccable/reference/routing.md +18 -0
- package/template/.agents/skills/design/impeccable/reference/shape.md +38 -144
- package/template/.agents/skills/design/impeccable/reference/typeset.md +51 -250
- package/template/.agents/skills/design/impeccable/reference/visualize.md +47 -0
- package/template/.agents/skills/design/impeccable/scripts/command-metadata.json +1 -1
- package/template/.agents/skills/design/impeccable/scripts/concept-seed.mjs +558 -0
- package/template/.agents/skills/design/impeccable/scripts/context-signals.mjs +119 -10
- package/template/.agents/skills/design/impeccable/scripts/context.mjs +534 -45
- package/template/.agents/skills/design/impeccable/scripts/critique-storage.mjs +18 -47
- package/template/.agents/skills/design/impeccable/scripts/detector/browser/injected/index.mjs +96 -10
- package/template/.agents/skills/design/impeccable/scripts/detector/cli/main.mjs +174 -26
- package/template/.agents/skills/design/impeccable/scripts/detector/design-system.mjs +233 -0
- package/template/.agents/skills/design/impeccable/scripts/detector/detect-antipatterns-browser.js +3348 -203
- package/template/.agents/skills/design/impeccable/scripts/detector/engines/browser/detect-url.mjs +102 -7
- package/template/.agents/skills/design/impeccable/scripts/detector/engines/regex/detect-text.mjs +297 -97
- package/template/.agents/skills/design/impeccable/scripts/detector/engines/static-html/css-cascade.mjs +187 -16
- package/template/.agents/skills/design/impeccable/scripts/detector/engines/static-html/detect-html.mjs +41 -11
- package/template/.agents/skills/design/impeccable/scripts/detector/findings.mjs +7 -1
- package/template/.agents/skills/design/impeccable/scripts/detector/node/file-system.mjs +16 -2
- package/template/.agents/skills/design/impeccable/scripts/detector/registry/antipatterns.mjs +207 -38
- package/template/.agents/skills/design/impeccable/scripts/detector/rules/checks.mjs +3082 -173
- package/template/.agents/skills/design/impeccable/scripts/detector/shared/constants.mjs +11 -0
- package/template/.agents/skills/design/impeccable/scripts/detector/shared/fonts.mjs +30 -0
- package/template/.agents/skills/design/impeccable/scripts/doctor.mjs +336 -0
- package/template/.agents/skills/design/impeccable/scripts/embed-prompt.mjs +133 -0
- package/template/.agents/skills/design/impeccable/scripts/generate-image.mjs +240 -0
- package/template/.agents/skills/design/impeccable/scripts/hook-admin.mjs +98 -18
- package/template/.agents/skills/design/impeccable/scripts/hook-before-edit.mjs +46 -6
- package/template/.agents/skills/design/impeccable/scripts/hook-lib.mjs +518 -50
- package/template/.agents/skills/design/impeccable/scripts/hook.mjs +25 -8
- package/template/.agents/skills/design/impeccable/scripts/lib/artifact-schema.mjs +93 -0
- package/template/.agents/skills/design/impeccable/scripts/lib/composition-catalog.mjs +200 -0
- package/template/.agents/skills/design/impeccable/scripts/lib/concept-catalog.mjs +357 -0
- package/template/.agents/skills/design/impeccable/scripts/lib/impeccable-config.mjs +27 -7
- package/template/.agents/skills/design/impeccable/scripts/lib/impeccable-paths.mjs +17 -8
- package/template/.agents/skills/design/impeccable/scripts/lib/provider.mjs +5 -0
- package/template/.agents/skills/design/impeccable/scripts/lib/roll-selection.mjs +362 -0
- package/template/.agents/skills/design/impeccable/scripts/lib/staleness-deep.mjs +457 -0
- package/template/.agents/skills/design/impeccable/scripts/lib/staleness-notice.mjs +169 -0
- package/template/.agents/skills/design/impeccable/scripts/lib/staleness.mjs +457 -0
- package/template/.agents/skills/design/impeccable/scripts/lib/surface-briefs.mjs +151 -0
- package/template/.agents/skills/design/impeccable/scripts/lib/target-slug.mjs +33 -0
- package/template/.agents/skills/design/impeccable/scripts/lib/template-extensions.mjs +146 -0
- package/template/.agents/skills/design/impeccable/scripts/live/accept-css.mjs +617 -0
- package/template/.agents/skills/design/impeccable/scripts/live/accept-verify.mjs +60 -0
- package/template/.agents/skills/design/impeccable/scripts/live/browser-script-parts.mjs +7 -1
- package/template/.agents/skills/design/impeccable/scripts/live/completion.mjs +10 -1
- package/template/.agents/skills/design/impeccable/scripts/live/event-validation.mjs +67 -5
- package/template/.agents/skills/design/impeccable/scripts/live/frameworks/astro.mjs +47 -0
- package/template/.agents/skills/design/impeccable/scripts/live/frameworks/detect-utils.mjs +73 -0
- package/template/.agents/skills/design/impeccable/scripts/live/frameworks/index.mjs +143 -0
- package/template/.agents/skills/design/impeccable/scripts/live/frameworks/journal.mjs +197 -0
- package/template/.agents/skills/design/impeccable/scripts/live/frameworks/nextjs.mjs +49 -0
- package/template/.agents/skills/design/impeccable/scripts/live/frameworks/nuxt.mjs +161 -0
- package/template/.agents/skills/design/impeccable/scripts/live/frameworks/script-src.mjs +17 -0
- package/template/.agents/skills/design/impeccable/scripts/live/frameworks/static-html.mjs +26 -0
- package/template/.agents/skills/design/impeccable/scripts/live/frameworks/sveltekit.mjs +71 -0
- package/template/.agents/skills/design/impeccable/scripts/live/frameworks/tag-strategy.mjs +247 -0
- package/template/.agents/skills/design/impeccable/scripts/live/frameworks/tanstack-start.mjs +70 -0
- package/template/.agents/skills/design/impeccable/scripts/live/frameworks/vite-generic.mjs +42 -0
- package/template/.agents/skills/design/impeccable/scripts/live/generation-preflight.mjs +149 -0
- package/template/.agents/skills/design/impeccable/scripts/live/instructions.mjs +142 -0
- package/template/.agents/skills/design/impeccable/scripts/live/poll-lanes.mjs +14 -0
- package/template/.agents/skills/design/impeccable/scripts/live/roots.mjs +508 -0
- package/template/.agents/skills/design/impeccable/scripts/live/session-store.mjs +324 -50
- package/template/.agents/skills/design/impeccable/scripts/live/source-lock.mjs +105 -0
- package/template/.agents/skills/design/impeccable/scripts/live/source-search.mjs +105 -0
- package/template/.agents/skills/design/impeccable/scripts/live/svelte-ast.mjs +961 -0
- package/template/.agents/skills/design/impeccable/scripts/live/svelte-component.mjs +588 -72
- package/template/.agents/skills/design/impeccable/scripts/live/sveltekit-adapter.mjs +59 -17
- package/template/.agents/skills/design/impeccable/scripts/live/tanstack-adapter.mjs +280 -0
- package/template/.agents/skills/design/impeccable/scripts/live/vocabulary.mjs +135 -0
- package/template/.agents/skills/design/impeccable/scripts/live-accept.mjs +210 -68
- package/template/.agents/skills/design/impeccable/scripts/live-browser.js +1562 -223
- package/template/.agents/skills/design/impeccable/scripts/live-commit-manual-edits.mjs +3 -0
- package/template/.agents/skills/design/impeccable/scripts/live-complete.mjs +33 -1
- package/template/.agents/skills/design/impeccable/scripts/live-inject.mjs +175 -255
- package/template/.agents/skills/design/impeccable/scripts/live-insert.mjs +26 -6
- package/template/.agents/skills/design/impeccable/scripts/live-manual-edit-evidence.mjs +6 -1
- package/template/.agents/skills/design/impeccable/scripts/live-poll.mjs +61 -16
- package/template/.agents/skills/design/impeccable/scripts/live-resume.mjs +39 -10
- package/template/.agents/skills/design/impeccable/scripts/live-server.mjs +573 -47
- package/template/.agents/skills/design/impeccable/scripts/live-status.mjs +17 -7
- package/template/.agents/skills/design/impeccable/scripts/live-wrap.mjs +124 -91
- package/template/.agents/skills/design/impeccable/scripts/live.mjs +88 -26
- package/template/.agents/skills/design/impeccable/scripts/palette.mjs +76 -81
- package/template/.agents/skills/design/impeccable/scripts/pin.mjs +18 -11
- package/template/.agents/skills/design/impeccable/scripts/serve-question.mjs +932 -0
- package/template/.agents/skills/design/impeccable/scripts/surface-brief.mjs +74 -0
- package/template/.agents/skills/design/shadcn/SKILL.md +46 -11
- package/template/.agents/skills/design/shadcn/cli.md +49 -16
- package/template/.agents/skills/design/shadcn/customization.md +14 -7
- package/template/.agents/skills/design/shadcn/evals/evals.json +30 -0
- package/template/.agents/skills/design/shadcn/mcp.md +27 -16
- package/template/.agents/skills/design/shadcn/registry.md +277 -0
- package/template/.agents/skills/design/shadcn/rules/chat.md +224 -0
- package/template/.agents/skills/design/shadcn/rules/composition.md +20 -2
- package/template/.agents/skills/design/shadcn/rules/styling.md +23 -0
- package/template/.agents/skills/find-skills/SKILL.md +2 -3
- package/template/.agents/skills/hono/SKILL.md +579 -0
- package/template/.agents/skills/integrations/langfuse/SKILL.md +10 -6
- package/template/.agents/skills/integrations/langfuse/references/ci-cd.md +41 -0
- package/template/.agents/skills/integrations/langfuse/references/cli.md +8 -0
- package/template/.agents/skills/integrations/langfuse/references/error-analysis.md +15 -27
- package/template/.agents/skills/integrations/langfuse/references/instrumentation.md +39 -52
- package/template/.agents/skills/integrations/langfuse/references/judge-calibration.md +5 -2
- package/template/.agents/skills/integrations/langfuse/references/prompt-engineering.md +35 -0
- package/template/.agents/skills/integrations/langfuse/references/prompt-migration.md +41 -196
- package/template/.agents/skills/integrations/langfuse/references/skill-feedback.md +3 -0
- package/template/.agents/skills/integrations/langfuse/references/trace-evaluator-upgrade.md +76 -0
- package/template/.agents/skills/integrations/langfuse/references/user-feedback.md +4 -0
- package/template/.agents/skills/integrations/langfuse/references/v4-project-migration.md +73 -0
- package/template/.agents/skills/supabase/CHANGELOG.md +71 -0
- package/template/.agents/skills/supabase/SKILL.md +145 -0
- package/template/.agents/skills/supabase/assets/feedback-issue-template.md +17 -0
- package/template/.agents/skills/supabase/references/skill-feedback.md +17 -0
- package/template/.agents/skills/supabase-postgres-best-practices/CHANGELOG.md +73 -0
- package/template/.agents/skills/supabase-postgres-best-practices/SKILL.md +64 -0
- package/template/.agents/skills/supabase-postgres-best-practices/references/_contributing.md +170 -0
- package/template/.agents/skills/supabase-postgres-best-practices/references/_sections.md +39 -0
- package/template/.agents/skills/supabase-postgres-best-practices/references/_template.md +34 -0
- package/template/.agents/skills/supabase-postgres-best-practices/references/advanced-full-text-search.md +55 -0
- package/template/.agents/skills/supabase-postgres-best-practices/references/advanced-jsonb-indexing.md +49 -0
- package/template/.agents/skills/supabase-postgres-best-practices/references/conn-idle-timeout.md +46 -0
- package/template/.agents/skills/supabase-postgres-best-practices/references/conn-limits.md +44 -0
- package/template/.agents/skills/supabase-postgres-best-practices/references/conn-pooling.md +41 -0
- package/template/.agents/skills/supabase-postgres-best-practices/references/conn-prepared-statements.md +46 -0
- package/template/.agents/skills/supabase-postgres-best-practices/references/data-batch-inserts.md +54 -0
- package/template/.agents/skills/supabase-postgres-best-practices/references/data-n-plus-one.md +53 -0
- package/template/.agents/skills/supabase-postgres-best-practices/references/data-pagination.md +50 -0
- package/template/.agents/skills/supabase-postgres-best-practices/references/data-upsert.md +50 -0
- package/template/.agents/skills/supabase-postgres-best-practices/references/lock-advisory.md +56 -0
- package/template/.agents/skills/supabase-postgres-best-practices/references/lock-deadlock-prevention.md +68 -0
- package/template/.agents/skills/supabase-postgres-best-practices/references/lock-short-transactions.md +50 -0
- package/template/.agents/skills/supabase-postgres-best-practices/references/lock-skip-locked.md +54 -0
- package/template/.agents/skills/supabase-postgres-best-practices/references/monitor-explain-analyze.md +45 -0
- package/template/.agents/skills/supabase-postgres-best-practices/references/monitor-pg-stat-statements.md +55 -0
- package/template/.agents/skills/supabase-postgres-best-practices/references/monitor-vacuum-analyze.md +55 -0
- package/template/.agents/skills/supabase-postgres-best-practices/references/query-composite-indexes.md +44 -0
- package/template/.agents/skills/supabase-postgres-best-practices/references/query-covering-indexes.md +40 -0
- package/template/.agents/skills/supabase-postgres-best-practices/references/query-index-types.md +48 -0
- package/template/.agents/skills/supabase-postgres-best-practices/references/query-missing-indexes.md +43 -0
- package/template/.agents/skills/supabase-postgres-best-practices/references/query-partial-indexes.md +45 -0
- package/template/.agents/skills/supabase-postgres-best-practices/references/schema-constraints.md +80 -0
- package/template/.agents/skills/supabase-postgres-best-practices/references/schema-data-types.md +46 -0
- package/template/.agents/skills/supabase-postgres-best-practices/references/schema-foreign-key-indexes.md +59 -0
- package/template/.agents/skills/supabase-postgres-best-practices/references/schema-lowercase-identifiers.md +55 -0
- package/template/.agents/skills/supabase-postgres-best-practices/references/schema-partitioning.md +55 -0
- package/template/.agents/skills/supabase-postgres-best-practices/references/schema-primary-keys.md +61 -0
- package/template/.agents/skills/supabase-postgres-best-practices/references/security-privileges.md +54 -0
- package/template/.agents/skills/supabase-postgres-best-practices/references/security-rls-basics.md +50 -0
- package/template/.agents/skills/supabase-postgres-best-practices/references/security-rls-performance.md +63 -0
- package/template/.agents/upstreams.json +34 -12
- package/template/.agents/skills/design/impeccable/reference/brand.md +0 -108
- package/template/.agents/skills/design/impeccable/reference/codex.md +0 -105
- package/template/.agents/skills/design/impeccable/reference/interaction-design.md +0 -189
- package/template/.agents/skills/integrations/langfuse/references/sdk-upgrade.md +0 -175
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Nuxt registry entry, and the Nuxt adapter itself.
|
|
3
|
+
*
|
|
4
|
+
* A script element placed in app.vue is compiled as Vue-rendered DOM and is
|
|
5
|
+
* not executed. Nuxt instead auto-discovers client plugins. Keep the adapter
|
|
6
|
+
* generated, dev-only, and outside user-authored source: Live creates one
|
|
7
|
+
* marked .client.ts plugin on start and removes it on stop.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import fs from 'node:fs';
|
|
11
|
+
import path from 'node:path';
|
|
12
|
+
import { buildLiveScriptSrc } from './script-src.mjs';
|
|
13
|
+
import { findConfigFile } from './detect-utils.mjs';
|
|
14
|
+
|
|
15
|
+
export const NUXT_PLUGIN_MARKER = 'impeccable-live-nuxt-plugin';
|
|
16
|
+
export const NUXT_PLUGIN_NAME = 'impeccable-live.client.ts';
|
|
17
|
+
|
|
18
|
+
const NUXT_CONFIG_RE = /^nuxt\.config\.(?:js|mjs|cjs|ts|mts|cts)$/;
|
|
19
|
+
|
|
20
|
+
export function detectNuxtProject(cwd = process.cwd()) {
|
|
21
|
+
const configFile = findConfigFile(cwd, NUXT_CONFIG_RE);
|
|
22
|
+
if (!configFile) return null;
|
|
23
|
+
|
|
24
|
+
const config = fs.readFileSync(path.join(cwd, configFile), 'utf-8');
|
|
25
|
+
const literalSrcDir = config.match(/\bsrcDir\s*:\s*(['"])([^'"]+)\1/);
|
|
26
|
+
let appDir = '';
|
|
27
|
+
if (literalSrcDir) {
|
|
28
|
+
const candidate = literalSrcDir[2]
|
|
29
|
+
.replace(/\\/g, '/')
|
|
30
|
+
.replace(/^\.\//, '')
|
|
31
|
+
.replace(/\/+$/, '');
|
|
32
|
+
const normalized = path.posix.normalize(candidate);
|
|
33
|
+
if (normalized !== '..' && !normalized.startsWith('../') && !path.isAbsolute(normalized)) {
|
|
34
|
+
appDir = normalized === '.' ? '' : normalized;
|
|
35
|
+
}
|
|
36
|
+
} else if (
|
|
37
|
+
fs.existsSync(path.join(cwd, 'app', 'app.vue'))
|
|
38
|
+
|| fs.existsSync(path.join(cwd, 'app', 'pages'))
|
|
39
|
+
) {
|
|
40
|
+
appDir = 'app';
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const pluginFile = [appDir, 'plugins', NUXT_PLUGIN_NAME].filter(Boolean).join('/');
|
|
44
|
+
return { configFile, appDir, pluginFile };
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export function buildNuxtPlugin(port, token) {
|
|
48
|
+
return `/* ${NUXT_PLUGIN_MARKER} */
|
|
49
|
+
const liveSrc = '${buildLiveScriptSrc(port, token)}';
|
|
50
|
+
const liveSelector = 'script[data-impeccable-live-nuxt]';
|
|
51
|
+
|
|
52
|
+
export default defineNuxtPlugin(() => {
|
|
53
|
+
if (!import.meta.dev || typeof document === 'undefined') return;
|
|
54
|
+
|
|
55
|
+
const expectedSrc = new URL(liveSrc, window.location.href).href;
|
|
56
|
+
let script = document.querySelector(liveSelector);
|
|
57
|
+
if (script?.src === expectedSrc) return;
|
|
58
|
+
script?.remove();
|
|
59
|
+
|
|
60
|
+
script = document.createElement('script');
|
|
61
|
+
script.src = liveSrc;
|
|
62
|
+
script.async = true;
|
|
63
|
+
script.dataset.impeccableLiveNuxt = '';
|
|
64
|
+
document.head.appendChild(script);
|
|
65
|
+
|
|
66
|
+
import.meta.hot?.dispose(() => {
|
|
67
|
+
if (script?.isConnected) script.remove();
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
/* /${NUXT_PLUGIN_MARKER} */
|
|
71
|
+
`;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export function applyNuxtLiveAdapter({ cwd = process.cwd(), port, token, project = detectNuxtProject(cwd) }) {
|
|
75
|
+
if (!project) return { error: 'nuxt_not_detected' };
|
|
76
|
+
const absFile = path.join(cwd, project.pluginFile);
|
|
77
|
+
const existing = fs.existsSync(absFile) ? fs.readFileSync(absFile, 'utf-8') : null;
|
|
78
|
+
if (existing !== null && !existing.includes(NUXT_PLUGIN_MARKER)) {
|
|
79
|
+
return {
|
|
80
|
+
file: project.pluginFile,
|
|
81
|
+
error: 'nuxt_plugin_conflict',
|
|
82
|
+
hint: `${project.pluginFile} already exists and is not managed by Impeccable Live`,
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const content = buildNuxtPlugin(port, token);
|
|
87
|
+
fs.mkdirSync(path.dirname(absFile), { recursive: true });
|
|
88
|
+
if (content !== existing) fs.writeFileSync(absFile, content, 'utf-8');
|
|
89
|
+
return {
|
|
90
|
+
file: project.pluginFile,
|
|
91
|
+
inserted: true,
|
|
92
|
+
changed: content !== existing,
|
|
93
|
+
devOnly: true,
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export function removeNuxtLiveAdapter({ cwd = process.cwd(), project = detectNuxtProject(cwd) }) {
|
|
98
|
+
if (!project) return { error: 'nuxt_not_detected' };
|
|
99
|
+
const absFile = path.join(cwd, project.pluginFile);
|
|
100
|
+
if (!fs.existsSync(absFile)) {
|
|
101
|
+
return { file: project.pluginFile, removed: false, note: 'no adapter present' };
|
|
102
|
+
}
|
|
103
|
+
const content = fs.readFileSync(absFile, 'utf-8');
|
|
104
|
+
if (!content.includes(NUXT_PLUGIN_MARKER)) {
|
|
105
|
+
return {
|
|
106
|
+
file: project.pluginFile,
|
|
107
|
+
removed: false,
|
|
108
|
+
error: 'nuxt_plugin_conflict',
|
|
109
|
+
hint: `${project.pluginFile} is not managed by Impeccable Live`,
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
fs.unlinkSync(absFile);
|
|
113
|
+
const pluginDir = path.dirname(absFile);
|
|
114
|
+
if (fs.readdirSync(pluginDir).length === 0) fs.rmdirSync(pluginDir);
|
|
115
|
+
return { file: project.pluginFile, removed: true };
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export const nuxt = {
|
|
119
|
+
name: 'nuxt',
|
|
120
|
+
|
|
121
|
+
detect(cwd) {
|
|
122
|
+
return detectNuxtProject(cwd);
|
|
123
|
+
},
|
|
124
|
+
|
|
125
|
+
inject: {
|
|
126
|
+
kind: 'adapter',
|
|
127
|
+
|
|
128
|
+
apply({ cwd, port, token, project }) {
|
|
129
|
+
return applyNuxtLiveAdapter({ cwd, port, token, project });
|
|
130
|
+
},
|
|
131
|
+
|
|
132
|
+
remove({ cwd, project }) {
|
|
133
|
+
return removeNuxtLiveAdapter({ cwd, project });
|
|
134
|
+
},
|
|
135
|
+
|
|
136
|
+
// The plugin path depends on the resolved srcDir, so it cannot live in the
|
|
137
|
+
// static ignore list the way the SvelteKit paths do.
|
|
138
|
+
ignorePatterns(project) {
|
|
139
|
+
return project?.pluginFile ? [project.pluginFile] : [];
|
|
140
|
+
},
|
|
141
|
+
|
|
142
|
+
artifacts({ project }) {
|
|
143
|
+
if (!project?.pluginFile) return [];
|
|
144
|
+
return [{
|
|
145
|
+
kind: 'created',
|
|
146
|
+
path: project.pluginFile,
|
|
147
|
+
marker: NUXT_PLUGIN_MARKER,
|
|
148
|
+
// Mirrors removeNuxtLiveAdapter: the generated `plugins/` directory
|
|
149
|
+
// goes when it empties, its parent stays.
|
|
150
|
+
pruneTo: path.posix.dirname(path.posix.dirname(project.pluginFile)),
|
|
151
|
+
}];
|
|
152
|
+
},
|
|
153
|
+
},
|
|
154
|
+
|
|
155
|
+
source: {
|
|
156
|
+
extensions: ['.vue'],
|
|
157
|
+
preview: 'source',
|
|
158
|
+
styleMode: 'scoped',
|
|
159
|
+
commentSyntax: 'html',
|
|
160
|
+
},
|
|
161
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one place that builds the `/live.js` URL the browser loads.
|
|
3
|
+
*
|
|
4
|
+
* Every injection path needs it (the generic script tag, the Nuxt client
|
|
5
|
+
* plugin, the SvelteKit root component, the TanStack mount component), and a
|
|
6
|
+
* separate module keeps that shared leaf free of import cycles: the framework
|
|
7
|
+
* entries import it, and nothing here imports a framework entry.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* When a token is supplied it rides as a `?token=...` query param so the
|
|
12
|
+
* server's token-gated /live.js handler authorizes the fetch.
|
|
13
|
+
*/
|
|
14
|
+
export function buildLiveScriptSrc(port, token) {
|
|
15
|
+
const base = 'http://localhost:' + port + '/live.js';
|
|
16
|
+
return token ? base + '?token=' + encodeURIComponent(token) : base;
|
|
17
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Static HTML registry entry: the terminal fallback.
|
|
3
|
+
*
|
|
4
|
+
* Hand-written pages, a multi-page site emitted by a generator, anything with
|
|
5
|
+
* no bundler config at the app root. `detect` always matches, so this entry
|
|
6
|
+
* must stay last in FRAMEWORKS. Its behavior is the plain tag strategy, which
|
|
7
|
+
* is what live-inject.mjs did for every unrecognized project before the
|
|
8
|
+
* registry existed.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
export const staticHtml = {
|
|
12
|
+
name: 'static-html',
|
|
13
|
+
|
|
14
|
+
detect() {
|
|
15
|
+
return { via: 'fallback' };
|
|
16
|
+
},
|
|
17
|
+
|
|
18
|
+
inject: { kind: 'tag' },
|
|
19
|
+
|
|
20
|
+
source: {
|
|
21
|
+
extensions: ['.html', '.htm'],
|
|
22
|
+
preview: 'source',
|
|
23
|
+
styleMode: 'scoped',
|
|
24
|
+
commentSyntax: 'html',
|
|
25
|
+
},
|
|
26
|
+
};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SvelteKit registry entry.
|
|
3
|
+
*
|
|
4
|
+
* Detection and the apply/remove pair are the existing adapter's
|
|
5
|
+
* (`../sveltekit-adapter.mjs`); this file only declares them to the registry
|
|
6
|
+
* and names the artifacts the journal has to be able to heal.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import {
|
|
10
|
+
SVELTE_LAYOUT_MARKER_OPEN,
|
|
11
|
+
SVELTE_LIVE_ROOT_COMPONENT,
|
|
12
|
+
applySvelteKitLiveAdapter,
|
|
13
|
+
detectSvelteKitProject,
|
|
14
|
+
removeSvelteKitLiveAdapter,
|
|
15
|
+
unpatchSvelteLayout,
|
|
16
|
+
} from '../sveltekit-adapter.mjs';
|
|
17
|
+
|
|
18
|
+
export const sveltekit = {
|
|
19
|
+
name: 'sveltekit',
|
|
20
|
+
|
|
21
|
+
detect(cwd, config) {
|
|
22
|
+
return detectSvelteKitProject(cwd, config);
|
|
23
|
+
},
|
|
24
|
+
|
|
25
|
+
inject: {
|
|
26
|
+
kind: 'adapter',
|
|
27
|
+
|
|
28
|
+
apply({ cwd, port, token, config }) {
|
|
29
|
+
return applySvelteKitLiveAdapter({ cwd, port, token, config });
|
|
30
|
+
},
|
|
31
|
+
|
|
32
|
+
remove({ cwd, config }) {
|
|
33
|
+
return removeSvelteKitLiveAdapter({ cwd, config });
|
|
34
|
+
},
|
|
35
|
+
|
|
36
|
+
// The generated root component and the `src/lib/impeccable/` runtime paths
|
|
37
|
+
// are already in the static LIVE_IGNORE_PATTERNS list, so nothing extra.
|
|
38
|
+
ignorePatterns() {
|
|
39
|
+
return [];
|
|
40
|
+
},
|
|
41
|
+
|
|
42
|
+
artifacts({ project }) {
|
|
43
|
+
return [
|
|
44
|
+
{
|
|
45
|
+
kind: 'created',
|
|
46
|
+
path: SVELTE_LIVE_ROOT_COMPONENT,
|
|
47
|
+
marker: 'impeccable-live-root',
|
|
48
|
+
pruneTo: 'src',
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
kind: 'patched',
|
|
52
|
+
path: project?.layoutFile || 'src/routes/+layout.svelte',
|
|
53
|
+
patch: 'sveltekit-layout',
|
|
54
|
+
markers: [SVELTE_LAYOUT_MARKER_OPEN],
|
|
55
|
+
},
|
|
56
|
+
];
|
|
57
|
+
},
|
|
58
|
+
|
|
59
|
+
unpatch: {
|
|
60
|
+
'sveltekit-layout': unpatchSvelteLayout,
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
|
|
64
|
+
source: {
|
|
65
|
+
extensions: ['.svelte'],
|
|
66
|
+
// Svelte resets component-local state on markup HMR updates, so variants
|
|
67
|
+
// are mounted from generated components rather than written into the route.
|
|
68
|
+
preview: 'component',
|
|
69
|
+
commentSyntax: 'html',
|
|
70
|
+
},
|
|
71
|
+
};
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The generic `tag` injection strategy.
|
|
3
|
+
*
|
|
4
|
+
* Frameworks without a dedicated adapter get a literal marker-wrapped
|
|
5
|
+
* `<script src>` block written into the entry template named by
|
|
6
|
+
* `.impeccable/live/config.json`. This module owns that block: building it,
|
|
7
|
+
* inserting it at the configured anchor, removing it again, and the
|
|
8
|
+
* Content-Security-Policy meta patch that keeps the cross-origin load allowed.
|
|
9
|
+
*
|
|
10
|
+
* It is deliberately framework-agnostic. Per-framework knowledge (Astro's
|
|
11
|
+
* `is:inline`, for instance) arrives as the `scriptAttrs` argument, resolved
|
|
12
|
+
* from the registry by the caller, so nothing here has to branch on a file
|
|
13
|
+
* extension or a project shape.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import { buildLiveScriptSrc } from './script-src.mjs';
|
|
17
|
+
|
|
18
|
+
export const MARKER_OPEN_TEXT = 'impeccable-live-start';
|
|
19
|
+
export const MARKER_CLOSE_TEXT = 'impeccable-live-end';
|
|
20
|
+
|
|
21
|
+
/** Markers that identify a file as still carrying our tag-strategy patch. */
|
|
22
|
+
export const TAG_PATCH_MARKERS = Object.freeze([MARKER_OPEN_TEXT, 'data-impeccable-csp-original']);
|
|
23
|
+
|
|
24
|
+
function commentOpen(syntax) { return syntax === 'jsx' ? '{/*' : '<!--'; }
|
|
25
|
+
function commentClose(syntax) { return syntax === 'jsx' ? '*/}' : '-->'; }
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* `scriptAttrs` is a pre-rendered attribute string (trailing space included)
|
|
29
|
+
* that the registry supplies for the target file. Astro is the only framework
|
|
30
|
+
* that uses it today: Astro processes `<script>` tags by default and rewrites
|
|
31
|
+
* src to its own bundled URL, so `is:inline ` opts out and the literal external
|
|
32
|
+
* src survives.
|
|
33
|
+
*/
|
|
34
|
+
export function buildTagBlock(syntax, port, token, scriptAttrs = '') {
|
|
35
|
+
const open = commentOpen(syntax);
|
|
36
|
+
const close = commentClose(syntax);
|
|
37
|
+
return (
|
|
38
|
+
open + ' ' + MARKER_OPEN_TEXT + ' ' + close + '\n' +
|
|
39
|
+
'<script ' + scriptAttrs + 'src="' + buildLiveScriptSrc(port, token) + '"></script>\n' +
|
|
40
|
+
open + ' ' + MARKER_CLOSE_TEXT + ' ' + close + '\n'
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function detectLineEnding(content) {
|
|
45
|
+
if (content.includes('\r\n')) return '\r\n';
|
|
46
|
+
if (content.includes('\r')) return '\r';
|
|
47
|
+
return '\n';
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function normalizeLineEndings(content, lineEnding) {
|
|
51
|
+
return lineEnding === '\n' ? content : content.replace(/\n/g, lineEnding);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function readLineEndingAt(content, index) {
|
|
55
|
+
if (content[index] === '\r' && content[index + 1] === '\n') return '\r\n';
|
|
56
|
+
if (content[index] === '\n') return '\n';
|
|
57
|
+
if (content[index] === '\r') return '\r';
|
|
58
|
+
return '';
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export function insertTag(content, config, port, token, scriptAttrs = '') {
|
|
62
|
+
const lineEnding = detectLineEnding(content);
|
|
63
|
+
const block = normalizeLineEndings(buildTagBlock(config.commentSyntax, port, token, scriptAttrs), lineEnding);
|
|
64
|
+
// insertBefore: match the LAST occurrence. Anchors like `</body>` naturally
|
|
65
|
+
// belong at the end, and the same literal can appear earlier in code blocks
|
|
66
|
+
// within rendered documentation pages.
|
|
67
|
+
if (config.insertBefore) {
|
|
68
|
+
const idx = content.lastIndexOf(config.insertBefore);
|
|
69
|
+
if (idx === -1) return content;
|
|
70
|
+
return content.slice(0, idx) + block + content.slice(idx);
|
|
71
|
+
}
|
|
72
|
+
// insertAfter: match the FIRST occurrence — typical anchors like `<head>` or
|
|
73
|
+
// `<body>` open near the top of the document.
|
|
74
|
+
const idx = content.indexOf(config.insertAfter);
|
|
75
|
+
if (idx === -1) return content;
|
|
76
|
+
const after = idx + config.insertAfter.length;
|
|
77
|
+
// Preserve an existing trailing newline if the anchor already has one.
|
|
78
|
+
// Slice the remainder from the original anchor offset, not prefix.length:
|
|
79
|
+
// in the no-newline case prefix is one char longer than the anchor (the
|
|
80
|
+
// appended '\n'), so slicing by prefix.length would drop the first real
|
|
81
|
+
// character after the anchor (#227).
|
|
82
|
+
const existingNewline = readLineEndingAt(content, after);
|
|
83
|
+
const prefix = content.slice(0, after) + (existingNewline || lineEnding);
|
|
84
|
+
const rest = content.slice(after + existingNewline.length);
|
|
85
|
+
return prefix + block + rest;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Remove the live script block. Matches either HTML or JSX comment markers
|
|
90
|
+
* regardless of config (so stale tags from a wrong config can still be cleaned).
|
|
91
|
+
*
|
|
92
|
+
* Indent-preserving: captures any whitespace immediately preceding the opener
|
|
93
|
+
* marker and re-emits it in place of the removed block. `insertTag` inserted
|
|
94
|
+
* the block *after* the original line's indent and *before* the anchor (e.g.
|
|
95
|
+
* `</body>`), which moved the indent onto the opener line and left the anchor
|
|
96
|
+
* unindented. Replacing the whole block (plus its trailing newline) with just
|
|
97
|
+
* the captured indent hands the indent back to the anchor that follows.
|
|
98
|
+
*/
|
|
99
|
+
export function removeTag(content, _syntax) {
|
|
100
|
+
const patterns = [
|
|
101
|
+
/([ \t]*)<!--\s*impeccable-live-start\s*-->[\s\S]*?<!--\s*impeccable-live-end\s*-->([ \t]*(?:\r\n|\n|\r|$)?)/,
|
|
102
|
+
/([ \t]*)\{\/\*\s*impeccable-live-start\s*\*\/\}[\s\S]*?\{\/\*\s*impeccable-live-end\s*\*\/\}([ \t]*(?:\r\n|\n|\r|$)?)/,
|
|
103
|
+
];
|
|
104
|
+
for (const pat of patterns) {
|
|
105
|
+
let changed = false;
|
|
106
|
+
let next = content;
|
|
107
|
+
do {
|
|
108
|
+
content = next;
|
|
109
|
+
next = content.replace(pat, (_match, leadingIndent, trailing = '') => {
|
|
110
|
+
if (/[\r\n]/.test(trailing)) return leadingIndent;
|
|
111
|
+
return leadingIndent || trailing || '';
|
|
112
|
+
});
|
|
113
|
+
if (next !== content) changed = true;
|
|
114
|
+
} while (next !== content);
|
|
115
|
+
if (changed) return next;
|
|
116
|
+
}
|
|
117
|
+
return content;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// ---------------------------------------------------------------------------
|
|
121
|
+
// Content-Security-Policy meta-tag patcher
|
|
122
|
+
//
|
|
123
|
+
// When the user's HTML carries `<meta http-equiv="Content-Security-Policy">`,
|
|
124
|
+
// the cross-origin load of /live.js (and the SSE/POST connection back to
|
|
125
|
+
// localhost:PORT) is blocked unless the CSP explicitly allows that origin.
|
|
126
|
+
//
|
|
127
|
+
// On insert: append `http://localhost:PORT` to `script-src` and `connect-src`,
|
|
128
|
+
// and stash the original `content` value in a `data-impeccable-csp-original`
|
|
129
|
+
// attribute (base64) so revert is exact.
|
|
130
|
+
//
|
|
131
|
+
// On remove: detect the marker attribute, decode it, restore the original
|
|
132
|
+
// content value verbatim, drop the marker.
|
|
133
|
+
//
|
|
134
|
+
// Header-based CSP (Next.js headers, Nuxt routeRules, SvelteKit kit.csp,
|
|
135
|
+
// shared helpers) is NOT patched here — those need framework-specific config
|
|
136
|
+
// edits and are handled via the existing detect-csp.mjs reference output.
|
|
137
|
+
// Only the in-source meta-tag form gets the auto-patch.
|
|
138
|
+
// ---------------------------------------------------------------------------
|
|
139
|
+
|
|
140
|
+
const CSP_MARKER_ATTR = 'data-impeccable-csp-original';
|
|
141
|
+
|
|
142
|
+
function findCspMetaTags(content) {
|
|
143
|
+
const out = [];
|
|
144
|
+
const tagRe = /<meta\s+([^>]*?)\/?>/gis;
|
|
145
|
+
let m;
|
|
146
|
+
while ((m = tagRe.exec(content)) !== null) {
|
|
147
|
+
const attrs = m[1];
|
|
148
|
+
if (!/(http-equiv|httpEquiv)\s*=\s*(['"])Content-Security-Policy\2/i.test(attrs)) continue;
|
|
149
|
+
out.push({ start: m.index, end: m.index + m[0].length, full: m[0], attrs });
|
|
150
|
+
}
|
|
151
|
+
return out;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
function getAttr(attrs, name) {
|
|
155
|
+
const re = new RegExp(`\\b${name}\\s*=\\s*(['"])([\\s\\S]*?)\\1`, 'i');
|
|
156
|
+
const m = attrs.match(re);
|
|
157
|
+
return m ? { quote: m[1], value: m[2], full: m[0] } : null;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
function appendOriginToDirective(csp, directive, origin) {
|
|
161
|
+
const re = new RegExp(`(^|;)(\\s*)(${directive})\\s+([^;]*)`, 'i');
|
|
162
|
+
const m = csp.match(re);
|
|
163
|
+
if (m) {
|
|
164
|
+
const tokens = m[4].trim().split(/\s+/);
|
|
165
|
+
if (tokens.includes(origin)) return csp;
|
|
166
|
+
return csp.replace(re, `${m[1]}${m[2]}${m[3]} ${[...tokens, origin].join(' ')}`);
|
|
167
|
+
}
|
|
168
|
+
// Directive missing — add it. Use 'self' + origin so we don't inadvertently
|
|
169
|
+
// narrow the policy compared to the default-src fallback (most users with
|
|
170
|
+
// an explicit CSP have 'self' there).
|
|
171
|
+
return csp.trim().replace(/;?\s*$/, '') + `; ${directive} 'self' ${origin}`;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
export function patchCspMeta(content, port) {
|
|
175
|
+
const tags = findCspMetaTags(content);
|
|
176
|
+
if (tags.length === 0) return content;
|
|
177
|
+
const origin = `http://localhost:${port}`;
|
|
178
|
+
|
|
179
|
+
// Walk last-to-first so prior splices don't invalidate later indices.
|
|
180
|
+
let result = content;
|
|
181
|
+
for (let i = tags.length - 1; i >= 0; i--) {
|
|
182
|
+
const tag = tags[i];
|
|
183
|
+
const attrs = tag.attrs;
|
|
184
|
+
if (getAttr(attrs, CSP_MARKER_ATTR)) continue; // already patched
|
|
185
|
+
const contentAttr = getAttr(attrs, 'content');
|
|
186
|
+
if (!contentAttr) continue;
|
|
187
|
+
|
|
188
|
+
const original = contentAttr.value;
|
|
189
|
+
let patched = original;
|
|
190
|
+
patched = appendOriginToDirective(patched, 'script-src', origin);
|
|
191
|
+
patched = appendOriginToDirective(patched, 'connect-src', origin);
|
|
192
|
+
// The shader overlay during 'generating' creates a screenshot via
|
|
193
|
+
// URL.createObjectURL, producing a `blob:` URL — img-src 'self' rejects
|
|
194
|
+
// those. Add `blob:` so the overlay doesn't throw a CSP violation.
|
|
195
|
+
patched = appendOriginToDirective(patched, 'img-src', 'blob:');
|
|
196
|
+
if (patched === original) continue;
|
|
197
|
+
|
|
198
|
+
const newContentAttr = `content=${contentAttr.quote}${patched}${contentAttr.quote}`;
|
|
199
|
+
const marker = `${CSP_MARKER_ATTR}="${Buffer.from(original, 'utf-8').toString('base64')}"`;
|
|
200
|
+
// The tagRe captures any whitespace between the last attribute and the
|
|
201
|
+
// closing `/>` as part of `attrs`. Naively appending ` ${marker}` after
|
|
202
|
+
// a replace would land it BEFORE that trailing space, leaving a double
|
|
203
|
+
// space inside attrs and clobbering the space before `/>`. Split off
|
|
204
|
+
// the trailing whitespace, splice the marker into the attribute body,
|
|
205
|
+
// and re-append the original trailing whitespace so a self-closing
|
|
206
|
+
// `<meta … />` round-trips byte-for-byte.
|
|
207
|
+
const trailingWs = (attrs.match(/[ \t]*$/) || [''])[0];
|
|
208
|
+
const attrsBody = attrs.slice(0, attrs.length - trailingWs.length);
|
|
209
|
+
const newAttrs = attrsBody.replace(contentAttr.full, newContentAttr) + ' ' + marker + trailingWs;
|
|
210
|
+
const newTag = tag.full.replace(attrs, newAttrs);
|
|
211
|
+
|
|
212
|
+
result = result.slice(0, tag.start) + newTag + result.slice(tag.end);
|
|
213
|
+
}
|
|
214
|
+
return result;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
export function revertCspMeta(content) {
|
|
218
|
+
const tags = findCspMetaTags(content);
|
|
219
|
+
if (tags.length === 0) return content;
|
|
220
|
+
|
|
221
|
+
let result = content;
|
|
222
|
+
for (let i = tags.length - 1; i >= 0; i--) {
|
|
223
|
+
const tag = tags[i];
|
|
224
|
+
const origAttr = getAttr(tag.attrs, CSP_MARKER_ATTR);
|
|
225
|
+
if (!origAttr) continue;
|
|
226
|
+
const contentAttr = getAttr(tag.attrs, 'content');
|
|
227
|
+
if (!contentAttr) continue;
|
|
228
|
+
|
|
229
|
+
let originalValue;
|
|
230
|
+
try { originalValue = Buffer.from(origAttr.value, 'base64').toString('utf-8'); }
|
|
231
|
+
catch { continue; }
|
|
232
|
+
|
|
233
|
+
const newContentAttr = `content=${contentAttr.quote}${originalValue}${contentAttr.quote}`;
|
|
234
|
+
let newAttrs = tag.attrs.replace(contentAttr.full, newContentAttr);
|
|
235
|
+
// Drop the marker attribute and any single space immediately preceding it.
|
|
236
|
+
newAttrs = newAttrs.replace(new RegExp(`\\s*${origAttr.full}`), '');
|
|
237
|
+
const newTag = tag.full.replace(tag.attrs, newAttrs);
|
|
238
|
+
|
|
239
|
+
result = result.slice(0, tag.start) + newTag + result.slice(tag.end);
|
|
240
|
+
}
|
|
241
|
+
return result;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/** The journal's undo for a tag-strategy patch: drop the block, restore CSP. */
|
|
245
|
+
export function unpatchTagFile(content) {
|
|
246
|
+
return revertCspMeta(removeTag(content));
|
|
247
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TanStack Start registry entry.
|
|
3
|
+
*
|
|
4
|
+
* Detection and the apply/remove pair are the existing adapter's
|
|
5
|
+
* (`../tanstack-adapter.mjs`); this file only declares them to the registry
|
|
6
|
+
* and names the artifacts the journal has to be able to heal.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import {
|
|
10
|
+
TANSTACK_MARKER_OPEN,
|
|
11
|
+
applyTanStackLiveAdapter,
|
|
12
|
+
detectTanStackStartProject,
|
|
13
|
+
removeTanStackLiveAdapter,
|
|
14
|
+
unpatchTanStackRoot,
|
|
15
|
+
} from '../tanstack-adapter.mjs';
|
|
16
|
+
|
|
17
|
+
export const tanstackStart = {
|
|
18
|
+
name: 'tanstack-start',
|
|
19
|
+
|
|
20
|
+
detect(cwd) {
|
|
21
|
+
return detectTanStackStartProject(cwd);
|
|
22
|
+
},
|
|
23
|
+
|
|
24
|
+
inject: {
|
|
25
|
+
kind: 'adapter',
|
|
26
|
+
|
|
27
|
+
apply({ cwd, port, token, project }) {
|
|
28
|
+
return applyTanStackLiveAdapter({ cwd, port, token, project });
|
|
29
|
+
},
|
|
30
|
+
|
|
31
|
+
remove({ cwd, project }) {
|
|
32
|
+
return removeTanStackLiveAdapter({ cwd, project });
|
|
33
|
+
},
|
|
34
|
+
|
|
35
|
+
// The mount component's extension follows the root route's, so the path
|
|
36
|
+
// cannot live in the static ignore list.
|
|
37
|
+
ignorePatterns(project) {
|
|
38
|
+
return project?.componentFile ? [project.componentFile] : [];
|
|
39
|
+
},
|
|
40
|
+
|
|
41
|
+
artifacts({ project }) {
|
|
42
|
+
if (!project) return [];
|
|
43
|
+
return [
|
|
44
|
+
{
|
|
45
|
+
kind: 'created',
|
|
46
|
+
path: project.componentFile,
|
|
47
|
+
marker: 'impeccable-live-tanstack',
|
|
48
|
+
pruneTo: 'src',
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
kind: 'patched',
|
|
52
|
+
path: project.rootRoute,
|
|
53
|
+
patch: 'tanstack-root',
|
|
54
|
+
markers: [TANSTACK_MARKER_OPEN],
|
|
55
|
+
},
|
|
56
|
+
];
|
|
57
|
+
},
|
|
58
|
+
|
|
59
|
+
unpatch: {
|
|
60
|
+
'tanstack-root': unpatchTanStackRoot,
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
|
|
64
|
+
source: {
|
|
65
|
+
extensions: ['.tsx', '.jsx'],
|
|
66
|
+
preview: 'source',
|
|
67
|
+
styleMode: 'scoped',
|
|
68
|
+
commentSyntax: 'jsx',
|
|
69
|
+
},
|
|
70
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generic Vite registry entry: a bundled app with a real `index.html` entry
|
|
3
|
+
* and no framework-specific document ownership. React, Vue, Solid, Preact and
|
|
4
|
+
* a plain TanStack Router SPA all land here — the marker-wrapped script block
|
|
5
|
+
* goes straight into the HTML entry.
|
|
6
|
+
*
|
|
7
|
+
* This is the entry that catches everything with a bundler config; only
|
|
8
|
+
* static-html sits below it.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { fileExists, findConfigFile, hasAnyDependency } from './detect-utils.mjs';
|
|
12
|
+
|
|
13
|
+
const VITE_CONFIG_RE = /^vite\.config\.(?:js|mjs|cjs|ts|mts|cts)$/;
|
|
14
|
+
|
|
15
|
+
export function detectViteProject(cwd = process.cwd()) {
|
|
16
|
+
const configFile = findConfigFile(cwd, VITE_CONFIG_RE);
|
|
17
|
+
if (configFile) return { configFile, via: 'config' };
|
|
18
|
+
if (hasAnyDependency(cwd, ['vite'])) return { configFile: null, via: 'package' };
|
|
19
|
+
// A zero-config Vite app is index.html + package.json, the same pair
|
|
20
|
+
// roots.mjs treats as an app root.
|
|
21
|
+
if (fileExists(cwd, 'index.html') && fileExists(cwd, 'package.json')) {
|
|
22
|
+
return { configFile: null, via: 'zero-config' };
|
|
23
|
+
}
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export const viteGeneric = {
|
|
28
|
+
name: 'vite-generic',
|
|
29
|
+
|
|
30
|
+
detect(cwd) {
|
|
31
|
+
return detectViteProject(cwd);
|
|
32
|
+
},
|
|
33
|
+
|
|
34
|
+
inject: { kind: 'tag' },
|
|
35
|
+
|
|
36
|
+
source: {
|
|
37
|
+
extensions: ['.tsx', '.jsx'],
|
|
38
|
+
preview: 'source',
|
|
39
|
+
styleMode: 'scoped',
|
|
40
|
+
commentSyntax: 'jsx',
|
|
41
|
+
},
|
|
42
|
+
};
|