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

fix(utils): delete the renderless/common directory and adjust all reference paths. #2849

Merged
merged 28 commits into from
Feb 7, 2025

Conversation

shenjunjian
Copy link
Collaborator

@shenjunjian shenjunjian commented Jan 26, 2025

PR

删除 renderless/common的目录,并同时调整所有的引用路径
原来renderless/common/runtime.ts 没有了
所有公共函数都从 @opentiny/utils vue-directive vue-hooks 三个包中来

PR Checklist

Please check if your PR fulfills the following requirements:

  • The commit message follows our Commit Message Guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

What is the current behavior?

Issue Number: N/A

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Summary by CodeRabbit

  • Dependency Removal

    • Removed js-sha256 dependency from Nuxt, Vue2, and Vue3 example projects.
  • Refactoring

    • Updated file upload hashing mechanism to use sha256 from @opentiny/utils.
    • Simplified cryptographic utility functions.
    • Removed getWindow and isWeb utility functions.
    • Updated global configuration and logging utilities to use globalThis.
    • Centralized server detection logic by importing isServer from @opentiny/utils.
    • Enhanced date handling by replacing several functions with new implementations from @opentiny/utils.
    • Improved component responsiveness and behavior by adjusting environment checks.
    • Modified import statements across multiple components to source utilities from @opentiny/utils.
  • New Features

    • Introduced a new date utility library, fecha, for comprehensive date manipulation.
    • Added new computed properties and methods to the select component for enhanced functionality.
  • Exports

    • Modified utility package exports.
    • Directly exposed sha256 function.
    • Streamlined global configuration exports.
    • Enhanced Popper class and added new properties for improved functionality.

Copy link

coderabbitai bot commented Jan 26, 2025

Important

Review skipped

More than 25% of the files skipped due to max files limit. The review is being skipped to prevent a low-quality review.

123 files out of 230 files are above the max files limit of 100. Please upgrade to Pro plan to get higher limits.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

This pull request involves a comprehensive refactoring of dependency management and utility functions across multiple files. The changes primarily focus on removing the js-sha256 dependency from example project configurations and modifying the cryptographic utility functions in the packages/utils directory. The modifications streamline the hashing and global configuration utilities, replacing custom window detection methods with globalThis and simplifying the sha256 function implementation.

Changes

File Change Summary
examples/nuxt/playground/package.json Removed "js-sha256": "^0.9.0" from devDependencies
examples/vue2/package.json Removed "js-sha256": "^0.9.0" from devDependencies
examples/vue3/package.json Removed "js-sha256": "^0.9.0" from devDependencies
packages/renderless/src/file-upload/index.ts Replaced crypt.sha256 with sha256 from @opentiny/utils
packages/utils/src/crypt/index.ts Converted sha256 to synchronous function, removed getWindow import and default export
packages/utils/src/globalConfig/index.ts Removed isWeb and getWindow functions, added isServer and browser constants
packages/utils/src/index.ts Updated exports, added sha256, removed crypt module export
packages/utils/src/logger/index.ts Replaced getWindow() with globalThis
packages/utils/src/dom/index.ts Removed local isServer declaration, imported from globalConfig
packages/utils/src/resize-event/index.ts Removed local isServer declaration, imported from globalConfig
packages/utils/src/resize-observer/index.ts Replaced isBrowser with isServer, modified observer connection logic
packages/utils/src/scroll-into-view/index.ts Removed local isServer declaration, imported from globalConfig
packages/utils/src/string/index.ts Removed globalEnvironment, replaced with globalThis
packages/vue/src/float-button/src/index.ts Updated element property logic to use isServer
packages/vue/src/grid/src/table/src/table.ts Updated relationContainer logic to use isServer
packages/vue/src/image/src/index.ts Updated scrollContainer property logic to use isServer
packages/vue/src/virtual-scroll-box/src/index.ts Refactored props definitions for clarity
packages/vue/src/virtual-tree/src/index.ts Refactored props definitions for clarity

Suggested Labels

refactoring

Suggested Reviewers

  • zzcr

Poem

🐰 A Rabbit's Refactoring Rhyme 🔧

Dependencies stripped, code grows lean,
globalThis replaces what once had been
Hashing simplified, utilities bright
Our codebase dances with newfound might!

Hop, hop, refactor! 🚀


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

Walkthrough

This PR refactors the utility functions by adjusting the sha256 implementation and removing the getWindow and isWeb functions. The changes involve replacing the crypt.sha256 with sha256 and utilizing globalThis instead of getWindow for accessing global objects.

Changes

Files Summary
examples/nuxt/playground/package.json, examples/vue2/package.json, examples/vue3/package.json Minor version updates in package.json files.
packages/renderless/src/file-upload/index.ts Replaced crypt.sha256 with sha256 for hashing operations.
packages/utils/src/crypt/index.ts Removed getWindow import and refactored sha256 to use globalThis.
packages/utils/src/globalConfig/index.ts Removed isWeb and getWindow functions.
packages/utils/src/index.ts Updated exports to remove crypt and include sha256.
packages/utils/src/logger/index.ts Replaced getWindow with globalThis for logger initialization.

const isArrayBuffer = Object.prototype.toString.call(message) === '[object ArrayBuffer]'
const msgUint8 = isArrayBuffer ? message : new TextEncoder().encode(message as string) // 编码为(utf-8)Uint8Array
const hashBuffer = await getWindow().crypto.subtle.digest('SHA-256', msgUint8) // 计算消息的哈希值
const hashBuffer = globalThis.crypto.subtle.digest('SHA-256', msgUint8) // 计算消息的哈希值

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The removal of await from the sha256 function suggests that crypto.subtle.digest is now expected to be synchronous, which is incorrect. crypto.subtle.digest returns a Promise, so the function should remain asynchronous, and await should be used here.

Copy link

[e2e-test-warn]
The component to be tested is missing.

The title of the Pull request should look like "fix(vue-renderless): [action-menu, alert] fix xxx bug".

Please make sure you've read our contributing guide

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🔭 Outside diff range comments (1)
packages/utils/src/index.ts (1)

Line range hint 11-200: Resolve naming conflicts in utility functions.

Several utilities have numbered suffixes (e.g., isDate1, toDate1, getScrollParent1) which indicates potential naming conflicts. Consider:

  1. Consolidating duplicate functionality
  2. Using more descriptive names instead of numeric suffixes
  3. Documenting the differences between similar functions

Example for better naming:

- export { getScrollParent as getScrollParent1 } from './popper'
+ export { getScrollParent as getPopperScrollParent } from './popper'
🧹 Nitpick comments (3)
packages/utils/src/logger/index.ts (2)

1-1: Consider adding type safety for globalThis.

While using globalThis is a modern approach, the current implementation with any type might be too permissive. Consider adding proper type definitions to ensure type safety.

-const _win: any = globalThis
+const _win: typeof globalThis = globalThis

2-2: Consider translating the Chinese comment to English.

For better international collaboration, consider translating the Chinese comment "使用 logger.xxx 代替 window.console.xxx, 避免语法警告" to English.

-/** 使用 logger.xxx 代替 window.console.xxx, 避免语法警告 */
+/** Use logger.xxx instead of window.console.xxx to avoid syntax warnings */
packages/utils/src/index.ts (1)

Line range hint 11-200: Technical debt should be tracked in issues.

The file contains multiple TODO comments indicating pending refactoring tasks:

  1. Moving global variables to component-specific locations
  2. Consolidating date-related utilities
  3. Removing or relocating various utilities

These should be tracked as separate issues for better visibility and planning.

Would you like me to help create issues to track these technical debt items? I can help generate detailed issue descriptions for each TODO comment.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cda8521 and 00dd4c5.

📒 Files selected for processing (8)
  • examples/nuxt/playground/package.json (1 hunks)
  • examples/vue2/package.json (1 hunks)
  • examples/vue3/package.json (1 hunks)
  • packages/renderless/src/file-upload/index.ts (3 hunks)
  • packages/utils/src/crypt/index.ts (1 hunks)
  • packages/utils/src/globalConfig/index.ts (0 hunks)
  • packages/utils/src/index.ts (1 hunks)
  • packages/utils/src/logger/index.ts (1 hunks)
💤 Files with no reviewable changes (1)
  • packages/utils/src/globalConfig/index.ts
🔇 Additional comments (7)
packages/utils/src/logger/index.ts (1)

Line range hint 1-5: Verify browser compatibility with the globalThis change.

The switch from getWindow() to globalThis might affect browser compatibility. While globalThis is well-supported in modern browsers, we should verify compatibility requirements.

✅ Verification successful

The globalThis change is compatible with the library's browser support requirements

The switch from getWindow() to globalThis is safe because:

  • The library is built on Vue 3 which already requires modern browsers
  • globalThis has broad support in all modern browsers since 2019
  • The change is isolated to the logger utility
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if there are any browser compatibility requirements specified
fd -t f "package.json|browserslist|.browserslistrc" -x cat {} \;

# Check if globalThis is used consistently across the codebase
rg "globalThis|getWindow" --type ts

Length of output: 65784

packages/utils/src/crypt/index.ts (1)

2-9: LGTM! Good improvements to the SHA256 implementation.

The changes improve the code by:

  1. Using the standardized globalThis instead of a custom window detection
  2. Simplifying the implementation by removing unnecessary async/await
  3. Maintaining the same functionality and output format

Let's verify the browser compatibility of globalThis.crypto:

✅ Verification successful

The change is safe for the project's browser targets

The codebase explicitly targets modern browsers (>1%, last 2 versions, no IE) where both globalThis and crypto.subtle are well-supported. This is consistent with the existing usage of globalThis across multiple files in the codebase.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check browser compatibility of globalThis.crypto
# Note: This will help ensure the changes don't break in older browsers

curl -s "https://raw.githubusercontent.com/mdn/browser-compat-data/main/api/crypto.json" | \
jq -r '.api.crypto.support | to_entries[] | select(.value.version_added != null) | "\(.key): \(.value.version_added)"'

Length of output: 273


Script:

#!/bin/bash
# Check compatibility for both globalThis and crypto.subtle.digest

# Check globalThis compatibility
echo "=== globalThis compatibility ==="
curl -s "https://raw.githubusercontent.com/mdn/browser-compat-data/main/javascript/builtins/globalThis.json" | \
jq -r '.javascript.builtins.globalThis.support | to_entries[] | select(.value.version_added != null) | "\(.key): \(.value.version_added)"'

echo -e "\n=== crypto.subtle.digest compatibility ==="
curl -s "https://raw.githubusercontent.com/mdn/browser-compat-data/main/api/SubtleCrypto.json" | \
jq -r '.api.SubtleCrypto.digest.support | to_entries[] | select(.value.version_added != null) | "\(.key): \(.value.version_added)"'

Length of output: 771


Script:

#!/bin/bash
# Search for crypto-related implementations and compatibility handling

echo "=== Checking for crypto-related files ==="
fd -t f -e ts -e js crypto

echo -e "\n=== Checking for globalThis usage ==="
rg "globalThis" -A 2 -B 2

echo -e "\n=== Checking for crypto polyfills or fallbacks ==="
rg -i "polyfill|fallback|compat" . -g "*crypto*"

echo -e "\n=== Checking package.json for browser targets ==="
fd package.json --exec cat {} | jq -r '.browserslist // .targets // .engines // empty'

Length of output: 2012

packages/renderless/src/file-upload/index.ts (2)

516-516: LGTM! Correctly adapted to sync SHA256.

The change properly adapts to the new synchronous SHA256 implementation.


2049-2049: LGTM! Correctly adapted to sync SHA256.

The change properly adapts to the new synchronous SHA256 implementation.

examples/nuxt/playground/package.json (1)

36-36: LGTM! Correctly removed unused js-sha256 dependency.

The removal of js-sha256 is appropriate as the implementation now uses the native Web Crypto API through globalThis.crypto.

examples/vue3/package.json (1)

61-61: LGTM! Correctly removed unused js-sha256 dependency.

The removal of js-sha256 is appropriate as the implementation now uses the native Web Crypto API through globalThis.crypto.

examples/vue2/package.json (1)

Line range hint 1-62: Verify the removal of js-sha256 dependency.

