Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactoring & Features #3

Merged
merged 15 commits into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .changeset/funny-beers-guess.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
'@difizen/mana-observable': patch
'@difizen/mana-common': patch
'@difizen/mana-l10n': patch
'@difizen/mana-app': patch
'@difizen/mana-docs': patch
'@difizen/mana-core': patch
'@difizen/mana-react': patch
'@difizen/mana-syringe': patch
---

1. The syringe module now supports setting dependencies.
2. Observable has been refactored with fewer entities and better event handling.
3. Fixed some other issues and improved code quality.
2 changes: 1 addition & 1 deletion .changeset/pre.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@
"@difizen/mana-syringe": "0.0.1",
"@difizen/mana-docs": "0.0.1"
},
"changesets": ["tricky-owls-agree"]
"changesets": ["funny-beers-guess", "tricky-owls-agree"]
}
50 changes: 50 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
// Use IntelliSense to learn about possible Node.js debug attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Debug ALL Jest Tests",
"type": "node",
"request": "launch",
"runtimeArgs": [
"--inspect-brk",
"${workspaceRoot}/node_modules/jest/bin/jest.js",
"--runInBand"
],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"port": 9229
},
{
"name": "Debug mana-syringe Jest Tests",
"type": "node",
"request": "launch",
"runtimeArgs": [
"--inspect-brk",
"${workspaceRoot}/node_modules/jest/bin/jest.js",
"--runInBand",
"./packages/mana-syringe"
],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"port": 9229
},
{
"name": "Debug mana-observable Jest Tests",
"type": "node",
"request": "launch",
"runtimeArgs": [
"--inspect-brk",
"${workspaceRoot}/node_modules/jest/bin/jest.js",
"--runInBand",
"./packages/mana-observable"
],
"console": "integratedTerminal",
"runtimeExecutable": "/Users/brokun/.nvm/versions/node/v16.20.0/bin/node",
"internalConsoleOptions": "neverOpen",
"port": 9229
}
]
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ pnpm run docs
```
pnpm changeset
pnpm changeset version
pnpm changeset publish
pnpm changeset publish # --tag
```
12 changes: 12 additions & 0 deletions apps/docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# @difizen/mana-docs

## 0.0.2-alpha.2

### Patch Changes

- 1. The syringe module now supports setting dependencies.
2. Observable has been refactored with fewer entities and better event handling.
3. Fixed some other issues and improved code quality.
- Updated dependencies
- @difizen/[email protected]
- @difizen/[email protected]
4 changes: 2 additions & 2 deletions apps/docs/docs/examples/menu.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ nav:
order: 3
---

# 工具栏
# 菜单

## 简单使用
## 菜单栏

<code src="../../src/menu/menubar"></code>

Expand Down
14 changes: 14 additions & 0 deletions apps/docs/docs/examples/modal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
title: 对话框
order: 8
toc: modal
nav:
title: 示例
order: 3
---

# 对话框

## antd 对话框

