@cogenta/render 0.1.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.
Files changed (205) hide show
  1. package/dist/astro/integration.d.ts +57 -0
  2. package/dist/astro/integration.d.ts.map +1 -0
  3. package/dist/astro/integration.js +72 -0
  4. package/dist/astro/integration.js.map +1 -0
  5. package/dist/build/index.d.ts +7 -0
  6. package/dist/build/index.d.ts.map +1 -0
  7. package/dist/build/index.js +7 -0
  8. package/dist/build/index.js.map +1 -0
  9. package/dist/build/integration.d.ts +25 -0
  10. package/dist/build/integration.d.ts.map +1 -0
  11. package/dist/build/integration.js +41 -0
  12. package/dist/build/integration.js.map +1 -0
  13. package/dist/build/plan.d.ts +41 -0
  14. package/dist/build/plan.d.ts.map +1 -0
  15. package/dist/build/plan.js +48 -0
  16. package/dist/build/plan.js.map +1 -0
  17. package/dist/build/refusal.d.ts +14 -0
  18. package/dist/build/refusal.d.ts.map +1 -0
  19. package/dist/build/refusal.js +110 -0
  20. package/dist/build/refusal.js.map +1 -0
  21. package/dist/build/requirements.d.ts +59 -0
  22. package/dist/build/requirements.d.ts.map +1 -0
  23. package/dist/build/requirements.js +74 -0
  24. package/dist/build/requirements.js.map +1 -0
  25. package/dist/build/run-build.d.ts +43 -0
  26. package/dist/build/run-build.d.ts.map +1 -0
  27. package/dist/build/run-build.js +73 -0
  28. package/dist/build/run-build.js.map +1 -0
  29. package/dist/build/targets.d.ts +47 -0
  30. package/dist/build/targets.d.ts.map +1 -0
  31. package/dist/build/targets.js +69 -0
  32. package/dist/build/targets.js.map +1 -0
  33. package/dist/cache/index.d.ts +7 -0
  34. package/dist/cache/index.d.ts.map +1 -0
  35. package/dist/cache/index.js +4 -0
  36. package/dist/cache/index.js.map +1 -0
  37. package/dist/cache/page-cache.d.ts +64 -0
  38. package/dist/cache/page-cache.d.ts.map +1 -0
  39. package/dist/cache/page-cache.js +128 -0
  40. package/dist/cache/page-cache.js.map +1 -0
  41. package/dist/cache/recorder.d.ts +49 -0
  42. package/dist/cache/recorder.d.ts.map +1 -0
  43. package/dist/cache/recorder.js +77 -0
  44. package/dist/cache/recorder.js.map +1 -0
  45. package/dist/cache/tags.d.ts +55 -0
  46. package/dist/cache/tags.d.ts.map +1 -0
  47. package/dist/cache/tags.js +62 -0
  48. package/dist/cache/tags.js.map +1 -0
  49. package/dist/config.d.ts +48 -0
  50. package/dist/config.d.ts.map +1 -0
  51. package/dist/config.js +44 -0
  52. package/dist/config.js.map +1 -0
  53. package/dist/content/client.d.ts +35 -0
  54. package/dist/content/client.d.ts.map +1 -0
  55. package/dist/content/client.js +155 -0
  56. package/dist/content/client.js.map +1 -0
  57. package/dist/content/types.d.ts +104 -0
  58. package/dist/content/types.d.ts.map +1 -0
  59. package/dist/content/types.js +16 -0
  60. package/dist/content/types.js.map +1 -0
  61. package/dist/context/render-context.d.ts +31 -0
  62. package/dist/context/render-context.d.ts.map +1 -0
  63. package/dist/context/render-context.js +152 -0
  64. package/dist/context/render-context.js.map +1 -0
  65. package/dist/context/types.d.ts +49 -0
  66. package/dist/context/types.d.ts.map +1 -0
  67. package/dist/context/types.js +2 -0
  68. package/dist/context/types.js.map +1 -0
  69. package/dist/images/errors.d.ts +20 -0
  70. package/dist/images/errors.d.ts.map +1 -0
  71. package/dist/images/errors.js +58 -0
  72. package/dist/images/errors.js.map +1 -0
  73. package/dist/images/format.d.ts +18 -0
  74. package/dist/images/format.d.ts.map +1 -0
  75. package/dist/images/format.js +34 -0
  76. package/dist/images/format.js.map +1 -0
  77. package/dist/images/geometry.d.ts +46 -0
  78. package/dist/images/geometry.d.ts.map +1 -0
  79. package/dist/images/geometry.js +127 -0
  80. package/dist/images/geometry.js.map +1 -0
  81. package/dist/images/index.d.ts +29 -0
  82. package/dist/images/index.d.ts.map +1 -0
  83. package/dist/images/index.js +30 -0
  84. package/dist/images/index.js.map +1 -0
  85. package/dist/images/pipeline.d.ts +51 -0
  86. package/dist/images/pipeline.d.ts.map +1 -0
  87. package/dist/images/pipeline.js +105 -0
  88. package/dist/images/pipeline.js.map +1 -0
  89. package/dist/images/sharp.d.ts +57 -0
  90. package/dist/images/sharp.d.ts.map +1 -0
  91. package/dist/images/sharp.js +139 -0
  92. package/dist/images/sharp.js.map +1 -0
  93. package/dist/images/srcset.d.ts +33 -0
  94. package/dist/images/srcset.d.ts.map +1 -0
  95. package/dist/images/srcset.js +94 -0
  96. package/dist/images/srcset.js.map +1 -0
  97. package/dist/images/store.d.ts +32 -0
  98. package/dist/images/store.d.ts.map +1 -0
  99. package/dist/images/store.js +54 -0
  100. package/dist/images/store.js.map +1 -0
  101. package/dist/images/types.d.ts +128 -0
  102. package/dist/images/types.d.ts.map +1 -0
  103. package/dist/images/types.js +22 -0
  104. package/dist/images/types.js.map +1 -0
  105. package/dist/images/wasm.d.ts +43 -0
  106. package/dist/images/wasm.d.ts.map +1 -0
  107. package/dist/images/wasm.js +128 -0
  108. package/dist/images/wasm.js.map +1 -0
  109. package/dist/index.d.ts +29 -0
  110. package/dist/index.d.ts.map +1 -0
  111. package/dist/index.js +29 -0
  112. package/dist/index.js.map +1 -0
  113. package/dist/pwa/build.d.ts +39 -0
  114. package/dist/pwa/build.d.ts.map +1 -0
  115. package/dist/pwa/build.js +38 -0
  116. package/dist/pwa/build.js.map +1 -0
  117. package/dist/pwa/client.d.ts +90 -0
  118. package/dist/pwa/client.d.ts.map +1 -0
  119. package/dist/pwa/client.js +76 -0
  120. package/dist/pwa/client.js.map +1 -0
  121. package/dist/pwa/index.d.ts +29 -0
  122. package/dist/pwa/index.d.ts.map +1 -0
  123. package/dist/pwa/index.js +22 -0
  124. package/dist/pwa/index.js.map +1 -0
  125. package/dist/pwa/manifest.d.ts +69 -0
  126. package/dist/pwa/manifest.d.ts.map +1 -0
  127. package/dist/pwa/manifest.js +108 -0
  128. package/dist/pwa/manifest.js.map +1 -0
  129. package/dist/pwa/offline.d.ts +44 -0
  130. package/dist/pwa/offline.d.ts.map +1 -0
  131. package/dist/pwa/offline.js +94 -0
  132. package/dist/pwa/offline.js.map +1 -0
  133. package/dist/pwa/service-worker.d.ts +71 -0
  134. package/dist/pwa/service-worker.d.ts.map +1 -0
  135. package/dist/pwa/service-worker.js +119 -0
  136. package/dist/pwa/service-worker.js.map +1 -0
  137. package/dist/pwa/strategy.d.ts +36 -0
  138. package/dist/pwa/strategy.d.ts.map +1 -0
  139. package/dist/pwa/strategy.js +180 -0
  140. package/dist/pwa/strategy.js.map +1 -0
  141. package/dist/pwa/sw-runtime.d.ts +109 -0
  142. package/dist/pwa/sw-runtime.d.ts.map +1 -0
  143. package/dist/pwa/sw-runtime.js +214 -0
  144. package/dist/pwa/sw-runtime.js.map +1 -0
  145. package/dist/pwa/types.d.ts +107 -0
  146. package/dist/pwa/types.d.ts.map +1 -0
  147. package/dist/pwa/types.js +18 -0
  148. package/dist/pwa/types.js.map +1 -0
  149. package/dist/pwa/version.d.ts +45 -0
  150. package/dist/pwa/version.d.ts.map +1 -0
  151. package/dist/pwa/version.js +89 -0
  152. package/dist/pwa/version.js.map +1 -0
  153. package/dist/skin/color.d.ts +50 -0
  154. package/dist/skin/color.d.ts.map +1 -0
  155. package/dist/skin/color.js +176 -0
  156. package/dist/skin/color.js.map +1 -0
  157. package/dist/skin/css.d.ts +19 -0
  158. package/dist/skin/css.d.ts.map +1 -0
  159. package/dist/skin/css.js +69 -0
  160. package/dist/skin/css.js.map +1 -0
  161. package/dist/skin/errors.d.ts +22 -0
  162. package/dist/skin/errors.d.ts.map +1 -0
  163. package/dist/skin/errors.js +59 -0
  164. package/dist/skin/errors.js.map +1 -0
  165. package/dist/skin/index.d.ts +15 -0
  166. package/dist/skin/index.d.ts.map +1 -0
  167. package/dist/skin/index.js +11 -0
  168. package/dist/skin/index.js.map +1 -0
  169. package/dist/skin/sheet.d.ts +42 -0
  170. package/dist/skin/sheet.d.ts.map +1 -0
  171. package/dist/skin/sheet.js +36 -0
  172. package/dist/skin/sheet.js.map +1 -0
  173. package/dist/skin/tokens.d.ts +90 -0
  174. package/dist/skin/tokens.d.ts.map +1 -0
  175. package/dist/skin/tokens.js +56 -0
  176. package/dist/skin/tokens.js.map +1 -0
  177. package/dist/skin/validate.d.ts +14 -0
  178. package/dist/skin/validate.d.ts.map +1 -0
  179. package/dist/skin/validate.js +272 -0
  180. package/dist/skin/validate.js.map +1 -0
  181. package/dist/theme/load-theme.d.ts +37 -0
  182. package/dist/theme/load-theme.d.ts.map +1 -0
  183. package/dist/theme/load-theme.js +102 -0
  184. package/dist/theme/load-theme.js.map +1 -0
  185. package/dist/theme/manifest.d.ts +48 -0
  186. package/dist/theme/manifest.d.ts.map +1 -0
  187. package/dist/theme/manifest.js +36 -0
  188. package/dist/theme/manifest.js.map +1 -0
  189. package/dist/theme/verify/forbidden.d.ts +39 -0
  190. package/dist/theme/verify/forbidden.d.ts.map +1 -0
  191. package/dist/theme/verify/forbidden.js +107 -0
  192. package/dist/theme/verify/forbidden.js.map +1 -0
  193. package/dist/theme/verify/scan-file.d.ts +15 -0
  194. package/dist/theme/verify/scan-file.d.ts.map +1 -0
  195. package/dist/theme/verify/scan-file.js +151 -0
  196. package/dist/theme/verify/scan-file.js.map +1 -0
  197. package/dist/theme/verify/scanner.d.ts +52 -0
  198. package/dist/theme/verify/scanner.d.ts.map +1 -0
  199. package/dist/theme/verify/scanner.js +304 -0
  200. package/dist/theme/verify/scanner.js.map +1 -0
  201. package/dist/theme/verify/verify-theme.d.ts +44 -0
  202. package/dist/theme/verify/verify-theme.d.ts.map +1 -0
  203. package/dist/theme/verify/verify-theme.js +179 -0
  204. package/dist/theme/verify/verify-theme.js.map +1 -0
  205. package/package.json +56 -0
