@edynamix/mf-isolation 0.0.30 → 0.0.32

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/dist/postcss.js CHANGED
@@ -1,8 +1,9 @@
1
- import { existsSync, readFileSync } from 'node:fs';
2
- import { list } from 'postcss';
1
+ import { existsSync, readdirSync, readFileSync } from 'node:fs';
2
+ import { basename, dirname, join } from 'node:path';
3
3
  import selectorParser from 'postcss-selector-parser';
4
4
  import valueParser from 'postcss-value-parser';
5
5
  import { getMfScopeSelector, MF_ROOT_SELECTOR, MF_SCOPE_ATTRIBUTE, validateMfScopeId } from './index.js';
6
+ import { MF_ROOT_FONT_SIZE_PROPERTY } from './root-font-size.js';
6
7
  const ANGULAR_COMPONENT_STYLE_PATTERN = /\.component\.(?:css|less|sass|scss)$/i;
7
8
  const VIEW_ENCAPSULATION_NONE_PATTERN = /(?:^|[,{])\s*encapsulation\s*:\s*(?:[A-Za-z_$][\w$]*\s*\.\s*)+None\b/m;
8
9
  const MF_OVERLAY_ATTRIBUTE = 'data-edyn-mf-overlay';
@@ -171,12 +172,33 @@ const hasRootOnlySelector = (selectorList) => {
171
172
  }).processSync(selectorList);
172
173
  return result;
173
174
  };