<code src="../../src/modal/antd-modal"></code>
4 changes: 2 additions & 2 deletions apps/docs/docs/index.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
hero:
title: 多包仓库模版
description: difi-monorepo-template
title: mana
description:
---
8 changes: 4 additions & 4 deletions apps/docs/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@difizen/mana-docs",
"version": "0.0.1",
"version": "0.0.2-alpha.2",
"private": true,
"license": "MIT",
"description": "Document site for mana",
Expand All @@ -10,7 +10,7 @@
},
"devDependencies": {
"@types/react": "^18.2.0",
"dumi": "^2.2.7",
"dumi": "^2.2.13",
"execa": "^5.1.1"
},
"engines": {
Expand All @@ -21,8 +21,8 @@
"react": "^18.2.0"
},
"dependencies": {
"@difizen/mana-app": "^0.0.2-alpha.1",
"@difizen/mana-react": "^0.0.2-alpha.1",
"@difizen/mana-app": "^0.0.2-alpha.2",
"@difizen/mana-react": "^0.0.2-alpha.2",
"@ant-design/icons": "^4.7.0",
"antd": "^5.8.6",
"styled-components": "^6.0.7"
Expand Down
27 changes: 27 additions & 0 deletions apps/docs/src/modal/antd-modal/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import {
createSlotPreference,
ManaComponents,
ManaModule,
RootSlotId,
ManaAppPreset,
} from '@difizen/mana-app';

import { ModalContainerView } from './modal-container-view';
import { DemoModalContribution } from './modal-contribution';

const BaseModule = ManaModule.create().register(
ModalContainerView,
createSlotPreference({
view: ModalContainerView,
slot: RootSlotId,
}),
DemoModalContribution,
);

const App = (): JSX.Element => {
return (
<ManaComponents.Application asChild={true} modules={[ManaAppPreset, BaseModule]} />
);
};

export default App;
28 changes: 28 additions & 0 deletions apps/docs/src/modal/antd-modal/modal-container-view.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { BaseView, view } from '@difizen/mana-app';
import { singleton } from '@difizen/mana-app';
import { ModalService, useInject } from '@difizen/mana-app';
import { Button } from 'antd';
import React from 'react';

import { demoModal } from './modal-contribution';

export const ModalContainerComponent: React.FC = () => {
const modalService = useInject(ModalService);
return (
<div style={{ height: 200 }}>
<Button
onClick={() => {
modalService.openModal(demoModal, 'a new modal!');
}}
>
打开弹窗
</Button>
</div>
);
};

@singleton()
@view('modal-container')
export class ModalContainerView extends BaseView {
override view = ModalContainerComponent;
}
32 changes: 32 additions & 0 deletions apps/docs/src/modal/antd-modal/modal-contribution.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import type { ModalItem, ModalItemProps } from '@difizen/mana-app';
import { ModalContribution, singleton } from '@difizen/mana-app';
import { Modal } from 'antd';

export const DemoModal = (props: ModalItemProps<string>) => {
const { visible, data, close } = props;
return (
<Modal
open={visible}
onOk={() => {
close();
}}
onCancel={() => {
close();
}}
>
<div>{data}</div>
</Modal>
);
};

export const demoModal: ModalItem<string> = {
id: 'demo-modal',
component: DemoModal,
};

@singleton({ contrib: ModalContribution })
export class DemoModalContribution implements ModalContribution {
registerModals(): ModalItem<string>[] {
return [demoModal];
}
}
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
"clean": "git clean -fX ."
},
"devDependencies": {
"react": "^18.2.0",
"@types/react": "^18.2.0",
"@types/react-dom": "^18.2.0",
"@babel/plugin-proposal-decorators": "^7.23.2",
"@babel/plugin-transform-class-properties": "^7.22.5",
"@babel/plugin-transform-flow-strip-types": "^7.22.5",
Expand All @@ -44,7 +47,7 @@
"babel-jest": "^29.7.0",
"babel-plugin-parameter-decorator": "^1.0.16",
"dotenv-cli": "^7.3.0",
"dumi": "^2.2.12",
"dumi": "^2.2.13",
"eslint": "^8.51.0",
"eslint-config-prettier": "^8.10.0",
"eslint-plugin-import": "^2.28.1",
Expand Down
15 changes: 15 additions & 0 deletions packages/mana-app/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
# @difizen/mana-app

## 0.0.2-alpha.2

### Patch Changes

- 1. The syringe module now supports setting dependencies.
2. Observable has been refactored with fewer entities and better event handling.
3. Fixed some other issues and improved code quality.
- Updated dependencies
- @difizen/[email protected]
- @difizen/[email protected]
- @difizen/[email protected]
- @difizen/[email protected]
- @difizen/[email protected]
- @difizen/[email protected]

## 0.0.2-alpha.1

### Patch Changes
Expand Down
14 changes: 7 additions & 7 deletions packages/mana-app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@difizen/mana-app",
"version": "0.0.2-alpha.1",
"version": "0.0.2-alpha.2",
"sideEffects": false,
"description": "",
"keywords": [
Expand Down Expand Up @@ -45,12 +45,12 @@
},
"dependencies": {
"@ant-design/icons": "^4.7.0",
"@difizen/mana-common": "^0.0.2-alpha.1",
"@difizen/mana-core": "^0.0.2-alpha.1",
"@difizen/mana-observable": "^0.0.2-alpha.1",
"@difizen/mana-react": "^0.0.2-alpha.1",
"@difizen/mana-syringe": "^0.0.2-alpha.1",
"@difizen/mana-l10n": "^0.0.2-alpha.1",
"@difizen/mana-common": "^0.0.2-alpha.2",
"@difizen/mana-core": "^0.0.2-alpha.2",
"@difizen/mana-observable": "^0.0.2-alpha.2",
"@difizen/mana-react": "^0.0.2-alpha.2",
"@difizen/mana-syringe": "^0.0.2-alpha.2",
"@difizen/mana-l10n": "^0.0.2-alpha.2",
"@types/lodash.debounce": "4.0.3",
"@types/react-virtualized": "^9.21.22",
"ahooks": "^3.7.8",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ export function TreeNodeTailDecorations(props: TreeNodeProps) {
const style = fontData
? treeView.applyFontStyles({}, fontData)
: color
? { color }
: undefined;
? { color }
: undefined;
const content =
data ||
(icon ? (
Expand Down
8 changes: 8 additions & 0 deletions packages/mana-common/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# @difizen/mana-common

## 0.0.2-alpha.2

### Patch Changes

- 1. The syringe module now supports setting dependencies.
2. Observable has been refactored with fewer entities and better event handling.
3. Fixed some other issues and improved code quality.

## 0.0.2-alpha.1

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/mana-common/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@difizen/mana-common",
"version": "0.0.2-alpha.1",
"version": "0.0.2-alpha.2",
"sideEffects": false,
"description": "",
"keywords": [
Expand Down
9 changes: 2 additions & 7 deletions packages/mana-common/src/event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,7 @@ export namespace Event {
}

type Callback = (...args: any[]) => any;
class CallbackList implements Iterable<Callback> {
protected mono = false;

constructor(mono = false) {
this.mono = mono;
}
export class CallbackList implements Iterable<Callback> {
protected _callbacks: [Callback, any][] | undefined;

get length(): number {
Expand Down Expand Up @@ -117,7 +112,7 @@ export class Emitter<T = any> {
protected _event?: Event<T>;
protected _callbacks: CallbackList | undefined;
protected _disposed = false;
protected _options: EmitterOptions | undefined;
protected _options?: EmitterOptions | undefined;

constructor(_options?: EmitterOptions) {
this._options = _options;
Expand Down
4 changes: 2 additions & 2 deletions packages/mana-common/src/platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,8 @@ export const OS =
_isMacintosh || _isIOS
? OperatingSystem.Macintosh
: _isWindows
? OperatingSystem.Windows
: OperatingSystem.Linux;
? OperatingSystem.Windows
: OperatingSystem.Linux;

let _isLittleEndian = true;
let _isLittleEndianComputed = false;
Expand Down
4 changes: 2 additions & 2 deletions packages/mana-common/src/valueTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -289,8 +289,8 @@ export type UriDto<T> = {
export type Dto<T> = T extends { toJSON: () => infer U }
? U
: T extends object
? { [k in keyof T]: Dto<T[k]> }
: T;
? { [k in keyof T]: Dto<T[k]> }
: T;

export function NotImplementedProxy<T>(name: string): { new (): T } {
return <any>class {
Expand Down
Loading