@esportsplus/reactivity 0.23.5 → 0.24.1
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/build/transformer/detector.js +1 -1
- package/build/transformer/index.d.ts +1 -1
- package/build/transformer/index.js +1 -1
- package/build/transformer/plugins/tsc.d.ts +1 -1
- package/build/transformer/plugins/vite.js +1 -1
- package/build/transformer/transforms/array.d.ts +1 -1
- package/build/transformer/transforms/array.js +1 -1
- package/build/transformer/transforms/object.d.ts +1 -1
- package/build/transformer/transforms/object.js +1 -1
- package/build/transformer/transforms/primitives.d.ts +1 -1
- package/build/transformer/transforms/primitives.js +1 -1
- package/build/types.d.ts +1 -1
- package/package.json +3 -9
- package/readme.md +1 -17
- package/src/transformer/detector.ts +1 -1
- package/src/transformer/index.ts +1 -1
- package/src/transformer/plugins/tsc.ts +1 -1
- package/src/transformer/plugins/vite.ts +1 -1
- package/src/transformer/transforms/array.ts +1 -1
- package/src/transformer/transforms/object.ts +1 -1
- package/src/transformer/transforms/primitives.ts +1 -1
- package/src/types.ts +1 -1
- package/build/transformer/plugins/esbuild.d.ts +0 -3
- package/build/transformer/plugins/esbuild.js +0 -31
- package/src/transformer/plugins/esbuild.ts +0 -45
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { mightNeedTransform as checkTransform } from '@esportsplus/typescript/transformer';
|
|
2
|
-
import ts from 'typescript';
|
|
2
|
+
import { ts } from '@esportsplus/typescript';
|
|
3
3
|
const REACTIVE_REGEX = /\breactive\b/;
|
|
4
4
|
function visit(ctx, node) {
|
|
5
5
|
if (ctx.hasImport && ctx.hasUsage) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { TransformResult } from '../types.js';
|
|
2
2
|
import { mightNeedTransform } from './detector.js';
|
|
3
|
-
import ts from 'typescript';
|
|
3
|
+
import { ts } from '@esportsplus/typescript';
|
|
4
4
|
declare const createTransformer: () => ts.TransformerFactory<ts.SourceFile>;
|
|
5
5
|
declare const transform: (sourceFile: ts.SourceFile) => TransformResult;
|
|
6
6
|
export { createTransformer, mightNeedTransform, transform };
|
|
@@ -2,7 +2,7 @@ import { mightNeedTransform } from './detector.js';
|
|
|
2
2
|
import { transformReactiveArrays } from './transforms/array.js';
|
|
3
3
|
import { transformReactiveObjects } from './transforms/object.js';
|
|
4
4
|
import { transformReactivePrimitives } from './transforms/primitives.js';
|
|
5
|
-
import ts from 'typescript';
|
|
5
|
+
import { ts } from '@esportsplus/typescript';
|
|
6
6
|
const createTransformer = () => {
|
|
7
7
|
return () => {
|
|
8
8
|
return (sourceFile) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TRANSFORM_PATTERN } from '@esportsplus/typescript/transformer';
|
|
2
2
|
import { mightNeedTransform, transform } from '../../transformer/index.js';
|
|
3
|
-
import ts from 'typescript';
|
|
3
|
+
import { ts } from '@esportsplus/typescript';
|
|
4
4
|
export default () => {
|
|
5
5
|
return {
|
|
6
6
|
enforce: 'pre',
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { uid } from '@esportsplus/typescript/transformer';
|
|
2
2
|
import { addMissingImports, applyReplacements } from './utilities.js';
|
|
3
|
-
import ts from 'typescript';
|
|
3
|
+
import { ts } from '@esportsplus/typescript';
|
|
4
4
|
const CLASS_NAME_REGEX = /class (\w+)/;
|
|
5
5
|
const EXTRA_IMPORTS = [
|
|
6
6
|
{ module: '@esportsplus/reactivity/constants', specifier: 'REACTIVE_OBJECT' },
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { Bindings } from '../../types.js';
|
|
2
|
-
import ts from 'typescript';
|
|
2
|
+
import { ts } from '@esportsplus/typescript';
|
|
3
3
|
declare const transformReactivePrimitives: (sourceFile: ts.SourceFile, bindings: Bindings) => string;
|
|
4
4
|
export { transformReactivePrimitives };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { uid } from '@esportsplus/typescript/transformer';
|
|
2
2
|
import { addMissingImports, applyReplacements } from './utilities.js';
|
|
3
|
-
import ts from 'typescript';
|
|
3
|
+
import { ts } from '@esportsplus/typescript';
|
|
4
4
|
function classifyReactiveArg(arg) {
|
|
5
5
|
if (ts.isArrowFunction(arg) || ts.isFunctionExpression(arg)) {
|
|
6
6
|
return 'computed';
|
package/build/types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { COMPUTED, SIGNAL, STATE_CHECK, STATE_DIRTY, STATE_IN_HEAP, STATE_NONE, STATE_RECOMPUTING } from './constants.js';
|
|
2
2
|
import { ReactiveArray, ReactiveObject } from './reactive/index.js';
|
|
3
|
-
import ts from 'typescript';
|
|
3
|
+
import { ts } from '@esportsplus/typescript';
|
|
4
4
|
type BindingType = 'array' | 'computed' | 'object' | 'signal';
|
|
5
5
|
type Bindings = Map<string, BindingType>;
|
|
6
6
|
interface Computed<T> {
|
package/package.json
CHANGED
|
@@ -4,10 +4,8 @@
|
|
|
4
4
|
"@esportsplus/utilities": "^0.27.2"
|
|
5
5
|
},
|
|
6
6
|
"devDependencies": {
|
|
7
|
-
"@esportsplus/typescript": "^0.
|
|
7
|
+
"@esportsplus/typescript": "^0.15.0",
|
|
8
8
|
"@types/node": "^25.0.3",
|
|
9
|
-
"esbuild": "^0.27.2",
|
|
10
|
-
"typescript": "^5.9.3",
|
|
11
9
|
"vite": "^7.3.0"
|
|
12
10
|
},
|
|
13
11
|
"exports": {
|
|
@@ -19,10 +17,6 @@
|
|
|
19
17
|
"import": "./build/constants.js",
|
|
20
18
|
"types": "./build/constants.d.ts"
|
|
21
19
|
},
|
|
22
|
-
"./plugins/esbuild": {
|
|
23
|
-
"import": "./build/transformer/plugins/esbuild.js",
|
|
24
|
-
"types": "./build/transformer/plugins/esbuild.d.ts"
|
|
25
|
-
},
|
|
26
20
|
"./plugins/tsc": {
|
|
27
21
|
"import": "./build/transformer/plugins/tsc.js",
|
|
28
22
|
"require": "./build/transformer/plugins/tsc.js",
|
|
@@ -42,9 +36,9 @@
|
|
|
42
36
|
},
|
|
43
37
|
"type": "module",
|
|
44
38
|
"types": "build/index.d.ts",
|
|
45
|
-
"version": "0.
|
|
39
|
+
"version": "0.24.1",
|
|
46
40
|
"scripts": {
|
|
47
|
-
"build": "tsc
|
|
41
|
+
"build": "tsc",
|
|
48
42
|
"build:test": "pnpm build && vite build --config test/vite.config.ts",
|
|
49
43
|
"-": "-"
|
|
50
44
|
}
|
package/readme.md
CHANGED
|
@@ -100,7 +100,7 @@ cleanup(); // stops the effect
|
|
|
100
100
|
|
|
101
101
|
## Transformer Plugins
|
|
102
102
|
|
|
103
|
-
The library requires a build-time transformer to convert `reactive()` calls into optimized code.
|
|
103
|
+
The library requires a build-time transformer to convert `reactive()` calls into optimized code. Two plugins are available:
|
|
104
104
|
|
|
105
105
|
### Vite Plugin
|
|
106
106
|
|
|
@@ -116,22 +116,6 @@ export default defineConfig({
|
|
|
116
116
|
});
|
|
117
117
|
```
|
|
118
118
|
|
|
119
|
-
### esbuild Plugin
|
|
120
|
-
|
|
121
|
-
```typescript
|
|
122
|
-
import esbuild from 'esbuild';
|
|
123
|
-
import reactivity from '@esportsplus/reactivity/plugins/esbuild';
|
|
124
|
-
|
|
125
|
-
await esbuild.build({
|
|
126
|
-
entryPoints: ['src/index.ts'],
|
|
127
|
-
bundle: true,
|
|
128
|
-
outfile: 'dist/index.js',
|
|
129
|
-
plugins: [
|
|
130
|
-
reactivity()
|
|
131
|
-
]
|
|
132
|
-
});
|
|
133
|
-
```
|
|
134
|
-
|
|
135
119
|
### TypeScript Custom Transformer
|
|
136
120
|
|
|
137
121
|
For direct TypeScript compilation using `ttsc` or `ts-patch`:
|
package/src/transformer/index.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { mightNeedTransform } from './detector';
|
|
|
3
3
|
import { transformReactiveArrays } from './transforms/array';
|
|
4
4
|
import { transformReactiveObjects } from './transforms/object';
|
|
5
5
|
import { transformReactivePrimitives } from './transforms/primitives';
|
|
6
|
-
import ts from 'typescript';
|
|
6
|
+
import { ts } from '@esportsplus/typescript';
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
const createTransformer = (): ts.TransformerFactory<ts.SourceFile> => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { TRANSFORM_PATTERN } from '@esportsplus/typescript/transformer';
|
|
2
2
|
import { mightNeedTransform, transform } from '~/transformer';
|
|
3
3
|
import type { Plugin } from 'vite';
|
|
4
|
-
import ts from 'typescript';
|
|
4
|
+
import { ts } from '@esportsplus/typescript';
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
export default (): Plugin => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { uid } from '@esportsplus/typescript/transformer';
|
|
2
2
|
import type { Bindings } from '~/types';
|
|
3
3
|
import { addMissingImports, applyReplacements, ExtraImport, Replacement } from './utilities';
|
|
4
|
-
import ts from 'typescript';
|
|
4
|
+
import { ts } from '@esportsplus/typescript';
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
const CLASS_NAME_REGEX = /class (\w+)/;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { uid, type Range } from '@esportsplus/typescript/transformer';
|
|
2
2
|
import type { BindingType, Bindings } from '~/types';
|
|
3
3
|
import { addMissingImports, applyReplacements, Replacement } from './utilities';
|
|
4
|
-
import ts from 'typescript';
|
|
4
|
+
import { ts } from '@esportsplus/typescript';
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
interface ArgContext {
|
package/src/types.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { COMPUTED, SIGNAL, STATE_CHECK, STATE_DIRTY, STATE_IN_HEAP, STATE_NONE, STATE_RECOMPUTING } from './constants';
|
|
2
2
|
import { ReactiveArray, ReactiveObject } from './reactive';
|
|
3
|
-
import ts from 'typescript';
|
|
3
|
+
import { ts } from '@esportsplus/typescript';
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
type BindingType = 'array' | 'computed' | 'object' | 'signal';
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { TRANSFORM_PATTERN } from '@esportsplus/typescript/transformer';
|
|
2
|
-
import { mightNeedTransform, transform } from '../../transformer/index.js';
|
|
3
|
-
import fs from 'fs';
|
|
4
|
-
import ts from 'typescript';
|
|
5
|
-
export default () => {
|
|
6
|
-
return {
|
|
7
|
-
name: '@esportsplus/reactivity/plugin-esbuild',
|
|
8
|
-
setup(build) {
|
|
9
|
-
build.onLoad({ filter: TRANSFORM_PATTERN }, async (args) => {
|
|
10
|
-
let code = await fs.promises.readFile(args.path, 'utf8');
|
|
11
|
-
if (!mightNeedTransform(code)) {
|
|
12
|
-
return null;
|
|
13
|
-
}
|
|
14
|
-
try {
|
|
15
|
-
let sourceFile = ts.createSourceFile(args.path, code, ts.ScriptTarget.Latest, true), result = transform(sourceFile);
|
|
16
|
-
if (!result.transformed) {
|
|
17
|
-
return null;
|
|
18
|
-
}
|
|
19
|
-
return {
|
|
20
|
-
contents: result.code,
|
|
21
|
-
loader: args.path.endsWith('x') ? 'tsx' : 'ts'
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
catch (error) {
|
|
25
|
-
console.error(`@esportsplus/reactivity: Error transforming ${args.path}:`, error);
|
|
26
|
-
return null;
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
};
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { TRANSFORM_PATTERN } from '@esportsplus/typescript/transformer';
|
|
2
|
-
import { mightNeedTransform, transform } from '~/transformer';
|
|
3
|
-
import type { OnLoadArgs, Plugin, PluginBuild } from 'esbuild';
|
|
4
|
-
import fs from 'fs';
|
|
5
|
-
import ts from 'typescript';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
export default (): Plugin => {
|
|
9
|
-
return {
|
|
10
|
-
name: '@esportsplus/reactivity/plugin-esbuild',
|
|
11
|
-
|
|
12
|
-
setup(build: PluginBuild) {
|
|
13
|
-
build.onLoad({ filter: TRANSFORM_PATTERN }, async (args: OnLoadArgs) => {
|
|
14
|
-
let code = await fs.promises.readFile(args.path, 'utf8');
|
|
15
|
-
|
|
16
|
-
if (!mightNeedTransform(code)) {
|
|
17
|
-
return null;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
try {
|
|
21
|
-
let sourceFile = ts.createSourceFile(
|
|
22
|
-
args.path,
|
|
23
|
-
code,
|
|
24
|
-
ts.ScriptTarget.Latest,
|
|
25
|
-
true
|
|
26
|
-
),
|
|
27
|
-
result = transform(sourceFile);
|
|
28
|
-
|
|
29
|
-
if (!result.transformed) {
|
|
30
|
-
return null;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
return {
|
|
34
|
-
contents: result.code,
|
|
35
|
-
loader: args.path.endsWith('x') ? 'tsx' : 'ts'
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
catch (error) {
|
|
39
|
-
console.error(`@esportsplus/reactivity: Error transforming ${args.path}:`, error);
|
|
40
|
-
return null;
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
};
|