Skip to content

Commit

Permalink
Merge branch 'canary' into 12-19-feat_ios_nbstore_swift_native_binding
Browse files Browse the repository at this point in the history
  • Loading branch information
Brooooooklyn authored Dec 27, 2024
2 parents 0819866 + 3ae3ae9 commit 0a7c170
Show file tree
Hide file tree
Showing 94 changed files with 597 additions and 440 deletions.
54 changes: 46 additions & 8 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,24 @@ concurrency:
cancel-in-progress: true

jobs:
optimize_ci:
name: Optimize CI
runs-on: ubuntu-latest
outputs:
skip: ${{ steps.graphite.outputs.skip }}
steps:
- uses: actions/checkout@v4
- name: Graphite CI Optimizer
uses: withgraphite/graphite-ci-action@main
id: graphite
with:
token: ${{ secrets.GRAPHITE_CI_OPTIMIZER_TOKEN }}

analyze:
name: Analyze
runs-on: ubuntu-latest
needs: optimize_ci
if: needs.optimize_ci.outputs.skip == 'false'
permissions:
actions: read
contents: read
Expand Down Expand Up @@ -77,6 +92,8 @@ jobs:
lint:
name: Lint
runs-on: ubuntu-latest
needs: optimize_ci
if: needs.optimize_ci.outputs.skip == 'false'

steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -105,6 +122,8 @@ jobs:
check-yarn-binary:
name: Check yarn binary
runs-on: ubuntu-latest
needs: optimize_ci
if: needs.optimize_ci.outputs.skip == 'false'
steps:
- uses: actions/checkout@v4
- name: Run check
Expand All @@ -115,6 +134,8 @@ jobs:
e2e-legacy-blocksuite-test:
name: Legacy Blocksuite E2E Test
runs-on: ubuntu-latest
needs: optimize_ci
if: needs.optimize_ci.outputs.skip == 'false'
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -145,6 +166,8 @@ jobs:
e2e-test:
name: E2E Test
runs-on: ubuntu-latest
needs: optimize_ci
if: needs.optimize_ci.outputs.skip == 'false'
env:
DISTRIBUTION: web
IN_CI_TEST: true
Expand Down Expand Up @@ -175,6 +198,8 @@ jobs:
e2e-mobile-test:
name: E2E Mobile Test
runs-on: ubuntu-latest
needs: optimize_ci
if: needs.optimize_ci.outputs.skip == 'false'
env:
DISTRIBUTION: mobile
IN_CI_TEST: true
Expand Down Expand Up @@ -206,7 +231,9 @@ jobs:
name: Unit Test
runs-on: ubuntu-latest
needs:
- optimize_ci
- build-native
if: needs.optimize_ci.outputs.skip == 'false'
env:
DISTRIBUTION: web
strategy:
Expand Down Expand Up @@ -243,6 +270,8 @@ jobs:
build-native:
name: Build AFFiNE native (${{ matrix.spec.target }})
runs-on: ${{ matrix.spec.os }}
needs: optimize_ci
if: needs.optimize_ci.outputs.skip == 'false'
env:
CARGO_PROFILE_RELEASE_DEBUG: '1'
strategy:
Expand Down Expand Up @@ -330,7 +359,10 @@ jobs:
server-test:
name: Server Test
runs-on: ubuntu-latest
needs: build-server-native
needs:
- optimize_ci
- build-server-native
if: needs.optimize_ci.outputs.skip == 'false'
env:
NODE_ENV: test
DISTRIBUTION: web
Expand Down Expand Up @@ -376,7 +408,7 @@ jobs:
uses: ./.github/actions/server-test-env