@@ -0,0 +1,39 @@
1
+ /**
2
+ * What a theme may not import, from contract D, "Isolation, vérifiée à
3
+ * l'installation".
4
+ *
5
+ * The lists below are the contract's, not a superset: refusing more than the
6
+ * frozen contract announces would break themes that are legitimate under it.
7
+ * What *is* added is the unprefixed spelling of each builtin — `import 'fs'`
8
+ * and `import 'node:fs'` load the same module, and a check that only knows one
9
+ * of the two spellings protects nothing.
10
+ */
11
+ /** Builtins the contract names, in their `node:` spelling. */
12
+ export declare const FORBIDDEN_NODE_BUILTINS: readonly ['node:fs', 'node:child_process', 'node:net', 'node:http', 'node:https', 'node:dgram', 'node:worker_threads', 'node:vm', 'node:process'];
13
+ /** Cogenta packages that carry the database, the secrets, or both. */
14
+ export declare const FORBIDDEN_COGENTA_PACKAGES: readonly ['@cogenta/core', '@cogenta/schema'];
15
+ /**
16
+ * Database driver packages: "tout paquet de driver de base" made explicit.
17
+ *
18
+ * Named one by one rather than pattern-matched, because a refusal must be able
19
+ * to say *which* driver it saw, and because a pattern loose enough to catch
20
+ * them all also catches innocent package names.
21
+ */
22
+ export declare const FORBIDDEN_DATABASE_PACKAGES: readonly ['drizzle-orm', 'pg', 'pg-native', 'postgres', 'mysql', 'mysql2', 'mariadb', 'sqlite3', 'better-sqlite3', 'node:sqlite', 'sqlite', '@libsql/client', '@neondatabase/serverless', '@planetscale/database', '@vercel/postgres', 'knex', 'kysely', 'typeorm', 'sequelize', 'prisma', '@prisma/client', 'mongodb', 'ioredis', 'redis', '@redis/client'];
23
+ export type ForbiddenKind = 'node-builtin' | 'cogenta-package' | 'database-driver';
24
+ interface ForbiddenModule {
25
+ readonly specifier: string;
26
+ readonly kind: ForbiddenKind;
27
+ }
28
+ /**
29
+ * Resolves a module specifier to the forbidden module it reaches, or null.
30
+ *
31
+ * Subpaths count: `node:fs/promises` is `node:fs`, `@cogenta/core/db` is
32
+ * `@cogenta/core`, and `drizzle-orm/postgres-js` is `drizzle-orm`. So does a
33
+ * relative path that walks out of the theme into one of them — but that is not
34
+ * a specifier question, it is caught by the scan covering every source file.
35
+ */
36
+ export declare function matchForbidden(specifier: string): ForbiddenModule | null;
37
+ export declare function describeKind(kind: ForbiddenKind): string;
38
+ export {};
39
+ //# sourceMappingURL=forbidden.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"forbidden.d.ts","sourceRoot":"","sources":["../../../src/theme/verify/forbidden.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,8DAA8D;AAC9D,eAAO,MAAM,uBAAuB,YAClC,SAAS,EACT,oBAAoB,EACpB,UAAU,EACV,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,qBAAqB,EACrB,SAAS,EACT,cAAc,CACN,CAAA;AAEV,sEAAsE;AACtE,eAAO,MAAM,0BAA0B,YAAI,eAAe,EAAE,iBAAiB,CAAU,CAAA;AAEvF;;;;;;GAMG;AACH,eAAO,MAAM,2BAA2B,YACtC,aAAa,EACb,IAAI,EACJ,WAAW,EACX,UAAU,EACV,OAAO,EACP,QAAQ,EACR,SAAS,EACT,SAAS,EACT,gBAAgB,EAChB,aAAa,EACb,QAAQ,EACR,gBAAgB,EAChB,0BAA0B,EAC1B,uBAAuB,EACvB,kBAAkB,EAClB,MAAM,EACN,QAAQ,EACR,SAAS,EACT,WAAW,EACX,QAAQ,EACR,gBAAgB,EAChB,SAAS,EACT,SAAS,EACT,OAAO,EACP,eAAe,CACP,CAAA;AAEV,MAAM,MAAM,aAAa,GAAG,cAAc,GAAG,iBAAiB,GAAG,iBAAiB,CAAA;AAElF,UAAU,eAAe;IACvB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAA;CAC7B;AAmBD;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG,eAAe,GAAG,IAAI,CAcxE;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,aAAa,GAAG,MAAM,CASxD"}
@@ -0,0 +1,107 @@
1
+ /**
2
+ * What a theme may not import, from contract D, "Isolation, vérifiée à
3
+ * l'installation".
4
+ *
5
+ * The lists below are the contract's, not a superset: refusing more than the
6
+ * frozen contract announces would break themes that are legitimate under it.
7
+ * What *is* added is the unprefixed spelling of each builtin — `import 'fs'`
8
+ * and `import 'node:fs'` load the same module, and a check that only knows one
9
+ * of the two spellings protects nothing.
10
+ */
11
+ /** Builtins the contract names, in their `node:` spelling. */
12
+ export const FORBIDDEN_NODE_BUILTINS = [
13
+ 'node:fs',
14
+ 'node:child_process',
15
+ 'node:net',
16
+ 'node:http',
17
+ 'node:https',
18
+ 'node:dgram',
19
+ 'node:worker_threads',
20
+ 'node:vm',
21
+ 'node:process',
22
+ ];
23
+ /** Cogenta packages that carry the database, the secrets, or both. */
24
+ export const FORBIDDEN_COGENTA_PACKAGES = ['@cogenta/core', '@cogenta/schema'];
25
+ /**
26
+ * Database driver packages: "tout paquet de driver de base" made explicit.
27
+ *
28
+ * Named one by one rather than pattern-matched, because a refusal must be able
29
+ * to say *which* driver it saw, and because a pattern loose enough to catch
30
+ * them all also catches innocent package names.
31
+ */
32
+ export const FORBIDDEN_DATABASE_PACKAGES = [
33
+ 'drizzle-orm',
34
+ 'pg',
35
+ 'pg-native',
36
+ 'postgres',
37
+ 'mysql',
38
+ 'mysql2',
39
+ 'mariadb',
40
+ 'sqlite3',
41
+ 'better-sqlite3',
42
+ 'node:sqlite',
43
+ 'sqlite',
44
+ '@libsql/client',
45
+ '@neondatabase/serverless',
46
+ '@planetscale/database',
47
+ '@vercel/postgres',
48
+ 'knex',
49
+ 'kysely',
50
+ 'typeorm',
51
+ 'sequelize',
52
+ 'prisma',
53
+ '@prisma/client',
54
+ 'mongodb',
55
+ 'ioredis',
56
+ 'redis',
57
+ '@redis/client',
58
+ ];
59
+ /** Every spelling that resolves to a forbidden module, mapped to why it is forbidden. */
60
+ const FORBIDDEN = new Map();
61
+ for (const specifier of FORBIDDEN_NODE_BUILTINS) {
62
+ const bare = specifier.slice('node:'.length);
63
+ FORBIDDEN.set(specifier, { specifier, kind: 'node-builtin' });
64
+ FORBIDDEN.set(bare, { specifier, kind: 'node-builtin' });
65
+ }
66
+ for (const specifier of FORBIDDEN_COGENTA_PACKAGES) {
67
+ FORBIDDEN.set(specifier, { specifier, kind: 'cogenta-package' });
68
+ }
69
+ for (const specifier of FORBIDDEN_DATABASE_PACKAGES) {
70
+ FORBIDDEN.set(specifier, { specifier, kind: 'database-driver' });
71
+ if (!specifier.startsWith('node:'))
72
+ FORBIDDEN.set(`node:${specifier}`, { specifier, kind: 'database-driver' });
73
+ }
74
+ /**
75
+ * Resolves a module specifier to the forbidden module it reaches, or null.
76
+ *
77
+ * Subpaths count: `node:fs/promises` is `node:fs`, `@cogenta/core/db` is
78
+ * `@cogenta/core`, and `drizzle-orm/postgres-js` is `drizzle-orm`. So does a
79
+ * relative path that walks out of the theme into one of them — but that is not
80
+ * a specifier question, it is caught by the scan covering every source file.
81
+ */
82
+ export function matchForbidden(specifier) {
83
+ const clean = specifier.trim();
84
+ if (clean.length === 0)
85
+ return null;
86
+ const exact = FORBIDDEN.get(clean);
87
+ if (exact !== undefined)
88
+ return exact;
89
+ // A scoped package owns two segments, everything else owns one.
90
+ const segments = clean.split('/');
91
+ const rootLength = clean.startsWith('@') ? 2 : 1;
92
+ if (segments.length <= rootLength)
93
+ return null;
94
+ const root = segments.slice(0, rootLength).join('/');
95
+ return FORBIDDEN.get(root) ?? null;
96
+ }
97
+ export function describeKind(kind) {
98
+ switch (kind) {
99
+ case 'node-builtin':
100
+ return 'a Node builtin the theme sandbox does not grant';
101
+ case 'cogenta-package':
102
+ return 'a Cogenta core package, which carries the database and the secrets';
103
+ case 'database-driver':
104
+ return 'a database driver';
105
+ }
106
+ }
107
+ //# sourceMappingURL=forbidden.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"forbidden.js","sourceRoot":"","sources":["../../../src/theme/verify/forbidden.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,8DAA8D;AAC9D,MAAM,CAAC,MAAM,uBAAuB,GAAG;IACrC,SAAS;IACT,oBAAoB;IACpB,UAAU;IACV,WAAW;IACX,YAAY;IACZ,YAAY;IACZ,qBAAqB;IACrB,SAAS;IACT,cAAc;CACN,CAAA;AAEV,sEAAsE;AACtE,MAAM,CAAC,MAAM,0BAA0B,GA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E,SAAS,EAAE,IAAI,EAAE,iBAAiB,EAAE,CAAC,CAAA;AAC9E,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,cAAc,CAAC,SAAiB;IAC9C,MAAM,KAAK,GAAG,SAAS,CAAC,IAAI,EAAE,CAAA;IAC9B,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,IAAI,CAAA;IAEnC,MAAM,KAAK,GAAG,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;IAClC,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,KAAK,CAAA;IAErC,gEAAgE;IAChE,MAAM,QAAQ,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IACjC,MAAM,UAAU,GAAG,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IAChD,IAAI,QAAQ,CAAC,MAAM,IAAI,UAAU;QAAE,OAAO,IAAI,CAAA;IAE9C,MAAM,IAAI,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IACpD,OAAO,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,IAAI,CAAA;AACpC,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,IAAmB;IAC9C,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,cAAc;YACjB,OAAO,iDAAiD,CAAA;QAC1D,KAAK,iBAAiB;YACpB,OAAO,oEAAoE,CAAA;QAC7E,KAAK,iBAAiB;YACpB,OAAO,mBAAmB,CAAA;IAC9B,CAAC;AACH,CAAC"}
@@ -0,0 +1,15 @@
1
+ import { type SourceFinding } from './scanner.js';
2
+ /**
3
+ * Which files are scanned. Everything a bundler would turn into code.
4
+ *
5
+ * `.astro`, `.ts`, `.js` and their variants are obvious. `.md`/`.mdx` are not
6
+ * scanned here: MDX imports are a real vector, but MDX is not part of the
7
+ * theme structure contract D fixes, and scanning it would need a Markdown
8
+ * reader this check does not have.
9
+ */
10
+ export declare const SCANNED_EXTENSIONS: readonly ['.astro', '.ts', '.tsx', '.mts', '.cts', '.js', '.jsx', '.mjs', '.cjs'];
11
+ /** Directories never scanned: not theme source, and enormous. */
12
+ export declare const IGNORED_DIRECTORIES: string[];
13
+ /** Findings of one source file, deduplicated by position and kind. */
14
+ export declare function scanSource(path: string, source: string): SourceFinding[];
15
+ //# sourceMappingURL=scan-file.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scan-file.d.ts","sourceRoot":"","sources":["../../../src/theme/verify/scan-file.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAY,MAAM,cAAc,CAAA;AAE3D;;;;;;;GAOG;AACH,eAAO,MAAM,kBAAkB,YAC7B,QAAQ,EACR,KAAK,EACL,MAAM,EACN,MAAM,EACN,MAAM,EACN,KAAK,EACL,MAAM,EACN,MAAM,EACN,MAAM,CACE,CAAA;AAEV,iEAAiE;AACjE,eAAO,MAAM,mBAAmB,UAAyD,CAAA;AAmIzF,sEAAsE;AACtE,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,aAAa,EAAE,CAiBxE"}
@@ -0,0 +1,151 @@
1
+ import { scanCode } from './scanner.js';
2
+ /**
3
+ * Which files are scanned. Everything a bundler would turn into code.
4
+ *
5
+ * `.astro`, `.ts`, `.js` and their variants are obvious. `.md`/`.mdx` are not
6
+ * scanned here: MDX imports are a real vector, but MDX is not part of the
7
+ * theme structure contract D fixes, and scanning it would need a Markdown
8
+ * reader this check does not have.
9
+ */
10
+ export const SCANNED_EXTENSIONS = [
11
+ '.astro',
12
+ '.ts',
13
+ '.tsx',
14
+ '.mts',
15
+ '.cts',
16
+ '.js',
17
+ '.jsx',
18
+ '.mjs',
19
+ '.cjs',
20
+ ];
21
+ /** Directories never scanned: not theme source, and enormous. */
22
+ export const IGNORED_DIRECTORIES = ['node_modules', 'dist', '.git', '.astro', 'coverage'];
23
+ /** Position of an absolute offset in the source, both 1-based. */
24
+ function positionAt(source, offset) {
25
+ let line = 1;
26
+ let lastBreak = -1;
27
+ for (let i = 0; i < offset && i < source.length; i += 1) {
28
+ if (source[i] === '\n') {
29
+ line += 1;
30
+ lastBreak = i;
31
+ }
32
+ }
33
+ return { line, column: offset - lastBreak };
34
+ }
35
+ /**
36
+ * The code inside an `.astro` file: the frontmatter, every `{…}` expression of
37
+ * the template, and every `<script>` body.
38
+ *
39
+ * The template markup itself is skipped rather than lexed, because prose is
40
+ * full of apostrophes and an apostrophe read as a quote would swallow the rest
41
+ * of the line — which is how a scanner ends up missing the import it was
42
+ * written to catch.
43
+ */
44
+ function astroChunks(source) {
45
+ const chunks = [];
46
+ let templateStart = 0;
47
+ // Astro's own rule: the frontmatter is fenced by `---` at the very start.
48
+ const fence = /^?\s*---\r?\n/u.exec(source);
49
+ if (fence !== null) {
50
+ const bodyStart = fence[0].length;
51
+ const close = /^---[ \t]*\r?$/mu.exec(source.slice(bodyStart));
52
+ const bodyEnd = close === null ? source.length : bodyStart + (close.index ?? 0);
53
+ chunks.push({ code: source.slice(bodyStart, bodyEnd), offset: bodyStart });
54
+ templateStart = close === null ? source.length : bodyEnd + close[0].length;
55
+ }
56
+ for (const chunk of braceExpressions(source, templateStart))
57
+ chunks.push(chunk);
58
+ for (const chunk of scriptBodies(source, templateStart))
59
+ chunks.push(chunk);
60
+ return chunks;
61
+ }
62
+ /**
63
+ * Every `{…}` region of the template, brace-matched while respecting the
64
+ * strings and comments inside it.
65
+ */
66
+ function braceExpressions(source, from) {
67
+ const chunks = [];
68
+ for (let i = from; i < source.length; i += 1) {
69
+ if (source[i] !== '{')
70
+ continue;
71
+ const start = i + 1;
72
+ let depth = 1;
73
+ let cursor = start;
74
+ while (cursor < source.length && depth > 0) {
75
+ const char = source[cursor];
76
+ if (char === '"' || char === "'" || char === '`') {
77
+ cursor = endOfString(source, cursor, char);
78
+ continue;
79
+ }
80
+ if (char === '/' && source[cursor + 1] === '/') {
81
+ while (cursor < source.length && source[cursor] !== '\n')
82
+ cursor += 1;
83
+ continue;
84
+ }
85
+ if (char === '/' && source[cursor + 1] === '*') {
86
+ const end = source.indexOf('*/', cursor + 2);
87
+ cursor = end === -1 ? source.length : end + 2;
88
+ continue;
89
+ }
90
+ if (char === '{')
91
+ depth += 1;
92
+ else if (char === '}')
93
+ depth -= 1;
94
+ cursor += 1;
95
+ }
96
+ const end = depth === 0 ? cursor - 1 : source.length;
97
+ chunks.push({ code: source.slice(start, end), offset: start });
98
+ i = end;
99
+ }
100
+ return chunks;
101
+ }
102
+ /** Index just past a string literal that starts at `start`. */
103
+ function endOfString(source, start, quote) {
104
+ let cursor = start + 1;
105
+ while (cursor < source.length) {
106
+ const char = source[cursor];
107
+ if (char === '\\') {
108
+ cursor += 2;
109
+ continue;
110
+ }
111
+ if (char === quote)
112
+ return cursor + 1;
113
+ if (quote !== '`' && char === '\n')
114
+ return cursor;
115
+ cursor += 1;
116
+ }
117
+ return cursor;
118
+ }
119
+ const SCRIPT_TAG = /<script\b[^>]*>/giu;
120
+ function scriptBodies(source, from) {
121
+ const chunks = [];
122
+ SCRIPT_TAG.lastIndex = from;
123
+ let opening = SCRIPT_TAG.exec(source);
124
+ while (opening !== null) {
125
+ const start = opening.index + opening[0].length;
126
+ const end = source.toLowerCase().indexOf('</script', start);
127
+ const stop = end === -1 ? source.length : end;
128
+ chunks.push({ code: source.slice(start, stop), offset: start });
129
+ SCRIPT_TAG.lastIndex = stop;
130
+ opening = SCRIPT_TAG.exec(source);
131
+ }
132
+ return chunks;
133
+ }
134
+ /** Findings of one source file, deduplicated by position and kind. */
135
+ export function scanSource(path, source) {
136
+ const chunks = path.endsWith('.astro') ? astroChunks(source) : [{ code: source, offset: 0 }];
137
+ const seen = new Set();
138
+ const findings = [];
139
+ for (const chunk of chunks) {
140
+ const at = positionAt(source, chunk.offset);
141
+ for (const finding of scanCode(chunk.code, { line: at.line, column: at.column })) {
142
+ const key = `${finding.kind}:${finding.line}:${finding.column}:${finding.specifier ?? ''}`;
143
+ if (seen.has(key))
144
+ continue;
145
+ seen.add(key);
146
+ findings.push(finding);
147
+ }
148
+ }
149
+ return findings.sort((a, b) => a.line - b.line || a.column - b.column);
150
+ }
151
+ //# sourceMappingURL=scan-file.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scan-file.js","sourceRoot":"","sources":["../../../src/theme/verify/scan-file.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,QAAQ,EAAE,MAAM,cAAc,CAAA;AAE3D;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,QAAQ;IACR,KAAK;IACL,MAAM;IACN,MAAM;IACN,MAAM;IACN,KAAK;IACL,MAAM;IACN,MAAM;IACN,MAAM;CACE,CAAA;AAEV,iEAAiE;AACjE,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,cAAc,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAA;AAOzF,kEAAkE;AAClE,SAAS,UAAU,CAAC,MAAc,EAAE,MAAc;IAChD,IAAI,IAAI,GAAG,CAAC,CAAA;IACZ,IAAI,SAAS,GAAG,CAAC,CAAC,CAAA;IAClB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,IAAI,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;QACxD,IAAI,MAAM,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC;YACvB,IAAI,IAAI,CAAC,CAAA;YACT,SAAS,GAAG,CAAC,CAAA;QACf,CAAC;IACH,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,GAAG,SAAS,EAAE,CAAA;AAC7C,CAAC;AAOD;;;;;;;;GAQG;AACH,SAAS,WAAW,CAAC,MAAc;IACjC,MAAM,MAAM,GA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,CAAC,IAAI,IAAI,OAAO,CAAC,IAAI,IAAI,OAAO,CAAC,MAAM,IAAI,OAAO,CAAC,SAAS,IAAI,EAAE,EAAE,CAAA;YAC1F,IAAI,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;gBAAE,SAAQ;YAC3B,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;YACb,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QACxB,CAAC;IACH,CAAC;IAED,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC,CAAA;AACxE,CAAC"}
@@ -0,0 +1,52 @@
1
+ import { type ForbiddenKind } from './forbidden.js';
2
+ /**
3
+ * The static analysis contract D requires, written by hand and on purpose.
4
+ *
5
+ * Rule R9 asks for a justification before any dependency, and here there is
6
+ * none to buy: TypeScript 7 ships a native compiler with no JavaScript parser
7
+ * API (`typescript.createSourceFile` no longer exists), and Astro's bundled
8
+ * compiler parses `.astro` files, not the TypeScript inside them. Adding a full
9
+ * parser — `@babel/parser`, `oxc-parser`, `acorn` + a TS plugin — to answer
10
+ * three questions about module specifiers would be a large dependency, and a
11
+ * *native* one in two of the three cases, which rule R10 forbids outright.
12
+ *
13
+ * So this is a lexer, not a parser. It never needs the syntax tree: it needs
14
+ * string literals that sit in module-specifier position, plus two shapes that
15
+ * are refused whatever they contain. Being a lexer also means it does not
16
+ * choke on syntax it has never seen, which matters when the input is a theme
17
+ * written against a newer TypeScript than the one that shipped this check.
18
+ *
19
+ * What it deliberately does **not** claim: soundness against a determined
20
+ * attacker. Nothing static is. It refuses every path that can be recognised —
21
+ * and refuses outright the paths that cannot be *read*, which is what closes
22
+ * the aliasing hole: an `import()` whose specifier is computed is refused for
23
+ * being unreadable, not for what it computes.
24
+ */
25
+ export type FindingKind =
26
+ /** A specifier that reaches a module the contract forbids. */
27
+ 'forbidden-import'
28
+ /** An `import()` whose specifier cannot be read statically. */
29
+ | 'unanalysable-import'
30
+ /** CommonJS, which no theme may use — and the usual door back to `fs`. */
31
+ | 'commonjs-require';
32
+ export interface SourceFinding {
33
+ readonly kind: FindingKind;
34
+ /** 1-based, in the file as it is on disk. */
35
+ readonly line: number;
36
+ /** 1-based. */
37
+ readonly column: number;
38
+ /** The specifier as written, when one could be read. */
39
+ readonly specifier: string | null;
40
+ /** The forbidden module the specifier reaches, in its canonical spelling. */
41
+ readonly resolved: string | null;
42
+ readonly forbiddenKind: ForbiddenKind | null;
43
+ }
44
+ export interface ScanOptions {
45
+ /** Line the snippet starts on in the file, 1-based. */
46
+ readonly line?: number;
47
+ /** Column the snippet starts on, 1-based. */
48
+ readonly column?: number;
49
+ }
50
+ /** Scans a fragment of TypeScript or JavaScript. */
51
+ export declare function scanCode(code: string, options?: ScanOptions): SourceFinding[];
52
+ //# sourceMappingURL=scanner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scanner.d.ts","sourceRoot":"","sources":["../../../src/theme/verify/scanner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAkB,MAAM,gBAAgB,CAAA;AAEnE;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,MAAM,MAAM,WAAW;AACrB,8DAA8D;AAC5D,kBAAkB;AACpB,+DAA+D;GAC7D,qBAAqB;AACvB,0EAA0E;GACxE,kBAAkB,CAAA;AAEtB,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAA;IAC1B,6CAA6C;IAC7C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,eAAe;IACf,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,wDAAwD;IACxD,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;IACjC,6EAA6E;IAC7E,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;IAChC,QAAQ,CAAC,aAAa,EAAE,aAAa,GAAG,IAAI,CAAA;CAC7C;AA0TD,MAAM,WAAW,WAAW;IAC1B,uDAAuD;IACvD,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAA;IACtB,6CAA6C;IAC7C,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CACzB;AAED,oDAAoD;AACpD,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,WAAgB,GAAG,aAAa,EAAE,CAEjF"}