@fluffjs/cli 0.0.8 → 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 (142) hide show
  1. package/BabelHelpers.d.ts +26 -0
  2. package/BabelHelpers.js +65 -0
  3. package/Cli.d.ts +5 -10
  4. package/Cli.js +123 -52
  5. package/CodeGenerator.d.ts +53 -39
  6. package/CodeGenerator.js +330 -725
  7. package/ComponentCompiler.d.ts +14 -16
  8. package/ComponentCompiler.js +187 -256
  9. package/DomPreProcessor.d.ts +36 -0
  10. package/DomPreProcessor.js +645 -0
  11. package/ErrorHelpers.d.ts +5 -0
  12. package/ErrorHelpers.js +8 -0
  13. package/ExpressionTransformer.d.ts +38 -28
  14. package/ExpressionTransformer.js +558 -230
  15. package/Generator.d.ts +1 -5
  16. package/Generator.js +128 -67
  17. package/GetterDependencyExtractor.d.ts +4 -0
  18. package/GetterDependencyExtractor.js +73 -0
  19. package/IndexHtmlTransformer.d.ts +6 -7
  20. package/IndexHtmlTransformer.js +82 -88
  21. package/Parse5Helpers.d.ts +16 -0
  22. package/Parse5Helpers.js +81 -0
  23. package/TemplateParser.d.ts +39 -21
  24. package/TemplateParser.js +462 -268
  25. package/Typeguards.d.ts +24 -0
  26. package/Typeguards.js +30 -0
  27. package/babel-plugin-class-transform.d.ts +3 -18
  28. package/babel-plugin-class-transform.js +3 -11
  29. package/babel-plugin-component.d.ts +4 -13
  30. package/babel-plugin-component.js +7 -0
  31. package/babel-plugin-imports.d.ts +3 -11
  32. package/babel-plugin-imports.js +5 -31
  33. package/babel-plugin-reactive.d.ts +2 -19
  34. package/babel-plugin-reactive.js +21 -76
  35. package/bin.js +2 -2
  36. package/fluff-esbuild-plugin.d.ts +2 -5
  37. package/fluff-esbuild-plugin.js +4 -1
  38. package/index.d.ts +6 -2
  39. package/index.js +1 -1
  40. package/interfaces/BabelPluginClassTransformState.d.ts +5 -0
  41. package/interfaces/BabelPluginComponentState.d.ts +4 -0
  42. package/interfaces/BabelPluginComponentState.js +1 -0
  43. package/interfaces/BabelPluginImportsState.d.ts +5 -0
  44. package/interfaces/BabelPluginImportsState.js +1 -0
  45. package/interfaces/BabelPluginReactiveState.d.ts +13 -0
  46. package/interfaces/BabelPluginReactiveState.js +1 -0
  47. package/interfaces/BabelPluginReactiveWatchCallInfo.d.ts +7 -0
  48. package/interfaces/BabelPluginReactiveWatchCallInfo.js +1 -0
  49. package/interfaces/BabelPluginReactiveWatchInfo.d.ts +5 -0
  50. package/interfaces/BabelPluginReactiveWatchInfo.js +1 -0
  51. package/interfaces/BabelToken.d.ts +8 -0
  52. package/interfaces/BabelToken.js +1 -0
  53. package/interfaces/BindingInfo.d.ts +12 -0
  54. package/interfaces/BindingInfo.js +1 -0
  55. package/interfaces/BreakMarkerConfig.d.ts +4 -0
  56. package/interfaces/BreakMarkerConfig.js +1 -0
  57. package/interfaces/BreakNode.d.ts +4 -0
  58. package/interfaces/BreakNode.js +1 -0
  59. package/interfaces/BundleOptions.d.ts +8 -0
  60. package/interfaces/BundleOptions.js +1 -0
  61. package/interfaces/ClassTransformOptions.d.ts +10 -0
  62. package/interfaces/ClassTransformOptions.js +1 -0
  63. package/interfaces/CliOptions.d.ts +6 -0
  64. package/interfaces/CliOptions.js +1 -0
  65. package/interfaces/CommentNode.d.ts +5 -0
  66. package/interfaces/CommentNode.js +1 -0
  67. package/interfaces/CompileResult.d.ts +6 -0
  68. package/interfaces/CompileResult.js +1 -0
  69. package/interfaces/CompilerOptions.d.ts +6 -0
  70. package/interfaces/CompilerOptions.js +1 -0
  71. package/interfaces/ComponentInfo.d.ts +8 -0
  72. package/interfaces/ComponentInfo.js +1 -0
  73. package/interfaces/ComponentMetadata.d.ts +9 -0
  74. package/interfaces/ComponentMetadata.js +1 -0
  75. package/interfaces/ControlFlow.d.ts +19 -0
  76. package/interfaces/ControlFlow.js +1 -0
  77. package/interfaces/ControlFlowNode.d.ts +6 -0
  78. package/interfaces/ControlFlowNode.js +1 -0
  79. package/interfaces/ControlFlowParseResult.d.ts +10 -0
  80. package/interfaces/ControlFlowParseResult.js +1 -0
  81. package/interfaces/ElementNode.d.ts +11 -0
  82. package/interfaces/ElementNode.js +1 -0
  83. package/interfaces/FluffConfigInterface.d.ts +7 -0
  84. package/interfaces/FluffConfigInterface.js +1 -0
  85. package/interfaces/FluffPluginOptions.d.ts +9 -0
  86. package/interfaces/FluffPluginOptions.js +1 -0
  87. package/interfaces/FluffTarget.d.ts +15 -0
  88. package/interfaces/FluffTarget.js +1 -0
  89. package/interfaces/ForMarkerConfig.d.ts +9 -0
  90. package/interfaces/ForMarkerConfig.js +1 -0
  91. package/interfaces/ForNode.d.ts +13 -0
  92. package/interfaces/ForNode.js +1 -0
  93. package/interfaces/GeneratorOptions.d.ts +5 -0
  94. package/interfaces/GeneratorOptions.js +1 -0
  95. package/interfaces/HtmlTransformOptions.d.ts +9 -0
  96. package/interfaces/HtmlTransformOptions.js +1 -0
  97. package/interfaces/IfBranch.d.ts +8 -0
  98. package/interfaces/IfBranch.js +1 -0
  99. package/interfaces/IfMarkerConfig.d.ts +8 -0
  100. package/interfaces/IfMarkerConfig.js +1 -0
  101. package/interfaces/IfNode.d.ts +7 -0
  102. package/interfaces/IfNode.js +1 -0
  103. package/interfaces/ImportTransformOptions.d.ts +7 -0
  104. package/interfaces/ImportTransformOptions.js +1 -0
  105. package/interfaces/InterpolationNode.d.ts +12 -0
  106. package/interfaces/InterpolationNode.js +1 -0
  107. package/interfaces/ParsedTemplate.d.ts +6 -0
  108. package/interfaces/ParsedTemplate.js +1 -0
  109. package/interfaces/ParsedTemplateOld.d.ts +9 -0
  110. package/interfaces/ParsedTemplateOld.js +1 -0
  111. package/interfaces/PropertyChain.d.ts +2 -0
  112. package/interfaces/PropertyChain.js +1 -0
  113. package/interfaces/Scope.d.ts +5 -0
  114. package/interfaces/Scope.js +1 -0
  115. package/interfaces/ServeOptions.d.ts +5 -0
  116. package/interfaces/ServeOptions.js +1 -0
  117. package/interfaces/SwitchCase.d.ts +8 -0
  118. package/interfaces/SwitchCase.js +1 -0
  119. package/interfaces/SwitchMarkerConfig.d.ts +11 -0
  120. package/interfaces/SwitchMarkerConfig.js +1 -0
  121. package/interfaces/SwitchNode.d.ts +10 -0
  122. package/interfaces/SwitchNode.js +1 -0
  123. package/interfaces/TemplateBinding.d.ts +10 -0
  124. package/interfaces/TemplateBinding.js +1 -0
  125. package/interfaces/TemplateNode.d.ts +7 -0
  126. package/interfaces/TemplateNode.js +1 -0
  127. package/interfaces/TextMarkerConfig.d.ts +10 -0
  128. package/interfaces/TextMarkerConfig.js +1 -0
  129. package/interfaces/TextNode.d.ts +5 -0
  130. package/interfaces/TextNode.js +1 -0
  131. package/interfaces/TokenizeResult.d.ts +6 -0
  132. package/interfaces/TokenizeResult.js +1 -0
  133. package/interfaces/TransformOptions.d.ts +11 -0
  134. package/interfaces/TransformOptions.js +1 -0
  135. package/interfaces/index.d.ts +34 -0
  136. package/interfaces/index.js +1 -0
  137. package/package.json +9 -1
  138. package/types/FluffConfig.d.ts +5 -27
  139. package/ControlFlowParser.d.ts +0 -55
  140. package/ControlFlowParser.js +0 -279
  141. package/types.d.ts +0 -46
  142. /package/{types.js → interfaces/BabelPluginClassTransformState.js} +0 -0