175
+ const escapeRegExp = (text) => text.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
176
+ // A component stylesheet need not be named *.component.scss (CampaignManagement's create-campaign.ts uses
177
+ // `styleUrl: './create-campaign.scss'`); treated as global CSS, Angular would then encapsulate the boundary itself and
178
+ // the rules could never match. Such a file is a component's when a sibling component source references it.
179
+ const referencingComponentSourceOf = (stylePath) => {
180
+ const directory = dirname(stylePath);
181
+ if (!existsSync(directory)) {
182
+ return undefined;
183
+ }
184
+ const reference = new RegExp(`styleUrls?\\s*:\\s*(?:\\[[^\\]]*?)?['"\`]\\./${escapeRegExp(basename(stylePath))}['"\`]`);
185
+ for (const fileName of readdirSync(directory)) {
186
+ if (!fileName.endsWith('.ts') || /\.(?:spec|test|d)\.ts$/.test(fileName)) {
187
+ continue;
188
+ }
189
+ const sourcePath = join(directory, fileName);
190
+ if (reference.test(readFileSync(sourcePath, 'utf8'))) {
191
+ return sourcePath;
192
+ }
193
+ }
194
+ return undefined;
195
+ };
174
196
  const getAngularComponentSourcePath = (stylePath) => {
175
197
  const cleanStylePath = stylePath.replace(/[?#].*$/, '');
176
- if (!ANGULAR_COMPONENT_STYLE_PATTERN.test(cleanStylePath)) {
177
- return undefined;
198
+ if (ANGULAR_COMPONENT_STYLE_PATTERN.test(cleanStylePath)) {
199
+ return cleanStylePath.replace(/\.(?:css|less|sass|scss)$/i, '.ts');
178
200
  }
179
- return cleanStylePath.replace(/\.(?:css|less|sass|scss)$/i, '.ts');
201
+ return /\.(?:css|less|sass|scss)$/i.test(cleanStylePath) ? referencingComponentSourceOf(cleanStylePath) : undefined;
180
202
  };
181
203
  const usesViewEncapsulationNone = (stylePath) => {
182
204
  const componentSourcePath = getAngularComponentSourcePath(stylePath);
@@ -264,67 +286,6 @@ const scopeSelectorList = (selectorList, scopeId, scopeSelector, rootScopeSelect
264
286
  }
265
287
  }).processSync(selectorList);
266
288
  };
267
- const findFunctionalPseudoEnd = (selector, openParenthesisIndex) => {
268
- let depth = 0;
269
- let quote;
270
- for (let index = openParenthesisIndex; index < selector.length; index += 1) {
271
- const character = selector[index];
272
- const previousCharacter = selector[index - 1];
273
- if (quote) {
274
- if (character === quote && previousCharacter !== '\\') {
275
- quote = undefined;
276
- }
277
- continue;
278
- }
279
- if (character === '"' || character === "'") {
280
- quote = character;
281
- continue;
282
- }
283
- if (character === '(') {
284
- depth += 1;
285
- }
286
- else if (character === ')') {
287
- depth -= 1;
288
- if (depth === 0) {
289
- return index;
290
- }
291
- }
292
- }
293
- return -1;
294
- };
295
- const scopeAngularSelector = (selector, boundarySelector) => {
296
- const normalizedSelector = selector.trim();
297
- const angularBoundary = `:host-context(${boundarySelector})`;
298
- const normalizedBoundary = normalizedSelector.slice(0, angularBoundary.length).replaceAll("'", '"');
299
- if (normalizedBoundary === angularBoundary) {
300
- return normalizedSelector;
301
- }
302
- if (/^:host-context\(/i.test(normalizedSelector)) {
303
- return `${angularBoundary}${normalizedSelector}`;
304
- }
305
- if (/^:host\(/i.test(normalizedSelector)) {
306
- const openParenthesisIndex = normalizedSelector.indexOf('(');
307
- const closeParenthesisIndex = findFunctionalPseudoEnd(normalizedSelector, openParenthesisIndex);
308
- if (closeParenthesisIndex !== -1) {
309
- const hostSelector = normalizedSelector.slice(openParenthesisIndex + 1, closeParenthesisIndex);
310
- const remainder = normalizedSelector.slice(closeParenthesisIndex + 1);
311
- return list
312
- .comma(hostSelector)
313
- .map((hostSelectorVariant) => `${angularBoundary}${hostSelectorVariant}${remainder}`)
314
- .join(', ');
315
- }
316
- }
317
- if (/^:host\b/i.test(normalizedSelector)) {
318
- return normalizedSelector.replace(/^:host\b/i, angularBoundary);
319
- }
320
- return `${angularBoundary} ${normalizedSelector}`;
321
- };
322
- const scopeAngularSelectorList = (selectorList, boundarySelector) => {
323
- return list
324
- .comma(selectorList)
325
- .map((selector) => scopeAngularSelector(selector, boundarySelector))
326
- .join(', ');
327
- };
328
289
  const namespaceKeyframes = (root, keyframePrefix) => {
329
290
  const keyframes = new Map();
330
291
  root.walkAtRules((atRule) => {
@@ -349,7 +310,143 @@ const namespaceKeyframes = (root, keyframePrefix) => {
349
310
  declaration.value = parsed.toString();
350
311
  });
351
312
  };
352
- const scopeGlobalRoot = (root, scopeId, scopeSelector, keyframePrefix) => {
313
+ const INITIAL_FONT_SIZE_PX = 16;
314
+ // Absolute-size keywords as browsers compute them, and the relative ones as they resolve on the root, whose parent size
315
+ // is the initial 16px.
316
+ const FONT_SIZE_KEYWORDS_PX = {
317
+ 'xx-small': 9,
318
+ 'x-small': 10,
319
+ small: 13,
320
+ medium: 16,
321
+ large: 18,
322
+ 'x-large': 24,
323
+ 'xx-large': 32,
324
+ 'xxx-large': 48,
325
+ smaller: INITIAL_FONT_SIZE_PX / 1.2,
326
+ larger: INITIAL_FONT_SIZE_PX * 1.2,
327
+ };
328
+ // On the root, every global keyword gives the initial size.
329
+ const GLOBAL_KEYWORDS = new Set(['inherit', 'initial', 'revert', 'revert-layer', 'unset']);
330
+ // em, rem and % on the root are relative to the initial size.
331
+ const FONT_SIZE_UNITS_PX = {
332
+ '%': INITIAL_FONT_SIZE_PX / 100,
333
+ cm: 96 / 2.54,
334
+ em: INITIAL_FONT_SIZE_PX,
335
+ in: 96,
336
+ mm: 96 / 25.4,
337
+ pc: 16,
338
+ pt: 96 / 72,
339
+ px: 1,
340
+ q: 96 / 101.6,
341
+ rem: INITIAL_FONT_SIZE_PX,
342
+ };
343
+ const fontSizeOfWord = (word) => {
344
+ const keyword = FONT_SIZE_KEYWORDS_PX[word.toLowerCase()];
345
+ if (keyword !== undefined) {
346
+ return keyword;
347
+ }
348
+ const dimension = valueParser.unit(word);
349
+ const unitPx = dimension ? FONT_SIZE_UNITS_PX[dimension.unit.toLowerCase()] : undefined;
350
+ const amount = Number(dimension ? dimension.number : Number.NaN);
351
+ return unitPx !== undefined && Number.isFinite(amount) && amount >= 0 ? amount * unitPx : undefined;
352
+ };
353
+ const significantValueNodes = (value) => {
354
+ return valueParser(value).nodes.filter((node) => node.type !== 'space' && node.type !== 'comment');
355
+ };
356
+ const globalKeywordFontSize = (nodes) => {
357
+ const [only] = nodes;
358
+ return nodes.length === 1 && only?.type === 'word' && GLOBAL_KEYWORDS.has(only.value.toLowerCase()) ? INITIAL_FONT_SIZE_PX : undefined;
359
+ };
360
+ const resolveFontSize = (value) => {
361
+ const nodes = significantValueNodes(value);
362
+ const [only] = nodes;
363
+ return globalKeywordFontSize(nodes) ?? (nodes.length === 1 && only?.type === 'word' ? fontSizeOfWord(only.value) : undefined);
364
+ };
365
+ // `font: [style] [variant] [weight] [stretch] <size>[/<line-height>] <family>`: the size is the word before `/`, or else
366
+ // the first word that is a size. A function (var(), calc()) or a family name reached first means it cannot be read.
367
+ const resolveFontShorthandSize = (value) => {
368
+ const nodes = significantValueNodes(value);
369
+ const globalSize = globalKeywordFontSize(nodes);
370
+ if (globalSize !== undefined) {
371
+ return globalSize;
372
+ }
373
+ const slashIndex = nodes.findIndex((node) => node.type === 'div' && node.value === '/');
374
+ if (slashIndex > 0) {
375
+ const size = nodes[slashIndex - 1];
376
+ return size?.type === 'word' ? fontSizeOfWord(size.value) : undefined;
377
+ }
378
+ for (const node of nodes) {
379
+ if (node.type !== 'word') {
380
+ return undefined;
381
+ }
382
+ const size = fontSizeOfWord(node.value);
383
+ if (size !== undefined) {
384
+ return size;
385
+ }
386
+ }
387
+ return undefined;
388
+ };
389
+ // `html` and `:root` size the document root, so rem; `body` and `html body` size only the body.
390
+ const targetsDocumentRoot = (selector) => {
391
+ let subject = [];
392
+ for (const node of selector.nodes) {
393
+ subject = node.type === 'combinator' ? [] : [...subject, node];
394
+ }
395
+ return subject.some((node) => (node.type === 'tag' && node.value.toLowerCase() === 'html') || (node.type === 'pseudo' && node.value === ':root'));
396
+ };
397
+ const documentRootSelectorsOf = (selectorList) => {
398
+ const selectors = [];
399
+ selectorParser((root) => {
400
+ for (const selector of root.nodes) {
401
+ if (targetsDocumentRoot(selector)) {
402
+ selectors.push(selector.toString().trim());
403
+ }
404
+ }
405
+ }).processSync(selectorList);
406
+ return selectors;
407
+ };
408
+ // Hosted, rem resolves against the host page's root, not the root size the module's own page set. Each rule that sizes
409
+ // the document root gets a sibling rule right after it that records that size as MF_ROOT_FONT_SIZE_PROPERTY, under the
410
+ // same conditions (@media, importance) and in the same cascade order; scoping then moves it onto the module boundary,
411
+ // where followModuleRootFontSize() makes rem lengths read it. CSS that never sizes the root is left byte-identical.
412
+ const recordRootFontSize = (root, warn) => {
413
+ root.walkRules((rule) => {
414
+ if (isKeyframesRule(rule)) {
415
+ return;
416
+ }
417
+ let sizing;
418
+ for (const node of rule.nodes) {
419
+ if (node.type === 'decl' && /^font(?:-size)?$/i.test(node.prop) && (node.important || !sizing?.important)) {
420
+ sizing = node;
421
+ }
422
+ }
423
+ if (!sizing) {
424
+ return;
425
+ }
426
+ const rootSelectors = documentRootSelectorsOf(rule.selector);
427
+ if (rootSelectors.length === 0) {
428
+ return;
429
+ }
430
+ const sizePx = sizing.prop.toLowerCase() === 'font' ? resolveFontShorthandSize(sizing.value) : resolveFontSize(sizing.value);
431
+ if (sizePx === undefined) {
432
+ warn(sizing, `Cannot resolve the document root font size "${sizing.value}" at build time; rem lengths in the hosted module will use the host page's root size.`);
433
+ return;
434
+ }
435
+ const recorded = rule.clone({ selector: rootSelectors.join(', ') });
436
+ recorded.raws.before = rule.raws.before || '\n';
437
+ recorded.removeAll();
438
+ // The recorded size points back at the declaration it came from, so source maps keep a source for it.
439
+ recorded.append({
440
+ important: sizing.important,
441
+ prop: MF_ROOT_FONT_SIZE_PROPERTY,
442
+ source: sizing.source,
443
+ value: `${Number(sizePx.toFixed(4))}px`,
444
+ });
445
+ rule.after(recorded);
446
+ });
447
+ };
448
+ const scopeGlobalRoot = (root, scopeId, scopeSelector, keyframePrefix, warn) => {
449
+ recordRootFontSize(root, warn);
353
450
  namespaceKeyframes(root, keyframePrefix);
354
451
  const contentRootSelector = `:where([${MF_SCOPE_ATTRIBUTE}="${scopeId}"]:not([${MF_OVERLAY_ATTRIBUTE}]))`;
355
452
  root.walkRules((rule) => {
@@ -377,13 +474,15 @@ const scopeGlobalRoot = (root, scopeId, scopeSelector, keyframePrefix) => {
377
474
  }
378
475
  });
379
476
  };
380
- const scopeAngularComponentRoot = (root, boundarySelector, keyframePrefix) => {
477
+ // Emulated component CSS keeps its selectors exactly as written, so Angular compiles what it compiled on the module's
478
+ // own page and every rule keeps its weight and reach: `mat-form-field[_ngcontent-x]` (0,1,1) still loses to a global
479
+ // `.mat-sidenav-content .mat-mdc-form-field` (0,2,0), template content rendered in an overlay (outside the component's
480
+ // host) keeps its component styles, and a top-level `::ng-deep` rule stays global to the module. Wrapping every rule in
481
+ // :host-context(<boundary>) added (0,2,0) to each, and limited all of them to the component's host. Isolation needs no
482
+ // boundary here: Angular's _ngcontent and _nghost attributes are unique to each component, and a hosted module's
483
+ // component styles live in its own shadow root.
484
+ const scopeAngularComponentRoot = (root, keyframePrefix) => {
381
485
  namespaceKeyframes(root, keyframePrefix);
382
- root.walkRules((rule) => {
383
- if (!isKeyframesRule(rule)) {
384
- rule.selector = scopeAngularSelectorList(rule.selector, boundarySelector);
385
- }
386
- });
387
486
  };
388
487
  export const scopeRemoteCss = ({ scopeId }) => {
389
488
  const validScopeId = validateMfScopeId(scopeId);
@@ -391,24 +490,23 @@ export const scopeRemoteCss = ({ scopeId }) => {
391
490
  const keyframePrefix = `edyn-mf-${validScopeId}--`;
392
491
  return {
393
492
  postcssPlugin: `edyn-mf-isolation-${validScopeId}`,
394
- Once(root) {
395
- scopeGlobalRoot(root, validScopeId, scopeSelector, keyframePrefix);
493
+ Once(root, { result }) {
494
+ scopeGlobalRoot(root, validScopeId, scopeSelector, keyframePrefix, (node, text) => node.warn(result, text));
396
495
  },
397
496
  };
398
497
  };
399
498
  export const scopeAngularRemoteCss = ({ scopeId }) => {
400
499
  const validScopeId = validateMfScopeId(scopeId);
401
500
  const scopeSelector = getMfScopeSelector(validScopeId);
402
- const boundarySelector = `[${MF_SCOPE_ATTRIBUTE}="${validScopeId}"]`;
403
501
  const keyframePrefix = `edyn-mf-${validScopeId}--`;
404
502
  return {
405
503
  postcssPlugin: `edyn-mf-angular-isolation-${validScopeId}`,
406
- Once(root) {
504
+ Once(root, { result }) {
407
505
  if (shouldUseAngularComponentScoping(root.source?.input.file)) {
408
- scopeAngularComponentRoot(root, boundarySelector, keyframePrefix);
506
+ scopeAngularComponentRoot(root, keyframePrefix);
409
507
  return;
410
508
  }
411
- scopeGlobalRoot(root, validScopeId, scopeSelector, keyframePrefix);
509
+ scopeGlobalRoot(root, validScopeId, scopeSelector, keyframePrefix, (node, text) => node.warn(result, text));
412
510
  },
413
511
  };
414
512
  };
@@ -1 +1 @@
1
- {"version":3,"file":"postcss.js","sourceRoot":"","sources":["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type Root, type Rule } from 'postcss';\nimport selectorParser from 'postcss-selector-parser';\nimport valueParser from 'postcss-value-parser';\nimport { getMfScopeSelector, MF_ROOT_SELECTOR, MF_SCOPE_ATTRIBUTE, validateMfScopeId } from './index.js';\n\nexport interface IScopeRemoteCssOptions {\n scopeId: string;\n}\n\nconst ANGULAR_COMPONENT_STYLE_PATTERN = /\\.component\\.(?:css|less|sass|scss)$/i;\nconst VIEW_ENCAPSULATION_NONE_PATTERN = /(?:^|[,{])\\s*encapsulation\\s*:\\s*(?:[A-Za-z_$][\\w$]*\\s*\\.\\s*)+None\\b/m;\nconst MF_OVERLAY_ATTRIBUTE = 'data-edyn-mf-overlay';\n\ntype TTypeScriptMaskState = 'block-comment' | 'code' | 'double-quote' | 'line-comment' | 'single-quote' | 'template';\n\nconst maskTypeScriptCommentsAndStrings = (source: string): string => {\n let maskedSource = '';\n let state: TTypeScriptMaskState = 'code';\n let escaped = false;\n\n const maskCharacter = (character: string): string => {\n return character === '\\n' || character === '\\r' ? character : ' ';\n };\n\n for (let index = 0; index < source.length; index += 1) {\n const character = source[index] ?? '';\n const nextCharacter = source[index + 1];\n\n if (state === 'code') {\n if (character === '/' && nextCharacter === '/') {\n maskedSource += ' ';\n index += 1;\n state = 'line-comment';\n } else if (character === '/' && nextCharacter === '*') {\n maskedSource += ' ';\n index += 1;\n state = 'block-comment';\n } else if (character === \"'\") {\n maskedSource += ' ';\n state = 'single-quote';\n } else if (character === '\"') {\n maskedSource += ' ';\n state = 'double-quote';\n } else if (character === '`') {\n maskedSource += ' ';\n state = 'template';\n } else {\n maskedSource += character;\n }\n continue;\n }\n\n if (state === 'line-comment') {\n maskedSource += maskCharacter(character);\n if (character === '\\n' || character === '\\r') {\n state = 'code';\n }\n continue;\n }\n\n if (state === 'block-comment') {\n if (character === '*' && nextCharacter === '/') {\n maskedSource += ' ';\n index += 1;\n state = 'code';\n } else {\n maskedSource += maskCharacter(character);\n }\n continue;\n }\n\n maskedSource += maskCharacter(character);\n if (escaped) {\n escaped = false;\n } else if (character === '\\\\') {\n escaped = true;\n } else if (\n (state === 'single-quote' && character === \"'\") ||\n (state === 'double-quote' && character === '\"') ||\n (state === 'template' && character === '`')\n ) {\n state = 'code';\n }\n }\n\n return maskedSource;\n};\n\nconst isKeyframesRule = (rule: Rule): boolean => {\n const parent = rule.parent;\n return parent?.type === 'atrule' && /keyframes$/i.test(parent.name);\n};\n\nconst isRootNode = (node: selectorParser.Node): boolean => {\n return (\n (node.type === 'tag' && (node.value.toLowerCase() === 'html' || node.value.toLowerCase() === 'body')) ||\n (node.type === 'pseudo' && (node.value === ':root' || node.value === MF_ROOT_SELECTOR))\n );\n};\n\nconst isScopeNode = (node: selectorParser.Node | undefined, scopeId: string): boolean => {\n if (node?.type === 'attribute' && node.attribute === MF_SCOPE_ATTRIBUTE && node.operator === '=' && node.value === scopeId) {\n return true;\n }\n\n const normalized = node?.toString().replaceAll('\"', '').replaceAll(\"'\", '');\n return (\n node?.type === 'pseudo' &&\n (normalized === `:where([${MF_SCOPE_ATTRIBUTE}=${scopeId}])` ||\n normalized === `:where([${MF_SCOPE_ATTRIBUTE}=${scopeId}]:not([${MF_OVERLAY_ATTRIBUTE}]))`)\n );\n};\n\nconst startsWithHostPseudo = (selector: selectorParser.Selector): boolean => {\n return selector.first?.type === 'pseudo' && selector.first.value === ':host';\n};\n\nconst removeRootIdentityIds = (selector: selectorParser.Selector): void => {\n let compound: selectorParser.Node[] = [];\n const removeIdsFromRootCompound = (): void => {\n if (compound.some(isRootNode)) {\n for (const node of compound) {\n if (node.type === 'id') {\n node.remove();\n }\n }\n }\n };\n\n for (const node of [...selector.nodes]) {\n if (node.type === 'combinator') {\n removeIdsFromRootCompound();\n compound = [];\n } else {\n compound.push(node);\n }\n }\n removeIdsFromRootCompound();\n};\n\nconst SPECIFICITY_CARRIER = 'edyn-mf-root';\n\n// Legacy rules such as `html body button` or `html body#app .mdc-checkbox__background` are weighed against Angular\n// Material's own rules by the html, body and #app they start from, so the scope that replaces that root must weigh\n// exactly the same. A plain scope attribute (0,1,0) drops the id of `body#app`, letting Material's checked colour win,\n// and outweighs the two types of `html body`, letting an override that lost to `.mat-mdc-button` on the old site win\n// hosted. The root becomes :where(<scope>):not(<carrier>): :where() weighs nothing, and the carrier has the same id,\n// class and type counts as the root part it replaces and never matches the scope element, so :not() always matches and\n// weighs exactly that. Neutral names keep `html`, `body` and `#app` out of the emitted CSS.\nconst rootSpecificityCarrier = (selector: selectorParser.Selector): string => {\n const compounds: selectorParser.Node[][] = [[]];\n for (const node of selector.nodes) {\n if (node.type === 'combinator') {\n compounds.push([]);\n } else {\n compounds.at(-1)?.push(node);\n }\n }\n\n const carrier: string[] = [];\n for (const compound of compounds) {\n if (!compound.some(isRootNode)) {\n continue;\n }\n const types = compound.filter((node) => node.type === 'tag' && isRootNode(node)).length;\n const pseudoRoots = compound.filter((node) => node.type === 'pseudo' && isRootNode(node)).length;\n const ids = compound.filter((node) => node.type === 'id').length;\n carrier.push(\n `${SPECIFICITY_CARRIER.repeat(Math.min(types, 1))}${`.${SPECIFICITY_CARRIER}`.repeat(pseudoRoots)}${`#${SPECIFICITY_CARRIER}`.repeat(ids)}`,\n );\n }\n\n return carrier.filter(Boolean).join(' ');\n};\n\nconst rootedDescendantScope = (selector: selectorParser.Selector, scopeId: string): string => {\n return `:where([${MF_SCOPE_ATTRIBUTE}=\"${scopeId}\"]):not(${rootSpecificityCarrier(selector)})`;\n};\n\nconst isRootOnlySelector = (selector: selectorParser.Selector): boolean => {\n const compounds: selectorParser.Node[][] = [[]];\n\n for (const node of selector.nodes) {\n if (node.type === 'combinator') {\n compounds.push([]);\n } else {\n compounds.at(-1)?.push(node);\n }\n }\n\n return compounds.every((compound) => compound.some(isRootNode));\n};\n\nconst hasRootOnlySelector = (selectorList: string): boolean => {\n let result = false;\n selectorParser((root) => {\n result = root.nodes.some(isRootOnlySelector);\n }).processSync(selectorList);\n return result;\n};\n\nconst getAngularComponentSourcePath = (stylePath: string): string | undefined => {\n const cleanStylePath = stylePath.replace(/[?#].*$/, '');\n if (!ANGULAR_COMPONENT_STYLE_PATTERN.test(cleanStylePath)) {\n return undefined;\n }\n\n return cleanStylePath.replace(/\\.(?:css|less|sass|scss)$/i, '.ts');\n};\n\nconst usesViewEncapsulationNone = (stylePath: string): boolean => {\n const componentSourcePath = getAngularComponentSourcePath(stylePath);\n if (!componentSourcePath || !existsSync(componentSourcePath)) {\n return false;\n }\n\n const componentSource = readFileSync(componentSourcePath, 'utf8');\n return VIEW_ENCAPSULATION_NONE_PATTERN.test(maskTypeScriptCommentsAndStrings(componentSource));\n};\n\nexport const shouldUseAngularComponentScoping = (stylePath: string | undefined): boolean => {\n return !!stylePath && !!getAngularComponentSourcePath(stylePath) && !usesViewEncapsulationNone(stylePath);\n};\n\nconst scopeSelectorList = (selectorList: string, scopeId: string, scopeSelector: string, rootScopeSelectors: string[]): string => {\n return selectorParser((root) => {\n const sourceSelectors = [...root.nodes];\n\n for (const selector of sourceSelectors) {\n const rootNodes = selector.nodes.filter(isRootNode);\n\n if (rootNodes.length > 0) {\n const replacementSelectors = isRootOnlySelector(selector) ? rootScopeSelectors : [rootedDescendantScope(selector, scopeId)];\n\n for (const replacementSelector of replacementSelectors) {\n const variant = selector.clone();\n removeRootIdentityIds(variant);\n const [firstRoot, ...duplicateRoots] = variant.nodes.filter(isRootNode);\n // The replacement can be a compound of several nodes, e.g. :where(<scope>):not(<carrier>).\n const scopeNodes = selectorParser()\n .astSync(replacementSelector)\n .first.nodes.map((node) => node.clone());\n const [scopeNode, ...followingScopeNodes] = scopeNodes;\n if (firstRoot && scopeNode) {\n firstRoot.replaceWith(scopeNode);\n let previous = scopeNode;\n for (const node of followingScopeNodes) {\n variant.insertAfter(previous, node);\n previous = node;\n }\n }\n\n for (const duplicateRoot of duplicateRoots) {\n const previous = duplicateRoot.prev();\n if (previous?.type === 'combinator') {\n previous.remove();\n }\n duplicateRoot.remove();\n }\n\n root.insertBefore(selector, variant);\n }\n selector.remove();\n continue;\n }\n\n if (startsWithHostPseudo(selector) || isScopeNode(selector.first, scopeId)) {\n continue;\n }\n\n const first = selector.first;\n const needsBoundaryVariant = first?.type === 'universal' || (first?.type === 'pseudo' && first.value.startsWith('::'));\n\n if (needsBoundaryVariant) {\n const hasSiblingCombinator = selector.nodes.some((node) => node.type === 'combinator' && (node.value === '+' || node.value === '~'));\n\n if (!hasSiblingCombinator) {\n const boundaryVariant = selector.clone();\n const boundaryScope = selectorParser().astSync(scopeSelector).first.first.clone();\n boundaryVariant.first.rawSpaceBefore = '';\n if (boundaryVariant.first.type === 'universal') {\n boundaryVariant.first.replaceWith(boundaryScope);\n } else {\n boundaryVariant.prepend(boundaryScope);\n }\n root.insertBefore(selector, boundaryVariant);\n }\n }\n\n const descendantScope = selectorParser().astSync(`${scopeSelector} *`).first;\n const prefixNodes = descendantScope.nodes.slice(0, -1).map((node) => node.clone());\n selector.first.rawSpaceBefore = '';\n for (const prefixNode of prefixNodes.reverse()) {\n selector.prepend(prefixNode);\n }\n }\n\n const seenSelectors = new Set<string>();\n for (const selector of [...root.nodes]) {\n const normalizedSelector = selector.toString().trim();\n if (seenSelectors.has(normalizedSelector)) {\n selector.remove();\n } else {\n seenSelectors.add(normalizedSelector);\n }\n }\n }).processSync(selectorList);\n};\n\nconst findFunctionalPseudoEnd = (selector: string, openParenthesisIndex: number): number => {\n let depth = 0;\n let quote: '\"' | \"'\" | undefined;\n\n for (let index = openParenthesisIndex; index < selector.length; index += 1) {\n const character = selector[index];\n const previousCharacter = selector[index - 1];\n\n if (quote) {\n if (character === quote && previousCharacter !== '\\\\') {\n quote = undefined;\n }\n continue;\n }\n\n if (character === '\"' || character === \"'\") {\n quote = character;\n continue;\n }\n\n if (character === '(') {\n depth += 1;\n } else if (character === ')') {\n depth -= 1;\n if (depth === 0) {\n return index;\n }\n }\n }\n\n return -1;\n};\n\nconst scopeAngularSelector = (selector: string, boundarySelector: string): string => {\n const normalizedSelector = selector.trim();\n const angularBoundary = `:host-context(${boundarySelector})`;\n const normalizedBoundary = normalizedSelector.slice(0, angularBoundary.length).replaceAll(\"'\", '\"');\n\n if (normalizedBoundary === angularBoundary) {\n return normalizedSelector;\n }\n\n if (/^:host-context\\(/i.test(normalizedSelector)) {\n return `${angularBoundary}${normalizedSelector}`;\n }\n\n if (/^:host\\(/i.test(normalizedSelector)) {\n const openParenthesisIndex = normalizedSelector.indexOf('(');\n const closeParenthesisIndex = findFunctionalPseudoEnd(normalizedSelector, openParenthesisIndex);\n if (closeParenthesisIndex !== -1) {\n const hostSelector = normalizedSelector.slice(openParenthesisIndex + 1, closeParenthesisIndex);\n const remainder = normalizedSelector.slice(closeParenthesisIndex + 1);\n return list\n .comma(hostSelector)\n .map((hostSelectorVariant) => `${angularBoundary}${hostSelectorVariant}${remainder}`)\n .join(', ');\n }\n }\n\n if (/^:host\\b/i.test(normalizedSelector)) {\n return normalizedSelector.replace(/^:host\\b/i, angularBoundary);\n }\n\n return `${angularBoundary} ${normalizedSelector}`;\n};\n\nconst scopeAngularSelectorList = (selectorList: string, boundarySelector: string): string => {\n return list\n .comma(selectorList)\n .map((selector) => scopeAngularSelector(selector, boundarySelector))\n .join(', ');\n};\n\nconst namespaceKeyframes = (root: Root, keyframePrefix: string): void => {\n const keyframes = new Map<string, string>();\n\n root.walkAtRules((atRule) => {\n if (!/keyframes$/i.test(atRule.name) || atRule.params.startsWith(keyframePrefix)) {\n return;\n }\n\n const originalName = atRule.params.trim();\n const scopedName = `${keyframePrefix}${originalName}`;\n keyframes.set(originalName, scopedName);\n atRule.params = scopedName;\n });\n\n root.walkDecls((declaration) => {\n if (!/^(?:-webkit-)?animation(?:-name)?$/i.test(declaration.prop) && !declaration.prop.startsWith('--animate-')) {\n return;\n }\n\n const parsed = valueParser(declaration.value);\n parsed.walk((node) => {\n if (node.type === 'word') {\n node.value = keyframes.get(node.value) ?? node.value;\n }\n });\n declaration.value = parsed.toString();\n });\n};\n\nconst scopeGlobalRoot = (root: Root, scopeId: string, scopeSelector: string, keyframePrefix: string): void => {\n namespaceKeyframes(root, keyframePrefix);\n const contentRootSelector = `:where([${MF_SCOPE_ATTRIBUTE}=\"${scopeId}\"]:not([${MF_OVERLAY_ATTRIBUTE}]))`;\n root.walkRules((rule) => {\n if (!isKeyframesRule(rule)) {\n const declarations = rule.nodes.filter((node) => node.type === 'decl');\n const customProperties = declarations.filter((declaration) => declaration.prop.startsWith('--'));\n const standardDeclarations = declarations.filter((declaration) => !declaration.prop.startsWith('--'));\n\n if (customProperties.length > 0 && standardDeclarations.length > 0 && hasRootOnlySelector(rule.selector)) {\n const customPropertyRule = rule.cloneBefore();\n customPropertyRule.walkDecls((declaration) => {\n if (!declaration.prop.startsWith('--')) {\n declaration.remove();\n }\n });\n customPropertyRule.selector = scopeSelectorList(customPropertyRule.selector, scopeId, scopeSelector, [':host', scopeSelector]);\n rule.walkDecls((declaration) => {\n if (declaration.prop.startsWith('--')) {\n declaration.remove();\n }\n });\n }\n\n const containsOnlyCustomProperties = declarations.length > 0 && declarations.every((declaration) => declaration.prop.startsWith('--'));\n const rootScopeSelectors = containsOnlyCustomProperties ? [':host', scopeSelector] : [':host', contentRootSelector];\n rule.selector = scopeSelectorList(rule.selector, scopeId, scopeSelector, rootScopeSelectors);\n }\n });\n};\n\nconst scopeAngularComponentRoot = (root: Root, boundarySelector: string, keyframePrefix: string): void => {\n namespaceKeyframes(root, keyframePrefix);\n root.walkRules((rule) => {\n if (!isKeyframesRule(rule)) {\n rule.selector = scopeAngularSelectorList(rule.selector, boundarySelector);\n }\n });\n};\n\nexport const scopeRemoteCss = ({ scopeId }: IScopeRemoteCssOptions): Plugin => {\n const validScopeId = validateMfScopeId(scopeId);\n const scopeSelector = getMfScopeSelector(validScopeId);\n const keyframePrefix = `edyn-mf-${validScopeId}--`;\n\n return {\n postcssPlugin: `edyn-mf-isolation-${validScopeId}`,\n Once(root) {\n scopeGlobalRoot(root, validScopeId, scopeSelector, keyframePrefix);\n },\n };\n};\n\nexport const scopeAngularRemoteCss = ({ scopeId }: IScopeRemoteCssOptions): Plugin => {\n const validScopeId = validateMfScopeId(scopeId);\n const scopeSelector = getMfScopeSelector(validScopeId);\n const boundarySelector = `[${MF_SCOPE_ATTRIBUTE}=\"${validScopeId}\"]`;\n const keyframePrefix = `edyn-mf-${validScopeId}--`;\n\n return {\n postcssPlugin: `edyn-mf-angular-isolation-${validScopeId}`,\n Once(root) {\n if (shouldUseAngularComponentScoping(root.source?.input.file)) {\n scopeAngularComponentRoot(root, boundarySelector, keyframePrefix);\n return;\n }\n\n scopeGlobalRoot(root, validScopeId, scopeSelector, keyframePrefix);\n },\n };\n};\n"]}
1
+ {"version":3,"file":"postcss.js","sourceRoot":"","sources":["../src/postcss.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAChE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEpD,OAAO,cAAc,MAAM,yBAAyB,CAAC;AACrD,OAAO,WAAW,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AACzG,OAAO,EAAE,0BAA0B,EAAE,MAAM,qBAAqB,CAAC;AAMjE,MAAM,+BAA+B,GAAG,uCAAuC,CAAC;AAChF,MAAM,+BAA+B,GAAG,uEAAuE,CAAC;AAChH,MAAM,oBAAoB,GAAG,sBAAsB,CAAC;AAIpD,MAAM,gCAAgC,GAAG,CAAC,MAAc,EAAU,EAAE;IAClE,IAAI,YAAY,GAAG,EAAE,CAAC;IACtB,IAAI,KAAK,GAAyB,MAAM,CAAC;IACzC,IAAI,OAAO,GAAG,KAAK,CAAC;IAEpB,MAAM,aAAa,GAAG,CAAC,SAAiB,EAAU,EAAE;QAClD,OAAO,SAAS,KAAK,IAAI,IAAI,SAAS,KAAK,IAAI,CAAC,CAAC,CAAC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CAAC;gBAC9D,yBAAyB,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC;gBAChD,OAAO;YACT,CAAC;YAED,eAAe,CAAC,IAAI,EAAE,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC;QAC9G,CAAC;KACF,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import { existsSync, readdirSync, readFileSync } from 'node:fs';\nimport { basename, dirname, join } from 'node:path';\nimport type { Declaration, Plugin, Root, Rule } from 'postcss';\nimport selectorParser from 'postcss-selector-parser';\nimport valueParser from 'postcss-value-parser';\nimport { getMfScopeSelector, MF_ROOT_SELECTOR, MF_SCOPE_ATTRIBUTE, validateMfScopeId } from './index.js';\nimport { MF_ROOT_FONT_SIZE_PROPERTY } from './root-font-size.js';\n\nexport interface IScopeRemoteCssOptions {\n scopeId: string;\n}\n\nconst ANGULAR_COMPONENT_STYLE_PATTERN = /\\.component\\.(?:css|less|sass|scss)$/i;\nconst VIEW_ENCAPSULATION_NONE_PATTERN = /(?:^|[,{])\\s*encapsulation\\s*:\\s*(?:[A-Za-z_$][\\w$]*\\s*\\.\\s*)+None\\b/m;\nconst MF_OVERLAY_ATTRIBUTE = 'data-edyn-mf-overlay';\n\ntype TTypeScriptMaskState = 'block-comment' | 'code' | 'double-quote' | 'line-comment' | 'single-quote' | 'template';\n\nconst maskTypeScriptCommentsAndStrings = (source: string): string => {\n let maskedSource = '';\n let state: TTypeScriptMaskState = 'code';\n let escaped = false;\n\n const maskCharacter = (character: string): string => {\n return character === '\\n' || character === '\\r' ? character : ' ';\n };\n\n for (let index = 0; index < source.length; index += 1) {\n const character = source[index] ?? '';\n const nextCharacter = source[index + 1];\n\n if (state === 'code') {\n if (character === '/' && nextCharacter === '/') {\n maskedSource += ' ';\n index += 1;\n state = 'line-comment';\n } else if (character === '/' && nextCharacter === '*') {\n maskedSource += ' ';\n index += 1;\n state = 'block-comment';\n } else if (character === \"'\") {\n maskedSource += ' ';\n state = 'single-quote';\n } else if (character === '\"') {\n maskedSource += ' ';\n state = 'double-quote';\n } else if (character === '`') {\n maskedSource += ' ';\n state = 'template';\n } else {\n maskedSource += character;\n }\n continue;\n }\n\n if (state === 'line-comment') {\n maskedSource += maskCharacter(character);\n if (character === '\\n' || character === '\\r') {\n state = 'code';\n }\n continue;\n }\n\n if (state === 'block-comment') {\n if (character === '*' && nextCharacter === '/') {\n maskedSource += ' ';\n index += 1;\n state = 'code';\n } else {\n maskedSource += maskCharacter(character);\n }\n continue;\n }\n\n maskedSource += maskCharacter(character);\n if (escaped) {\n escaped = false;\n } else if (character === '\\\\') {\n escaped = true;\n } else if (\n (state === 'single-quote' && character === \"'\") ||\n (state === 'double-quote' && character === '\"') ||\n (state === 'template' && character === '`')\n ) {\n state = 'code';\n }\n }\n\n return maskedSource;\n};\n\nconst isKeyframesRule = (rule: Rule): boolean => {\n const parent = rule.parent;\n return parent?.type === 'atrule' && /keyframes$/i.test(parent.name);\n};\n\nconst isRootNode = (node: selectorParser.Node): boolean => {\n return (\n (node.type === 'tag' && (node.value.toLowerCase() === 'html' || node.value.toLowerCase() === 'body')) ||\n (node.type === 'pseudo' && (node.value === ':root' || node.value === MF_ROOT_SELECTOR))\n );\n};\n\nconst isScopeNode = (node: selectorParser.Node | undefined, scopeId: string): boolean => {\n if (node?.type === 'attribute' && node.attribute === MF_SCOPE_ATTRIBUTE && node.operator === '=' && node.value === scopeId) {\n return true;\n }\n\n const normalized = node?.toString().replaceAll('\"', '').replaceAll(\"'\", '');\n return (\n node?.type === 'pseudo' &&\n (normalized === `:where([${MF_SCOPE_ATTRIBUTE}=${scopeId}])` ||\n normalized === `:where([${MF_SCOPE_ATTRIBUTE}=${scopeId}]:not([${MF_OVERLAY_ATTRIBUTE}]))`)\n );\n};\n\nconst startsWithHostPseudo = (selector: selectorParser.Selector): boolean => {\n return selector.first?.type === 'pseudo' && selector.first.value === ':host';\n};\n\nconst removeRootIdentityIds = (selector: selectorParser.Selector): void => {\n let compound: selectorParser.Node[] = [];\n const removeIdsFromRootCompound = (): void => {\n if (compound.some(isRootNode)) {\n for (const node of compound) {\n if (node.type === 'id') {\n node.remove();\n }\n }\n }\n };\n\n for (const node of [...selector.nodes]) {\n if (node.type === 'combinator') {\n removeIdsFromRootCompound();\n compound = [];\n } else {\n compound.push(node);\n }\n }\n removeIdsFromRootCompound();\n};\n\nconst SPECIFICITY_CARRIER = 'edyn-mf-root';\n\n// Legacy rules such as `html body button` or `html body#app .mdc-checkbox__background` are weighed against Angular\n// Material's own rules by the html, body and #app they start from, so the scope that replaces that root must weigh\n// exactly the same. A plain scope attribute (0,1,0) drops the id of `body#app`, letting Material's checked colour win,\n// and outweighs the two types of `html body`, letting an override that lost to `.mat-mdc-button` on the old site win\n// hosted. The root becomes :where(<scope>):not(<carrier>): :where() weighs nothing, and the carrier has the same id,\n// class and type counts as the root part it replaces and never matches the scope element, so :not() always matches and\n// weighs exactly that. Neutral names keep `html`, `body` and `#app` out of the emitted CSS.\nconst rootSpecificityCarrier = (selector: selectorParser.Selector): string => {\n const compounds: selectorParser.Node[][] = [[]];\n for (const node of selector.nodes) {\n if (node.type === 'combinator') {\n compounds.push([]);\n } else {\n compounds.at(-1)?.push(node);\n }\n }\n\n const carrier: string[] = [];\n for (const compound of compounds) {\n if (!compound.some(isRootNode)) {\n continue;\n }\n const types = compound.filter((node) => node.type === 'tag' && isRootNode(node)).length;\n const pseudoRoots = compound.filter((node) => node.type === 'pseudo' && isRootNode(node)).length;\n const ids = compound.filter((node) => node.type === 'id').length;\n carrier.push(\n `${SPECIFICITY_CARRIER.repeat(Math.min(types, 1))}${`.${SPECIFICITY_CARRIER}`.repeat(pseudoRoots)}${`#${SPECIFICITY_CARRIER}`.repeat(ids)}`,\n );\n }\n\n return carrier.filter(Boolean).join(' ');\n};\n\nconst rootedDescendantScope = (selector: selectorParser.Selector, scopeId: string): string => {\n return `:where([${MF_SCOPE_ATTRIBUTE}=\"${scopeId}\"]):not(${rootSpecificityCarrier(selector)})`;\n};\n\nconst isRootOnlySelector = (selector: selectorParser.Selector): boolean => {\n const compounds: selectorParser.Node[][] = [[]];\n\n for (const node of selector.nodes) {\n if (node.type === 'combinator') {\n compounds.push([]);\n } else {\n compounds.at(-1)?.push(node);\n }\n }\n\n return compounds.every((compound) => compound.some(isRootNode));\n};\n\nconst hasRootOnlySelector = (selectorList: string): boolean => {\n let result = false;\n selectorParser((root) => {\n result = root.nodes.some(isRootOnlySelector);\n }).processSync(selectorList);\n return result;\n};\n\nconst escapeRegExp = (text: string): string => text.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n\n// A component stylesheet need not be named *.component.scss (CampaignManagement's create-campaign.ts uses\n// `styleUrl: './create-campaign.scss'`); treated as global CSS, Angular would then encapsulate the boundary itself and\n// the rules could never match. Such a file is a component's when a sibling component source references it.\nconst referencingComponentSourceOf = (stylePath: string): string | undefined => {\n const directory = dirname(stylePath);\n if (!existsSync(directory)) {\n return undefined;\n }\n const reference = new RegExp(`styleUrls?\\\\s*:\\\\s*(?:\\\\[[^\\\\]]*?)?['\"\\`]\\\\./${escapeRegExp(basename(stylePath))}['\"\\`]`);\n for (const fileName of readdirSync(directory)) {\n if (!fileName.endsWith('.ts') || /\\.(?:spec|test|d)\\.ts$/.test(fileName)) {\n continue;\n }\n const sourcePath = join(directory, fileName);\n if (reference.test(readFileSync(sourcePath, 'utf8'))) {\n return sourcePath;\n }\n }\n return undefined;\n};\n\nconst getAngularComponentSourcePath = (stylePath: string): string | undefined => {\n const cleanStylePath = stylePath.replace(/[?#].*$/, '');\n if (ANGULAR_COMPONENT_STYLE_PATTERN.test(cleanStylePath)) {\n return cleanStylePath.replace(/\\.(?:css|less|sass|scss)$/i, '.ts');\n }\n return /\\.(?:css|less|sass|scss)$/i.test(cleanStylePath) ? referencingComponentSourceOf(cleanStylePath) : undefined;\n};\n\nconst usesViewEncapsulationNone = (stylePath: string): boolean => {\n const componentSourcePath = getAngularComponentSourcePath(stylePath);\n if (!componentSourcePath || !existsSync(componentSourcePath)) {\n return false;\n }\n\n const componentSource = readFileSync(componentSourcePath, 'utf8');\n return VIEW_ENCAPSULATION_NONE_PATTERN.test(maskTypeScriptCommentsAndStrings(componentSource));\n};\n\nexport const shouldUseAngularComponentScoping = (stylePath: string | undefined): boolean => {\n return !!stylePath && !!getAngularComponentSourcePath(stylePath) && !usesViewEncapsulationNone(stylePath);\n};\n\nconst scopeSelectorList = (selectorList: string, scopeId: string, scopeSelector: string, rootScopeSelectors: string[]): string => {\n return selectorParser((root) => {\n const sourceSelectors = [...root.nodes];\n\n for (const selector of sourceSelectors) {\n const rootNodes = selector.nodes.filter(isRootNode);\n\n if (rootNodes.length > 0) {\n const replacementSelectors = isRootOnlySelector(selector) ? rootScopeSelectors : [rootedDescendantScope(selector, scopeId)];\n\n for (const replacementSelector of replacementSelectors) {\n const variant = selector.clone();\n removeRootIdentityIds(variant);\n const [firstRoot, ...duplicateRoots] = variant.nodes.filter(isRootNode);\n // The replacement can be a compound of several nodes, e.g. :where(<scope>):not(<carrier>).\n const scopeNodes = selectorParser()\n .astSync(replacementSelector)\n .first.nodes.map((node) => node.clone());\n const [scopeNode, ...followingScopeNodes] = scopeNodes;\n if (firstRoot && scopeNode) {\n firstRoot.replaceWith(scopeNode);\n let previous = scopeNode;\n for (const node of followingScopeNodes) {\n variant.insertAfter(previous, node);\n previous = node;\n }\n }\n\n for (const duplicateRoot of duplicateRoots) {\n const previous = duplicateRoot.prev();\n if (previous?.type === 'combinator') {\n previous.remove();\n }\n duplicateRoot.remove();\n }\n\n root.insertBefore(selector, variant);\n }\n selector.remove();\n continue;\n }\n\n if (startsWithHostPseudo(selector) || isScopeNode(selector.first, scopeId)) {\n continue;\n }\n\n const first = selector.first;\n const needsBoundaryVariant = first?.type === 'universal' || (first?.type === 'pseudo' && first.value.startsWith('::'));\n\n if (needsBoundaryVariant) {\n const hasSiblingCombinator = selector.nodes.some((node) => node.type === 'combinator' && (node.value === '+' || node.value === '~'));\n\n if (!hasSiblingCombinator) {\n const boundaryVariant = selector.clone();\n const boundaryScope = selectorParser().astSync(scopeSelector).first.first.clone();\n boundaryVariant.first.rawSpaceBefore = '';\n if (boundaryVariant.first.type === 'universal') {\n boundaryVariant.first.replaceWith(boundaryScope);\n } else {\n boundaryVariant.prepend(boundaryScope);\n }\n root.insertBefore(selector, boundaryVariant);\n }\n }\n\n const descendantScope = selectorParser().astSync(`${scopeSelector} *`).first;\n const prefixNodes = descendantScope.nodes.slice(0, -1).map((node) => node.clone());\n selector.first.rawSpaceBefore = '';\n for (const prefixNode of prefixNodes.reverse()) {\n selector.prepend(prefixNode);\n }\n }\n\n const seenSelectors = new Set<string>();\n for (const selector of [...root.nodes]) {\n const normalizedSelector = selector.toString().trim();\n if (seenSelectors.has(normalizedSelector)) {\n selector.remove();\n } else {\n seenSelectors.add(normalizedSelector);\n }\n }\n }).processSync(selectorList);\n};\n\nconst namespaceKeyframes = (root: Root, keyframePrefix: string): void => {\n const keyframes = new Map<string, string>();\n\n root.walkAtRules((atRule) => {\n if (!/keyframes$/i.test(atRule.name) || atRule.params.startsWith(keyframePrefix)) {\n return;\n }\n\n const originalName = atRule.params.trim();\n const scopedName = `${keyframePrefix}${originalName}`;\n keyframes.set(originalName, scopedName);\n atRule.params = scopedName;\n });\n\n root.walkDecls((declaration) => {\n if (!/^(?:-webkit-)?animation(?:-name)?$/i.test(declaration.prop) && !declaration.prop.startsWith('--animate-')) {\n return;\n }\n\n const parsed = valueParser(declaration.value);\n parsed.walk((node) => {\n if (node.type === 'word') {\n node.value = keyframes.get(node.value) ?? node.value;\n }\n });\n declaration.value = parsed.toString();\n });\n};\n\nconst INITIAL_FONT_SIZE_PX = 16;\n// Absolute-size keywords as browsers compute them, and the relative ones as they resolve on the root, whose parent size\n// is the initial 16px.\nconst FONT_SIZE_KEYWORDS_PX: Readonly<Record<string, number>> = {\n 'xx-small': 9,\n 'x-small': 10,\n small: 13,\n medium: 16,\n large: 18,\n 'x-large': 24,\n 'xx-large': 32,\n 'xxx-large': 48,\n smaller: INITIAL_FONT_SIZE_PX / 1.2,\n larger: INITIAL_FONT_SIZE_PX * 1.2,\n};\n// On the root, every global keyword gives the initial size.\nconst GLOBAL_KEYWORDS = new Set(['inherit', 'initial', 'revert', 'revert-layer', 'unset']);\n// em, rem and % on the root are relative to the initial size.\nconst FONT_SIZE_UNITS_PX: Readonly<Record<string, number>> = {\n '%': INITIAL_FONT_SIZE_PX / 100,\n cm: 96 / 2.54,\n em: INITIAL_FONT_SIZE_PX,\n in: 96,\n mm: 96 / 25.4,\n pc: 16,\n pt: 96 / 72,\n px: 1,\n q: 96 / 101.6,\n rem: INITIAL_FONT_SIZE_PX,\n};\n\nconst fontSizeOfWord = (word: string): number | undefined => {\n const keyword = FONT_SIZE_KEYWORDS_PX[word.toLowerCase()];\n if (keyword !== undefined) {\n return keyword;\n }\n const dimension = valueParser.unit(word);\n const unitPx = dimension ? FONT_SIZE_UNITS_PX[dimension.unit.toLowerCase()] : undefined;\n const amount = Number(dimension ? dimension.number : Number.NaN);\n return unitPx !== undefined && Number.isFinite(amount) && amount >= 0 ? amount * unitPx : undefined;\n};\n\nconst significantValueNodes = (value: string): valueParser.Node[] => {\n return valueParser(value).nodes.filter((node) => node.type !== 'space' && node.type !== 'comment');\n};\n\nconst globalKeywordFontSize = (nodes: valueParser.Node[]): number | undefined => {\n const [only] = nodes;\n return nodes.length === 1 && only?.type === 'word' && GLOBAL_KEYWORDS.has(only.value.toLowerCase()) ? INITIAL_FONT_SIZE_PX : undefined;\n};\n\nconst resolveFontSize = (value: string): number | undefined => {\n const nodes = significantValueNodes(value);\n const [only] = nodes;\n return globalKeywordFontSize(nodes) ?? (nodes.length === 1 && only?.type === 'word' ? fontSizeOfWord(only.value) : undefined);\n};\n\n// `font: [style] [variant] [weight] [stretch] <size>[/<line-height>] <family>`: the size is the word before `/`, or else\n// the first word that is a size. A function (var(), calc()) or a family name reached first means it cannot be read.\nconst resolveFontShorthandSize = (value: string): number | undefined => {\n const nodes = significantValueNodes(value);\n const globalSize = globalKeywordFontSize(nodes);\n if (globalSize !== undefined) {\n return globalSize;\n }\n\n const slashIndex = nodes.findIndex((node) => node.type === 'div' && node.value === '/');\n if (slashIndex > 0) {\n const size = nodes[slashIndex - 1];\n return size?.type === 'word' ? fontSizeOfWord(size.value) : undefined;\n }\n\n for (const node of nodes) {\n if (node.type !== 'word') {\n return undefined;\n }\n const size = fontSizeOfWord(node.value);\n if (size !== undefined) {\n return size;\n }\n }\n return undefined;\n};\n\n// `html` and `:root` size the document root, so rem; `body` and `html body` size only the body.\nconst targetsDocumentRoot = (selector: selectorParser.Selector): boolean => {\n let subject: selectorParser.Node[] = [];\n for (const node of selector.nodes) {\n subject = node.type === 'combinator' ? [] : [...subject, node];\n }\n return subject.some((node) => (node.type === 'tag' && node.value.toLowerCase() === 'html') || (node.type === 'pseudo' && node.value === ':root'));\n};\n\nconst documentRootSelectorsOf = (selectorList: string): string[] => {\n const selectors: string[] = [];\n selectorParser((root) => {\n for (const selector of root.nodes) {\n if (targetsDocumentRoot(selector)) {\n selectors.push(selector.toString().trim());\n }\n }\n }).processSync(selectorList);\n return selectors;\n};\n\ntype TWarn = (node: Declaration, text: string) => void;\n\n// Hosted, rem resolves against the host page's root, not the root size the module's own page set. Each rule that sizes\n// the document root gets a sibling rule right after it that records that size as MF_ROOT_FONT_SIZE_PROPERTY, under the\n// same conditions (@media, importance) and in the same cascade order; scoping then moves it onto the module boundary,\n// where followModuleRootFontSize() makes rem lengths read it. CSS that never sizes the root is left byte-identical.\nconst recordRootFontSize = (root: Root, warn: TWarn): void => {\n root.walkRules((rule) => {\n if (isKeyframesRule(rule)) {\n return;\n }\n\n let sizing: Declaration | undefined;\n for (const node of rule.nodes) {\n if (node.type === 'decl' && /^font(?:-size)?$/i.test(node.prop) && (node.important || !sizing?.important)) {\n sizing = node;\n }\n }\n if (!sizing) {\n return;\n }\n\n const rootSelectors = documentRootSelectorsOf(rule.selector);\n if (rootSelectors.length === 0) {\n return;\n }\n\n const sizePx = sizing.prop.toLowerCase() === 'font' ? resolveFontShorthandSize(sizing.value) : resolveFontSize(sizing.value);\n if (sizePx === undefined) {\n warn(\n sizing,\n `Cannot resolve the document root font size \"${sizing.value}\" at build time; rem lengths in the hosted module will use the host page's root size.`,\n );\n return;\n }\n\n const recorded = rule.clone({ selector: rootSelectors.join(', ') });\n recorded.raws.before = rule.raws.before || '\\n';\n recorded.removeAll();\n // The recorded size points back at the declaration it came from, so source maps keep a source for it.\n recorded.append({\n important: sizing.important,\n prop: MF_ROOT_FONT_SIZE_PROPERTY,\n source: sizing.source,\n value: `${Number(sizePx.toFixed(4))}px`,\n });\n rule.after(recorded);\n });\n};\n\nconst scopeGlobalRoot = (root: Root, scopeId: string, scopeSelector: string, keyframePrefix: string, warn: TWarn): void => {\n recordRootFontSize(root, warn);\n namespaceKeyframes(root, keyframePrefix);\n const contentRootSelector = `:where([${MF_SCOPE_ATTRIBUTE}=\"${scopeId}\"]:not([${MF_OVERLAY_ATTRIBUTE}]))`;\n root.walkRules((rule) => {\n if (!isKeyframesRule(rule)) {\n const declarations = rule.nodes.filter((node) => node.type === 'decl');\n const customProperties = declarations.filter((declaration) => declaration.prop.startsWith('--'));\n const standardDeclarations = declarations.filter((declaration) => !declaration.prop.startsWith('--'));\n\n if (customProperties.length > 0 && standardDeclarations.length > 0 && hasRootOnlySelector(rule.selector)) {\n const customPropertyRule = rule.cloneBefore();\n customPropertyRule.walkDecls((declaration) => {\n if (!declaration.prop.startsWith('--')) {\n declaration.remove();\n }\n });\n customPropertyRule.selector = scopeSelectorList(customPropertyRule.selector, scopeId, scopeSelector, [':host', scopeSelector]);\n rule.walkDecls((declaration) => {\n if (declaration.prop.startsWith('--')) {\n declaration.remove();\n }\n });\n }\n\n const containsOnlyCustomProperties = declarations.length > 0 && declarations.every((declaration) => declaration.prop.startsWith('--'));\n const rootScopeSelectors = containsOnlyCustomProperties ? [':host', scopeSelector] : [':host', contentRootSelector];\n rule.selector = scopeSelectorList(rule.selector, scopeId, scopeSelector, rootScopeSelectors);\n }\n });\n};\n\n// Emulated component CSS keeps its selectors exactly as written, so Angular compiles what it compiled on the module's\n// own page and every rule keeps its weight and reach: `mat-form-field[_ngcontent-x]` (0,1,1) still loses to a global\n// `.mat-sidenav-content .mat-mdc-form-field` (0,2,0), template content rendered in an overlay (outside the component's\n// host) keeps its component styles, and a top-level `::ng-deep` rule stays global to the module. Wrapping every rule in\n// :host-context(<boundary>) added (0,2,0) to each, and limited all of them to the component's host. Isolation needs no\n// boundary here: Angular's _ngcontent and _nghost attributes are unique to each component, and a hosted module's\n// component styles live in its own shadow root.\nconst scopeAngularComponentRoot = (root: Root, keyframePrefix: string): void => {\n namespaceKeyframes(root, keyframePrefix);\n};\n\nexport const scopeRemoteCss = ({ scopeId }: IScopeRemoteCssOptions): Plugin => {\n const validScopeId = validateMfScopeId(scopeId);\n const scopeSelector = getMfScopeSelector(validScopeId);\n const keyframePrefix = `edyn-mf-${validScopeId}--`;\n\n return {\n postcssPlugin: `edyn-mf-isolation-${validScopeId}`,\n Once(root, { result }) {\n scopeGlobalRoot(root, validScopeId, scopeSelector, keyframePrefix, (node, text) => node.warn(result, text));\n },\n };\n};\n\nexport const scopeAngularRemoteCss = ({ scopeId }: IScopeRemoteCssOptions): Plugin => {\n const validScopeId = validateMfScopeId(scopeId);\n const scopeSelector = getMfScopeSelector(validScopeId);\n const keyframePrefix = `edyn-mf-${validScopeId}--`;\n\n return {\n postcssPlugin: `edyn-mf-angular-isolation-${validScopeId}`,\n Once(root, { result }) {\n if (shouldUseAngularComponentScoping(root.source?.input.file)) {\n scopeAngularComponentRoot(root, keyframePrefix);\n return;\n }\n\n scopeGlobalRoot(root, validScopeId, scopeSelector, keyframePrefix, (node, text) => node.warn(result, text));\n },\n };\n};\n"]}
@@ -0,0 +1,7 @@
1
+ export declare const MF_ROOT_FONT_SIZE_PROPERTY = "--edyn-mf-rem";
2
+ export declare const ROOT_FONT_SIZE_DECLARATION_PATTERN: RegExp;
3
+ export declare const REM_LENGTH_HINT_PATTERN: RegExp;
4
+ export declare const UNFOLLOWED_REM_PATTERN: RegExp;
5
+ /** Rewrites every rem length in CSS declaration text to follow the module's root font size; running it again changes nothing. */
6
+ export declare const rewriteRemLengths: (declarations: string) => string;
7
+ //# sourceMappingURL=root-font-size.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"root-font-size.d.ts","sourceRoot":"","sources":["../src/root-font-size.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,0BAA0B,kBAAkB,CAAC;AAG1D,eAAO,MAAM,kCAAkC,QAAmD,CAAC;AACnG,eAAO,MAAM,uBAAuB,QAAW,CAAC;AAQhD,eAAO,MAAM,sBAAsB,QAA6C,CAAC;AAMjF,iIAAiI;AACjI,eAAO,MAAM,iBAAiB,GAAI,cAAc,MAAM,KAAG,MAQxD,CAAC","sourcesContent":["// `rem` always resolves against the page's <html>, even inside a shadow root. A module page that sized its own root\n// (`html, body { font-size: 12px }`) drew every rem length from that size, but hosted, the same lengths use the host\n// page's root (16px): Material's `.mat-mdc-button > .mat-icon { font-size: 1.125rem }` drew 13.5px on the old page and\n// 18px hosted. The build-time PostCSS plugin records the module's root size as this property on the module boundary;\n// followModuleRootFontSize() rewrites every rem length in the module's shadow root to read it.\nexport const MF_ROOT_FONT_SIZE_PROPERTY = '--edyn-mf-rem';\n\nconst ROOT_FONT_SIZE_FALLBACK = `var(${MF_ROOT_FONT_SIZE_PROPERTY}, 1rem)`;\nexport const ROOT_FONT_SIZE_DECLARATION_PATTERN = new RegExp(`${MF_ROOT_FONT_SIZE_PROPERTY}\\\\s*:`);\nexport const REM_LENGTH_HINT_PATTERN = /\\drem/i;\n// A number with the rem unit that is not part of an identifier (`foo-2rem`) and not the fallback this rewrite writes.\nconst REM_LENGTH_PATTERN = new RegExp(`(?<![\\\\w.-]|var\\\\(${MF_ROOT_FONT_SIZE_PROPERTY},\\\\s*)(-?(?:\\\\d+\\\\.?\\\\d*|\\\\.\\\\d+))rem(?![\\\\w-])`, 'gi');\n// Strings and url() keep their text: `content: \"2rem\"` or `url(2rem.png)` are not lengths.\nconst VERBATIM_PATTERN = /\"(?:[^\"\\\\]|\\\\.)*\"|'(?:[^'\\\\]|\\\\.)*'|url\\((?:[^()\"'\\\\]|\\\\.)*\\)/gi;\n\n// The same match without the global flag, as a quick test: it skips the fallback this rewrite writes, so a followed\n// value does not look like work again.\nexport const UNFOLLOWED_REM_PATTERN = new RegExp(REM_LENGTH_PATTERN.source, 'i');\n\nconst rewriteOutsideVerbatim = (text: string): string => {\n return text.replace(REM_LENGTH_PATTERN, (_match, amount: string) => `calc(${amount} * ${ROOT_FONT_SIZE_FALLBACK})`);\n};\n\n/** Rewrites every rem length in CSS declaration text to follow the module's root font size; running it again changes nothing. */\nexport const rewriteRemLengths = (declarations: string): string => {\n let rewritten = '';\n let start = 0;\n for (const verbatim of declarations.matchAll(VERBATIM_PATTERN)) {\n rewritten += rewriteOutsideVerbatim(declarations.slice(start, verbatim.index)) + verbatim[0];\n start = verbatim.index + verbatim[0].length;\n }\n return rewritten + rewriteOutsideVerbatim(declarations.slice(start));\n};\n"]}
@@ -0,0 +1,30 @@
1
+ // `rem` always resolves against the page's <html>, even inside a shadow root. A module page that sized its own root
2
+ // (`html, body { font-size: 12px }`) drew every rem length from that size, but hosted, the same lengths use the host
3
+ // page's root (16px): Material's `.mat-mdc-button > .mat-icon { font-size: 1.125rem }` drew 13.5px on the old page and
4
+ // 18px hosted. The build-time PostCSS plugin records the module's root size as this property on the module boundary;
5
+ // followModuleRootFontSize() rewrites every rem length in the module's shadow root to read it.
6
+ export const MF_ROOT_FONT_SIZE_PROPERTY = '--edyn-mf-rem';
7
+ const ROOT_FONT_SIZE_FALLBACK = `var(${MF_ROOT_FONT_SIZE_PROPERTY}, 1rem)`;
8
+ export const ROOT_FONT_SIZE_DECLARATION_PATTERN = new RegExp(`${MF_ROOT_FONT_SIZE_PROPERTY}\\s*:`);
9
+ export const REM_LENGTH_HINT_PATTERN = /\drem/i;
10
+ // A number with the rem unit that is not part of an identifier (`foo-2rem`) and not the fallback this rewrite writes.
11
+ const REM_LENGTH_PATTERN = new RegExp(`(?<![\\w.-]|var\\(${MF_ROOT_FONT_SIZE_PROPERTY},\\s*)(-?(?:\\d+\\.?\\d*|\\.\\d+))rem(?![\\w-])`, 'gi');
12
+ // Strings and url() keep their text: `content: "2rem"` or `url(2rem.png)` are not lengths.
13
+ const VERBATIM_PATTERN = /"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'|url\((?:[^()"'\\]|\\.)*\)/gi;
14
+ // The same match without the global flag, as a quick test: it skips the fallback this rewrite writes, so a followed
15
+ // value does not look like work again.
16
+ export const UNFOLLOWED_REM_PATTERN = new RegExp(REM_LENGTH_PATTERN.source, 'i');
17
+ const rewriteOutsideVerbatim = (text) => {
18
+ return text.replace(REM_LENGTH_PATTERN, (_match, amount) => `calc(${amount} * ${ROOT_FONT_SIZE_FALLBACK})`);
19
+ };
20
+ /** Rewrites every rem length in CSS declaration text to follow the module's root font size; running it again changes nothing. */
21
+ export const rewriteRemLengths = (declarations) => {
22
+ let rewritten = '';
23
+ let start = 0;
24
+ for (const verbatim of declarations.matchAll(VERBATIM_PATTERN)) {
25
+ rewritten += rewriteOutsideVerbatim(declarations.slice(start, verbatim.index)) + verbatim[0];
26
+ start = verbatim.index + verbatim[0].length;
27
+ }
28
+ return rewritten + rewriteOutsideVerbatim(declarations.slice(start));
29
+ };
30
+ //# sourceMappingURL=root-font-size.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"root-font-size.js","sourceRoot":"","sources":["../src/root-font-size.ts"],"names":[],"mappings":"AAAA,oHAAoH;AACpH,qHAAqH;AACrH,uHAAuH;AACvH,qHAAqH;AACrH,+FAA+F;AAC/F,MAAM,CAAC,MAAM,0BAA0B,GAAG,eAAe,CAAC;AAE1D,MAAM,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,CAAC,CAAC;AACvE,CAAC,CAAC","sourcesContent":["// `rem` always resolves against the page's <html>, even inside a shadow root. A module page that sized its own root\n// (`html, body { font-size: 12px }`) drew every rem length from that size, but hosted, the same lengths use the host\n// page's root (16px): Material's `.mat-mdc-button > .mat-icon { font-size: 1.125rem }` drew 13.5px on the old page and\n// 18px hosted. The build-time PostCSS plugin records the module's root size as this property on the module boundary;\n// followModuleRootFontSize() rewrites every rem length in the module's shadow root to read it.\nexport const MF_ROOT_FONT_SIZE_PROPERTY = '--edyn-mf-rem';\n\nconst ROOT_FONT_SIZE_FALLBACK = `var(${MF_ROOT_FONT_SIZE_PROPERTY}, 1rem)`;\nexport const ROOT_FONT_SIZE_DECLARATION_PATTERN = new RegExp(`${MF_ROOT_FONT_SIZE_PROPERTY}\\\\s*:`);\nexport const REM_LENGTH_HINT_PATTERN = /\\drem/i;\n// A number with the rem unit that is not part of an identifier (`foo-2rem`) and not the fallback this rewrite writes.\nconst REM_LENGTH_PATTERN = new RegExp(`(?<![\\\\w.-]|var\\\\(${MF_ROOT_FONT_SIZE_PROPERTY},\\\\s*)(-?(?:\\\\d+\\\\.?\\\\d*|\\\\.\\\\d+))rem(?![\\\\w-])`, 'gi');\n// Strings and url() keep their text: `content: \"2rem\"` or `url(2rem.png)` are not lengths.\nconst VERBATIM_PATTERN = /\"(?:[^\"\\\\]|\\\\.)*\"|'(?:[^'\\\\]|\\\\.)*'|url\\((?:[^()\"'\\\\]|\\\\.)*\\)/gi;\n\n// The same match without the global flag, as a quick test: it skips the fallback this rewrite writes, so a followed\n// value does not look like work again.\nexport const UNFOLLOWED_REM_PATTERN = new RegExp(REM_LENGTH_PATTERN.source, 'i');\n\nconst rewriteOutsideVerbatim = (text: string): string => {\n return text.replace(REM_LENGTH_PATTERN, (_match, amount: string) => `calc(${amount} * ${ROOT_FONT_SIZE_FALLBACK})`);\n};\n\n/** Rewrites every rem length in CSS declaration text to follow the module's root font size; running it again changes nothing. */\nexport const rewriteRemLengths = (declarations: string): string => {\n let rewritten = '';\n let start = 0;\n for (const verbatim of declarations.matchAll(VERBATIM_PATTERN)) {\n rewritten += rewriteOutsideVerbatim(declarations.slice(start, verbatim.index)) + verbatim[0];\n start = verbatim.index + verbatim[0].length;\n }\n return rewritten + rewriteOutsideVerbatim(declarations.slice(start));\n};\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@edynamix/mf-isolation",
3
- "version": "0.0.30",
3
+ "version": "0.0.32",
4
4
  "description": "CSS and overlay isolation helpers for eDynamix microfrontends.",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",
@@ -94,6 +94,7 @@
94
94
  "@playwright/test": "1.60.0",
95
95
  "@types/bun": "1.3.14",
96
96
  "@types/node": "22.20.2",
97
+ "happy-dom": "20.11.2",
97
98
  "knip": "6.32.2",
98
99
  "postcss": "8.5.28",
99
100
  "typescript": "5.8.3",