The removal of js-sha256 dependency aligns with the PR objectives. However, we should ensure that any code using this dependency has been properly migrated.

✅ Verification successful

Removal of js-sha256 is safe and represents an improvement

The dependency has been properly replaced with Web Crypto API's native SHA256 implementation in packages/utils/src/crypt/index.ts. The new implementation is more secure, potentially faster, and reduces external dependencies.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any remaining usage of js-sha256 in the codebase

# Search for any remaining imports or usage of js-sha256
echo "Checking for js-sha256 imports or usage..."
rg -l "js-sha256|require\(['\"']js-sha256['\"]" || echo "No js-sha256 imports found"

# Search for SHA256-related functionality that might need the library
echo -e "\nChecking for SHA256-related code..."
rg -l "sha256|SHA256" || echo "No SHA256-related code found"

Length of output: 610


Script:

#!/bin/bash
# Check the cryptography implementation and its tests
echo "=== Checking cryptography implementation ==="
cat packages/utils/src/crypt/index.ts

echo -e "\n=== Checking cryptography tests ==="
cat packages/utils/src/crypt/__test__/crypt.test.ts

echo -e "\n=== Checking test snapshots ==="
cat packages/utils/src/crypt/__test__/__snapshots__/crypt.test.ts.snap

Length of output: 1350

Comment on lines 5 to 8
export { xss, logger, ResizeObserver }

export { sha256 } from './crypt'
export { globalConfig, getViewportWindow } from './globalConfig'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Breaking change detected in mobile utils

The export reorganization is properly implemented, but there's one breaking change that needs to be addressed:

  • Update packages/mobile/utils/xss.ts to use getViewportWindow() instead of getWindow() in the line: let log = { logger: getWindow().console }
🔗 Analysis chain

Export reorganization looks good but needs documentation.

The reorganization of exports and separation of sha256 from the crypt module improves modularity. However, since this is a breaking change, it should be documented.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for potential breaking changes impact

# Search for direct imports of the removed crypt module
echo "Checking for imports of the removed crypt module..."
rg "import.*from ['\"]@opentiny/vue-utils/crypt['\"]" || echo "No direct crypt imports found"

# Search for destructured imports of getWindow and isWeb
echo -e "\nChecking for imports of removed getWindow and isWeb utilities..."
rg "import.*\{.*(getWindow|isWeb).*\}.*from ['\"]@opentiny/vue-utils['\"]" || echo "No getWindow/isWeb imports found"

Length of output: 542


Script:

#!/bin/bash
# Check for TypeScript references and indirect usages

# Check for type references
echo "Checking for TypeScript type references..."
rg "import type.*\{.*(getWindow|isWeb).*\}.*from ['\"]@opentiny/vue-utils['\"]" || echo "No type references found"

# Check implementation of new exports
echo -e "\nVerifying new exports implementation..."
ast-grep --pattern 'export { sha256 } from "./crypt"'
ast-grep --pattern 'export { globalConfig, getViewportWindow } from "./globalConfig"'

# Check for any references to these functions in the codebase
echo -e "\nChecking for any function references..."
rg "getWindow\s*\(" || echo "No getWindow function calls found"
rg "isWeb\s*\(" || echo "No isWeb function calls found"

Length of output: 753


Script:

#!/bin/bash
# Verify the actual implementation files

echo "Checking crypt.ts content..."
fd -e ts crypt.ts --exec cat {}

echo -e "\nChecking globalConfig.ts content..."
fd -e ts globalConfig.ts --exec cat {}

echo -e "\nChecking if getViewportWindow is the replacement for getWindow..."
rg "getViewportWindow" -A 3

Length of output: 3041

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🔭 Outside diff range comments (1)
packages/renderless/src/common/string.ts (1)

Line range hint 592-601: Fix potential infinite loop in text truncation.

The current implementation has a risk of infinite loop if the text cannot be truncated to fit within the specified width. Add a check to prevent this.

   } else {
+    if (text.length <= 3) return { t: '...', o: true }
     for (let i = -1; ; i--) {
       t = text.slice(0, i) + '...'
       metric = ctx.measureText(t)

       if (metric.width < w) {
         return { t, o: true }
       }
+      if (t.length <= 3) return { t: '...', o: true }
     }
   }
🧹 Nitpick comments (15)
packages/renderless/src/common/string.ts (1)

Line range hint 584-586: Add proper TypeScript types for canvas context.

The canvas context should be properly typed to ensure type safety.

-  const canvas = document.createElement('canvas')
-  const ctx = canvas.getContext('2d')
+  const canvas = document.createElement('canvas')
+  const ctx = canvas.getContext('2d') as CanvasRenderingContext2D
packages/utils/src/resize-observer/index.ts (1)

100-100: Consider fallback for legacy environments.

Using globalThis.Function is modern and neat. However, older environments might lack globalThis. If legacy support is crucial, consider adding a fallback or polyfill.

packages/vue/src/virtual-tree/src/index.ts (2)

11-14: Default row height set to 36.

This is a common default for row-based layouts. If your design requires further customization, consider exposing a prop or documenting the recommended usage.


19-19: treeOp: null removes type safety.

Using null means no type checks or constraints for treeOp. If you need to enforce or document any expected structure, consider defining a more explicit type.

packages/vue/src/virtual-scroll-box/src/index.ts (1)

11-12: Row and column buffer defaults.

Defaults of 200 for rowBuffer and columnBuffer offer a wide view area for pre-rendered rows/columns. Confirm this suits typical usage and memory constraints.

packages/vue-common/src/breakpoint.ts (1)

2-2: LGTM! Consider separating environment checks.

The change correctly imports isServer from the centralized location.

Consider separating the environment checks for better clarity:

