@caretcms/caretize 0.1.0 → 0.1.2

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.
Files changed (70) hide show
  1. package/README.md +41 -5
  2. package/dist/bind-collection.js +1 -1
  3. package/dist/bind-collection.js.map +1 -1
  4. package/dist/bind-route.d.ts.map +1 -1
  5. package/dist/bind-route.js +9 -4
  6. package/dist/bind-route.js.map +1 -1
  7. package/dist/cli-args.d.ts +16 -1
  8. package/dist/cli-args.d.ts.map +1 -1
  9. package/dist/cli-args.js +39 -3
  10. package/dist/cli-args.js.map +1 -1
  11. package/dist/cli.js +390 -27
  12. package/dist/cli.js.map +1 -1
  13. package/dist/detect.d.ts +17 -1
  14. package/dist/detect.d.ts.map +1 -1
  15. package/dist/detect.js +61 -22
  16. package/dist/detect.js.map +1 -1
  17. package/dist/diff.d.ts +20 -0
  18. package/dist/diff.d.ts.map +1 -0
  19. package/dist/diff.js +75 -0
  20. package/dist/diff.js.map +1 -0
  21. package/dist/discover.d.ts.map +1 -1
  22. package/dist/discover.js +8 -2
  23. package/dist/discover.js.map +1 -1
  24. package/dist/escalation.d.ts +47 -0
  25. package/dist/escalation.d.ts.map +1 -0
  26. package/dist/escalation.js +112 -0
  27. package/dist/escalation.js.map +1 -0
  28. package/dist/frontmatter.d.ts +41 -4
  29. package/dist/frontmatter.d.ts.map +1 -1
  30. package/dist/frontmatter.js +122 -12
  31. package/dist/frontmatter.js.map +1 -1
  32. package/dist/import-wrap.d.ts +30 -0
  33. package/dist/import-wrap.d.ts.map +1 -1
  34. package/dist/import-wrap.js +101 -7
  35. package/dist/import-wrap.js.map +1 -1
  36. package/dist/init.d.ts +70 -0
  37. package/dist/init.d.ts.map +1 -0
  38. package/dist/init.js +198 -0
  39. package/dist/init.js.map +1 -0
  40. package/dist/keys.d.ts +55 -0
  41. package/dist/keys.d.ts.map +1 -0
  42. package/dist/keys.js +84 -0
  43. package/dist/keys.js.map +1 -0
  44. package/dist/output.d.ts +63 -10
  45. package/dist/output.d.ts.map +1 -1
  46. package/dist/output.js +190 -22
  47. package/dist/output.js.map +1 -1
  48. package/dist/plan.d.ts +7 -0
  49. package/dist/plan.d.ts.map +1 -1
  50. package/dist/plan.js +17 -4
  51. package/dist/plan.js.map +1 -1
  52. package/dist/preflight.d.ts +2 -0
  53. package/dist/preflight.d.ts.map +1 -1
  54. package/dist/preflight.js +18 -3
  55. package/dist/preflight.js.map +1 -1
  56. package/dist/run.js +6 -4
  57. package/dist/run.js.map +1 -1
  58. package/dist/select-policy.d.ts +38 -0
  59. package/dist/select-policy.d.ts.map +1 -0
  60. package/dist/select-policy.js +44 -0
  61. package/dist/select-policy.js.map +1 -0
  62. package/dist/tiers.d.ts +42 -0
  63. package/dist/tiers.d.ts.map +1 -0
  64. package/dist/tiers.js +67 -0
  65. package/dist/tiers.js.map +1 -0
  66. package/dist/wrap.d.ts +9 -4
  67. package/dist/wrap.d.ts.map +1 -1
  68. package/dist/wrap.js +3 -2
  69. package/dist/wrap.js.map +1 -1
  70. package/package.json +2 -2
@@ -3,7 +3,10 @@
3
3
  * loop detection and `props.ts`'s cross-file prop detection). Kept neutral so
4
4
  * those two passes are siblings rather than one depending on the other.
5
5
  */
6
- /** Inner content range of the frontmatter fence, or null if there is none. */
6
+ /** Inner content range of the frontmatter fence, or null if there is none.
7
+ * Tolerates a leading UTF-8 BOM — the compiler does too, and a bare
8
+ * startsWith("---") used to silently disable every frontmatter tier for
9
+ * BOM-prefixed files. */
7
10
  export declare function frontmatterRange(source: string): {
8
11
  start: number;
9
12
  end: number;
@@ -15,12 +18,46 @@ export type ImportKind = "json" | "module";
15
18
  * Default-import bindings whose data could be wrapped with `editable()`, mapped
16
19
  * to their specifier + kind. Only DEFAULT imports of a `.json` data file or a
17
20
  * `.js`/`.ts` module are returned — named imports (`import { x }`), namespace
18
- * imports (`import * as`), `import type`, and bare/package or extensionless
19
- * specifiers are excluded, because their value shape can't be assumed safe to
20
- * stega-encode. `import faqs from "./data/faqs.json"` `faqs {json}`.
21
+ * imports (`import * as`), `import type`, and bare/package specifiers are excluded,
22
+ * because their value shape can't be assumed safe to stega-encode. Relative/aliased
23
+ * extensionless paths (`../data/site`) ARE included see {@link classifyDataSpecifier}.
24
+ * `import faqs from "./data/faqs.json"` → `faqs → {json}`.
21
25
  */
22
26
  export declare function importBindingNames(fmText: string): Map<string, {
23
27
  specifier: string;
24
28
  importKind: ImportKind;
25
29
  }>;
30
+ /**
31
+ * NAMED-import bindings whose data could be wrapped with `editable()`, mapped to
32
+ * their specifier + kind. The named counterpart to {@link importBindingNames}:
33
+ * `import { services } from "../data/site.ts"` → `services → {module}`.
34
+ *
35
+ * Same specifier filter (relative `.json`/JS-TS module only). Handles multiple
36
+ * bindings per statement (`import { a, b }`), an inline `type` specifier
37
+ * (`import { type T, a }` → only `a`), and a leading default binding
38
+ * (`import def, { a }` → the named half). Namespace imports and `import type {…}`
39
+ * are excluded.
40
+ *
41
+ * IMPORTANT — pre-aliased bindings are SKIPPED. A binding already written as
42
+ * `X as Y` was renamed deliberately, and the named-import wrapper renames by
43
+ * inserting ` as <raw>` after the local name; doing that to an aliased binding
44
+ * would emit `{ X as Y as Yraw }` (invalid JS). So `import { data as items }`
45
+ * yields nothing here.
46
+ */
47
+ export declare function namedImportBindingNames(fmText: string): Map<string, {
48
+ specifier: string;
49
+ importKind: ImportKind;
50
+ }>;
51
+ /**
52
+ * Local names that `astro:assets` `Image`/`Picture` are imported under, e.g.
53
+ * `import { Image, Picture as Pic } from "astro:assets"` → `{"Image","Pic"}`.
54
+ *
55
+ * Used by `detect.ts` to recognize these components (which render to a native
56
+ * `<img>` Astro forwards `data-caret` to) instead of skipping them as opaque
57
+ * components. The specifier must be exactly `"astro:assets"`, so a user's own
58
+ * `import { Image } from "./my-image"` is NOT matched. Unlike data-import
59
+ * wrapping, aliasing is fine here — we only need the local name to match against,
60
+ * nothing is renamed.
61
+ */
62
+ export declare function imageComponentNames(fmText: string): Set<string>;
26
63
  //# sourceMappingURL=frontmatter.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"frontmatter.d.ts","sourceRoot":"","sources":["../src/frontmatter.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,8EAA8E;AAC9E,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAOtF;AAED,gFAAgF;AAChF,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,CAM7D;AAED,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,QAAQ,CAAC;AAE3C;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,MAAM,GACb,GAAG,CAAC,MAAM,EAAE;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,UAAU,CAAA;CAAE,CAAC,CAa5D"}
1
+ {"version":3,"file":"frontmatter.d.ts","sourceRoot":"","sources":["../src/frontmatter.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;0BAG0B;AAC1B,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAQtF;AAED,gFAAgF;AAChF,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,CAM7D;AAED,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,QAAQ,CAAC;AAE3C;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,MAAM,GACb,GAAG,CAAC,MAAM,EAAE;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,UAAU,CAAA;CAAE,CAAC,CAW5D;AAmCD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,MAAM,GACb,GAAG,CAAC,MAAM,EAAE;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,UAAU,CAAA;CAAE,CAAC,CAmB5D;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,CAoB/D"}
@@ -3,9 +3,13 @@
3
3
  * loop detection and `props.ts`'s cross-file prop detection). Kept neutral so
4
4
  * those two passes are siblings rather than one depending on the other.
5
5
  */
6
- /** Inner content range of the frontmatter fence, or null if there is none. */
6
+ /** Inner content range of the frontmatter fence, or null if there is none.
7
+ * Tolerates a leading UTF-8 BOM — the compiler does too, and a bare
8
+ * startsWith("---") used to silently disable every frontmatter tier for
9
+ * BOM-prefixed files. */
7
10
  export function frontmatterRange(source) {
8
- if (!source.startsWith("---"))
11
+ const fenceAt = source.charCodeAt(0) === 0xfeff ? 1 : 0;
12
+ if (!source.startsWith("---", fenceAt))
9
13
  return null;
10
14
  const firstNL = source.indexOf("\n");
11
15
  if (firstNL < 0)
@@ -28,9 +32,10 @@ export function literalConstNames(fmText) {
28
32
  * Default-import bindings whose data could be wrapped with `editable()`, mapped
29
33
  * to their specifier + kind. Only DEFAULT imports of a `.json` data file or a
30
34
  * `.js`/`.ts` module are returned — named imports (`import { x }`), namespace
31
- * imports (`import * as`), `import type`, and bare/package or extensionless
32
- * specifiers are excluded, because their value shape can't be assumed safe to
33
- * stega-encode. `import faqs from "./data/faqs.json"` `faqs {json}`.
35
+ * imports (`import * as`), `import type`, and bare/package specifiers are excluded,
36
+ * because their value shape can't be assumed safe to stega-encode. Relative/aliased
37
+ * extensionless paths (`../data/site`) ARE included see {@link classifyDataSpecifier}.
38
+ * `import faqs from "./data/faqs.json"` → `faqs → {json}`.
34
39
  */
35
40
  export function importBindingNames(fmText) {
36
41
  const out = new Map();
@@ -38,15 +43,120 @@ export function importBindingNames(fmText) {
38
43
  let m;
39
44
  while ((m = re.exec(fmText))) {
40
45
  const [, name, spec] = m;
41
- let importKind;
42
- if (/\.json$/.test(spec))
43
- importKind = "json";
44
- else if (/\.(?:js|ts|mjs|cjs|mts|cts)$/.test(spec))
45
- importKind = "module";
46
- else
47
- continue; // bare/package or extensionless — shape unknown, leave alone
46
+ const importKind = classifyDataSpecifier(spec);
47
+ if (!importKind)
48
+ continue; // bare/package or extensionless — shape unknown
48
49
  out.set(name, { specifier: spec, importKind });
49
50
  }
50
51
  return out;
51
52
  }
53
+ /**
54
+ * Shared specifier filter → the data kind, or null when the shape can't be assumed.
55
+ * A `.json` file is `json`; a JS/TS module file is `module`; a relative or aliased
56
+ * EXTENSIONLESS path (the user's own `../data/site`, `@/data/site`) is treated as a
57
+ * `module` too — the most common way data files are actually imported. Bare package
58
+ * specifiers (`react`, `@scope/pkg`) and non-data extensions (`.astro`, `.css`,
59
+ * `.png`) stay null. The real wrap safety is enforced downstream by
60
+ * `classifyConstUsage` on the AST, not by this specifier shape.
61
+ */
62
+ function classifyDataSpecifier(spec) {
63
+ if (/\.json$/.test(spec))
64
+ return "json";
65
+ if (/\.(?:js|ts|mjs|cjs|mts|cts)$/.test(spec))
66
+ return "module";
67
+ if (isExtensionlessLocalPath(spec))
68
+ return "module";
69
+ return null;
70
+ }
71
+ /**
72
+ * A relative (`./`, `../`) or common-alias (`~/`, `@/`) path whose last segment has
73
+ * no file extension — i.e. a local JS/TS module imported by its extensionless path
74
+ * (`../data/site`). Excludes bare packages and any path ending in `.ext` (those are
75
+ * handled by the explicit extension checks above, or intentionally left out).
76
+ */
77
+ function isExtensionlessLocalPath(spec) {
78
+ const isLocal = spec.startsWith("./") ||
79
+ spec.startsWith("../") ||
80
+ spec.startsWith("~/") ||
81
+ spec.startsWith("@/");
82
+ if (!isLocal)
83
+ return false;
84
+ const lastSegment = spec.slice(spec.lastIndexOf("/") + 1);
85
+ return lastSegment.length > 0 && !lastSegment.includes(".");
86
+ }
87
+ /**
88
+ * NAMED-import bindings whose data could be wrapped with `editable()`, mapped to
89
+ * their specifier + kind. The named counterpart to {@link importBindingNames}:
90
+ * `import { services } from "../data/site.ts"` → `services → {module}`.
91
+ *
92
+ * Same specifier filter (relative `.json`/JS-TS module only). Handles multiple
93
+ * bindings per statement (`import { a, b }`), an inline `type` specifier
94
+ * (`import { type T, a }` → only `a`), and a leading default binding
95
+ * (`import def, { a }` → the named half). Namespace imports and `import type {…}`
96
+ * are excluded.
97
+ *
98
+ * IMPORTANT — pre-aliased bindings are SKIPPED. A binding already written as
99
+ * `X as Y` was renamed deliberately, and the named-import wrapper renames by
100
+ * inserting ` as <raw>` after the local name; doing that to an aliased binding
101
+ * would emit `{ X as Y as Yraw }` (invalid JS). So `import { data as items }`
102
+ * yields nothing here.
103
+ */
104
+ export function namedImportBindingNames(fmText) {
105
+ const out = new Map();
106
+ // Optional leading default binding (`def,`) then the `{ … }` named group.
107
+ const re = /\bimport\s+(?!type\b)(?:[A-Za-z_$][\w$]*\s*,\s*)?\{([^}]+)\}\s+from\s*['"]([^'"]+)['"]/g;
108
+ let m;
109
+ while ((m = re.exec(fmText))) {
110
+ const importKind = classifyDataSpecifier(m[2]);
111
+ if (!importKind)
112
+ continue;
113
+ for (const raw of m[1].split(",")) {
114
+ const token = raw.trim();
115
+ if (!token)
116
+ continue;
117
+ if (/\bas\b/.test(token))
118
+ continue; // pre-aliased — skip (see doc above)
119
+ if (/^type\b/.test(token))
120
+ continue; // inline `type` specifier
121
+ if (!/^[A-Za-z_$][\w$]*$/.test(token))
122
+ continue;
123
+ out.set(token, { specifier: m[2], importKind });
124
+ }
125
+ }
126
+ return out;
127
+ }
128
+ /**
129
+ * Local names that `astro:assets` `Image`/`Picture` are imported under, e.g.
130
+ * `import { Image, Picture as Pic } from "astro:assets"` → `{"Image","Pic"}`.
131
+ *
132
+ * Used by `detect.ts` to recognize these components (which render to a native
133
+ * `<img>` Astro forwards `data-caret` to) instead of skipping them as opaque
134
+ * components. The specifier must be exactly `"astro:assets"`, so a user's own
135
+ * `import { Image } from "./my-image"` is NOT matched. Unlike data-import
136
+ * wrapping, aliasing is fine here — we only need the local name to match against,
137
+ * nothing is renamed.
138
+ */
139
+ export function imageComponentNames(fmText) {
140
+ const out = new Set();
141
+ let m;
142
+ // Named (incl. a leading default binding): import [Def,] { Image, … } from "astro:assets"
143
+ const named = /\bimport\s+(?!type\b)(?:[A-Za-z_$][\w$]*\s*,\s*)?\{([^}]+)\}\s+from\s*['"]astro:assets['"]/g;
144
+ while ((m = named.exec(fmText))) {
145
+ for (const raw of m[1].split(",")) {
146
+ const token = raw.trim();
147
+ if (!token || /^type\b/.test(token))
148
+ continue;
149
+ // `Image as Img` → local name is the alias; plain `Image` → itself.
150
+ const aliased = /^[A-Za-z_$][\w$]*\s+as\s+([A-Za-z_$][\w$]*)$/.exec(token);
151
+ const local = aliased ? aliased[1] : token;
152
+ if (/^[A-Za-z_$][\w$]*$/.test(local))
153
+ out.add(local);
154
+ }
155
+ }
156
+ // Default (rare/legacy): import Image from "astro:assets"
157
+ const def = /\bimport\s+(?!type\b)([A-Za-z_$][\w$]*)\s+from\s*['"]astro:assets['"]/g;
158
+ while ((m = def.exec(fmText)))
159
+ out.add(m[1]);
160
+ return out;
161
+ }
52
162
  //# sourceMappingURL=frontmatter.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"frontmatter.js","sourceRoot":"","sources":["../src/frontmatter.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,8EAA8E;AAC9E,MAAM,UAAU,gBAAgB,CAAC,MAAc;IAC7C,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IAC3C,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACrC,IAAI,OAAO,GAAG,CAAC;QAAE,OAAO,IAAI,CAAC;IAC7B,MAAM,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,CA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AC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;YAClC,MAAM,KAAK,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC;YACzB,IAAI,CAAC,KAAK,IAAI,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC;gBAAE,SAAS;YAC9C,oEAAoE;YACpE,MAAM,OAAO,GAAG,8CAA8C,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YAC3E,MAAM,KAAK,GAAG,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;YAC3C,IAAI,oBAAoB,CAAC,IAAI,CAAC,KAAK,CAAC;gBAAE,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QACvD,CAAC;IACH,CAAC;IACD,0DAA0D;IAC1D,MAAM,GAAG,GAAG,wEAAwE,CAAC;IACrF,OAAO,CAAC,CAAC,GAAG,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAAE,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC7C,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -41,16 +41,46 @@ export interface ImportWrapCandidate {
41
41
  * suffix and a new const line is inserted; nothing is deleted.
42
42
  */
43
43
  export declare function wrapImport(source: string, varName: string, key: string): WrapResult;
44
+ /**
45
+ * Rebind a NAMED imported `varName` to `await editable("<key>", <varName>Raw)`,
46
+ * renaming the binding inside the destructure to the raw name. Pure insertion:
47
+ * the destructure gains ` as <raw>` after the local name and a new const line
48
+ * follows the statement; nothing is deleted.
49
+ *
50
+ * import { services } from "../data/site.ts";
51
+ * → import { services as servicesRaw } from "../data/site.ts";
52
+ * const services = await editable("…", servicesRaw);
53
+ *
54
+ * Multi-binding-safe: called once per binding, threading the mutated source
55
+ * forward. After `services` is renamed, the statement reads
56
+ * `{ services as servicesRaw, team }`; the next call locates `team` by
57
+ * whole-identifier match, never inside `servicesRaw`.
58
+ */
59
+ export declare function wrapNamedImport(source: string, varName: string, key: string): WrapResult;
44
60
  /**
45
61
  * Detect Tier-3 candidates: DEFAULT imports of a `.json`/module data file that
46
62
  * are `.map()`/`.flatMap()`'d in the template. Key is derived from the file's
47
63
  * scope (`collection::id`) plus the binding name as the field.
48
64
  */
49
65
  export declare function detectImportWrapCandidates(source: string, relPath: string): ImportWrapCandidate[];
66
+ /**
67
+ * Tier-3 named variant: NAMED imports (`import { services } from "./data.ts"`)
68
+ * `.map()`'d in the template. Same scope/key/idempotency logic as the default
69
+ * detector — only the binding resolver differs ({@link namedImportBindingNames}).
70
+ */
71
+ export declare function detectNamedImportWrapCandidates(source: string, relPath: string): ImportWrapCandidate[];
50
72
  /**
51
73
  * Safety-checked Tier-3 detection: import-backed candidates minus any whose
52
74
  * mapped fields flow into a native-element attribute (where `editable()`'s stega
53
75
  * encoding would corrupt an href/src/class/…). Mirrors `detectWrapTargetsSafe`.
54
76
  */
55
77
  export declare function detectImportWrapTargetsSafe(source: string, relPath: string, root?: AstroNode): Promise<WrapTarget[]>;
78
+ /**
79
+ * Safety-checked Tier-3 named-import detection: the named counterpart to
80
+ * {@link detectImportWrapTargetsSafe}. Same `classifyConstUsage` gate — a named
81
+ * import whose fields flow into a native-element attribute stays UNSAFE and
82
+ * unwrapped. Targets carry `origin: "named-import"` so `run.ts` routes them to
83
+ * {@link wrapNamedImport}.
84
+ */
85
+ export declare function detectNamedImportWrapTargetsSafe(source: string, relPath: string, root?: AstroNode): Promise<WrapTarget[]>;
56
86
  //# sourceMappingURL=import-wrap.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"import-wrap.d.ts","sourceRoot":"","sources":["../src/import-wrap.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAGH,OAAO,EAAc,KAAK,SAAS,EAAE,MAAM,YAAY,CAAC;AAExD,OAAO,EAGL,KAAK,UAAU,EAChB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAA0B,KAAK,U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,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,UAAU,CAuDnF;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,UAAU,CA8DxF;AAED;;;;GAIG;AACH,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,GACd,mBAAmB,EAAE,CAEvB;AAED;;;;GAIG;AACH,wBAAgB,+BAA+B,CAC7C,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,GACd,mBAAmB,EAAE,CAEvB;AAgDD;;;;GAIG;AACH,wBAAsB,2BAA2B,CAC/C,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,EACf,IAAI,CAAC,EAAE,SAAS,GACf,OAAO,CAAC,UAAU,EAAE,CAAC,CAOvB;AAED;;;;;;GAMG;AACH,wBAAsB,gCAAgC,CACpD,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,EACf,IAAI,CAAC,EAAE,SAAS,GACf,OAAO,CAAC,UAAU,EAAE,CAAC,CAOvB"}
@@ -24,14 +24,15 @@
24
24
  import { deriveScope, isValidField, slugifyText } from "./name.js";
25
25
  import { parseAstro } from "./parse.js";
26
26
  import { classifyConstUsage } from "./usage.js";
27
- import { frontmatterRange, importBindingNames, } from "./frontmatter.js";
28
- import { isIdentifier } from "./identifiers.js";
27
+ import { frontmatterRange, importBindingNames, namedImportBindingNames, } from "./frontmatter.js";
28
+ import { escapeRe, identRefRe, isIdentifier } from "./identifiers.js";
29
29
  import { IMPORT_LINE, IMPORT_RE } from "./wrap.js";
30
30
  /** Pick a non-colliding suffixed name for the raw (pre-editable) import binding. */
31
31
  function rawNameFor(source, varName) {
32
32
  for (const suffix of ["Raw", "Source", "Data"]) {
33
33
  const candidate = `${varName}${suffix}`;
34
- if (!new RegExp(`\\b${candidate}\\b`).test(source))
34
+ // identRefRe: $-aware boundaries + escaping (`\b$faqsRaw\b` never matches).
35
+ if (!identRefRe(candidate).test(source))
35
36
  return candidate;
36
37
  }
37
38
  return null;
@@ -50,10 +51,10 @@ export function wrapImport(source, varName, key) {
50
51
  return { output: source, ok: false, reason: "no frontmatter block" };
51
52
  const fmText = source.slice(fm.start, fm.end);
52
53
  // Idempotent: bail if this binding is already an editable() rebind.
53
- if (new RegExp(`\\bconst\\s+${varName}\\s*=\\s*await\\s+editable\\s*\\(`).test(fmText)) {
54
+ if (new RegExp(`\\bconst\\s+${escapeRe(varName)}\\s*=\\s*await\\s+editable\\s*\\(`).test(fmText)) {
54
55
  return { output: source, ok: true, alreadyWrapped: true };
55
56
  }
56
- const importRe = new RegExp(`\\bimport\\s+(?!type\\b)(${varName})\\s+from\\s*['"][^'"]+['"]`);
57
+ const importRe = new RegExp(`\\bimport\\s+(?!type\\b)(${escapeRe(varName)})\\s+from\\s*['"][^'"]+['"]`);
57
58
  const m = importRe.exec(fmText);
58
59
  if (!m) {
59
60
  return { output: source, ok: false, reason: `default import of ${varName} not found` };
@@ -85,18 +86,95 @@ export function wrapImport(source, varName, key) {
85
86
  }
86
87
  return { output, ok: true };
87
88
  }
89
+ /**
90
+ * Rebind a NAMED imported `varName` to `await editable("<key>", <varName>Raw)`,
91
+ * renaming the binding inside the destructure to the raw name. Pure insertion:
92
+ * the destructure gains ` as <raw>` after the local name and a new const line
93
+ * follows the statement; nothing is deleted.
94
+ *
95
+ * import { services } from "../data/site.ts";
96
+ * → import { services as servicesRaw } from "../data/site.ts";
97
+ * const services = await editable("…", servicesRaw);
98
+ *
99
+ * Multi-binding-safe: called once per binding, threading the mutated source
100
+ * forward. After `services` is renamed, the statement reads
101
+ * `{ services as servicesRaw, team }`; the next call locates `team` by
102
+ * whole-identifier match, never inside `servicesRaw`.
103
+ */
104
+ export function wrapNamedImport(source, varName, key) {
105
+ if (!isIdentifier(varName)) {
106
+ return { output: source, ok: false, reason: `invalid identifier: ${varName}` };
107
+ }
108
+ const fm = frontmatterRange(source);
109
+ if (!fm)
110
+ return { output: source, ok: false, reason: "no frontmatter block" };
111
+ const fmText = source.slice(fm.start, fm.end);
112
+ // Idempotent: bail if this binding is already an editable() rebind.
113
+ if (new RegExp(`\\bconst\\s+${escapeRe(varName)}\\s*=\\s*await\\s+editable\\s*\\(`).test(fmText)) {
114
+ return { output: source, ok: true, alreadyWrapped: true };
115
+ }
116
+ // Locate the named-import statement that contains `varName` as a whole
117
+ // identifier inside its `{ … }` (lookbehind/ahead keep it off `varNameRaw`).
118
+ const stmtRe = new RegExp(`\\bimport\\s+(?!type\\b)(?:[A-Za-z_$][\\w$]*\\s*,\\s*)?` +
119
+ `\\{[^}]*(?<![\\w$])${escapeRe(varName)}(?![\\w$])[^}]*\\}\\s+from\\s*['"][^'"]+['"]`);
120
+ const m = stmtRe.exec(fmText);
121
+ if (!m) {
122
+ return { output: source, ok: false, reason: `named import of ${varName} not found` };
123
+ }
124
+ // Position of the binding within the matched statement (first whole-word hit;
125
+ // the `{ … }` precedes the specifier, so this lands inside the destructure).
126
+ const inner = identRefRe(varName).exec(m[0]);
127
+ if (!inner) {
128
+ return { output: source, ok: false, reason: `could not locate ${varName} in import` };
129
+ }
130
+ const rawName = rawNameFor(source, varName);
131
+ if (!rawName) {
132
+ return { output: source, ok: false, reason: `could not pick a free name for ${varName}` };
133
+ }
134
+ const identEndRel = m.index + inner.index + varName.length;
135
+ let stmtEndRel = m.index + m[0].length;
136
+ if (fmText[stmtEndRel] === ";")
137
+ stmtEndRel++;
138
+ const identEndAbs = fm.start + identEndRel;
139
+ const stmtEndAbs = fm.start + stmtEndRel;
140
+ const aliasSuffix = ` as ${rawName}`;
141
+ const constLine = `\nconst ${varName} = await editable(${JSON.stringify(key)}, ${rawName});`;
142
+ // Two pure insertions: the destructure binding gains ` as <raw>`, and a new
143
+ // const line follows the import statement.
144
+ let output = source.slice(0, identEndAbs) +
145
+ aliasSuffix +
146
+ source.slice(identEndAbs, stmtEndAbs) +
147
+ constLine +
148
+ source.slice(stmtEndAbs);
149
+ if (!IMPORT_RE.test(source)) {
150
+ output = output.slice(0, fm.start) + IMPORT_LINE + "\n" + output.slice(fm.start);
151
+ }
152
+ return { output, ok: true };
153
+ }
88
154
  /**
89
155
  * Detect Tier-3 candidates: DEFAULT imports of a `.json`/module data file that
90
156
  * are `.map()`/`.flatMap()`'d in the template. Key is derived from the file's
91
157
  * scope (`collection::id`) plus the binding name as the field.
92
158
  */
93
159
  export function detectImportWrapCandidates(source, relPath) {
160
+ return detectMappedImportCandidates(source, relPath, importBindingNames);
161
+ }
162
+ /**
163
+ * Tier-3 named variant: NAMED imports (`import { services } from "./data.ts"`)
164
+ * `.map()`'d in the template. Same scope/key/idempotency logic as the default
165
+ * detector — only the binding resolver differs ({@link namedImportBindingNames}).
166
+ */
167
+ export function detectNamedImportWrapCandidates(source, relPath) {
168
+ return detectMappedImportCandidates(source, relPath, namedImportBindingNames);
169
+ }
170
+ /** Shared core: resolve import bindings via `resolve`, keep the `.map()`'d ones. */
171
+ function detectMappedImportCandidates(source, relPath, resolve) {
94
172
  const fm = frontmatterRange(source);
95
173
  if (!fm)
96
174
  return [];
97
175
  const fmText = source.slice(fm.start, fm.end);
98
176
  const template = source.slice(fm.end);
99
- const imports = importBindingNames(fmText);
177
+ const imports = resolve(fmText);
100
178
  if (imports.size === 0)
101
179
  return [];
102
180
  // Of the imported bindings, the ones actually iterated in the template.
@@ -116,7 +194,7 @@ export function detectImportWrapCandidates(source, relPath) {
116
194
  const candidates = [];
117
195
  for (const varName of mapped) {
118
196
  // Already rebound on a prior run → not a candidate.
119
- if (new RegExp(`\\bconst\\s+${varName}\\s*=\\s*await\\s+editable\\s*\\(`).test(fmText)) {
197
+ if (new RegExp(`\\bconst\\s+${escapeRe(varName)}\\s*=\\s*await\\s+editable\\s*\\(`).test(fmText)) {
120
198
  continue;
121
199
  }
122
200
  const field = isValidField(varName) ? varName : slugifyText(varName);
@@ -146,4 +224,20 @@ export async function detectImportWrapTargetsSafe(source, relPath, root) {
146
224
  .filter((c) => classifyConstUsage(ast, c.varName).safe)
147
225
  .map((c) => ({ varName: c.varName, key: c.key, origin: "import" }));
148
226
  }
227
+ /**
228
+ * Safety-checked Tier-3 named-import detection: the named counterpart to
229
+ * {@link detectImportWrapTargetsSafe}. Same `classifyConstUsage` gate — a named
230
+ * import whose fields flow into a native-element attribute stays UNSAFE and
231
+ * unwrapped. Targets carry `origin: "named-import"` so `run.ts` routes them to
232
+ * {@link wrapNamedImport}.
233
+ */
234
+ export async function detectNamedImportWrapTargetsSafe(source, relPath, root) {
235
+ const candidates = detectNamedImportWrapCandidates(source, relPath);
236
+ if (candidates.length === 0)
237
+ return [];
238
+ const ast = root ?? (await parseAstro(source));
239
+ return candidates
240
+ .filter((c) => classifyConstUsage(ast, c.varName).safe)
241
+ .map((c) => ({ varName: c.varName, key: c.key, origin: "named-import" }));
242
+ }
149
243
  //# sourceMappingURL=import-wrap.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"import-wrap.js","sourceRoot":"","sources":["../src/import-wrap.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACnE,OAAO,EAAE,UAAU,EAAkB,MAAM,YAAY,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EACL,gBAAgB,EAChB,kBAAkB,GAEnB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,SAAS,EAAoC,MAAM,WAAW,CAAC;AAcrF,oFAAoF;AACpF,SAAS,UAAU,CAAC,MAAc,EAAE,OAAe;IACjD,KAAK,MAAM,MAAM,IAAI,CAAC,KAAK,EAAE,QAAQ,EAAE,MAAM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aretCMS into an
3
+ * Astro project so tagging actually makes content editable (the gap preflight
4
+ * only *warns* about today). Kept process-free and side-effect-free so the
5
+ * load-bearing logic — editing an existing astro.config, scaffolding .env — is
6
+ * unit-testable; cli.ts owns the readline I/O, the npm install, and disk writes.
7
+ *
8
+ * Config editing mirrors caretize's write contract: every edit is a PURE
9
+ * INSERTION of the original bytes (verified by a subsequence check), so an edit
10
+ * can add to a config but never delete or reorder what's there. When the config
11
+ * shape isn't one we can touch confidently, planConfigWiring returns ok:false
12
+ * and the caller falls back to printing a snippet to paste — never a silent
13
+ * corruption.
14
+ */
15
+ export type InitMode = "static" | "server";
16
+ /** A complete, minimal embedded-mode config — written verbatim when a project
17
+ * has no astro.config at all, and shown as the paste-me snippet when an
18
+ * existing config is too complex to edit safely. */
19
+ export declare function freshConfig(mode?: InitMode): string;
20
+ /** What's missing from the config and therefore needs wiring in. Computed by the
21
+ * caller from preflight + a scan for an existing `adapter:` key. */
22
+ export interface WiringNeeds {
23
+ /** caret() not referenced — add the import + an integrations entry. */
24
+ caret: boolean;
25
+ /** No `adapter:` configured and server mode was selected — add @astrojs/node. */
26
+ adapter: boolean;
27
+ /** output isn't "server" and server mode was selected — add output: 'server'. */
28
+ output: boolean;
29
+ /** Static sites use caret({ delivery: "static" }) rather than SSR wiring. */
30
+ staticDelivery: boolean;
31
+ }
32
+ export interface WiringResult {
33
+ /** The edited config (=== source when nothing could be inserted). */
34
+ output: string;
35
+ /** Human-readable list of what was inserted, for the closing summary. */
36
+ inserted: string[];
37
+ /** Things we deliberately did NOT auto-apply (would require a replacement,
38
+ * not an insertion) — surfaced so the user fixes them by hand. */
39
+ manual: string[];
40
+ /** false → the config shape wasn't recognized; caller should fall back to the
41
+ * paste-me snippet rather than write a half-edited file. */
42
+ ok: boolean;
43
+ }
44
+ /** Index of the `{` that opens the config object — defineConfig({…}) preferred,
45
+ * bare `export default {…}` accepted. null when neither shape is present. */
46
+ export declare function findConfigObjectBrace(source: string): number | null;
47
+ /**
48
+ * Plan the edits that wire caret() / the adapter / output into an EXISTING
49
+ * config. Returns the edited text plus what was inserted vs. what needs manual
50
+ * attention. All edits are pure insertions; the result is subsequence-verified
51
+ * against the source, and any failure (unrecognized shape, verification miss)
52
+ * yields ok:false so the caller prints a snippet instead.
53
+ */
54
+ export declare function planConfigWiring(source: string, needs: WiringNeeds): WiringResult;
55
+ /**
56
+ * Plan additions to a project's .env. Generates nothing itself — the caller
57
+ * passes a freshly-generated `secret` (mirrors backup.ts injecting its
58
+ * timestamp), keeping this deterministic and testable. Existing keys (commented
59
+ * or not) are never touched, so re-running init is idempotent.
60
+ *
61
+ * CARET_SESSION_SECRET is a machine secret → generated outright. The edit
62
+ * password is left as a COMMENTED placeholder so dev keeps printing a temp
63
+ * password (an empty value would suppress that), while still reminding the user
64
+ * to set one before deploying.
65
+ */
66
+ export declare function renderEnvAdditions(existing: string, secret: string): {
67
+ append: string;
68
+ added: string[];
69
+ };
70
+ //# sourceMappingURL=init.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAeH,MAAM,MAAM,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAM3C;;qDAEqD;AACrD,wBAAgB,WAAW,CAAC,IAAI,GAAE,QAAmB,GAAG,MAAM,CAuB7D;AAED;qEACqE;AACrE,MAAM,WAAW,WAAW;IAC1B,uEAAuE;IACvE,KAAK,EAAE,OAAO,CAAC;IACf,iFAAiF;IACjF,OAAO,EAAE,OAAO,CAAC;IACjB,iFAAiF;IACjF,MAAM,EAAE,OAAO,CAAC;IAChB,6EAA6E;IAC7E,cAAc,EAAE,OAAO,CAAC;CACzB;AAED,MAAM,WAAW,YAAY;IAC3B,qEAAqE;IACrE,MAAM,EAAE,MAAM,CAAC;IACf,yEAAyE;IACzE,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB;uEACmE;IACnE,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB;iEAC6D;IAC7D,EAAE,EAAE,OAAO,CAAC;CACb;AAED;8EAC8E;AAC9E,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAMnE;AAWD;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,GAAG,YAAY,CAyFjF;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,GACb;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,EAAE,CAAA;CAAE,CAoBrC"}