@esportsplus/reactivity 0.25.11 → 0.25.13

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.
@@ -40,22 +40,22 @@ function visit(ctx, node) {
40
40
  ts.forEachChild(node, n => visit(ctx, n));
41
41
  }
42
42
  const transform = (sourceFile) => {
43
- let bindings = new Map(), code = sourceFile.getFullText(), current = sourceFile, result, transformed = false;
43
+ let bindings = new Map(), changed = false, code = sourceFile.getFullText(), current = sourceFile, result;
44
44
  if (!contains(code)) {
45
- return { code, sourceFile, transformed: false };
45
+ return { changed: false, code, sourceFile };
46
46
  }
47
47
  for (let i = 0, n = transforms.length; i < n; i++) {
48
48
  result = transforms[i](current, bindings, COMPILER_NAMESPACE);
49
49
  if (result !== code) {
50
50
  current = ts.createSourceFile(sourceFile.fileName, result, sourceFile.languageVersion, true);
51
51
  code = result;
52
- transformed = true;
52
+ changed = true;
53
53
  }
54
54
  }
55
- if (transformed) {
55
+ if (changed) {
56
56
  code = `import * as ${COMPILER_NAMESPACE} from '@esportsplus/reactivity';\n` + code;
57
57
  sourceFile = ts.createSourceFile(sourceFile.fileName, code, sourceFile.languageVersion, true);
58
58
  }
59
- return { code, sourceFile, transformed };
59
+ return { changed, code, sourceFile };
60
60
  };
61
61
  export { transform };
@@ -1,3 +1,3 @@
1
- import { ts } from '@esportsplus/typescript';
2
- declare const _default: (_program: ts.Program) => ts.TransformerFactory<ts.SourceFile>;
1
+ import { plugin } from '@esportsplus/typescript/transformer';
2
+ declare const _default: ReturnType<typeof plugin.tsc>;
3
3
  export default _default;
@@ -1,9 +1,3 @@
1
- import { transform } from '../../transformer/index.js';
2
- export default (_program) => {
3
- return () => {
4
- return (sourceFile) => {
5
- let result = transform(sourceFile);
6
- return result.transformed ? result.sourceFile : sourceFile;
7
- };
8
- };
9
- };
1
+ import { plugin } from '@esportsplus/typescript/transformer';
2
+ import { transform } from '../index.js';
3
+ export default plugin.tsc(transform);
@@ -1,3 +1,13 @@
1
- import type { Plugin } from 'vite';
2
- declare const _default: () => Plugin;
1
+ declare const _default: ({ root }?: {
2
+ root?: string;
3
+ }) => {
4
+ configResolved(config: import("vite").ResolvedConfig): void;
5
+ enforce: string;
6
+ name: string;
7
+ transform(code: string, id: string): {
8
+ code: string;
9
+ map: null;
10
+ } | null;
11
+ watchChange(id: string): void;
12
+ };
3
13
  export default _default;
@@ -1,26 +1,7 @@
1
- import { ts } from '@esportsplus/typescript';
2
- import { TRANSFORM_PATTERN } from '@esportsplus/typescript/transformer';
3
- import { transform } from '../../transformer/index.js';
4
1
  import { PACKAGE } from '../../constants.js';
5
- export default () => {
6
- return {
7
- enforce: 'pre',
8
- name: `${PACKAGE}/plugin-vite`,
9
- transform(code, id) {
10
- if (!TRANSFORM_PATTERN.test(id) || id.includes('node_modules')) {
11
- return null;
12
- }
13
- try {
14
- let result = transform(ts.createSourceFile(id, code, ts.ScriptTarget.Latest, true));
15
- if (!result.transformed) {
16
- return null;
17
- }
18
- return { code: result.code, map: null };
19
- }
20
- catch (error) {
21
- console.error(`${PACKAGE}: Error transforming ${id}:`, error);
22
- return null;
23
- }
24
- }
25
- };
26
- };
2
+ import { plugin } from '@esportsplus/typescript/transformer';
3
+ import { transform } from '../index.js';
4
+ export default plugin.vite({
5
+ name: PACKAGE,
6
+ transform
7
+ });
package/build/types.d.ts CHANGED
@@ -41,8 +41,8 @@ type Signal<T> = {
41
41
  value: T;
42
42
  };
43
43
  interface TransformResult {
44
+ changed: boolean;
44
45
  code: string;
45
46
  sourceFile: ts.SourceFile;
46
- transformed: boolean;
47
47
  }
48
48
  export type { Bindings, Computed, Link, Reactive, Signal, TransformResult };
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "@esportsplus/utilities": "^0.27.2"
5
5
  },
6
6
  "devDependencies": {
7
- "@esportsplus/typescript": "^0.17.5",
7
+ "@esportsplus/typescript": "^0.18.0",
8
8
  "@types/node": "^25.0.3",
9
9
  "vite": "^7.3.0"
10
10
  },
@@ -36,7 +36,7 @@
36
36
  },
37
37
  "type": "module",
38
38
  "types": "build/index.d.ts",
39
- "version": "0.25.11",
39
+ "version": "0.25.13",
40
40
  "scripts": {
41
41
  "build": "tsc",
42
42
  "build:test": "pnpm build && vite build --config test/vite.config.ts",
@@ -61,13 +61,13 @@ function visit(ctx: { imported: boolean; used: boolean; }, node: ts.Node): void
61
61
 
62
62
  const transform = (sourceFile: ts.SourceFile): TransformResult => {
63
63
  let bindings: Bindings = new Map(),
64
+ changed = false,
64
65
  code = sourceFile.getFullText(),
65
66
  current = sourceFile,
66
- result: string,
67
- transformed = false;
67
+ result: string;
68
68
 
69
69
  if (!contains(code)) {
70
- return { code, sourceFile, transformed: false };
70
+ return { changed: false, code, sourceFile };
71
71
  }
72
72
 
73
73
  for (let i = 0, n = transforms.length; i < n; i++) {
@@ -76,16 +76,16 @@ const transform = (sourceFile: ts.SourceFile): TransformResult => {
76
76
  if (result !== code) {
77
77
  current = ts.createSourceFile(sourceFile.fileName, result, sourceFile.languageVersion, true);
78
78
  code = result;
79
- transformed = true;
79
+ changed = true;
80
80
  }
81
81
  }
82
82
 
83
- if (transformed) {
83
+ if (changed) {
84
84
  code = `import * as ${COMPILER_NAMESPACE} from '@esportsplus/reactivity';\n` + code;
85
85
  sourceFile = ts.createSourceFile(sourceFile.fileName, code, sourceFile.languageVersion, true);
86
86
  }
87
87
 
88
- return { code, sourceFile, transformed };
88
+ return { changed, code, sourceFile };
89
89
  };
90
90
 
91
91
 
@@ -1,14 +1,5 @@
1
- import { transform } from '~/transformer';
2
- import { ts } from '@esportsplus/typescript';
1
+ import { plugin } from '@esportsplus/typescript/transformer';
2
+ import { transform } from '..';
3
3
 
4
4
 
5
- // TypeScript custom transformers API requires program parameter, but we don't use it
6
- export default (_program: ts.Program): ts.TransformerFactory<ts.SourceFile> => {
7
- return () => {
8
- return (sourceFile: ts.SourceFile): ts.SourceFile => {
9
- let result = transform(sourceFile);
10
-
11
- return result.transformed ? result.sourceFile : sourceFile;
12
- };
13
- };
14
- };
5
+ export default plugin.tsc(transform) as ReturnType<typeof plugin.tsc>;
@@ -1,34 +1,9 @@
1
- import type { Plugin } from 'vite';
2
- import { ts } from '@esportsplus/typescript';
3
- import { TRANSFORM_PATTERN } from '@esportsplus/typescript/transformer';
4
- import { transform } from '~/transformer';
5
- import { PACKAGE } from '~/constants';
1
+ import { PACKAGE } from '../../constants';
2
+ import { plugin } from '@esportsplus/typescript/transformer';
3
+ import { transform } from '..';
6
4
 
7
5
 
8
- export default (): Plugin => {
9
- return {
10
- enforce: 'pre',
11
- name: `${PACKAGE}/plugin-vite`,
12
- transform(code: string, id: string) {
13
- if (!TRANSFORM_PATTERN.test(id) || id.includes('node_modules')) {
14
- return null;
15
- }
16
-
17
- try {
18
- let result = transform(
19
- ts.createSourceFile(id, code, ts.ScriptTarget.Latest, true)
20
- );
21
-
22
- if (!result.transformed) {
23
- return null;
24
- }
25
-
26
- return { code: result.code, map: null };
27
- }
28
- catch (error) {
29
- console.error(`${PACKAGE}: Error transforming ${id}:`, error);
30
- return null;
31
- }
32
- }
33
- };
34
- };
6
+ export default plugin.vite({
7
+ name: PACKAGE,
8
+ transform
9
+ });
package/src/types.ts CHANGED
@@ -56,9 +56,9 @@ type Signal<T> = {
56
56
  };
57
57
 
58
58
  interface TransformResult {
59
+ changed: boolean;
59
60
  code: string;
60
61
  sourceFile: ts.SourceFile;
61
- transformed: boolean;
62
62
  }
63
63
 
64
64