From 4ce38593d4b6cf70c5aa6fd7034cd60128fc6fc2 Mon Sep 17 00:00:00 2001 From: zjxxxxxxxxx <43126836+zjxxxxxxxxx@users.noreply.github.com> Date: Sat, 14 Dec 2024 14:15:35 +0800 Subject: [PATCH 1/2] chore: Save temporary changes (#303) --- .codesandbox/tasks.json | 6 +-- packages/client/src/inspector/getBoxModel.ts | 47 +++++++++++-------- .../client/src/utils/preventEventOverlay.tsx | 12 +++-- scripts/create-codesandbox-tasks.ts | 4 ++ 4 files changed, 41 insertions(+), 28 deletions(-) diff --git a/.codesandbox/tasks.json b/.codesandbox/tasks.json index 2625b0e..3783f68 100644 --- a/.codesandbox/tasks.json +++ b/.codesandbox/tasks.json @@ -2,15 +2,15 @@ "$schema": "https://codesandbox.io/schemas/tasks.json", "setupTasks": [ { - "name": "Install Dependencies", + "name": "Install dependencies", "command": "pnpm install:ci" }, { - "name": "Build Packages", + "name": "Build packages", "command": "pnpm build" }, { - "name": "Create Tasks", + "name": "Create tasks", "command": "pnpm tasks" } ], diff --git a/packages/client/src/inspector/getBoxModel.ts b/packages/client/src/inspector/getBoxModel.ts index 0b064e0..8e55479 100644 --- a/packages/client/src/inspector/getBoxModel.ts +++ b/packages/client/src/inspector/getBoxModel.ts @@ -39,28 +39,22 @@ export function getBoxModel(el: HTMLElement | null): [BoxRect, BoxLines] { bottom, left, } = getDOMRect(el); - const getStyle = createStyleGetter(el); - - const zoom = getCompositeZoom(el); - function withZoom(value: number, use = true) { - return use ? value * zoom : value; - } + const getStyle = createGetStyle(el); - // Negative values will cause the position to shift and should be ignored. - const marginTop = withZoom(Math.max(getStyle('margin-top'), 0)); - const marginRight = withZoom(Math.max(getStyle('margin-right'), 0)); - const marginBottom = withZoom(Math.max(getStyle('margin-bottom'), 0)); - const marginLeft = withZoom(Math.max(getStyle('margin-left'), 0)); + const marginTop = getStyle('margin-top'); + const marginRight = getStyle('margin-right'); + const marginBottom = getStyle('margin-bottom'); + const marginLeft = getStyle('margin-left'); - const borderTop = withZoom(getStyle('border-top'), IS_BORDER_WITH_ZOOM); - const borderRight = withZoom(getStyle('border-right'), IS_BORDER_WITH_ZOOM); - const borderBottom = withZoom(getStyle('border-bottom'), IS_BORDER_WITH_ZOOM); - const borderLeft = withZoom(getStyle('border-left'), IS_BORDER_WITH_ZOOM); + const borderTop = getStyle('border-top', IS_BORDER_WITH_ZOOM); + const borderRight = getStyle('border-right', IS_BORDER_WITH_ZOOM); + const borderBottom = getStyle('border-bottom', IS_BORDER_WITH_ZOOM); + const borderLeft = getStyle('border-left', IS_BORDER_WITH_ZOOM); - const paddingTop = withZoom(getStyle('padding-top')); - const paddingRight = withZoom(getStyle('padding-right')); - const paddingBottom = withZoom(getStyle('padding-bottom')); - const paddingLeft = withZoom(getStyle('padding-left')); + const paddingTop = getStyle('padding-top'); + const paddingRight = getStyle('padding-right'); + const paddingBottom = getStyle('padding-bottom'); + const paddingLeft = getStyle('padding-left'); const positionTop = top - marginTop; const positionRight = right + marginRight; @@ -86,6 +80,16 @@ export function getBoxModel(el: HTMLElement | null): [BoxRect, BoxLines] { ]; } +function createGetStyle(el: HTMLElement) { + const getStyle = createStyleGetter(el); + const zoom = getCompositeZoom(el); + return (prop: string, useZoom = true) => { + // Need to ensure [value >= 0]. + const value = Math.max(getStyle(prop), 0); + return useZoom ? value * zoom : value; + }; +} + export function getDefaultBoxModel(): [BoxRect, BoxLines] { return [ createBoxRect(), @@ -101,7 +105,10 @@ function createBoxRect(width = 0, height = 0, top = 0, right = 0, bottom = 0, le return { width, height, - ...createBoxLine(top, right, bottom, left), + top, + right, + bottom, + left, }; } diff --git a/packages/client/src/utils/preventEventOverlay.tsx b/packages/client/src/utils/preventEventOverlay.tsx index dd6226b..60da253 100644 --- a/packages/client/src/utils/preventEventOverlay.tsx +++ b/packages/client/src/utils/preventEventOverlay.tsx @@ -3,7 +3,7 @@ import { getOptions } from '../options'; import { appendChild } from './dom'; import { isTopWindow } from './topWindow'; -let unmount: () => void; +let unmount: (() => void) | null = null; export const preventEventOverlay = { mount() { @@ -16,15 +16,17 @@ export const preventEventOverlay = { }; unmount = () => { - off('pointerdown', unmount, eventOpts); - off('pointerup', unmount, eventOpts); - off('pointerout', unmount, eventOpts); + off('pointerdown', unmount!, eventOpts); + off('pointerup', unmount!, eventOpts); + off('pointerout', unmount!, eventOpts); if (isTopWindow) { - off('pointermove', unmount, eventOpts); + off('pointermove', unmount!, eventOpts); } overlay.remove(); + + unmount = null; }; on('pointerdown', unmount, eventOpts); diff --git a/scripts/create-codesandbox-tasks.ts b/scripts/create-codesandbox-tasks.ts index f1a533c..bcca3e8 100644 --- a/scripts/create-codesandbox-tasks.ts +++ b/scripts/create-codesandbox-tasks.ts @@ -1,4 +1,5 @@ import { resolve } from 'node:path'; +import { execSync } from 'node:child_process'; import { playgrounds, readjson, writejson } from './utils'; const TASKS_PATH = resolve('.codesandbox/tasks.json'); @@ -22,4 +23,7 @@ function main() { }); writejson(TASKS_PATH, taskJson); + + execSync('git add .'); + execSync(`git commit -m 'Timestamp of temporary changes: ${Date.now()}'`); } From bdc07269ad8a6535754f8a9b1fc72f6fc03f7a10 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sat, 14 Dec 2024 06:16:10 +0000 Subject: [PATCH 2/2] Version Packages --- .changeset/blue-deers-run.md | 5 ----- .changeset/empty-cherries-pay.md | 5 ----- packages/client/CHANGELOG.md | 11 +++++++++++ packages/client/package.json | 2 +- packages/rollup/CHANGELOG.md | 9 +++++++++ packages/rollup/package.json | 2 +- packages/server/CHANGELOG.md | 7 +++++++ packages/server/package.json | 2 +- packages/shared/CHANGELOG.md | 2 ++ packages/shared/package.json | 2 +- packages/vite/CHANGELOG.md | 9 +++++++++ packages/vite/package.json | 2 +- packages/webpack/CHANGELOG.md | 9 +++++++++ packages/webpack/package.json | 2 +- 14 files changed, 53 insertions(+), 16 deletions(-) delete mode 100644 .changeset/blue-deers-run.md delete mode 100644 .changeset/empty-cherries-pay.md diff --git a/.changeset/blue-deers-run.md b/.changeset/blue-deers-run.md deleted file mode 100644 index 627ba12..0000000 --- a/.changeset/blue-deers-run.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@open-editor/client': patch ---- - -Fix mobile scrolling not working diff --git a/.changeset/empty-cherries-pay.md b/.changeset/empty-cherries-pay.md deleted file mode 100644 index 4d84f69..0000000 --- a/.changeset/empty-cherries-pay.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@open-editor/client': patch ---- - -Fix for non-enabled state triggering rendering diff --git a/packages/client/CHANGELOG.md b/packages/client/CHANGELOG.md index f706a14..8db0429 100644 --- a/packages/client/CHANGELOG.md +++ b/packages/client/CHANGELOG.md @@ -1,5 +1,16 @@ # @open-editor/client +## 0.9.3 + +### Patch Changes + +- [#302](https://github.com/zjxxxxxxxxx/open-editor/pull/302) [`04f16de`](https://github.com/zjxxxxxxxxx/open-editor/commit/04f16dec84eed3e0d3072566bdc462ea33ad2886) Thanks [@zjxxxxxxxxx](https://github.com/zjxxxxxxxxx)! - Fix mobile scrolling not working + +- [#300](https://github.com/zjxxxxxxxxx/open-editor/pull/300) [`31ddb51`](https://github.com/zjxxxxxxxxx/open-editor/commit/31ddb51848a6603ac832e8a84b86769fdd8c7caa) Thanks [@zjxxxxxxxxx](https://github.com/zjxxxxxxxxx)! - Fix for non-enabled state triggering rendering + +- Updated dependencies []: + - @open-editor/shared@0.9.3 + ## 0.9.2 ### Patch Changes diff --git a/packages/client/package.json b/packages/client/package.json index 56aea88..34f5aa1 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -1,6 +1,6 @@ { "name": "@open-editor/client", - "version": "0.9.2", + "version": "0.9.3", "description": "internal utils shared across @open-editor packages", "main": "./dist/index.js", "module": "./dist/index.mjs", diff --git a/packages/rollup/CHANGELOG.md b/packages/rollup/CHANGELOG.md index 06ae7f0..1fcdc6a 100644 --- a/packages/rollup/CHANGELOG.md +++ b/packages/rollup/CHANGELOG.md @@ -1,5 +1,14 @@ # @open-editor/rollup +## 0.9.3 + +### Patch Changes + +- Updated dependencies [[`04f16de`](https://github.com/zjxxxxxxxxx/open-editor/commit/04f16dec84eed3e0d3072566bdc462ea33ad2886), [`31ddb51`](https://github.com/zjxxxxxxxxx/open-editor/commit/31ddb51848a6603ac832e8a84b86769fdd8c7caa)]: + - @open-editor/client@0.9.3 + - @open-editor/server@0.9.3 + - @open-editor/shared@0.9.3 + ## 0.9.2 ### Patch Changes diff --git a/packages/rollup/package.json b/packages/rollup/package.json index ffaee2b..924894d 100644 --- a/packages/rollup/package.json +++ b/packages/rollup/package.json @@ -1,6 +1,6 @@ { "name": "@open-editor/rollup", - "version": "0.9.2", + "version": "0.9.3", "description": "🚀 A rollup plugin for fast find source code.", "main": "./dist/index.js", "module": "./dist/index.mjs", diff --git a/packages/server/CHANGELOG.md b/packages/server/CHANGELOG.md index e99b966..cefbd7b 100644 --- a/packages/server/CHANGELOG.md +++ b/packages/server/CHANGELOG.md @@ -1,5 +1,12 @@ # @open-editor/server +## 0.9.3 + +### Patch Changes + +- Updated dependencies []: + - @open-editor/shared@0.9.3 + ## 0.9.2 ### Patch Changes diff --git a/packages/server/package.json b/packages/server/package.json index 3be13c8..a02c692 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -1,6 +1,6 @@ { "name": "@open-editor/server", - "version": "0.9.2", + "version": "0.9.3", "description": "internal utils shared across @open-editor packages", "main": "./dist/index.js", "module": "./dist/index.mjs", diff --git a/packages/shared/CHANGELOG.md b/packages/shared/CHANGELOG.md index 3d6c2bc..762311c 100644 --- a/packages/shared/CHANGELOG.md +++ b/packages/shared/CHANGELOG.md @@ -1,5 +1,7 @@ # @open-editor/shared +## 0.9.3 + ## 0.9.2 ## 0.9.1 diff --git a/packages/shared/package.json b/packages/shared/package.json index 06ae12a..e33daa0 100644 --- a/packages/shared/package.json +++ b/packages/shared/package.json @@ -1,6 +1,6 @@ { "name": "@open-editor/shared", - "version": "0.9.2", + "version": "0.9.3", "description": "internal utils shared across @open-editor packages", "main": "./dist/index.js", "module": "./dist/index.mjs", diff --git a/packages/vite/CHANGELOG.md b/packages/vite/CHANGELOG.md index 160363e..e82152d 100644 --- a/packages/vite/CHANGELOG.md +++ b/packages/vite/CHANGELOG.md @@ -1,5 +1,14 @@ # @open-editor/vite +## 0.9.3 + +### Patch Changes + +- Updated dependencies [[`04f16de`](https://github.com/zjxxxxxxxxx/open-editor/commit/04f16dec84eed3e0d3072566bdc462ea33ad2886), [`31ddb51`](https://github.com/zjxxxxxxxxx/open-editor/commit/31ddb51848a6603ac832e8a84b86769fdd8c7caa)]: + - @open-editor/client@0.9.3 + - @open-editor/server@0.9.3 + - @open-editor/shared@0.9.3 + ## 0.9.2 ### Patch Changes diff --git a/packages/vite/package.json b/packages/vite/package.json index cf36d2c..e59f0ad 100644 --- a/packages/vite/package.json +++ b/packages/vite/package.json @@ -1,6 +1,6 @@ { "name": "@open-editor/vite", - "version": "0.9.2", + "version": "0.9.3", "description": "🚀 A vite plugin for fast find source code.", "main": "./dist/index.js", "module": "./dist/index.mjs", diff --git a/packages/webpack/CHANGELOG.md b/packages/webpack/CHANGELOG.md index 5f4c86e..4e1e2cf 100644 --- a/packages/webpack/CHANGELOG.md +++ b/packages/webpack/CHANGELOG.md @@ -1,5 +1,14 @@ # @open-editor/webpack +## 0.9.3 + +### Patch Changes + +- Updated dependencies [[`04f16de`](https://github.com/zjxxxxxxxxx/open-editor/commit/04f16dec84eed3e0d3072566bdc462ea33ad2886), [`31ddb51`](https://github.com/zjxxxxxxxxx/open-editor/commit/31ddb51848a6603ac832e8a84b86769fdd8c7caa)]: + - @open-editor/client@0.9.3 + - @open-editor/server@0.9.3 + - @open-editor/shared@0.9.3 + ## 0.9.2 ### Patch Changes diff --git a/packages/webpack/package.json b/packages/webpack/package.json index 77de207..d4aaf94 100644 --- a/packages/webpack/package.json +++ b/packages/webpack/package.json @@ -1,6 +1,6 @@ { "name": "@open-editor/webpack", - "version": "0.9.2", + "version": "0.9.3", "description": "🚀 A webpack plugin for fast find source code.", "main": "./dist/index.js", "module": "./dist/index.mjs",