-  if (isServer || typeof matchMedia !== 'function') {
+  if (isServer) {
+    return {
+      matches: false,
+      media: mediaQueryString,
+      addEventListener: () => {},
+      removeEventListener: () => {}
+    }
+  }
+  
+  if (typeof matchMedia !== 'function') {
     return {
       matches: false,
       media: mediaQueryString,
       addEventListener: () => {},
       removeEventListener: () => {}
     }
   } else {
     return window.matchMedia(mediaQueryString)
   }
packages/utils/src/fastdom/singleton.ts (1)

11-11: LGTM! Consider caching the RAF function.

The change from isBrowser to !isServer maintains the same logic. However, since RAF is called frequently for DOM operations, consider caching the result of the condition check.

 const RAF = (function () {
+  const isNotServer = !isServer
-  if (!isServer) {
+  if (isNotServer) {
     return window.requestAnimationFrame.bind(window)
   }
   return function (callback) {

Also applies to: 14-14

packages/vue/src/float-button/src/index.ts (1)

14-14: LGTM! Consider improving type safety.

The change from isBrowser to !isServer maintains the same logic. However, the type could be more specific.

   element: {
     default: !isServer ? document.body : null,
-    type: !isServer ? HTMLElement : Object
+    type: !isServer ? HTMLElement : null
   }

Also applies to: 98-99

packages/utils/src/touch-emulator/index.ts (1)

8-8: Consider caching the matches property.

The matches property is assigned conditionally but could be accessed frequently. Consider caching the entire Element.prototype.matches check result.

-const matches = !isServer ? Element.prototype.matches : null
+const matches = !isServer && Element.prototype.matches || null
packages/vue-hooks/src/vue-popup.ts (1)

15-17: Address TODO comment for type definitions.

The file contains a TODO comment about types. Consider completing the type definitions for better type safety.

Would you like me to help implement the missing type definitions or create an issue to track this task?

packages/renderless/src/split/index.ts (1)

11-11: LGTM! The environment check refactoring improves consistency.

The change from isBrowser to isServer aligns with the codebase-wide standardization of environment checks. The additional state check in computeOffset provides better protection against undefined errors during component cleanup.

Consider extracting the environment and state check into a separate utility function for reuse:

+const isValidEnvironment = (state) => state && !isServer
+
 export const computeOffset =
   ({ api, nextTick, props, vm, state }) =>
   () => {
     setTimeout(() => {
-      if (state && !isServer) {
+      if (isValidEnvironment(state)) {
         state.totalPane = vm.$refs.outerWrapper[state.offsetSize]
         state.leftTopPane = state.totalPane * (state.offset / 100)
       }
     })

Also applies to: 175-175

packages/utils/src/espace-ctrl/index.ts (1)

Line range hint 384-396: Consider using globalThis for WebSocket check.

While the environment check is correct, the WebSocket check could be more robust by using globalThis.

-if (isServer || !window.WebSocket) {
+if (isServer || !globalThis.WebSocket) {
   const notFn = function () {
     return undefined
   }
packages/utils/src/globalConfig/index.ts (1)

24-33: Optimize Edge browser detection performance.

The current implementation uses the delete operator which can impact performance.

Apply this diff to improve performance:

 const isEdge = (browser) => {
   if (browser.chrome && ~navigator.userAgent.indexOf('Edg')) {
     browser.name = 'edge'
     browser.edge = true
-    delete browser.chrome
+    browser.chrome = undefined
   } else if (!document.documentMode && !!window.StyleMedia) {
     browser.name = 'edge'
     browser.edge = true
   }
 }
🧰 Tools
🪛 Biome (1.9.4)

[error] 29-29: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)

packages/renderless/src/base-select/index.ts (1)

1868-1871: Consider using optional chaining for nextTick callback.

The server check replacement looks good, but the code could be improved further:

  1. The isBrowser to isServer change aligns with the codebase's server-side check pattern
  2. The nextTick callback could benefit from optional chaining

Apply these improvements:

-    if (isServer) return
-    nextTick(() => {
-      const parentEl = parent.$el
-      const inputEl = parentEl.querySelector('input[data-tag="tiny-input-inner"]')
+    if (isServer) return
+    nextTick(() => {
+      const inputEl = parent.$el?.querySelector('input[data-tag="tiny-input-inner"]')
packages/vue/src/grid/src/table/src/table.ts (1)

1014-1014: LGTM! Consider adding a comment for clarity.

The change from isBrowser to !isServer is a good modernization that aligns with best practices for environment detection. However, since this is a critical environment check, consider adding a brief comment explaining the logic.

-      relationContainer: () => (!isServer ? $table.$el.querySelector(`.${hiddenContainerClass}`) : null),
+      relationContainer: () => (!isServer ? $table.$el.querySelector(`.${hiddenContainerClass}`) : null), // Skip DOM operations on server-side
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 00dd4c5 and 6e7aacd.

📒 Files selected for processing (44)
  • packages/renderless/src/base-select/index.ts (2 hunks)
  • packages/renderless/src/cascader-select/column-index.ts (2 hunks)
  • packages/renderless/src/cascader/index.ts (2 hunks)
  • packages/renderless/src/common/browser.ts (0 hunks)
  • packages/renderless/src/common/deps/clickoutside.ts (1 hunks)
  • packages/renderless/src/common/string.ts (2 hunks)
  • packages/renderless/src/image-viewer/index.ts (1 hunks)
  • packages/renderless/src/input/index.ts (2 hunks)
  • packages/renderless/src/milestone/index.ts (1 hunks)
  • packages/renderless/src/nav-menu/index.ts (2 hunks)
  • packages/renderless/src/picker/index.ts (0 hunks)
  • packages/renderless/src/select-dropdown/vue.ts (2 hunks)
  • packages/renderless/src/select/index.ts (2 hunks)
  • packages/renderless/src/select/vue.ts (2 hunks)
  • packages/renderless/src/split/index.ts (3 hunks)
  • packages/renderless/src/tabs-mf/wheel.ts (3 hunks)
  • packages/renderless/src/time-spinner/index.ts (2 hunks)
  • packages/renderless/src/upload-list/vue.ts (2 hunks)
  • packages/utils/src/bigInt/index.ts (0 hunks)
  • packages/utils/src/browser/index.ts (0 hunks)
  • packages/utils/src/dom/index.ts (1 hunks)
  • packages/utils/src/espace-ctrl/index.ts (3 hunks)
  • packages/utils/src/fastdom/singleton.ts (1 hunks)
  • packages/utils/src/fullscreen/screenfull.ts (5 hunks)
  • packages/utils/src/globalConfig/index.ts (1 hunks)
  • packages/utils/src/index.ts (1 hunks)
  • packages/utils/src/popper/index.ts (3 hunks)
  • packages/utils/src/popup-manager/index.ts (1 hunks)
  • packages/utils/src/prop-util/index.ts (0 hunks)
  • packages/utils/src/resize-event/index.ts (1 hunks)
  • packages/utils/src/resize-observer/index.ts (5 hunks)
  • packages/utils/src/scroll-into-view/index.ts (1 hunks)
  • packages/utils/src/scroll-width/index.ts (1 hunks)
  • packages/utils/src/string/index.ts (3 hunks)
  • packages/utils/src/touch-emulator/index.ts (2 hunks)
  • packages/vue-common/src/breakpoint.ts (1 hunks)
  • packages/vue-directive/src/clickoutside.ts (1 hunks)
  • packages/vue-hooks/src/vue-popper.ts (1 hunks)
  • packages/vue-hooks/src/vue-popup.ts (1 hunks)
  • packages/vue/src/float-button/src/index.ts (2 hunks)
  • packages/vue/src/grid/src/table/src/table.ts (2 hunks)
  • packages/vue/src/image/src/index.ts (2 hunks)
  • packages/vue/src/virtual-scroll-box/src/index.ts (1 hunks)
  • packages/vue/src/virtual-tree/src/index.ts (1 hunks)
💤 Files with no reviewable changes (5)
  • packages/renderless/src/common/browser.ts
  • packages/renderless/src/picker/index.ts
  • packages/utils/src/bigInt/index.ts
  • packages/utils/src/browser/index.ts
  • packages/utils/src/prop-util/index.ts
🧰 Additional context used
🪛 eslint
packages/renderless/src/split/index.ts

[error] 45-45: Insert ··

(prettier/prettier)


[error] 46-46: Insert ··

(prettier/prettier)

🪛 Biome (1.9.4)
packages/renderless/src/base-select/index.ts

[error] 1866-1868: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

packages/utils/src/globalConfig/index.ts

[error] 29-29: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)

🔇 Additional comments (45)
packages/renderless/src/common/string.ts (1)

246-246: LGTM! Secure random number generation using globalThis.

The implementation correctly uses globalThis.crypto.getRandomValues for cryptographically secure random number generation.

packages/utils/src/resize-observer/index.ts (4)

15-15: Confirm SSR environment detection implementation.

Switching to isServer is consistent with a server-centric approach. However, please verify that isServer is correctly configured for all SSR contexts to avoid mismatches in browser-based or hybrid scenarios.


219-219: Skip connect logic on the server side.

Preventing DOM-based event logic when isServer or this.connected_ is true makes sense and protects against SSR-related errors.


246-246: No-op disconnect on server side seems harmless.

If we are already disconnected or running in SSR mode, safely skipping teardown code helps avoid unnecessary operations.


400-400: Return an empty rectangle in SSR mode.

Returning emptyRect aligns well with expectations in a server environment and prevents layout computations that depend on the DOM.

packages/vue/src/virtual-tree/src/index.ts (2)

9-10: Flexible prop types for width and height.

Defining them as [Number, String] allows consumers to set numeric or string-based dimensions (e.g., percentages). Ensure the component logic gracefully handles string values.


15-18: Scrollbar size defaulted to 6.

While 6px is a minimal scrollbar dimension, it may be too small for certain accessibility requirements. Confirm it meets your project's UX guidelines.

packages/vue/src/virtual-scroll-box/src/index.ts (3)

9-10: Flexible width and height definitions.

Allowing [Number, String] grants better control (e.g., 100%, 500px). Be sure to handle string values correctly in calculations.


13-13: Scrollbar size declared as [Number, String].

This allows for dynamic or fluid scrollbar sizing. Verify you're applying appropriate cast or logic when working with these values.


14-20: Arrays with arrow function defaults.

Defining arrays as default: () => [] is a recommended Vue pattern, ensuring each component gets its own array instance. Good job. Also, verify that empty arrays won't cause runtime issues if the rest of the component expects populated data.

packages/utils/src/scroll-into-view/index.ts (1)

13-13: LGTM! Centralizing server-side detection.

The change correctly imports isServer from the centralized location, maintaining the same functionality while improving maintainability.

Let's verify that the imported isServer is properly exported from globalConfig:

✅ Verification successful

Import verification successful

The isServer constant is properly exported from globalConfig/index.ts with the correct server-side detection implementation. The import in scroll-into-view/index.ts will work as expected.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Verify isServer export in globalConfig
rg -l "export.*isServer" "packages/utils/src/globalConfig"

Length of output: 99


Script:

#!/bin/bash
# View the isServer export implementation
rg "export.*isServer" -A 2 "packages/utils/src/globalConfig/index.ts"

Length of output: 153

packages/utils/src/resize-event/index.ts (1)

14-14: LGTM! Proper SSR handling maintained.

The change correctly imports isServer while maintaining proper server-side rendering compatibility for the ResizeObserver functionality.

packages/utils/src/scroll-width/index.ts (1)

13-14: LGTM! Proper DOM handling maintained.

The change correctly imports isServer while maintaining proper DOM manipulation guards for server-side rendering.

packages/vue/src/image/src/index.ts (1)

15-15: LGTM! Consistent environment check update.

The change from isBrowser to !isServer maintains the same logic while aligning with the new environment detection approach.

Also applies to: 39-39

packages/renderless/src/tabs-mf/wheel.ts (2)

1-1: LGTM! Environment check in detectEventModel is correct.

The change from isBrowser to !isServer maintains the same logic for detecting the event model.

Also applies to: 25-25


Line range hint 35-44: LGTM! Early return pattern improves readability.

The early return for server environment is a good pattern. The wheel event detection is correctly isolated to browser environments.

packages/utils/src/touch-emulator/index.ts (1)

Line range hint 117-122: Verify touch emulation in SSR environments.

The touch emulation logic has been updated to use isServer check. Please ensure this doesn't affect server-side rendering or hydration.

✅ Verification successful

Touch emulation is properly guarded for SSR environments

The implementation correctly handles server-side rendering by:

  • Guarding all browser-specific code with isServer checks
  • Consistent environment detection across touch-related features
  • Proper protection of window/document access
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for touch event related code to verify consistent environment checks
rg -l "touchstart|touchmove|touchend" | xargs rg "isServer|typeof window"

Length of output: 1247


Error: No shell scripts found


Script:

#!/bin/bash
# Find and show the globalConfig implementation
fd globalConfig.ts
cat packages/utils/src/globalConfig.ts

Length of output: 128

packages/vue-directive/src/clickoutside.ts (1)

13-13: LGTM! Improved server-side handling.

The change to use imported isServer improves consistency and the event listeners are correctly conditional.

Also applies to: 20-33

packages/renderless/src/common/deps/clickoutside.ts (1)

15-16: Consider consolidating duplicate clickoutside implementations.

This file appears to duplicate functionality from packages/vue-directive/src/clickoutside.ts. Consider consolidating these implementations to reduce maintenance overhead.

packages/vue-hooks/src/vue-popup.ts (1)

Line range hint 108-112: Verify popup behavior in SSR applications.

The doOpen function uses isServer check. Please ensure this doesn't affect popup behavior during server-side rendering and hydration.

✅ Verification successful

Popup implementation is SSR-safe

The popup behavior is properly handled during server-side rendering:

  • The doOpen function includes an isServer check that prevents client-side operations during SSR
  • The PopupManager properly initializes its state and DOM-related properties as null for SSR
  • Modal stack and DOM manipulations are only performed on the client side
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for popup-related code to verify consistent environment checks
rg "isServer.*popup|popup.*isServer" -A 3

Length of output: 43


Script:

#!/bin/bash
# Search for server-side rendering related checks with various terms
echo "=== Searching for server-side checks ==="
rg "isServer|typeof window|typeof document" -A 3

echo -e "\n=== Looking for doOpen function ==="
ast-grep --pattern 'function doOpen() {
  $$$
}'

echo -e "\n=== Finding PopupManager usage ==="
rg "PopupManager\." -A 3

Length of output: 66090


Script:

#!/bin/bash
# Find popup-related files and their content
echo "=== Looking for popup files ==="
fd "popup|vue-popup" -t f

echo -e "\n=== Examining popup implementation ==="
rg "doOpen" -A 5 packages/vue-hooks/src/vue-popup.ts

echo -e "\n=== Looking for PopupManager implementation ==="
rg "class PopupManager|const PopupManager" -A 10

Length of output: 4682

packages/renderless/src/upload-list/vue.ts (1)

36-36: LGTM! Clean refactoring of environment detection.

The changes correctly replace browser detection with server-side detection, maintaining the same logical flow while improving code consistency.

Also applies to: 69-69

packages/utils/src/fullscreen/screenfull.ts (2)

Line range hint 59-73: LGTM! Proper early return for server environment.

The early return in getFullScreenEvents ensures that fullscreen events are not initialized in a server environment.


Line range hint 158-195: Well-structured fallbacks for server environment.

Good addition of server-side fallbacks for fullscreen properties, ensuring consistent behavior across environments.

packages/renderless/src/milestone/index.ts (1)

22-22: LGTM! Safe CSS variable handling.

The changes correctly handle CSS variables by checking for server environment before accessing DOM APIs.

Also applies to: 25-28

packages/utils/src/popup-manager/index.ts (1)

15-15: LGTM! Consistent environment check implementation.

The import of isServer from globalConfig aligns with the project's standardization of environment detection. The implementation maintains proper handling of server-side rendering scenarios.

packages/vue-hooks/src/vue-popper.ts (1)

18-19: LGTM! Environment check standardization.

The import of isServer from @opentiny/utils maintains consistency with the project's standardized approach to environment detection.

packages/utils/src/espace-ctrl/index.ts (1)

Line range hint 403-414: LGTM! Proper initialization guard.

The initialization logic correctly prevents server-side execution while maintaining the same functionality.

packages/utils/src/dom/index.ts (1)

15-15: LGTM! Centralizing server detection.

The change to import isServer from @opentiny/utils improves maintainability by centralizing server detection logic.

packages/renderless/src/time-spinner/index.ts (1)

16-16: LGTM! Standardizing server detection.

The change to import isServer from @opentiny/utils aligns with the project-wide standardization of server detection.

packages/renderless/src/input/index.ts (2)

14-14: LGTM! Standardizing server detection.

The change to import isServer from @opentiny/utils aligns with the project-wide standardization of server detection.


458-461: Great documentation improvement!

The added comments clearly explain the text width calculation logic and potential whitespace issues, which helps prevent misunderstandings and debugging challenges.

packages/renderless/src/nav-menu/index.ts (1)

27-27: LGTM! Standardizing server detection.

The change to import and use isServer from @opentiny/utils maintains the same logical behavior while standardizing server detection across the codebase.

Also applies to: 494-494

packages/renderless/src/cascader/index.ts (2)

13-13: LGTM! Import statement updated for better environment detection.

The change to import isServer from @opentiny/utils aligns with the codebase's transition to centralized environment detection.


359-359: LGTM! Condition updated for better server-side rendering support.

The change from if (isBrowser) to if (!isServer) maintains the same logic while making the server-side rendering check more explicit.

packages/renderless/src/select/vue.ts (2)

118-118: LGTM! Import statement updated for better environment detection.

The change to import isServer from @opentiny/utils aligns with the codebase's transition to centralized environment detection.


209-209: LGTM! Computed property updated for better server-side rendering support.

The change to use !isServer maintains the same logic while making the server-side rendering check more explicit.

packages/utils/src/string/index.ts (2)

246-246: LGTM! Updated to use standard globalThis.

The change to use globalThis instead of globalEnvironment improves cross-environment compatibility by using the standard global object reference.


814-814: LGTM! Condition updated for better server-side rendering support.

The change to use isServer aligns with the codebase's transition to server-centric checks.

packages/renderless/src/image-viewer/index.ts (1)

18-18: LGTM! Simplified event handling.

The change to hardcode mousewheelEventName to 'mousewheel' standardizes the event name across all browsers, removing unnecessary browser-specific handling.

packages/utils/src/globalConfig/index.ts (1)

8-8: LGTM! Clean isServer implementation.

The isServer constant provides a simple and effective way to detect server-side rendering environments.

packages/utils/src/index.ts (1)

5-8: LGTM! Clean export organization.

The reorganization of exports improves modularity by:

  1. Separating the sha256 function from the crypt module
  2. Grouping related exports from globalConfig
packages/renderless/src/select-dropdown/vue.ts (1)

99-99: LGTM! Consistent environment check.

The change to use !isServer in the watch condition aligns with the standardized approach for environment detection across the codebase.

packages/utils/src/popper/index.ts (1)

277-277: LGTM: Browser check replaced with server check.

The change from isBrowser to !isServer maintains the same logic while aligning with the codebase's move towards server-side checks.

Run this script to verify all browser checks have been consistently updated:

✅ Verification successful

Browser check refactoring is correctly isolated to utils package

The change from isBrowser to !isServer is correctly implemented and doesn't require changes in other packages as they maintain their own browser detection utilities.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any remaining isBrowser imports or usages
rg "isBrowser" --type ts

Length of output: 3444


Script:

#!/bin/bash
# Find all popper-related files
echo "=== Finding popper files ==="
fd popper

# Check content of the specific file
echo -e "\n=== Checking file content ==="
cat "packages/utils/src/popper/index.ts" 2>/dev/null || echo "File not found"

Length of output: 30487

packages/renderless/src/select/index.ts (2)

2401-2404: Good addition of SSR compatibility check!

The early return when isServer is true prevents DOM manipulation code from running on the server side, which is essential for proper Server-Side Rendering (SSR) support.


19-19: LGTM: Import statement is correctly placed.

The import of isServer from '@opentiny/utils' is properly added and aligns with its usage in the watchShowClose function.

@@ -1,4 +1,4 @@
import { isBrowser } from '../common/browser'
import { isServer } from '@opentiny/utils'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix the server check condition in onTouchStart.

The current condition if (isServer) return will prevent touch handling in server environments, but allow it in server environments. This appears to be the opposite of the intended behavior, as touch events should only be handled in browser environments.

Apply this fix:

-  if (isServer) return
+  if (!isServer) {
     touch.start(event)
     if (state.moving) {
       const dom = vm.$refs.roller
       // ... rest of the function
     }
+  }

Also applies to: 45-45

Comment on lines +61 to +82
// 整体的浏览器判断标准已过时
if (!!window.chrome && (!!window.chrome.webstore || /^Google\b/.test(window.navigator.vendor))) {
browser.name = 'chrome'
browser.chrome = true
matches = navigator.userAgent.match(/chrome\/(\d+)/i)
browser.version = !!matches && !!matches[1] && parseInt(matches[1], 10)
matches = undefined
} else if (!!document.all || !!document.documentMode) {
browser.name = 'ie'
browser.version = getIEVersion()
browser.ie = true
} else if (typeof window.InstallTrigger !== 'undefined') {
// 过时的判断条件, 最新的ff中已经没有该属性。
browser.name = 'firefox'
browser.firefox = true
} else if (Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0) {
browser.name = 'safari'
browser.safari = true
} else if ((!!window.opr && !!window.opr.addons) || !!window.opera) {
browser.name = 'opera'
browser.opera = true
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Update browser detection logic to use modern APIs.

The current browser detection logic uses outdated methods:

  • window.chrome.webstore is deprecated
  • document.all is a legacy feature
  • InstallTrigger is no longer available in modern Firefox
  • HTMLElement.toString() behavior is unreliable for Safari detection

Consider using more modern and reliable methods:

  1. User-Agent Client Hints API for Chrome/Edge
  2. navigator.userAgentData for modern browsers
  3. Feature detection instead of browser detection where possible

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

♻️ Duplicate comments (1)
packages/utils/src/index.ts (1)

7-8: ⚠️ Potential issue

Document breaking changes in exports.

The removal of getWindow and isWeb in favor of getViewportWindow and isServer represents breaking changes that need to be documented. Please:

  1. Add migration guide for users of removed utilities
  2. Update relevant documentation
  3. Consider bumping the major version
🧹 Nitpick comments (9)
packages/vue/src/image-viewer/src/mobileTouch.ts (2)

69-89: Consider improving gesture detection logic.

The swipe detection logic has several areas for improvement:

  1. Magic numbers for thresholds should be constants
  2. Inconsistent thresholds between X (10) and Y (100) directions
  3. Missing TypeScript types for event parameters

Consider applying these improvements:

+ const SWIPE_THRESHOLD_X = 10;
+ const SWIPE_THRESHOLD_Y = 10;

- if (Math.abs(disX) > 10 || Math.abs(disY) > 100) {
+ if (Math.abs(disX) > SWIPE_THRESHOLD_X || Math.abs(disY) > SWIPE_THRESHOLD_Y) {

Also, consider adding TypeScript types:

interface TouchPosition {
  x: number;
  y: number;
}

class TinyTouch {
  private tinyVueTouches: TouchPosition;
  
  start(e: TouchEvent): void {
    // ...
  }
  
  end(e: TouchEvent): void {
    // ...
  }
  
  move(e: TouchEvent): void {
    // ...
  }
}

52-56: Consider adding a configurable long-press duration.

The long-press detection uses a hardcoded 1000ms timeout. Consider making this configurable through the binding value.

+ interface TinyTouchOptions {
+   fn: Function;
+   longTapDelay?: number;
+ }

  constructor(element, tinyBinding, type) {
    // ...
-   that.tinyVueCallBack = isObject(tinyBinding.value) ? tinyBinding.value.fn : tinyBinding.value
+   const options = isObject(tinyBinding.value) ? tinyBinding.value : { fn: tinyBinding.value };
+   that.tinyVueCallBack = options.fn;
+   that.longTapDelay = options.longTapDelay || 1000;
    // ...
  }

  start(e) {
    // ...
-   }, 1000)
+   }, this.longTapDelay)
packages/vue/src/grid-toolbar/src/index.ts (1)

Line range hint 1012-1014: Consider adding TypeScript type annotations.

While the functionality is correct, adding proper TypeScript type annotations would improve code maintainability and catch potential type-related issues at compile time. For example:

-applySettings({ columns, pageSize, updatedSorting }) {
+interface SettingsConfig {
+  columns?: Array<{[key: string]: any}>;
+  pageSize?: number;
+  updatedSorting?: boolean;
+}
+
+applySettings({ columns, pageSize, updatedSorting }: SettingsConfig) {
packages/renderless/src/date-range/vue.ts (1)

Line range hint 1-1: Overall Assessment: Well-structured utility function migration.

The changes consistently migrate date utility functions from @opentiny/vue-renderless/common/deps/date-util to @opentiny/utils with appropriate renaming. The validation logic remains intact across all components.

Consider adding migration notes to the PR description to help other developers understand the changes and update their code accordingly.

packages/utils/src/date-util/fecha.ts (1)

1-343: Well-structured date utility implementation.

The implementation provides a comprehensive set of date manipulation utilities with proper:

  • Internationalization support
  • Format masks for common date formats
  • Robust parsing and formatting logic
  • Timezone handling
  • Error handling for invalid dates

Consider adding JSDoc comments to document the public API methods and their parameters.

🧰 Tools
🪛 Biome (1.9.4)

[error] 26-26: The regular expression includes this negated empty character class.

Negated empty character classes match anything.
If you want to match against [, escape it [.
Otherwise, remove the character class or fill it.

(lint/correctness/noEmptyCharacterClassInRegex)


[error] 235-235: isNaN is unsafe. It attempts a type coercion. Use Number.isNaN instead.

See the MDN documentation for more details.
Unsafe fix: Use Number.isNaN instead.

(lint/suspicious/noGlobalIsNan)

packages/renderless/src/date-range/index.ts (2)

198-198: Use optional chaining for better readability.

The conditional check can be simplified using optional chaining.

Apply this diff to improve the code:

-      state.rightDate = value && value[1] && state.unlinkPanels ? right : nextMonth1(state.leftDate)
+      state.rightDate = value?.[1] && state.unlinkPanels ? right : nextMonth1(state.leftDate)
🧰 Tools
🪛 Biome (1.9.4)

[error] 198-198: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)


529-529: Avoid assignment in expressions.

Using assignments in expressions can make the code harder to understand. Consider using a separate assignment statement.

Apply this diff to improve readability:

-  () =>
-    (state.leftDate = nextMonth1(state.leftDate))
+  () => {
+    state.leftDate = nextMonth1(state.leftDate)
+  }
🧰 Tools
🪛 Biome (1.9.4)

[error] 529-531: The assignment should not be in an expression.

The use of assignments in expressions is confusing.
Expressions are often considered as side-effect free.

(lint/suspicious/noAssignInExpressions)

packages/renderless/src/date-panel/index.ts (1)

195-195: Avoid assignment in expressions.

Using assignments in expressions can make the code harder to understand. Consider using a separate assignment statement.

Apply this diff to improve readability:

-  () =>
-    (state.date = nextMonth1(state.date))
+  () => {
+    state.date = nextMonth1(state.date)
+  }
🧰 Tools
🪛 Biome (1.9.4)

[error] 195-195: The assignment should not be in an expression.

The use of assignments in expressions is confusing.
Expressions are often considered as side-effect free.

(lint/suspicious/noAssignInExpressions)

packages/utils/src/index.ts (1)

Line range hint 171-171: Plan architectural improvements for component-specific utilities.

Multiple TODO comments indicate needed architectural improvements:

  1. Component-specific utilities should be moved to their respective components
  2. Some utilities need conversion to hooks
  3. Better naming needed for utilities like FullscreenApi

Consider:

  1. Creating a tracking issue for these architectural improvements
  2. Prioritizing the conversion of touch utilities to hooks
  3. Moving component-specific utilities to their respective components to improve maintainability

Also applies to: 177-177, 196-196

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6e7aacd and dba8c92.

📒 Files selected for processing (23)
  • packages/renderless/src/calendar-bar/index.ts (1 hunks)
  • packages/renderless/src/calendar-view/index.ts (1 hunks)
  • packages/renderless/src/calendar/index.ts (1 hunks)
  • packages/renderless/src/date-panel/index.ts (7 hunks)
  • packages/renderless/src/date-panel/vue.ts (2 hunks)
  • packages/renderless/src/date-range/index.ts (18 hunks)
  • packages/renderless/src/date-range/vue.ts (2 hunks)
  • packages/utils/src/date-util/fecha.ts (1 hunks)
  • packages/utils/src/date-util/index.ts (1 hunks)
  • packages/utils/src/index.ts (1 hunks)
  • packages/vue/src/date-table/src/index.ts (2 hunks)
  • packages/vue/src/grid-toolbar/src/index.ts (1 hunks)
  • packages/vue/src/grid/src/body/src/body.tsx (2 hunks)
  • packages/vue/src/grid/src/footer/src/footer.ts (1 hunks)
  • packages/vue/src/grid/src/header/src/header.ts (1 hunks)
  • packages/vue/src/grid/src/table/src/methods.ts (2 hunks)
  • packages/vue/src/grid/src/table/src/table.ts (4 hunks)
  • packages/vue/src/grid/src/tools/formatter.ts (1 hunks)
  • packages/vue/src/image-viewer/src/mobileTouch.ts (4 hunks)
  • packages/vue/src/month-table/package.json (1 hunks)
  • packages/vue/src/month-table/src/pc.vue (2 hunks)
  • packages/vue/src/recycle-scroller/src/idState.ts (1 hunks)
  • packages/vue/src/year-table/src/index.ts (2 hunks)
✅ Files skipped from review due to trivial changes (10)
  • packages/utils/src/date-util/index.ts
  • packages/vue/src/grid/src/tools/formatter.ts
  • packages/vue/src/grid/src/footer/src/footer.ts
  • packages/vue/src/grid/src/header/src/header.ts
  • packages/renderless/src/calendar/index.ts
  • packages/renderless/src/calendar-bar/index.ts
  • packages/vue/src/recycle-scroller/src/idState.ts
  • packages/vue/src/grid/src/table/src/methods.ts
  • packages/renderless/src/calendar-view/index.ts
  • packages/vue/src/grid/src/body/src/body.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/vue/src/grid/src/table/src/table.ts
🧰 Additional context used
🪛 Biome (1.9.4)
packages/renderless/src/date-panel/index.ts

[error] 195-195: The assignment should not be in an expression.

The use of assignments in expressions is confusing.
Expressions are often considered as side-effect free.

(lint/suspicious/noAssignInExpressions)

packages/renderless/src/date-range/index.ts

[error] 198-198: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)


[error] 529-531: The assignment should not be in an expression.

The use of assignments in expressions is confusing.
Expressions are often considered as side-effect free.

(lint/suspicious/noAssignInExpressions)

packages/utils/src/date-util/fecha.ts

[error] 26-26: The regular expression includes this negated empty character class.

Negated empty character classes match anything.
If you want to match against [, escape it [.
Otherwise, remove the character class or fill it.

(lint/correctness/noEmptyCharacterClassInRegex)


[error] 235-235: isNaN is unsafe. It attempts a type coercion. Use Number.isNaN instead.

See the MDN documentation for more details.
Unsafe fix: Use Number.isNaN instead.

(lint/suspicious/noGlobalIsNan)

🔇 Additional comments (16)
packages/vue/src/image-viewer/src/mobileTouch.ts (2)

1-1: LGTM! Import changes align with the refactoring objectives.

The changes to import isObject from @opentiny/utils and the ESLint configuration are appropriate.

Also applies to: 14-14


53-53: LGTM! Improved type safety with strict equality operators.

The changes from == to === enhance type safety and follow TypeScript best practices.

Also applies to: 70-70, 74-74, 78-78, 82-82, 86-86, 91-91

packages/vue/src/month-table/package.json (3)

20-23: LGTM! Test dependencies added.

The addition of test utilities (@opentiny-internal/vue-test-utils and vitest) suggests improved test coverage capabilities for this component.


14-18: Verify the usage of @opentiny/utils package.

The addition of @opentiny/utils aligns with the PR's objective to adjust utility functions. Since this PR mentions removing getWindow and isWeb, we should verify that any such usage in this component has been migrated to the new utilities.

Let's check for any remaining usage of the old utilities:

✅ Verification successful

Dependency usage verified successfully

The @opentiny/utils package is correctly used in the component, importing the isDate1 utility. No instances of deprecated utilities (getWindow, isWeb) were found, and the dependency is properly utilized.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for usage of deprecated utilities in the month-table component

# Search for getWindow usage
rg "getWindow|isWeb" "packages/vue/src/month-table"

# Check imports from the new utils package
rg "from ['\"]\@opentiny/utils['\"]" "packages/vue/src/month-table" -A 5

Length of output: 233


Script:

#!/bin/bash
# Search for any usage of getWindow or isWeb utilities
rg -t js -t vue "getWindow|isWeb" packages/vue/src/month-table/

# Check imports from @opentiny/utils with fixed regex
rg -t js -t vue "from ['\"]@opentiny/utils['\"]" packages/vue/src/month-table/

# Also check the renderless implementation
rg -t js -t vue "getWindow|isWeb" packages/vue/src/month-table-renderless/

Length of output: 311


Script:

#!/bin/bash
# Find all files in the month-table directories first
echo "Files in month-table directories:"
find packages/vue/src/month-table* -type f

echo -e "\nChecking for getWindow or isWeb usage:"
rg "getWindow|isWeb" packages/vue/src/month-table*

echo -e "\nChecking imports from @opentiny/utils:"
rg "from ['\"]@opentiny/utils['\"]" packages/vue/src/month-table*

Length of output: 631


3-3: Verify the impact of module type and side effects configuration.

The addition of "type": "module" and "sideEffects": false could affect:

  1. How the package is imported in consuming applications
  2. Tree-shaking optimization in build processes

Let's verify the module resolution and imports:

Also applies to: 6-7

✅ Verification successful

The module type and side effects configuration changes are safe

The changes align with the codebase patterns and won't cause compatibility issues:

  • ESM usage is consistent with the existing codebase
  • No side effects were detected that would conflict with tree-shaking optimizations
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for potential issues with ES modules configuration

# Check if any CommonJS require() calls exist which might break
rg "require\(['\"]@opentiny/vue-month-table['\"]" -A 5

# Check if any files still use .js extension with ESM syntax
fd -e js -x grep -l "import.*from" {} \;

Length of output: 19858


Script:

#!/bin/bash
# Check for potential side effects in month-table component

# Look for global state modifications
ast-grep --pattern 'window.$_ = $_' packages/vue/src/month-table
ast-grep --pattern 'document.$_ = $_' packages/vue/src/month-table

# Check for direct DOM manipulations
ast-grep --pattern 'document.createElement($_)' packages/vue/src/month-table
ast-grep --pattern 'document.querySelector($_)' packages/vue/src/month-table

# Look for lifecycle hooks that might have side effects
ast-grep --pattern 'mounted() {
  $$$
}' packages/vue/src/month-table

# Check for any global event listeners
rg "addEventListener|removeEventListener" packages/vue/src/month-table

Length of output: 438

packages/vue/src/grid-toolbar/src/index.ts (2)

Line range hint 1012-1014: LGTM! Proper type checking before applying pagination settings.

The isNumber utility is correctly used to validate the pageSize parameter before applying changes to the grid's pagination configuration.


25-25: LGTM! Moving utility function to a centralized location.

The change to import isNumber from @opentiny/utils aligns with good architectural practices by centralizing utility functions.

Let's verify that the new import path is valid and that no other files still import isNumber from the old location:

✅ Verification successful

✓ Import change verified and correct

The isNumber utility is properly exported from @opentiny/utils with identical implementation, and no files are using the old import path anymore.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if the new import path exists and if there are any remaining old imports
echo "Checking for the new utility path..."
rg -p "export.*isNumber" "@opentiny/utils"

echo "Checking for any remaining old imports..."
rg "from ['\"]\@opentiny\/vue-renderless\/common\/type['\"].*isNumber"

Length of output: 490


Script:

#!/bin/bash
# First, find the utils package location
echo "Locating utils package..."
fd -t f "package.json" | xargs grep -l "@opentiny/utils"

# Search for isNumber export in the codebase
echo -e "\nSearching for isNumber export..."
rg "export.+isNumber"

# Check for old imports with fixed regex
echo -e "\nChecking for old imports..."
rg "from ['\"]@opentiny/vue-renderless/common/type['\"].*isNumber"

# Check current usage of isNumber
echo -e "\nChecking current isNumber usage..."
rg "isNumber\("

Length of output: 10086

packages/vue/src/year-table/src/index.ts (1)

2-2: Verify the impact of the date utility function migration.

The migration from isDate to isDate1 appears consistent with the broader refactoring pattern. However, we should verify that the behavior remains identical.

Also applies to: 14-14

✅ Verification successful

Migration from isDate to isDate1 is safe

The change is verified to be safe as isDate1 is an alias export of the original isDate function (isDate as isDate1), ensuring identical behavior.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Compare implementations of isDate and isDate1 to ensure identical behavior
# Search for both old and new implementations to verify consistency

echo "Searching for old isDate implementation..."
rg -p "function isDate" --type ts

echo "Searching for new isDate1 implementation..."
rg -p "function isDate1" --type ts

echo "Checking for any remaining usages of old isDate..."
rg -p "isDate\(" --type ts

Length of output: 3772


Script:

#!/bin/bash
# Search for isDate1 implementation and related migration patterns

echo "Searching for isDate1 implementation..."
rg -p "export (const|function) isDate1" --type ts

echo "Searching for isDate1 usages..."
rg -p "isDate1\(" --type ts

echo "Looking for migration documentation..."
fd -e md -e txt -X grep -l "isDate.*isDate1" {}

echo "Checking for similar migration patterns..."
rg -p "import.*@opentiny/utils.*isDate1" --type ts

Length of output: 918


Script:

#!/bin/bash
# Search specifically in utils package for isDate1 implementation
echo "Searching in utils package..."
cd packages/utils && rg -p "isDate1" --type ts

echo "Checking package.json for utils..."
cat packages/utils/package.json

Length of output: 324

packages/vue/src/date-table/src/index.ts (1)

3-3: LGTM! Consistent with the utility function migration.

The validation logic correctly handles both single date values and arrays of dates using the new isDate1 function.

Also applies to: 14-14

packages/vue/src/month-table/src/pc.vue (2)

16-16: Good improvement in variable naming.

Changed key to _key in the v-for loop to avoid using the reserved word 'key' as a variable name.


29-29: LGTM! Consistent with the utility function migration.

The validation logic matches the pattern used in other components, properly handling both single date values and arrays.

Also applies to: 37-37

packages/renderless/src/date-panel/vue.ts (1)

149-149: LGTM!

The update from toDate to toDate1 is consistent with the broader refactoring of date utility functions.

packages/utils/src/date-util/fecha.ts (1)

65-65: ⚠️ Potential issue

Fix the regular expression pattern.

The regular expression pattern contains an empty negated character class [^], which matches any character. Consider using a more specific pattern or the dot (.) character instead.

Apply this diff to fix the regex pattern:

-const regexEscape = (str) => str.replace(/[|\\{()[^$+*?.-]/g, '\\$&')
+const regexEscape = (str) => str.replace(/[|\\{()[$+*?.-]/g, '\\$&')

Likely invalid or redundant comment.

packages/renderless/src/date-range/index.ts (1)

14-25: LGTM! Consistent utility function updates.

The import statements have been updated to use the new utility function names (toDate1, parseDate1, nextMonth1), maintaining consistency with the broader refactoring effort.

packages/renderless/src/date-panel/index.ts (1)

16-31: LGTM! Consistent utility function updates.

The import statements have been updated to use the new utility function names (isDate1, parseDate1, nextMonth1), maintaining consistency with the broader refactoring effort.

packages/utils/src/index.ts (1)

23-24: Address technical debt in date utilities.

The comment indicates pending consolidation of date-related utilities. This technical debt should be addressed:

  1. Compare functionality between duplicate functions
  2. Consolidate where possible
  3. Remove the TODO comment once addressed

Let's analyze the duplicate functions:

@@ -52,7 +52,7 @@ import {
computerEnableYearArrow,
watchPickerVisible
} from './index'
import { nextMonth, extractDateFormat, extractTimeFormat } from '../common/deps/date-util'
import { nextMonth1, extractDateFormat, extractTimeFormat } from '@opentiny/utils'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Migration of date utility functions is incomplete

Several components are still using date utilities from the old location ../common/deps/date-util. The migration to @opentiny/utils needs to be completed in:

  • packages/renderless/src/year-range/*
  • packages/renderless/src/time-range/*
  • packages/renderless/src/time/*
  • packages/renderless/src/time-spinner/*
  • packages/renderless/src/month-range/*
  • packages/renderless/src/picker/*
  • packages/renderless/src/date-table/*
  • packages/renderless/src/calendar/*
  • packages/renderless/src/calendar-view/*
  • packages/renderless/src/calendar-bar/*
🔗 Analysis chain

Verify complete migration of date utility functions.

While the changes to use nextMonth1 are consistent with the utility function migration, we should verify that all related date utility functions have been migrated.

Also applies to: 98-98

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any remaining unmigrated date utility functions
# Search for imports from the old location and usage of old function names

echo "Checking for remaining imports from old location..."
rg -p "from '\.\./common/deps/date-util'" --type ts

echo "Checking for any remaining usages of old nextMonth..."
rg -p "nextMonth\(" --type ts

echo "Checking for other potential date utility functions that might need migration..."
rg -p "import.*from '\.\./common/deps/date-util'" --type ts

Length of output: 5788

Comment on lines 234 to 235
if (!isDate(dateObj) || isNaN(dateObj.getTime())) {
throw new Error('Invalid Date in fecha.format')
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Replace isNaN with Number.isNaN.

Using the global isNaN is unsafe as it performs type coercion. Use Number.isNaN instead for more precise number validation.

Apply this diff to fix the issue:

-    if (!isDate(dateObj) || isNaN(dateObj.getTime())) {
+    if (!isDate(dateObj) || Number.isNaN(dateObj.getTime())) {
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (!isDate(dateObj) || isNaN(dateObj.getTime())) {
throw new Error('Invalid Date in fecha.format')
if (!isDate(dateObj) || Number.isNaN(dateObj.getTime())) {
throw new Error('Invalid Date in fecha.format')
🧰 Tools
🪛 Biome (1.9.4)

[error] 235-235: isNaN is unsafe. It attempts a type coercion. Use Number.isNaN instead.

See the MDN documentation for more details.
Unsafe fix: Use Number.isNaN instead.

(lint/suspicious/noGlobalIsNan)

Comment on lines 25 to 58
getI18nSettings,
isDate as isDate1,
toDate as toDate1,
isDateObject,
formatDate,
parseDate as parseDate1,
getDayCountOfMonth,
getDayCountOfYear,
getFirstDayOfMonth,
prevDate,
nextDate,
getStartDateOfMonth,
getWeekNumber,
getRangeHours,
range,
getMonthDays,
getPrevMonthLastDays,
getRangeMinutes,
modifyDate,
modifyTime,
modifyWithTimeString,
clearTime,
clearMilliseconds,
limitTimeRange,
timeWithinRange,
changeYearMonthAndClampDate,
nextMonth as nextMonth1,
prevMonth,
nextYear,
prevYear,
extractTimeFormat,
extractDateFormat,
validateRangeInOneMonth
} from './date-util'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Verify necessity of duplicate date utility functions.

Several functions are duplicated with numeric suffixes (e.g., isDate1, toDate1, nextMonth1). This increases maintenance burden and may confuse users.

Consider:

  1. Consolidating duplicate functions if they serve the same purpose
  2. If different, rename to reflect their specific use cases rather than using numeric suffixes
  3. Add JSDoc comments to clarify the differences between similar functions

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (2)
packages/vue/src/time-picker/index.ts (1)

14-14: LGTM! Consider documenting the utility centralization.

The change aligns with the broader effort to centralize utility functions. Consider adding documentation about this architectural change to help other developers understand the new utility organization.

Consider:

  1. Adding a comment in the README about the centralization of utilities in @opentiny/utils
  2. Creating a migration guide for teams that might be importing these utilities from the old locations
packages/vue/src/grid-toolbar/src/custom-saas.vue (1)

798-799: Fix formatting in ternary expressions.

The ternary expressions need consistent indentation.

Apply this formatting fix:

-            ? [this.opt.asc, this.opt.cancelSort]
-            : [this.opt.asc, this.opt.desc]
+              ? [this.opt.asc, this.opt.cancelSort]
+              : [this.opt.asc, this.opt.desc]

Also applies to: 804-805, 971-972

🧰 Tools
🪛 ESLint

[error] 798-798: Insert ··

(prettier/prettier)


[error] 799-799: Insert ··

(prettier/prettier)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between dba8c92 and 97c1f84.

📒 Files selected for processing (37)
  • packages/vue/src/cascader-node/package.json (1 hunks)
  • packages/vue/src/cascader-node/src/pc.vue (1 hunks)
  • packages/vue/src/date-picker/package.json (1 hunks)
  • packages/vue/src/date-picker/src/pc.vue (1 hunks)
  • packages/vue/src/date-table/package.json (1 hunks)
  • packages/vue/src/grid-manager/package.json (1 hunks)
  • packages/vue/src/grid-select/package.json (1 hunks)
  • packages/vue/src/grid-toolbar/package.json (1 hunks)
  • packages/vue/src/grid-toolbar/src/custom-saas.vue (5 hunks)
  • packages/vue/src/grid-toolbar/src/custom.vue (2 hunks)
  • packages/vue/src/grid-toolbar/src/multiple-history.ts (1 hunks)
  • packages/vue/src/grid/src/adapter/src/setup.ts (1 hunks)
  • packages/vue/src/grid/src/cell/src/cell.ts (2 hunks)
  • packages/vue/src/grid/src/fetch-data/src/methods.ts (1 hunks)
  • packages/vue/src/grid/src/filter/src/panel.tsx (2 hunks)
  • packages/vue/src/grid/src/grid/grid.ts (1 hunks)
  • packages/vue/src/grid/src/header/src/header.ts (1 hunks)
  • packages/vue/src/grid/src/keyboard/src/methods.ts (1 hunks)
  • packages/vue/src/grid/src/pager/src/methods.ts (1 hunks)
  • packages/vue/src/grid/src/table/src/methods.ts (2 hunks)
  • packages/vue/src/grid/src/table/src/table.ts (4 hunks)
  • packages/vue/src/grid/src/toolbar/src/methods.ts (1 hunks)
  • packages/vue/src/grid/src/tools/formatter.ts (1 hunks)
  • packages/vue/src/grid/src/validator/src/methods.ts (1 hunks)
  • packages/vue/src/guide/package.json (1 hunks)
  • packages/vue/src/image-viewer/package.json (1 hunks)
  • packages/vue/src/image/package.json (1 hunks)
  • packages/vue/src/input/package.json (1 hunks)
  • packages/vue/src/message/index.ts (1 hunks)
  • packages/vue/src/message/package.json (1 hunks)
  • packages/vue/src/query-builder/package.json (1 hunks)
  • packages/vue/src/query-builder/src/utils/generateID.ts (1 hunks)
  • packages/vue/src/recycle-scroller/package.json (1 hunks)
  • packages/vue/src/time-picker/index.ts (1 hunks)
  • packages/vue/src/time-picker/package.json (1 hunks)
  • packages/vue/src/time-select/index.ts (1 hunks)
  • packages/vue/src/time-select/package.json (1 hunks)
✅ Files skipped from review due to trivial changes (5)
  • packages/vue/src/grid/src/validator/src/methods.ts
  • packages/vue/src/grid/src/grid/grid.ts
  • packages/vue/src/grid/src/fetch-data/src/methods.ts
  • packages/vue/src/grid/src/cell/src/cell.ts
  • packages/vue/src/grid/src/toolbar/src/methods.ts
🚧 Files skipped from review as they are similar to previous changes (4)
  • packages/vue/src/grid/src/header/src/header.ts
  • packages/vue/src/grid/src/tools/formatter.ts
  • packages/vue/src/grid/src/table/src/table.ts
  • packages/vue/src/grid/src/table/src/methods.ts
🧰 Additional context used
🪛 ESLint
packages/vue/src/grid-toolbar/src/custom-saas.vue

[error] 798-798: Insert ··

(prettier/prettier)


[error] 799-799: Insert ··

(prettier/prettier)


[error] 804-804: Insert ··

(prettier/prettier)


[error] 805-805: Insert ··

(prettier/prettier)


[error] 971-971: Insert ··

(prettier/prettier)


[error] 972-972: Insert ··

(prettier/prettier)

🔇 Additional comments (70)
packages/vue/src/grid-toolbar/package.json (1)

15-15: New Dependency Addition on "@opentiny/utils":
The addition of "@opentiny/utils": "workspace:~", integrates the updated utilities into the grid-toolbar package. Please ensure that this workspace reference correctly resolves to the intended version of @opentiny/utils and remains consistent with your workspace’s versioning strategy. It would also be good to verify that any changes in the utils package (especially around the updated SHA256 functionality and environment detection replacements) are fully compatible with the grid-toolbar package usage.

packages/vue/src/time-picker/package.json (4)

3-3: ESM Module Declaration Added

Adding "type": "module" explicitly defines the package as an ECMAScript module. This change improves inter-package consistency and ensures consumers interpret the module format correctly.


6-7: License & Side-Effects Specification Introduced

The inclusion of "license": "MIT" clarifies the legal usage, and "sideEffects": false helps bundlers optimize for tree shaking. Both are valuable enhancements for package clarity and performance.


15-19: Dependency Reorganization and Addition

The dependencies section now:

  • Adds "@opentiny/utils": "workspace:~" to centralize utility functions.
  • Reintroduces and reorganizes "@opentiny/vue-common", "@opentiny/vue-renderless", and "@opentiny/vue-theme".

Please verify that:

  • The versions specified with workspace specifiers align with the overall monorepo versioning.
  • All internal references in the time-picker code are updated to reflect any necessary changes arising from this reorganization.

21-24: DevDependencies Reintroduced for Testing

The reintroduction of "@opentiny-internal/vue-test-utils" and "vitest" helps reestablish the testing framework for the package. Ensure that these tools are properly configured and that tests are added/updated as required by the PR checklist.

packages/vue/src/recycle-scroller/package.json (5)

3-3: Explicit Module Declaration Added.
The addition of "type": "module" explicitly declares the package as an ECMAScript module, which improves clarity for consumers and bundlers.


6-6: License Specification Added.
Including "license": "MIT" clearly communicates the licensing for the package, ensuring consistency across the project.


7-7: Side Effects Optimization Declared.
Setting "sideEffects": false informs bundlers that the module does not include side effects, which can improve tree-shaking and overall bundle optimization.


11-11: Workspace Dependency on @opentiny/utils.
Adding "@opentiny/utils": "workspace:~" as a dependency aligns with the project’s workspace strategy. Please verify that the version resolution syntax (workspace:~) is intentional and consistent with other packages in the monorepo.


16-19: Restructured DevDependencies Section.
The reorganization of the "devDependencies" block, including the addition of "@opentiny-internal/vue-test-utils": "workspace:*" and "vitest": "catalog:", improves clarity. Ensure that the version alias "catalog:" for "vitest" is correct and intentional, as it deviates from the more common semantic versioning patterns seen elsewhere.

packages/vue/src/guide/package.json (4)

3-3: Addition of "type": "module" Field
The introduction of "type": "module" clearly signals that this package uses ECMAScript modules. This is important for proper module resolution and aligns with modern JavaScript practices.


6-7: Inclusion of Licensing and Side Effects Metadata
Adding "license": "MIT" provides clear licensing information, and "sideEffects": false helps bundlers optimize imports. Both fields improve package metadata and are aligned with good practices.


12-16: Updating and Restoring Dependency Entries
The dependencies block now includes:

  • "@opentiny/utils": "workspace:~"
  • "@opentiny/vue-common": "workspace:~"
  • "@opentiny/vue-renderless": "workspace:~"
  • "@opentiny/vue-theme": "workspace:~"
  • Additionally, "shepherd.js": "11.1.1" has been added.

These changes restore several dependencies and add new ones, ensuring that all required packages are available. Please verify that the workspace versions (using "workspace:~") resolve as intended within your monorepo setup.


18-21: Reintroducing Testing Utilities in DevDependencies
The "devDependencies" section now includes:

  • "@opentiny-internal/vue-test-utils": "workspace:*"
  • "vitest": "catalog:"

This reintroduction aligns with similar changes in other packages and ensures that robust testing utilities are available for development. Confirm that these versions match your monorepo’s overall testing configuration and that "vitest": "catalog:" is correctly interpreted by your dependency manager.

packages/vue/src/query-builder/package.json (2)

3-3: Module Type, Licensing, and Side Effects Fields Added
The additions of "type": "module", "license": "MIT", and "sideEffects": false help modernize the package configuration and clarify its module behavior and licensing. These are all in line with current best practices.

Also applies to: 6-7


31-34: Reintroduced DevDependencies Block – Verify Specifiers
The addition of the devDependencies section—with "@opentiny-internal/vue-test-utils": "workspace:*" and "vitest": "catalog:"—indicates a move towards reintroducing internal testing utilities. Please confirm that the version specifier "catalog:" for Vitest is intentional and correctly resolved in your workspace configuration.

packages/vue/src/query-builder/src/utils/generateID.ts (2)

3-51: Well-implemented UUID generation with robust fallback strategy.

The implementation is excellent with several notable strengths:

  • Prioritizes secure crypto.randomUUID() when available
  • Falls back to crypto.getRandomValues() with proper v4 UUID formatting
  • Provides a last-resort implementation using random()
  • Includes comprehensive documentation and clear code comments

1-1: Verify the compatibility of the imported random function.

The import source has been changed from @opentiny/vue-renderless/common/string to @opentiny/utils. Please ensure that the random function from the new source maintains the same interface and behavior.

✅ Verification successful

🏁 Script executed:

#!/bin/bash
# Description: Compare the implementation of random function in both locations

# Search for the old implementation
echo "Old implementation:"
rg -A 5 "export.*random.*=" "packages/vue-renderless/common/string"

# Search for the new implementation
echo "New implementation:"
rg -A 5 "export.*random.*=" "packages/utils"

Length of output: 662


UUID Fallback Strategy: Validate random Compatibility

The output confirms that the new random function is exported from packages/utils/src/string/index.ts and its implementation using crypto.getRandomValues matches the expected interface for generating UUIDs. There is no indication of any interface or behavioral discrepancies with the previous version.

packages/vue/src/grid-manager/package.json (4)

3-3: ES Module Declaration Added
The addition of "type": "module" ensures that the package is correctly interpreted as using ES modules.


6-7: License and Side Effects Metadata Introduced
Including "license": "MIT" and "sideEffects": false clarifies the package’s licensing and informs bundlers that there are no side effects on import.


15-15: Centralizing Utility Dependency
Adding the dependency "@opentiny/utils": "workspace:~" promotes consistency by centralizing shared utility functions across packages.


18-21: Reintroduction of Testing Utilities
Restoring the devDependencies with "@opentiny-internal/vue-test-utils": "workspace:*" and "vitest": "catalog:" ensures that the testing tools are uniformly available.

packages/vue/src/message/package.json (4)

3-3: ES Module Declaration Added
The new "type": "module" field ensures compatibility with ES module imports throughout the package.


6-7: License and Side Effects Fields Added
Introducing "license": "MIT" and "sideEffects": false improves package metadata clarity and optimizes bundler behavior.


10-13: Addition of Build Scripts
The newly added "scripts" block standardizes the build process using pnpm, which enhances consistency across the project’s packages.


15-15: Utility Dependency Inclusion
Adding "@opentiny/utils": "workspace:~" as a dependency streamlines the usage of common utilities across the codebase.

packages/vue/src/date-table/package.json (4)

3-3: ES Module Declaration Introduced
The inclusion of "type": "module" enables ES module support, enhancing interoperability.


6-7: Metadata Update for Licensing and Build Optimization
By adding "license": "MIT" and "sideEffects": false, the package now documents its licensing and assures bundlers about side-effect-free imports.


15-15: Utility Dependency Standardization
The addition of "@opentiny/utils": "workspace:~" aligns this package with the centralized approach for utility functions.


20-23: Reinstatement of Testing Dependencies
Reintroducing the devDependencies—"@opentiny-internal/vue-test-utils": "workspace:*" and "vitest": "catalog:"—ensures that testing capabilities remain consistent with other packages.

packages/vue/src/grid-select/package.json (4)

3-3: ES Module Declaration Added
Adding "type": "module" ensures that consumers of the package get proper ES module semantics.


6-7: License and Side Effects Specification Added
The new "license": "MIT" and "sideEffects": false entries provide clear metadata and assist in optimizing module bundling.


15-19: Updated Dependencies for Consistency
The updated dependencies—including the new "@opentiny/utils": "workspace:~" and reorganized entries like "@opentiny/vue-common", "@opentiny/vue-grid", and "@opentiny/vue-renderless"—support a unified dependency management strategy.


21-24: Reintroduction of DevDependencies
Restoring the devDependencies with "@opentiny-internal/vue-test-utils": "workspace:*" and "vitest": "catalog:" maintains consistency with testing support across packages.

packages/vue/src/image/package.json (5)

3-3: ES Module Declaration Introduced
The inclusion of "type": "module" correctly designates this package as an ES module.


6-7: License and Side Effects Fields Added
Adding "license": "MIT" and "sideEffects": false improves metadata clarity and informs bundlers that the module is free of side effects.


15-16: Utility Dependency Inclusion
The addition of "@opentiny/utils": "workspace:~" and the retention of "@opentiny/vue-common": "workspace:~" reinforce the move toward centralized utilities.


17-20: Verify Dependency Placement for Vue Icon and Theme
The ai-summary indicates that "@opentiny/vue-icon" and "@opentiny/vue-theme" should be moved from dependencies to devDependencies. Please verify that their current placement in the "dependencies" section aligns with their intended runtime usage.


22-25: Consistent DevDependencies Configuration
Restoring the testing dependencies "@opentiny-internal/vue-test-utils": "workspace:*" and "vitest": "catalog:" ensures that the package continues to support a standardized testing approach across the project.

packages/vue/src/date-picker/package.json (4)

3-3: ECMAScript Module Declaration

Adding "type": "module" clearly indicates that this package is using ES modules. This change improves interoperability and helps bundlers correctly interpret the module format.


6-7: License and Side Effects Metadata

The new "license": "MIT" and "sideEffects": false fields enhance clarity regarding licensing and provide hints to bundlers for tree-shaking, respectively.


15-21: Dependencies Reorganization and Updates

Reintroducing and reordering dependencies (such as "@opentiny/utils", "@opentiny/vue-input", "@opentiny/vue-picker", and "@opentiny/vue-renderless") aligns with the broader repository restructuring. Please verify that the version labels (using workspace:~) are consistent and compatible with other packages.


23-26: DevDependencies Reintroduction

The readdition of "@opentiny-internal/vue-test-utils" and "vitest" supports improved testing practices. Confirm that these versions match the expectations across the project.

packages/vue/src/cascader-node/package.json (4)

3-3: Module Format Standardization

Adding "type": "module" ensures consistency with the repository’s shift toward modern ECMAScript modules, which simplifies integration with current tooling.


6-7: License and Side Effects Declaration

Introducing "license": "MIT" and "sideEffects": false provides both legal clarity and bundler optimization hints.


15-21: Updated Dependencies

The dependencies section now includes "@opentiny/utils" and repositions packages such as "@opentiny/vue-common", "@opentiny/vue-radio", and "@opentiny/vue-renderless". This reorganization reflects the updated dependency management strategy. Please double-check that these updates are harmonized with other modules.


23-26: DevDependencies Configuration

Reintroducing "@opentiny-internal/vue-test-utils" and "vitest" reestablishes the testing foundation for this package.

packages/vue/src/input/package.json (4)

3-3: ES Module Declaration

The addition of "type": "module" is appropriate for enabling ECMAScript module support, aligning this package with modern JavaScript standards.


6-7: License and Side Effects Clarification

By adding "license": "MIT" and "sideEffects": false, the package now provides important metadata for legal clarity and optimization during bundling.


15-24: Dependencies Update and Reordering

The dependencies have been restructured to include "@opentiny/utils" and reorganized packages such as "@opentiny/vue-common", "@opentiny/vue-icon", and "@opentiny/vue-tooltip". This update supports a standardized configuration across packages. Please verify that the dependency versions and workspace notations are consistent with the overall project.


25-28: Reintroducing DevDependencies

The reinstated devDependencies— "@opentiny-internal/vue-test-utils" and "vitest"—ensure that adequate testing support is maintained throughout the package.

packages/vue/src/image-viewer/package.json (4)

3-3: ES Module Format Confirmation

Including "type": "module" confirms the package’s use of modern module semantics, aiding both developers and build tools.


6-7: Legal and Optimization Metadata

The new "license": "MIT" and "sideEffects": false settings ensure legal compliance and improve the bundling process by signaling that there are no unexpected side effects.


15-23: Comprehensive Dependencies Update

The dependencies section now features additions such as "@opentiny/utils", "@opentiny/vue-action-sheet", "@opentiny/vue-dropdown-menu", "@opentiny/vue-icon", and "@opentiny/vue-renderless", along with reordering of existing dependencies. This consolidates dependency management across the project—please verify that all versions are aligned with project standards.


25-28: Standardized DevDependencies

Restoring "@opentiny-internal/vue-test-utils" and "vitest" enhances development and testing consistency.

packages/vue/src/cascader-node/src/pc.vue (1)

94-96: LGTM! Proper handling of object comparison.

The use of isEqual for deep object comparison is correct, and the reassignment of the reference when values are equal is a good practice for Vue's reactivity system.

packages/vue/src/message/index.ts (1)

2-2: Verify compatibility of the new extend implementation.

The import source for extend has been changed as part of utility function centralization. Please ensure that the new implementation in @opentiny/utils maintains the same deep merge behavior required for component extension.

packages/vue/src/date-picker/src/pc.vue (1)

15-15: LGTM! Consistent with utility centralization.

The change aligns with the broader effort to centralize utility functions.

packages/vue/src/time-select/index.ts (1)

13-13: LGTM! Consistent with utility centralization.

The change aligns with the broader effort to centralize utility functions.

packages/vue/src/grid/src/adapter/src/setup.ts (1)

25-25: Verify the compatibility of the new extend implementation.

The extend function is used for merging configuration options. Ensure that the implementation from @opentiny/utils maintains the same deep merge behavior as the previous version.

✅ Verification successful

🏁 Script executed:

#!/bin/bash
# Description: Check if the new extend implementation maintains the same behavior
# Search for tests or usage patterns of extend function

# Look for test files related to extend
fd -e test.ts -e spec.ts -e test.js -e spec.js | xargs rg "extend.*@opentiny/utils"

# Look for other usages of extend with similar patterns
rg "extend\(true, \{.*\}, .*\)" -A 2

Length of output: 5815


Deep Merge Behavior Confirmed

All instances using extend(true, ..., ...) across the codebase—including in configuration merging in grid, toolbar, picker, and other components—show that the new implementation from @opentiny/utils is used in the same deep merge pattern as before. This indicates the new implementation maintains the required deep merge behavior, ensuring compatibility in critical configuration operations.

packages/vue/src/grid-toolbar/src/multiple-history.ts (1)

14-14: Verify array merging behavior with the new extend implementation.

The extend function is used in mergeArray for combining array items. Ensure that the implementation from @opentiny/utils maintains the same array merging behavior.

✅ Verification successful

🏁 Script executed:

#!/bin/bash
# Description: Check if the new extend implementation maintains array merging behavior
# Search for tests or similar usage patterns

# Look for test files related to mergeArray
fd -e test.ts -e spec.ts -e test.js -e spec.js | xargs rg "mergeArray.*extend"

# Look for similar array merging patterns
rg "extend\(true, \{\}, .*\[\].*\)" -A 2

Length of output: 123


Let's gather a bit more context on how the array merge is implemented in the file. We'll inspect the usage of both the mergeArray function and the extend call in the relevant file to determine if the new implementation produces the expected behavior.


🏁 Script executed:

#!/bin/bash
# Check for the mergeArray function and its surrounding context in the file.
rg -n "mergeArray" packages/vue/src/grid-toolbar/src/multiple-history.ts -C 8

# Check the usage of extend in the same file to see how it's applied.
rg -n "extend(" packages/vue/src/grid-toolbar/src/multiple-history.ts -C 8

Length of output: 1102


Let's run another script with the proper escaping to check the usage of extend in the file.


🏁 Script executed:

#!/bin/bash
# Check for usages of extend in the file with properly escaped parenthesis
rg -n "extend\(" packages/vue/src/grid-toolbar/src/multiple-history.ts -C 8

Length of output: 406


Array Merging Behavior Review:
The implementation in mergeArray calls

result.push(extend(true, {}, toItem || {}, fromItem))

which indicates a deep merge of the source objects. Based on our code inspection, the usage of the new extend from @opentiny/utils appears consistent with the intended behavior (merging properties, including recursively merging nested children arrays). Although no dedicated unit tests for mergeArray were located via our search, the merge logic itself is clear and in line with expected deep merge patterns. It is recommended that manual or additional automated tests be run to exercise edge cases (e.g., handling of nested objects in children) to fully validate the behavior in practical grid scenarios.

packages/vue/src/grid/src/pager/src/methods.ts (1)

5-5: Verify shallow copy behavior with the new extend implementation.

The extend function is used with false parameter in beforePageChangeHandler, indicating a shallow copy operation. Ensure that the implementation from @opentiny/utils maintains the same shallow copy behavior.

✅ Verification successful

🏁 Script executed:

#!/bin/bash
# Description: Check if the new extend implementation maintains shallow copy behavior
# Search for tests or similar usage patterns

# Look for test files related to shallow copy
fd -e test.ts -e spec.ts -e test.js -e spec.js | xargs rg "extend\(false,"

# Look for similar shallow copy patterns
rg "extend\(false, .*\)" -A 2

Length of output: 878


Shallow Copy Behavior Verified

The usage of extend with the false flag in both packages/vue/src/grid/src/grid/grid.ts and packages/vue/src/grid/src/pager/src/methods.ts confirms that the shallow copy behavior is maintained consistently with the new implementation from @opentiny/utils.

  • Verify that the same shallow copy pattern (extend(false, { $grid: this }, params)) is used across relevant files.
packages/vue/src/grid-toolbar/src/custom.vue (1)

181-181: Verify deep merge behavior in Vue computed context.

The extend function is used with true parameter in the historyConfig computed property. Ensure that the implementation from @opentiny/utils maintains the same deep merge behavior and reactivity in Vue context.

✅ Verification successful

🏁 Script executed:

#!/bin/bash
# Description: Check if the new extend implementation maintains deep merge behavior in Vue context
# Search for tests or similar usage patterns

# Look for test files related to Vue computed properties using extend
fd -e test.ts -e spec.ts -e test.js -e spec.js | xargs rg "extend.*computed"

# Look for similar Vue computed patterns
rg "extend\(true, \{\}, .*computed" -A 2

Length of output: 121


🏁 Script executed:

#!/bin/bash
# Extract context around the computed property "historyConfig" in the custom.vue file to verify deep merge usage
rg "historyConfig" packages/vue/src/grid-toolbar/src/custom.vue -C 10

Length of output: 2502


Deep merge behavior in Vue computed property verified.

The computed property historyConfig uses extend(true, {}, ...) for deep merging. The implementation in packages/vue/src/grid-toolbar/src/custom.vue correctly follows the pattern of a deep merge, which should maintain Vue reactivity as the computed property recomputes based on its dependencies.

packages/vue/src/grid/src/keyboard/src/methods.ts (1)

28-28: LGTM! Import statement updated correctly.

The change to import extend from @opentiny/utils aligns with the broader refactoring effort to centralize utility functions.

packages/vue/src/grid/src/filter/src/panel.tsx (2)

32-32: LGTM! Import statement updated correctly.

The change to import extend from @opentiny/utils aligns with the broader refactoring effort to centralize utility functions.


1-1: Review computed property usage.

The ESLint disable comment suggests that computed properties might be used as methods. Consider refactoring these instances to proper computed properties or methods based on their usage.

✅ Verification successful

🏁 Script executed:

#!/bin/bash
# Search for computed properties used as methods
ast-grep --pattern 'computed: {
  $$$
  $name() {
    $$$
  }
  $$$
}'

Length of output: 72


I'll run a new script to list any computed property definitions in this file for further context. Please run the script below to show a few lines around any "computed:" declarations in packages/vue/src/grid/src/filter/src/panel.tsx.


🏁 Script executed:

#!/bin/bash
# Display computed properties in panel.tsx for further investigation
rg -n --context 5 "computed:" packages/vue/src/grid/src/filter/src/panel.tsx

Length of output: 312


Computed properties appear correctly defined.

The computed block in packages/vue/src/grid/src/filter/src/panel.tsx defines the condition and visible getters properly, and our search did not reveal any instances where they’re invoked as methods (i.e. with parentheses). If their usage elsewhere in the file also accesses them as simple properties, the ESLint disable comment may no longer be necessary.

packages/vue/src/grid-toolbar/src/custom-saas.vue (3)

291-295: LGTM! Improved variable naming.

Renaming the loop variable from 'column' to 'columnLi' enhances code clarity by avoiding variable shadowing with the parent scope.

Also applies to: 303-303


388-388: LGTM! Import statement updated correctly.

The change to import extend from @opentiny/utils aligns with the broader refactoring effort to centralize utility functions.


444-444: LGTM! Added explicit emits declaration.

Adding explicit emits improves the component contract by clearly documenting the events that can be emitted.

packages/vue/src/time-select/package.json (1)

3-7: LGTM! Package configuration improved.

The changes enhance the package configuration by:

  • Declaring ECMAScript module type
  • Adding proper MIT license
  • Adding performance optimization hint with sideEffects
  • Adding @opentiny/utils dependency
  • Adding necessary test utilities

Also applies to: 15-19, 21-24

@@ -14,7 +14,7 @@ import { renderless, api } from '@opentiny/vue-renderless/cascader-node/vue'
import { $prefix, setup, h, $props, defineComponent } from '@opentiny/vue-common'
import Checkbox from '@opentiny/vue-checkbox'
import Radio from '@opentiny/vue-radio'
import { isEqual } from '@opentiny/vue-renderless/common/object'
import { isEqual } from '@opentiny/utils'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

LGTM! Verify package availability.

The consolidation of utility functions into @opentiny/utils improves code organization and maintainability.

Run the following script to verify the package and function availability:


🏁 Script executed:

#!/bin/bash
# Description: Verify the availability of isEqual in @opentiny/utils

# Check if the package is installed and accessible
npm list @opentiny/utils

# Search for isEqual exports
ast-grep --pattern 'export { $_ as isEqual }'

Length of output: 126

Action Required: @opentiny/utils is Not Properly Available

The shell script results indicate:

  • The dependency check with npm list @opentiny/utils shows no installed instance.
  • The AST grep did not locate any export of an isEqual function from the package.

This suggests that the intended utility function is either missing from the package or not properly exported, which may lead to runtime errors.

  • Verify that @opentiny/utils is added as a dependency in your project.
  • Confirm that the isEqual function is indeed exported from @opentiny/utils (or adjust the import if it has been renamed or relocated).

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

♻️ Duplicate comments (1)
packages/utils/src/index.ts (1)

24-58: 🛠️ Refactor suggestion

Refactor duplicate date utility functions.

Several functions are duplicated with numeric suffixes (e.g., isDate1, toDate1, nextMonth1). This pattern:

  • Increases maintenance burden
  • May confuse users about which function to use
  • Violates the DRY principle

Consider:

  1. Consolidating duplicate functions if they serve the same purpose
  2. If different, rename to reflect their specific use cases rather than using numeric suffixes
  3. Add JSDoc comments to clarify the differences between similar functions
🧹 Nitpick comments (1)
packages/utils/src/index.ts (1)

111-112: Remove redundant comments.

The comments "无直接引用" (no direct reference) don't provide meaningful information and should be removed or replaced with more descriptive comments.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 97c1f84 and 63ec0f0.

📒 Files selected for processing (12)
  • packages/renderless/src/base-select/index.ts (3 hunks)
  • packages/renderless/src/grid/utils/common.ts (1 hunks)
  • packages/renderless/src/nav-menu/index.ts (2 hunks)
  • packages/renderless/src/popeditor/index.ts (1 hunks)
  • packages/renderless/src/select/index.ts (3 hunks)
  • packages/renderless/src/tree-select/index.ts (1 hunks)
  • packages/renderless/src/tree/index.ts (1 hunks)
  • packages/utils/src/index.ts (3 hunks)
  • packages/vue/src/grid/src/fetch-data/src/methods.ts (1 hunks)
  • packages/vue/src/grid/src/filter/src/methods.ts (1 hunks)
  • packages/vue/src/scrollbar/package.json (1 hunks)
  • packages/vue/src/scrollbar/src/pc.vue (1 hunks)
✅ Files skipped from review due to trivial changes (4)
  • packages/renderless/src/tree/index.ts
  • packages/renderless/src/tree-select/index.ts
  • packages/vue/src/grid/src/filter/src/methods.ts
  • packages/renderless/src/popeditor/index.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/vue/src/grid/src/fetch-data/src/methods.ts
🧰 Additional context used
🪛 Biome (1.9.4)
packages/renderless/src/base-select/index.ts

[error] 1866-1868: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

🔇 Additional comments (15)
packages/vue/src/scrollbar/package.json (6)

3-3: Addition of Module Type Declaration

The "type": "module" field has been added to indicate that this package uses ECMAScript modules. This is appropriate if your codebase and build tools are set up for ESM.


6-6: License Field Declaration

Adding the "license": "MIT" field clarifies the licensing of this package. This explicit declaration is beneficial for open source compliance and clarity.


7-7: Declaration of Side Effects

The addition of "sideEffects": false informs bundlers that this package is free from side effects, potentially enabling better tree-shaking. Verify that none of the module files introduce unintended side effects before confirming.


15-15: Centralized Utility Dependency Addition

Including "@opentiny/utils": "workspace:~" in the dependencies aligns with the broader effort to centralize utility functions across packages. Ensure the version alignment is consistent with your workspace settings.


17-17: Update to vue-renderless Dependency

The update for "@opentiny/vue-renderless": "workspace:~" standardizes the dependency version within your workspace. Double-check that this change does not break compatibility with other packages relying on vue-renderless.


20-23: Reorganization of DevDependencies

The devDependencies block now includes:

  • "@opentiny-internal/vue-test-utils": "workspace:*"
  • "vitest": "catalog:"

This reordering aligns with project testing standards and dependency management practices. Verify that the new versions and specifiers work seamlessly with your CI and local test environment.

packages/vue/src/scrollbar/src/pc.vue (1)

16-16: LGTM! Import path updated correctly.

The import path change aligns with the centralization of utility functions under @opentiny/utils.

packages/utils/src/index.ts (1)

23-23: Address the TODO comment about merging date utilities.

The comment indicates that date.ts and date-util.ts need to be merged. This should be prioritized to reduce code duplication and maintenance overhead.

Would you like me to help create an issue to track the merging of these date utility files?

packages/renderless/src/grid/utils/common.ts (1)

27-27: LGTM! Import path updated correctly.

The import path change aligns with the centralization of utility functions under @opentiny/utils.

packages/renderless/src/nav-menu/index.ts (2)

24-24: LGTM! Import paths updated correctly.

The import path changes align with the centralization of utility functions under @opentiny/utils.

Also applies to: 27-27


494-494: Verify the impact of switching from isBrowser to isServer check.

The environment check has been inverted from !isBrowser to isServer. While semantically equivalent, this is a breaking change that might affect other parts of the codebase.

Run the following script to check for other occurrences of this pattern:

✅ Verification successful

🏁 Script executed:

#!/bin/bash
# Description: Check for other instances of isBrowser to isServer conversion

# Search for remaining isBrowser checks
echo "Checking for remaining isBrowser checks..."
rg "isBrowser|!isBrowser" || echo "No isBrowser checks found"

# Search for isServer checks
echo -e "\nChecking for isServer checks..."
rg "isServer" || echo "No isServer checks found"

Length of output: 15750


Environment Check Conversion Verified

The change from using !isBrowser to isServer is consistent with similar patterns throughout the codebase. In our search results, many modules already use the isServer check. Since isServer is defined as the inverse of isBrowser (i.e. isServer is true when window is undefined), this inversion is semantically equivalent and does not introduce any breaking behavior.

packages/renderless/src/base-select/index.ts (2)

1-1: LGTM! Improved imports organization.

Centralizing utility imports from @opentiny/utils improves maintainability and consistency.

Also applies to: 7-7, 19-19


1868-1868: LGTM! Improved server-side rendering check.

Changed from !isBrowser to isServer for a more explicit server-side rendering check.

🧰 Tools
🪛 Biome (1.9.4)

[error] 1866-1868: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

packages/renderless/src/select/index.ts (2)

1-1: LGTM! Improved imports organization.

Centralizing utility imports from @opentiny/utils improves maintainability and consistency.

Also applies to: 7-7, 19-19


2401-2401: LGTM! Improved server-side rendering check.

Changed from !isBrowser to isServer for a more explicit server-side rendering check.

@shenjunjian shenjunjian changed the title WIP fix(utils): 调整sha256, 移除 getWindow, isWeb WIP fix(utils): delete the renderless/common directory and adjust all reference paths. Feb 7, 2025
@shenjunjian shenjunjian changed the title WIP fix(utils): delete the renderless/common directory and adjust all reference paths. fix(utils): delete the renderless/common directory and adjust all reference paths. Feb 7, 2025
@github-actions github-actions bot added the bug Something isn't working label Feb 7, 2025
@zzcr zzcr merged commit 2581baa into opentiny:dev Feb 7, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants