Skip to content
This repository was archived by the owner on Oct 16, 2024. It is now read-only.

Commit 5fb8f11

Browse files
authored
Merge pull request #188 from agile-ts/tree-shakeable-support
Tree shakeable support
2 parents b4c4360 + 5907794 commit 5fb8f11

File tree

103 files changed

+3252
-2374
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

103 files changed

+3252
-2374
lines changed

benchmark/benchmarks/react/1000fields/bench/agilets/collection.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import React from 'react';
22
import ReactDom from 'react-dom';
3-
import { createCollection, shared } from '@agile-ts/core';
3+
import { createCollection, LogCodeManager, shared } from '@agile-ts/core';
44
import reactIntegration, { useAgile, useValue } from '@agile-ts/react';
5-
import { assignSharedAgileLoggerConfig } from '@agile-ts/logger';
65

7-
assignSharedAgileLoggerConfig({ active: false });
6+
LogCodeManager.setAllowLogging(false);
87
shared.integrate(reactIntegration);
98

109
export default function (target: HTMLElement, fieldsCount: number) {

benchmark/benchmarks/react/1000fields/bench/agilets/nestedState.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import * as React from 'react';
22
import * as ReactDom from 'react-dom';
3-
import { createState, shared, State } from '@agile-ts/core';
3+
import { createState, LogCodeManager, shared, State } from '@agile-ts/core';
44
import reactIntegration, { useAgile } from '@agile-ts/react';
5-
import { assignSharedAgileLoggerConfig } from '@agile-ts/logger';
65

7-
assignSharedAgileLoggerConfig({ active: false });
6+
LogCodeManager.setAllowLogging(false);
87
shared.integrate(reactIntegration);
98

109
export default function (target: HTMLElement, fieldsCount: number) {

benchmark/benchmarks/react/1000fields/bench/agilets/state.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import React from 'react';
22
import ReactDom from 'react-dom';
3-
import { createState, shared } from '@agile-ts/core';
3+
import { createState, LogCodeManager, shared } from '@agile-ts/core';
44
import reactIntegration, { useAgile } from '@agile-ts/react';
5-
import { assignSharedAgileLoggerConfig } from '@agile-ts/logger';
65

7-
assignSharedAgileLoggerConfig({ active: false });
6+
LogCodeManager.setAllowLogging(false);
87
shared.integrate(reactIntegration);
98

109
export default function (target: HTMLElement, fieldsCount: number) {

benchmark/benchmarks/react/computed/bench/agilets/autoTracking.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
import React from 'react';
22
import ReactDom from 'react-dom';
3-
import { createComputed, createState, shared } from '@agile-ts/core';
3+
import {
4+
createComputed,
5+
createState,
6+
LogCodeManager,
7+
shared,
8+
} from '@agile-ts/core';
49
import reactIntegration, { useAgile } from '@agile-ts/react';
5-
import { assignSharedAgileLoggerConfig } from '@agile-ts/logger';
610

7-
assignSharedAgileLoggerConfig({ active: false });
11+
LogCodeManager.setAllowLogging(false);
812
shared.integrate(reactIntegration);
913

1014
const COUNT = createState(0);

benchmark/benchmarks/react/computed/bench/agilets/hardCoded.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
import React from 'react';
22
import ReactDom from 'react-dom';
3-
import { createComputed, createState, shared } from '@agile-ts/core';
3+
import {
4+
createComputed,
5+
createState,
6+
LogCodeManager,
7+
shared,
8+
} from '@agile-ts/core';
49
import reactIntegration, { useAgile } from '@agile-ts/react';
5-
import { assignSharedAgileLoggerConfig } from '@agile-ts/logger';
610

7-
assignSharedAgileLoggerConfig({ active: false });
11+
LogCodeManager.setAllowLogging(false);
812
shared.integrate(reactIntegration);
913

1014
const COUNT = createState(0);

benchmark/benchmarks/react/counter/bench/agilets.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import React from 'react';
22
import ReactDom from 'react-dom';
3-
import { createState, shared } from '@agile-ts/core';
3+
import { createState, LogCodeManager, shared } from '@agile-ts/core';
44
import reactIntegration, { useAgile } from '@agile-ts/react';
5-
import { assignSharedAgileLoggerConfig } from '@agile-ts/logger';
65

7-
assignSharedAgileLoggerConfig({ active: false });
6+
LogCodeManager.setAllowLogging(false);
87
shared.integrate(reactIntegration);
98

109
const COUNT = createState(0);

examples/plainjs/develop/tree-shaking/package.json

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,16 @@
66
"scripts": {
77
"test": "echo \"Error: no test specified\" && exit 1",
88
"build": "webpack",
9-
"install:dev:agile": "yalc add @agile-ts/core @agile-ts/react & yarn install",
10-
"install:prod:agile": "yarn add @agile-ts/core @agile-ts/react & yarn install"
9+
"install:dev:agile": "yalc add @agile-ts/core & yarn install",
10+
"install:prod:agile": "yarn add @agile-ts/core & yarn install"
1111
},
1212
"author": "",
1313
"license": "ISC",
1414
"devDependencies": {
1515
"webpack": "^5.47.0",
16-
"webpack-cli": "^4.7.2"
16+
"webpack-cli": "^4.8.0"
1717
},
1818
"dependencies": {
19-
"@agile-ts/core": "file:.yalc/@agile-ts/core",
20-
"@agile-ts/react": "file:.yalc/@agile-ts/react",
21-
"react": "^17.0.2"
19+
"@agile-ts/core": "file:.yalc/@agile-ts/core"
2220
}
2321
}
Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
import { createState } from '@agile-ts/core';
2-
import { useAgile } from '@agile-ts/react';
1+
import { createLightState } from '@agile-ts/core';
32

4-
const MY_STATE = createState('hi');
3+
const MY_STATE = createLightState('hi');
54

65
console.log(MY_STATE.value);
7-
8-
useAgile(MY_STATE);

examples/react-native/develop/AwesomeTSProject/core/index.ts

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,16 @@
1-
import { Agile } from '@agile-ts/core';
2-
import { Event } from '@agile-ts/event';
1+
import { createState, createComputed, createCollection } from '@agile-ts/core';
2+
import { createEvent, Event } from '@agile-ts/event';
33
import { Alert } from 'react-native';
44

5-
export const App = new Agile({
6-
logConfig: { active: true },
7-
});
8-
9-
export const MY_STATE = App.createState<string>('MyState', { key: 'my-state' }); //.persist();
10-
export const MY_STATE_2 = App.createState<string>('MyState2'); //.persist("my-state2");
11-
export const MY_STATE_3 = App.createState<number>(1); //.persist("my-state2");
5+
export const MY_STATE = createState<string>('MyState', { key: 'my-state' }); //.persist();
6+
export const MY_STATE_2 = createState<string>('MyState2'); //.persist("my-state2");
7+
export const MY_STATE_3 = createState<number>(1); //.persist("my-state2");
128

139
MY_STATE.watch('test', (value: any) => {
1410
console.log('Watch ' + value);
1511
});
1612

17-
export const MY_COMPUTED = App.createComputed<string>(() => {
13+
export const MY_COMPUTED = createComputed<string>(() => {
1814
return 'test' + MY_STATE.value + '_computed_' + MY_STATE_2.value;
1915
});
2016

@@ -23,7 +19,7 @@ interface collectionValueInterface {
2319
name: string;
2420
}
2521

26-
export const MY_COLLECTION = App.createCollection<collectionValueInterface>(
22+
export const MY_COLLECTION = createCollection<collectionValueInterface>(
2723
(collection) => ({
2824
key: 'my-collection',
2925
groups: {
@@ -43,7 +39,7 @@ MY_COLLECTION.getGroup('myGroup')?.persist({
4339

4440
console.log('Initial: myCollection ', MY_COLLECTION);
4541

46-
export const MY_EVENT = new Event<{ name: string }>(App);
42+
export const MY_EVENT = createEvent<{ name: string }>();
4743

4844
MY_EVENT.on('Test', (payload) => {
4945
Alert.alert(

examples/react/develop/class-component-ts/src/core/index.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
1-
import { Agile, clone, Logger } from '@agile-ts/core';
2-
import { Event } from '@agile-ts/event';
1+
import {
2+
clone,
3+
createState,
4+
createComputed,
5+
createCollection,
6+
} from '@agile-ts/core';
7+
import { createEvent, Event } from '@agile-ts/event';
38

4-
export const App = new Agile({
5-
logConfig: { level: Logger.level.DEBUG, timestamp: true },
6-
waitForMount: false,
7-
});
8-
9-
export const MY_STATE = App.createState<string>('MyState'); //.persist();
10-
export const MY_STATE_2 = App.createState<string>('MyState2', {
9+
export const MY_STATE = createState<string>('MyState'); //.persist();
10+
export const MY_STATE_2 = createState<string>('MyState2', {
1111
key: 'myState2',
1212
}).persist();
1313
MY_STATE_2.onLoad(() => {
1414
console.log('On Load');
1515
});
16-
export const MY_STATE_3 = App.createState<number>(1); //.persist("my-state2");
16+
export const MY_STATE_3 = createState<number>(1); //.persist("my-state2");
1717

1818
MY_STATE.watch('test', (value: any) => {
1919
console.log('Watch ' + value);
2020
});
2121

22-
export const MY_COMPUTED = App.createComputed<string>(() => {
22+
export const MY_COMPUTED = createComputed<string>(() => {
2323
return 'test' + MY_STATE.value + '_computed_' + MY_STATE_2.value;
2424
}, []).setKey('myComputed');
2525

@@ -28,7 +28,7 @@ interface collectionValueInterface {
2828
name: string;
2929
}
3030

31-
export const MY_COLLECTION = App.createCollection<collectionValueInterface>(
31+
export const MY_COLLECTION = createCollection<collectionValueInterface>(
3232
(collection) => ({
3333
key: 'my-collection',
3434
groups: {
@@ -48,7 +48,7 @@ MY_COLLECTION.getGroup('myGroup')?.persist({
4848

4949
console.log('Initial: myCollection ', clone(MY_COLLECTION));
5050

51-
export const MY_EVENT = new Event<{ name: string }>(App, {
51+
export const MY_EVENT = createEvent<{ name: string }>({
5252
delay: 3000,
5353
key: 'myEvent',
5454
});

0 commit comments

Comments
 (0)