@principles/core 1.284.1 → 1.284.3

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.
@@ -3095,8 +3095,9 @@ describe('PRI-416: barrel cap guards', () => {
3095
3095
  // The extractor strips comments from captured tokens and validates that every
3096
3096
  // frozen entry is a real identifier — the snapshot must be a name SET, never
3097
3097
  // source-text fragments (review finding: 12/1719 comment-polluted entries).
3098
- // Wildcard re-exports and non-identifier captures fail loud: the guard refuses
3099
- // to freeze a surface it cannot prove.
3098
+ // Whitespace variants of the block form are captured, not missed. Wildcard
3099
+ // re-exports, default exports and non-identifier captures fail loud: the
3100
+ // guard refuses to freeze a surface it cannot prove.
3100
3101
  describe('PRI-775: barrel export surface freeze', () => {
3101
3102
  const IDENTIFIER_RE = /^[A-Za-z_$][A-Za-z0-9_$]*$/;
3102
3103
  function extractExportNames(src) {
@@ -3105,8 +3106,13 @@ describe('PRI-775: barrel export surface freeze', () => {
3105
3106
  + 'the surface of a star re-export, so the freeze refuses to guess: enumerate the '
3106
3107
  + 'exports explicitly or extend this guard deliberately.');
3107
3108
  }
3109
+ if (/^export\s+default/m.test(src)) {
3110
+ throw new Error('PRI-775: default export detected. A barrel default export is invisible to the '
3111
+ + 'name-set snapshot, so the freeze refuses to guess: use a named export or '
3112
+ + 'extend this guard deliberately.');
3113
+ }
3108
3114
  const names = new Set();
3109
- for (const block of src.match(/export (?:type )?\{[^}]*\}/g) ?? []) {
3115
+ for (const block of src.match(/\bexport\s*(?:type\s*)?\{[^}]*\}/g) ?? []) {
3110
3116
  // Strip comments BEFORE splitting on commas: a comment that itself
3111
3117
  // contains a comma would otherwise be cut in half and glue comment
3112
3118
  // text onto the following real symbol (hit on real barrel source).
@@ -3213,6 +3219,12 @@ describe('PRI-775: barrel export surface freeze', () => {
3213
3219
  expect(() => extractExportNames("export * from './x.js';")).toThrow(/wildcard/);
3214
3220
  // Text fragments that never reduce to an identifier fail loud, never freeze.
3215
3221
  expect(() => extractExportNames('export { 123bad } from "./x.js";')).toThrow(/non-identifier/);
3222
+ // Whitespace variants of the block form are captured, not missed
3223
+ // (`export{Foo}` slipped past the old strict-space regex).
3224
+ expect(extractExportNames("export{NoSpace} from './x.js';")).toEqual(['NoSpace']);
3225
+ expect(extractExportNames("export type{NoSpaceType} from './x.js';")).toEqual(['NoSpaceType']);
3226
+ // A barrel default export is invisible to the name set: refuse.
3227
+ expect(() => extractExportNames("import Foo from './x.js';\nexport default Foo;\n")).toThrow(/default/);
3216
3228
  });
3217
3229
  });
3218
3230
  // ── PRI-443: Pure module boundary guards ──────────────────────────────────────