- name: Run server tests
run: yarn affine @affine/server test:coverage
run: yarn affine @affine/server test:coverage --forbid-only
env:
CARGO_TARGET_DIR: '${{ github.workspace }}/target'
COPILOT_OPENAI_API_KEY: 'use_fake_openai_api_key'
Expand Down Expand Up @@ -410,7 +442,9 @@ jobs:
name: Server Copilot Api Test
runs-on: ubuntu-latest
needs:
- optimize_ci
- build-server-native
if: needs.optimize_ci.outputs.skip == 'false'
env:
NODE_ENV: test
DISTRIBUTION: web
Expand Down Expand Up @@ -576,6 +610,11 @@ jobs:
server-e2e-test:
name: ${{ matrix.tests.name }}
runs-on: ubuntu-latest
needs:
- optimize_ci
- build-server-native
- build-native
if: needs.optimize_ci.outputs.skip == 'false'
env:
DISTRIBUTION: web
DATABASE_URL: postgresql://affine:affine@localhost:5432/affine
Expand All @@ -599,9 +638,6 @@ jobs:
# Reference: https://github.com/electron/electron/issues/42510
sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0
xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- yarn affine @affine-test/affine-desktop-cloud e2e
needs:
- build-server-native
- build-native
services:
postgres:
image: postgres
Expand Down Expand Up @@ -666,6 +702,11 @@ jobs:
desktop-test:
name: Desktop Test (${{ matrix.spec.os }}, ${{ matrix.spec.platform }}, ${{ matrix.spec.arch }}, ${{ matrix.spec.target }}, ${{ matrix.spec.test }})
runs-on: ${{ matrix.spec.os }}
needs:
- optimize_ci
- build-electron-renderer
- build-native
if: needs.optimize_ci.outputs.skip == 'false'
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -698,9 +739,6 @@ jobs:
target: x86_64-pc-windows-msvc,
test: true,
}
needs:
- build-electron-renderer
- build-native
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
Expand Down
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,4 @@ packages/frontend/graphql/src/schema.ts
packages/frontend/apps/android/App/app/build/**
blocksuite/tests-legacy/snapshots
**/.storybook
**/.coverage
1 change: 1 addition & 0 deletions blocksuite/affine/block-attachment/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"license": "MIT",
"dependencies": {
"@blocksuite/affine-block-embed": "workspace:*",
"@blocksuite/affine-block-surface": "workspace:*",
"@blocksuite/affine-components": "workspace:*",
"@blocksuite/affine-model": "workspace:*",
"@blocksuite/affine-shared": "workspace:*",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { EdgelessLegacySlotIdentifier } from '@blocksuite/affine-block-surface';
import type { HoverController } from '@blocksuite/affine-components/hover';
import { AttachmentBlockStyles } from '@blocksuite/affine-model';
import {
EMBED_CARD_HEIGHT,
EMBED_CARD_WIDTH,
} from '@blocksuite/affine-shared/consts';
import { type BlockService, toGfxBlockComponent } from '@blocksuite/block-std';
import type { Slot } from '@blocksuite/store';
import { toGfxBlockComponent } from '@blocksuite/block-std';
import { styleMap } from 'lit/directives/style-map.js';

import { AttachmentBlockComponent } from './attachment-block.js';
Expand All @@ -17,30 +17,22 @@ export class AttachmentEdgelessBlockComponent extends toGfxBlockComponent(

override blockDraggable = false;

get rootService(): null | (BlockService & { slots: Record<string, Slot> }) {
return this.std.getService('affine:page');
get slots() {
return this.std.get(EdgelessLegacySlotIdentifier);
}

override connectedCallback(): void {
super.connectedCallback();

const rootService = this.rootService;
if (!rootService) {
console.warn('rootService is not found');
return;
}

// TODO: move root service slots to extension
this._disposables.add(
rootService.slots.elementResizeStart.on(() => {
this.slots.elementResizeStart.on(() => {
this._isResizing = true;
this._showOverlay = true;
})
);

// TODO: move root service slots to extension
this._disposables.add(
rootService.slots.elementResizeEnd.on(() => {
this.slots.elementResizeEnd.on(() => {
this._isResizing = false;
this._showOverlay =
this._isResizing || this._isDragging || !this._isSelected;
Expand Down
3 changes: 3 additions & 0 deletions blocksuite/affine/block-attachment/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
},
{
"path": "../block-embed"
},
{
"path": "../block-surface"
}
]
}
8 changes: 4 additions & 4 deletions blocksuite/affine/block-embed/src/common/insert-embed-card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ export function insertEmbedCard(
editing: false,
});

// @ts-expect-error TODO: fix after edgeless refactor
edgelessRoot.tools.setEdgelessTool({
type: 'default',
});
gfx.tool.setTool(
// @ts-expect-error FIXME: resolve after gfx tool refactor
'default'
);
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { EdgelessLegacySlotIdentifier } from '@blocksuite/affine-block-surface';
import {
blockComponentSymbol,
type BlockService,
Expand Down Expand Up @@ -49,21 +50,22 @@ export function toEdgelessEmbedBlock<
return;
}

get edgelessSlots() {
return this.std.get(EdgelessLegacySlotIdentifier);
}

override connectedCallback(): void {
super.connectedCallback();
const rootService = this.rootService;

this._disposables.add(
// @ts-expect-error TODO: fix after edgeless slots are migrated to extension
rootService.slots.elementResizeStart.on(() => {
this.edgelessSlots.elementResizeStart.on(() => {
this._isResizing = true;
this._showOverlay = true;
})
);

this._disposables.add(
// @ts-expect-error TODO: fix after edgeless slots are migrated to extension
rootService.slots.elementResizeEnd.on(() => {
this.edgelessSlots.elementResizeEnd.on(() => {
this._isResizing = false;
this._showOverlay =
this._isResizing || this._isDragging || !this._isSelected;
Expand Down
4 changes: 4 additions & 0 deletions blocksuite/affine/block-embed/src/effects.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import type * as SurfaceEffects from '@blocksuite/affine-block-surface/effects';

import { EmbedFigmaBlockComponent } from './embed-figma-block';
import { EmbedEdgelessBlockComponent } from './embed-figma-block/embed-edgeless-figma-block';
import type { EmbedFigmaBlockService } from './embed-figma-block/embed-figma-service';
Expand Down Expand Up @@ -90,6 +92,8 @@ export function effects() {
);
}

declare type _GLOBAL = typeof SurfaceEffects;

declare global {
interface HTMLElementTagNameMap {
'affine-embed-figma-block': EmbedFigmaBlockComponent;
Expand Down
3 changes: 3 additions & 0 deletions blocksuite/affine/block-embed/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
},
{
"path": "../shared"
},
{
"path": "../block-surface"
}
]
}
2 changes: 1 addition & 1 deletion blocksuite/affine/block-latex/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export * from './latex-block';
export * from './latex-spec';

// Global types
declare type _Global =
declare type _GLOBAl =
| typeof NoteType
| typeof CommandsType
| typeof RemarkMathType;
1 change: 1 addition & 0 deletions blocksuite/affine/block-note/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"license": "MIT",
"dependencies": {
"@blocksuite/affine-block-embed": "workspace:*",
"@blocksuite/affine-block-surface": "workspace:*",
"@blocksuite/affine-components": "workspace:*",
"@blocksuite/affine-model": "workspace:*",
"@blocksuite/affine-shared": "workspace:*",
Expand Down
21 changes: 10 additions & 11 deletions blocksuite/affine/block-note/src/note-edgeless-block.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { EdgelessLegacySlotIdentifier } from '@blocksuite/affine-block-surface';
import { MoreIndicatorIcon } from '@blocksuite/affine-components/icons';
import type { NoteBlockModel } from '@blocksuite/affine-model';
import {
Expand All @@ -13,11 +14,7 @@ import {
matchFlavours,
stopPropagation,
} from '@blocksuite/affine-shared/utils';
import type {
BlockComponent,
BlockService,
EditorHost,
} from '@blocksuite/block-std';
import type { BlockComponent, EditorHost } from '@blocksuite/block-std';
import { ShadowlessElement, toGfxBlockComponent } from '@blocksuite/block-std';
import {
almostEqual,
Expand All @@ -26,7 +23,7 @@ import {
Point,
WithDisposable,
} from '@blocksuite/global/utils';
import type { BlockModel, Slot } from '@blocksuite/store';
import type { BlockModel } from '@blocksuite/store';
import { css, html, nothing } from 'lit';
import { property, query, state } from 'lit/decorators.js';
import { classMap } from 'lit/directives/class-map.js';
Expand Down Expand Up @@ -153,9 +150,7 @@ export class EdgelessNoteBlockComponent extends toGfxBlockComponent(
}

get rootService() {
return this.std.getService('affine:page') as BlockService & {
slots: Record<string, Slot>;
};
return this.std.getService('affine:page');
}

private _collapsedContent() {
Expand Down Expand Up @@ -330,20 +325,24 @@ export class EdgelessNoteBlockComponent extends toGfxBlockComponent(
);
}

get edgelessSlots() {
return this.std.get(EdgelessLegacySlotIdentifier);
}

override firstUpdated() {
const { _disposables } = this;
const selection = this.gfx.selection;

_disposables.add(
this.rootService.slots.elementResizeStart.on(() => {
this.edgelessSlots.elementResizeStart.on(() => {
if (selection.selectedElements.includes(this.model)) {
this._isResizing = true;
}
})
);

_disposables.add(
this.rootService.slots.elementResizeEnd.on(() => {
this.edgelessSlots.elementResizeEnd.on(() => {
this._isResizing = false;
})
);
Expand Down
3 changes: 3 additions & 0 deletions blocksuite/affine/block-note/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
},
{
"path": "../block-embed"
},
{
"path": "../block-surface"
}
]
}
Loading

0 comments on commit 0a7c170

Please sign in to comment.