@@ -0,0 +1,26 @@
1
+ import _generate from '@babel/generator';
2
+ import _traverse from '@babel/traverse';
3
+ import * as t from '@babel/types';
4
+ export declare const generate: typeof _generate.generate;
5
+ export declare const traverse: {
6
+ <S>(parent: _traverse.Node, opts: _traverse.TraverseOptions<S>, scope: _traverse.Scope | undefined, state: S, parentPath?: _traverse.NodePath): void;
7
+ (parent: _traverse.Node, opts?: _traverse.TraverseOptions, scope?: _traverse.Scope, state?: any, parentPath?: _traverse.NodePath): void;
8
+ visitors: typeof _traverse.visitors;
9
+ verify: typeof _traverse.visitors.verify;
10
+ explode: typeof _traverse.visitors.explode;
11
+ cheap: (node: _traverse.Node, enter: (node: _traverse.Node) => void) => void;
12
+ node: (node: _traverse.Node, opts: _traverse.TraverseOptions, scope?: _traverse.Scope, state?: any, path?: _traverse.NodePath, skipKeys?: Record<string, boolean>) => void;
13
+ clearNode: (node: _traverse.Node, opts?: _traverse.RemovePropertiesOptions) => void;
14
+ removeProperties: (tree: _traverse.Node, opts?: _traverse.RemovePropertiesOptions) => _traverse.Node;
15
+ hasType: (tree: _traverse.Node, type: _traverse.Node["type"], denylistTypes?: string[]) => boolean;
16
+ cache: typeof _traverse.cache;
17
+ };
18
+ export declare function findDecoratorIndex(decorators: t.Decorator[], name: string): number;
19
+ export declare function getDecoratorName(decorator: t.Decorator): string | null;
20
+ export interface DecoratedNode {
21
+ decorators?: t.Decorator[] | null;
22
+ }
23
+ export declare function filterDecoratorsFromNode(node: DecoratedNode, removeDecorators: string[]): void;
24
+ export declare function parseMethodBody(body: string): t.Statement[];
25
+ export declare function buildHostBindingUpdateStatement(hostProperty: string): t.Statement;
26
+ //# sourceMappingURL=BabelHelpers.d.ts.map
@@ -0,0 +1,65 @@
1
+ import _generate from '@babel/generator';
2
+ import { parse } from '@babel/parser';
3
+ import _traverse from '@babel/traverse';
4
+ import * as t from '@babel/types';
5
+ export const generate = _generate.default ?? _generate;
6
+ export const traverse = _traverse.default ?? _traverse;
7
+ export function findDecoratorIndex(decorators, name) {
8
+ return decorators.findIndex(dec => {
9
+ if (t.isCallExpression(dec.expression) && t.isIdentifier(dec.expression.callee)) {
10
+ return dec.expression.callee.name === name;
11
+ }
12
+ return false;
13
+ });
14
+ }
15
+ export function getDecoratorName(decorator) {
16
+ const expr = decorator.expression;
17
+ if (t.isCallExpression(expr) && t.isIdentifier(expr.callee)) {
18
+ return expr.callee.name;
19
+ }
20
+ if (t.isIdentifier(expr)) {
21
+ return expr.name;
22
+ }
23
+ return null;
24
+ }
25
+ export function filterDecoratorsFromNode(node, removeDecorators) {
26
+ const { decorators } = node;
27
+ if (!decorators)
28
+ return;
29
+ node.decorators = decorators.filter(dec => {
30
+ const name = getDecoratorName(dec);
31
+ return !name || !removeDecorators.includes(name);
32
+ });
33
+ }
34
+ export function parseMethodBody(body) {
35
+ const wrappedCode = `class __Temp__ { __temp__() { ${body} } }`;
36
+ const ast = parse(wrappedCode, { sourceType: 'module' });
37
+ const [classDecl] = ast.program.body;
38
+ if (t.isClassDeclaration(classDecl)) {
39
+ const [method] = classDecl.body.body;
40
+ if (t.isClassMethod(method)) {
41
+ return method.body.body;
42
+ }
43
+ }
44
+ return [];
45
+ }
46
+ export function buildHostBindingUpdateStatement(hostProperty) {
47
+ if (hostProperty.startsWith('class.')) {
48
+ const className = hostProperty.slice(6);
49
+ return t.ifStatement(t.identifier('__v'), t.expressionStatement(t.callExpression(t.memberExpression(t.memberExpression(t.thisExpression(), t.identifier('classList')), t.identifier('add')), [t.stringLiteral(className)])), t.expressionStatement(t.callExpression(t.memberExpression(t.memberExpression(t.thisExpression(), t.identifier('classList')), t.identifier('remove')), [t.stringLiteral(className)])));
50
+ }
51
+ else if (hostProperty.startsWith('attr.')) {
52
+ const attrName = hostProperty.slice(5);
53
+ return t.ifStatement(t.binaryExpression('!=', t.identifier('__v'), t.nullLiteral()), t.expressionStatement(t.callExpression(t.memberExpression(t.thisExpression(), t.identifier('setAttribute')), [
54
+ t.stringLiteral(attrName),
55
+ t.callExpression(t.identifier('String'), [t.identifier('__v')])
56
+ ])), t.expressionStatement(t.callExpression(t.memberExpression(t.thisExpression(), t.identifier('removeAttribute')), [t.stringLiteral(attrName)])));
57
+ }
58
+ else if (hostProperty.startsWith('style.')) {
59
+ const styleProp = hostProperty.slice(6);
60
+ return t.expressionStatement(t.assignmentExpression('=', t.memberExpression(t.memberExpression(t.thisExpression(), t.identifier('style')), t.identifier(styleProp)), t.logicalExpression('||', t.identifier('__v'), t.stringLiteral(''))));
61
+ }
62
+ else {
63
+ return t.expressionStatement(t.assignmentExpression('=', t.memberExpression(t.thisExpression(), t.identifier(hostProperty)), t.identifier('__v')));
64
+ }
65
+ }
package/Cli.d.ts CHANGED
@@ -1,8 +1,4 @@
1
- interface CliOptions {
2
- cwd?: string;
3
- nxPackage?: string;
4
- noGzip?: boolean;
5
- }
1
+ import type { CliOptions } from './interfaces/CliOptions.js';
6
2
  export declare class Cli {
7
3
  private readonly cwd;
8
4
  private readonly nxPackage;
@@ -28,10 +24,9 @@ export declare class Cli {
28
24
  private findFiles;
29
25
  private matchesPatterns;
30
26
  private matchGlob;
27
+ static parseArgs(argv: string[]): {
28
+ options: CliOptions;
29
+ args: string[];
30
+ };
31
31
  }
32
- export declare function parseArgs(argv: string[]): {
33
- options: CliOptions;
34
- args: string[];
35
- };
36
- export {};
37
32
  //# sourceMappingURL=Cli.d.ts.map
package/Cli.js CHANGED
@@ -1,12 +1,16 @@
1
+ import * as t from '@babel/types';
2
+ import { randomUUID } from 'crypto';
1
3
  import * as esbuild from 'esbuild';
2
4
  import * as fs from 'fs';
3
5
  import * as path from 'path';
6
+ import picomatch from 'picomatch';
4
7
  import { gzipSync } from 'zlib';
8
+ import { generate } from './BabelHelpers.js';
5
9
  import { ComponentCompiler } from './ComponentCompiler.js';
6
10
  import { fluffPlugin } from './fluff-esbuild-plugin.js';
7
- import { transformIndexHtml } from './IndexHtmlTransformer.js';
8
- import { DEFAULT_CONFIG } from './types/FluffConfig.js';
9
11
  import { Generator } from './Generator.js';
12
+ import { IndexHtmlTransformer } from './IndexHtmlTransformer.js';
13
+ import { DEFAULT_CONFIG } from './types/FluffConfig.js';
10
14
  export class Cli {
11
15
  cwd;
12
16
  nxPackage;
@@ -295,6 +299,27 @@ Examples:
295
299
  const entryPoint = target.entryPoint
296
300
  ? path.join(srcDir, target.entryPoint)
297
301
  : this.generateEntryPoint(srcDir, target.components);
302
+ let inlineStyles = '';
303
+ if (target.styles && target.styles.length > 0) {
304
+ const styleContents = [];
305
+ for (const styleGlob of target.styles) {
306
+ const styleFiles = this.findFiles(srcDir, [styleGlob]);
307
+ for (const styleFile of styleFiles) {
308
+ styleContents.push(fs.readFileSync(styleFile, 'utf-8'));
309
+ }
310
+ }
311
+ if (styleContents.length > 0) {
312
+ inlineStyles = styleContents.join('\n');
313
+ if (bundleOptions.minify) {
314
+ const cssResult = await esbuild.transform(inlineStyles, {
315
+ loader: 'css',
316
+ minify: true
317
+ });
318
+ inlineStyles = cssResult.code;
319
+ }
320
+ console.log(' ✓ Bundled global styles');
321
+ }
322
+ }
298
323
  console.log(' Building with esbuild...');
299
324
  const result = await esbuild.build({
300
325
  entryPoints: [entryPoint],
@@ -307,7 +332,15 @@ Examples:
307
332
  splitting: bundleOptions.splitting ?? false,
308
333
  treeShaking: true,
309
334
  metafile: true,
310
- plugins: [fluffPlugin({ srcDir: appDir, minify: bundleOptions.minify ?? true })],
335
+ plugins: [
336
+ fluffPlugin({
337
+ srcDir: appDir,
338
+ outDir,
339
+ minify: bundleOptions.minify ?? true,
340
+ skipDefine: false,
341
+ production: true
342
+ })
343
+ ],
311
344
  external: bundleOptions.external ?? [],
312
345
  logLevel: 'warning',
313
346
  tsconfigRaw: '{}'
@@ -319,8 +352,8 @@ Examples:
319
352
  const jsBundleName = path.basename(jsBundle);
320
353
  const jsPath = path.join(outDir, jsBundleName);
321
354
  if (bundleOptions.gzip) {
322
- const jsContent = fs.readFileSync(jsPath);
323
- const gzipped = gzipSync(jsContent, { level: 9 });
355
+ const gzipContent = fs.readFileSync(jsPath);
356
+ const gzipped = gzipSync(gzipContent, { level: 9 });
324
357
  fs.writeFileSync(`${jsPath}.gz`, gzipped);
325
358
  fs.unlinkSync(jsPath);
326
359
  console.log(` ✓ Created ${jsBundleName}.gz (${gzipped.length} bytes)`);
@@ -347,9 +380,10 @@ Examples:
347
380
  const indexHtmlPath = path.join(srcDir, target.indexHtml);
348
381
  if (fs.existsSync(indexHtmlPath)) {
349
382
  const indexHtml = fs.readFileSync(indexHtmlPath, 'utf-8');
350
- const transformed = await transformIndexHtml(indexHtml, {
383
+ const transformed = await IndexHtmlTransformer.transform(indexHtml, {
351
384
  jsBundle: jsBundle ? path.basename(jsBundle) : 'main.js',
352
385
  cssBundle: cssBundle ? path.basename(cssBundle) : undefined,
386
+ inlineStyles: inlineStyles || undefined,
353
387
  gzip: bundleOptions.gzip,
354
388
  minify: bundleOptions.minify
355
389
  });
@@ -436,26 +470,58 @@ Examples:
436
470
  async serveTarget(target, projectRoot, workspaceRoot, projectRelativePath) {
437
471
  const srcDir = path.resolve(projectRoot, target.srcDir);
438
472
  const appDir = path.join(srcDir, 'app');
439
- const outDir = (workspaceRoot && projectRelativePath)
440
- ? path.join(workspaceRoot, 'dist', projectRelativePath)
441
- : path.resolve(projectRoot, target.outDir);
473
+ const fluffDir = path.join(this.cwd, '.fluff');
474
+ const serveId = randomUUID();
475
+ const outDir = path.join(fluffDir, serveId);
442
476
  if (!fs.existsSync(outDir)) {
443
477
  fs.mkdirSync(outDir, { recursive: true });
444
478
  }
479
+ const cleanup = () => {
480
+ try {
481
+ if (fs.existsSync(outDir)) {
482
+ fs.rmSync(outDir, { recursive: true, force: true });
483
+ }
484
+ }
485
+ catch {
486
+ }
487
+ };
488
+ process.on('exit', cleanup);
489
+ process.on('SIGINT', () => {
490
+ cleanup();
491
+ process.exit(0);
492
+ });
493
+ process.on('SIGTERM', () => {
494
+ cleanup();
495
+ process.exit(0);
496
+ });
445
497
  const serveOptions = target.serve ?? {};
446
498
  const port = serveOptions.port ?? 3000;
447
499
  const host = serveOptions.host ?? 'localhost';
448
500
  const entryPoint = target.entryPoint
449
501
  ? path.join(srcDir, target.entryPoint)
450
502
  : this.generateEntryPoint(srcDir, target.components);
503
+ let inlineStyles = '';
504
+ if (target.styles && target.styles.length > 0) {
505
+ const styleContents = [];
506
+ for (const styleGlob of target.styles) {
507
+ const styleFiles = this.findFiles(srcDir, [styleGlob]);
508
+ for (const styleFile of styleFiles) {
509
+ styleContents.push(fs.readFileSync(styleFile, 'utf-8'));
510
+ }
511
+ }
512
+ if (styleContents.length > 0) {
513
+ inlineStyles = styleContents.join('\n');
514
+ }
515
+ }
451
516
  if (target.indexHtml) {
452
517
  const indexHtmlPath = path.join(srcDir, target.indexHtml);
453
518
  if (fs.existsSync(indexHtmlPath)) {
454
519
  const indexHtml = fs.readFileSync(indexHtmlPath, 'utf-8');
455
- const transformed = await transformIndexHtml(indexHtml, {
520
+ const transformed = await IndexHtmlTransformer.transform(indexHtml, {
456
521
  jsBundle: path.basename(entryPoint)
457
522
  .replace('.ts', '.js'),
458
523
  cssBundle: undefined,
524
+ inlineStyles: inlineStyles || undefined,
459
525
  gzip: false,
460
526
  minify: false,
461
527
  liveReload: true
@@ -496,7 +562,16 @@ Examples:
496
562
  minify: false,
497
563
  treeShaking: true,
498
564
  sourcemap: true,
499
- plugins: [fluffPlugin({ srcDir: appDir, minify: false, sourcemap: true })],
565
+ plugins: [
566
+ fluffPlugin({
567
+ srcDir: appDir,
568
+ outDir,
569
+ minify: false,
570
+ sourcemap: true,
571
+ skipDefine: false,
572
+ production: false
573
+ })
574
+ ],
500
575
  logLevel: 'info'
501
576
  });
502
577
  await ctx.watch();
@@ -511,12 +586,13 @@ Examples:
511
586
  }
512
587
  generateEntryPoint(srcDir, componentPatterns) {
513
588
  const componentFiles = this.findFiles(srcDir, componentPatterns);
514
- const imports = componentFiles.map(f => {
589
+ const importDecls = componentFiles.map(f => {
515
590
  const relativePath = './' + path.relative(srcDir, f)
516
591
  .replace(/\\/g, '/');
517
- return `import '${relativePath}';`;
592
+ return t.importDeclaration([], t.stringLiteral(relativePath));
518
593
  });
519
- const entryContent = imports.join('\n');
594
+ const program = t.program(importDecls);
595
+ const entryContent = generate(program, { compact: false }).code;
520
596
  const entryPath = path.join(srcDir, '__generated_entry.ts');
521
597
  fs.writeFileSync(entryPath, entryContent);
522
598
  return entryPath;
@@ -550,45 +626,40 @@ Examples:
550
626
  return false;
551
627
  }
552
628
  matchGlob(filePath, pattern) {
553
- const regexPattern = pattern
554
- .replace(/\./g, '\\.')
555
- .replace(/\*\*/g, '{{GLOBSTAR}}')
556
- .replace(/\*/g, '[^/]*')
557
- .replace(/\{\{GLOBSTAR}}\//g, '(.*\\/)?')
558
- .replace(/\{\{GLOBSTAR}}/g, '.*');
559
- const regex = new RegExp(`^${regexPattern}$`);
560
- return regex.test(filePath);
629
+ const normalizedPath = filePath.replace(/\\/g, '/');
630
+ const isMatch = picomatch(pattern, { dot: false });
631
+ return isMatch(normalizedPath);
561
632
  }
562
- }
563
- export function parseArgs(argv) {
564
- const options = {};
565
- const args = [];
566
- let i = 0;
567
- while (i < argv.length) {
568
- const arg = argv[i];
569
- if (arg === '--nx' && argv[i + 1]) {
570
- options.nxPackage = argv[i + 1];
571
- i += 2;
572
- }
573
- else if (arg === '--cwd' && argv[i + 1]) {
574
- options.cwd = argv[i + 1];
575
- i += 2;
576
- }
577
- else if (arg === '--no-gzip') {
578
- options.noGzip = true;
579
- i++;
580
- }
581
- else if (arg?.startsWith('--')) {
582
- console.error(`Unknown option: ${arg}`);
583
- process.exit(1);
584
- }
585
- else if (arg) {
586
- args.push(arg);
587
- i++;
588
- }
589
- else {
590
- i++;
633
+ static parseArgs(argv) {
634
+ const options = {};
635
+ const args = [];
636
+ let i = 0;
637
+ while (i < argv.length) {
638
+ const arg = argv[i];
639
+ if (arg === '--nx' && argv[i + 1]) {
640
+ options.nxPackage = argv[i + 1];
641
+ i += 2;
642
+ }
643
+ else if (arg === '--cwd' && argv[i + 1]) {
644
+ options.cwd = argv[i + 1];
645
+ i += 2;
646
+ }
647
+ else if (arg === '--no-gzip') {
648
+ options.noGzip = true;
649
+ i++;
650
+ }
651
+ else if (arg?.startsWith('--')) {
652
+ console.error(`Unknown option: ${arg}`);
653
+ process.exit(1);
654
+ }
655
+ else if (arg) {
656
+ args.push(arg);
657
+ i++;
658
+ }
659
+ else {
660
+ i++;
661
+ }
591
662
  }
663
+ return { options, args };
592
664
  }
593
- return { options, args };
594
665
  }
@@ -1,42 +1,56 @@
1
- import type { ControlFlow, TemplateBinding } from './types.js';
1
+ import type { BreakMarkerConfig } from './interfaces/BreakMarkerConfig.js';
2
+ import type { ForMarkerConfig } from './interfaces/ForMarkerConfig.js';
3
+ import type { IfMarkerConfig } from './interfaces/IfMarkerConfig.js';
4
+ import type { SwitchMarkerConfig } from './interfaces/SwitchMarkerConfig.js';
5
+ import type { TextMarkerConfig } from './interfaces/TextMarkerConfig.js';
6
+ import type { ParsedTemplate } from './TemplateParser.js';
7
+ export type { BreakMarkerConfig } from './interfaces/BreakMarkerConfig.js';
8
+ export type { ForMarkerConfig } from './interfaces/ForMarkerConfig.js';
9
+ export type { IfMarkerConfig } from './interfaces/IfMarkerConfig.js';
10
+ export type { SwitchMarkerConfig } from './interfaces/SwitchMarkerConfig.js';
11
+ export type { TextMarkerConfig } from './interfaces/TextMarkerConfig.js';
12
+ export type MarkerConfig = IfMarkerConfig | ForMarkerConfig | SwitchMarkerConfig | TextMarkerConfig | BreakMarkerConfig;
2
13
  export declare class CodeGenerator {
3
- private reactiveProperties;
4
- private templateRefs;
5
- setReactiveProperties(props: Set<string>): void;
6
- setTemplateRefs(refs: string[]): void;
7
- generateRenderMethod(html: string, styles?: string): string;
8
- generateBindingsSetup(bindings: TemplateBinding[], controlFlows: ControlFlow[]): string;
9
- private getPropertyRef;
10
- private extractBaseProp;
11
- private escapeForTemplateLiteral;
12
- private escapeForTemplateLiteralPreservingExpressions;
13
- private dotsToDashes;
14
- private removeIndexSuffix;
15
- private generateBindingCode;
16
- private generateTextBinding;
17
- private generatePropertyBinding;
18
- private generateEventBinding;
19
- private generateRefLookups;
20
- private generateClassBinding;
21
- private generateStyleBinding;
22
- private generateControlFlowCode;
23
- private processContentBindings;
24
- private walkAndTransformBindings;
25
- private isParse5Element;
26
- private processAndGenerateBindings;
27
- private transformInterpolationsInContent;
28
- private generateBindingSetupCode;
29
- private extractPropertyBindings;
30
- private generateUnifiedRender;
31
- private generateIfCode;
32
- private generateForCode;
33
- private generateForBindingSetup;
34
- private extractEventBindings;
35
- private walkAndExtractEventBindings;
36
- private generateSwitchCode;
37
- private kebabToCamel;
38
- private extractTextBindings;
39
- private walkAndExtractTextBindings;
40
- private walkAndExtractPropertyBindings;
14
+ private readonly componentSelectors;
15
+ private readonly componentSelector;
16
+ private static readonly globalExprIdsByExpr;
17
+ private static globalExprs;
18
+ private static readonly globalHandlerIdsByExpr;
19
+ private static globalHandlers;
20
+ private markerId;
21
+ private readonly markerConfigs;
22
+ private readonly usedExprIds;
23
+ private readonly usedHandlerIds;
24
+ private readonly bindingsMap;
25
+ private rootFragment;
26
+ private readonly collectedTemplates;
27
+ constructor(componentSelectors?: Set<string>, componentSelector?: string);
28
+ static resetGlobalState(): void;
29
+ generateRenderMethod(template: ParsedTemplate, styles?: string): string;
30
+ generateHtml(template: ParsedTemplate): string;
31
+ generateRenderMethodFromHtml(html: string, styles?: string, markerConfigJson?: string): string;
32
+ getMarkerConfigJson(): string;
33
+ generateBindingsSetup(): string;
34
+ getBindingsMap(): Record<string, Record<string, unknown>[]>;
35
+ generateExpressionAssignments(): string;
36
+ static generateGlobalExprTable(): string;
37
+ private static buildExpressionArrowFunction;
38
+ private static buildHandlerArrowFunction;
39
+ private static normalizeCompiledExpr;
40
+ private nextMarkerId;
41
+ private renderNodesToParent;
42
+ private renderNodeToParent;
43
+ private renderElementToParent;
44
+ private renderTextToParent;
45
+ private isComponentTag;
46
+ private serializeBinding;
47
+ private internExpression;
48
+ private internHandler;
49
+ private renderInterpolationToParent;
50
+ private renderCommentToParent;
51
+ private renderIfToParent;
52
+ private renderForToParent;
53
+ private renderSwitchToParent;
54
+ private renderBreakToParent;
41
55
  }
42
56
  //# sourceMappingURL=CodeGenerator.d.ts.map