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

feat: add svelte starter #282

Closed
wants to merge 2 commits into from
Closed

feat: add svelte starter #282

wants to merge 2 commits into from

Conversation

ZackAmes
Copy link
Contributor

@ZackAmes ZackAmes commented Oct 1, 2024

Closes #

Introduced changes

Checklist

  • Linked relevant issue
  • Updated relevant documentation
  • Added relevant tests
  • Add a dedicated CI job for new examples
  • Performed self-review of the code

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced a new Svelte application template using Dojo RECS for easier project initialization.
    • Added comprehensive README documentation for setting up a development environment with Svelte, TypeScript, and Vite.
    • Implemented a new CSS framework for styling the application, supporting light and dark modes.
    • Created a new configuration file for managing component values in the Dojo Engine context.
    • Added several new functions for managing burner accounts and enhancing gameplay interactions.
  • Bug Fixes

    • Improved handling of Hot Module Replacement (HMR) issues to ensure better state preservation in components.
  • Documentation

    • Updated README to guide users through the setup process and highlight differences from SvelteKit.
  • Chores

    • Updated .gitignore to ignore node_modules and maintain a cleaner repository.

Copy link

coderabbitai bot commented Oct 1, 2024

Walkthrough

The changes introduce a new Svelte project template utilizing Vite and TypeScript, along with various configuration files and components to support a Dojo Engine integration. Key additions include a .gitignore file, a README for setup instructions, multiple TypeScript files for managing game-like interactions, and a structured configuration for Vite and Svelte. The project aims to provide a foundational framework for building applications with reactive state management and component-based architecture.

Changes

File(s) Change Summary
examples/example-vite-svelte-recs/.gitignore Updated to ignore the node_modules directory.
examples/example-vite-svelte-recs/README.md Introduced a README file detailing setup instructions for a Svelte, TypeScript, and Vite project.
examples/example-vite-svelte-recs/dojoConfig.ts Added a configuration file that exports a dojoConfig constant, integrating a manifest into the Dojo framework.
examples/example-vite-svelte-recs/index.html Created an index.html file establishing the basic structure for the web application.
examples/example-vite-svelte-recs/package.json Configured a new Svelte project with scripts for development, building, and dependencies for Dojo Engine and related libraries.
examples/example-vite-svelte-recs/src/App.svelte Introduced a Svelte component managing interactions in a game-like environment with reactive state.
examples/example-vite-svelte-recs/src/app.css Added a CSS file for comprehensive styling of the web application.
examples/example-vite-svelte-recs/src/dojo/componentValueStore.ts Created a Svelte store for managing component values associated with entities in a Dojo context.
examples/example-vite-svelte-recs/src/dojo/createClientComponents.ts Introduced a function to create client components with overridable properties for a Dojo application.
examples/example-vite-svelte-recs/src/dojo/setup.ts Added a setup function to initialize components and manage synchronization in a Dojo application.
examples/example-vite-svelte-recs/src/dojo/typescript/contracts.gen.ts Defined a contract interface for interacting with a Dojo-based blockchain environment, including methods for smart contract actions.
examples/example-vite-svelte-recs/src/dojo/typescript/models.gen.ts Introduced TypeScript type definitions for game entities and properties, including directions and movements.
examples/example-vite-svelte-recs/src/dojo/world.ts Created a file to initialize a new world instance using the Dojo Engine.
examples/example-vite-svelte-recs/src/handlers.ts Added functions for managing burner actions within the application.
examples/example-vite-svelte-recs/src/main.ts Introduced an initialization function for the Svelte application, setting up stores and components.
examples/example-vite-svelte-recs/src/stores.ts Created writable stores to manage application state, including Dojo and account information.
examples/example-vite-svelte-recs/src/vite-env.d.ts Added TypeScript declarations for Svelte components in a Vite environment.
examples/example-vite-svelte-recs/svelte.config.js Configured Svelte project settings to utilize Vite's preprocessing capabilities.
examples/example-vite-svelte-recs/tsconfig.json Extended TypeScript configuration for Svelte, specifying compiler options.
examples/example-vite-svelte-recs/tsconfig.node.json Introduced a new TypeScript configuration for Node.js with specific compiler options.
examples/example-vite-svelte-recs/vite.config.ts Created a Vite configuration file to integrate Svelte and additional plugins.
packages/create-dojo/src/commands/start.ts Added a new template option for initializing a Svelte application using Dojo RECS.

Possibly related PRs

  • feat: add vanillajs + phaser example #249: The addition of a .gitignore file in the vanilla/phaser example is related as it also includes ignoring the node_modules directory, similar to the main PR's update to the .gitignore file.
  • fix: docs and example #231: Although primarily focused on documentation, this PR includes changes to files that may relate to the overall structure and setup of the project, which could indirectly connect to the changes made in the main PR.
  • fix: utils - change way to compute selector hash #250: This PR enhances logging and error handling in functions that may interact with the same components or systems as those modified in the main PR, suggesting a potential connection in functionality.
  • fix: sync #264: The changes in movement direction handling in this PR may relate to the overall structure of the application, which could be impacted by the updates in the main PR regarding project organization and file management.
  • feat: sdk v2 #266: The introduction of a new enumeration for movement directions in this PR aligns with the changes in the main PR that focus on improving the structure and clarity of the codebase.
  • fix: submodule #272: The modifications to the CI workflow and submodule paths may reflect a broader restructuring that could relate to the organization and management of the project as seen in the main PR.

🐇 In a world of code and light,
A Svelte app takes flight,
With Dojo's might and Vite's speed,
A template born to meet the need.
So hop along, let's celebrate,
This project’s journey is truly great! 🌟


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 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

@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: 30

🧹 Outside diff range and nitpick comments (24)
examples/example-vite-svelte-recs/src/dojo/world.ts (1)

1-3: LGTM! Consider adding a brief comment.

The implementation looks good. It correctly imports the createWorld function and exports a singleton world instance, which is a common pattern in game development and state management.

Consider adding a brief comment explaining the purpose of this file and the world constant. For example:

import { createWorld } from "@dojoengine/recs";

// Create and export a singleton world instance for use throughout the application
export const world = createWorld();

This would help other developers quickly understand the file's purpose and the importance of the world constant.

examples/example-vite-svelte-recs/src/vite-env.d.ts (1)

4-8: LGTM: Correct module declaration for Svelte components.

The module declaration for "*.svelte" files is well-structured and follows best practices. It correctly imports the ComponentType from Svelte and exports a default component, allowing proper TypeScript integration for Svelte components.

For improved clarity, consider adding a brief comment explaining the purpose of this declaration:

+// This declaration allows TypeScript to recognize .svelte files as modules
 declare module "*.svelte" {
   import type { ComponentType } from "svelte";
   const component: ComponentType;
   export default component;
 }
examples/example-vite-svelte-recs/svelte.config.js (2)

4-5: Consider updating the comment for clarity.

The comment provides a useful link to the Svelte documentation, which is helpful. However, the text mentions "compile-time-svelte-preprocess", while the link points to the general preprocessing documentation. Consider updating the comment to more accurately reflect the linked content.

You could update the comment as follows:

- // Consult https://svelte.dev/docs#compile-time-svelte-preprocess
- // for more information about preprocessors
+ // For more information about Svelte preprocessors, consult:
+ // https://svelte.dev/docs#svelte-preprocess

1-7: Consider adding more documentation to the configuration file.

As this is part of a new Svelte starter template for the dojo.js project, it would be beneficial to add more comments explaining the purpose of this configuration and how it integrates with the dojo.js ecosystem. This could include:

  1. A brief explanation of why vitePreprocess is used.
  2. Any specific considerations for dojo.js projects.
  3. Instructions on how to extend this configuration for more advanced use cases.

This additional documentation would align with the PR objective of updating documentation and would make the starter template more user-friendly for newcomers to both Svelte and dojo.js.

Would you like me to draft an expanded version of this configuration file with additional comments and documentation?

examples/example-vite-svelte-recs/vite.config.ts (1)

6-8: Consider additional configuration options.

While the basic setup is correct, you might want to consider adding more configuration options depending on your project requirements. Some suggestions:

  1. Add a base option if the project will be deployed to a subdirectory.
  2. Configure build options for optimizing the production build.
  3. Set up resolve.alias for common import paths.
  4. Configure server options for development server settings.

Example:

export default defineConfig({
  plugins: [svelte(), wasm(), topLevelAwait()],
  base: '/your-subdirectory/', // If deploying to a subdirectory
  build: {
    outDir: 'dist',
    minify: 'terser',
  },
  resolve: {
    alias: {
      '@': '/src',
    },
  },
  server: {
    port: 3000,
  },
});
examples/example-vite-svelte-recs/src/stores.ts (1)

9-9: LGTM with a minor suggestion: burnerStore is correctly defined.

The burnerStore is properly implemented as a writable store to hold an array of Burner objects. This is suitable for managing multiple burner accounts.

Consider maintaining consistent spacing between store definitions. You might want to remove the empty line before this definition to keep the code more compact, or add empty lines between all store definitions for consistency.

examples/example-vite-svelte-recs/index.html (1)

1-13: Overall: Well-structured HTML template for Vite + Svelte + TypeScript project.

This index.html file provides a solid foundation for your Svelte application. It includes all necessary elements and follows best practices for modern web development.

Consider adding a <noscript> tag with a message for users who have JavaScript disabled, to improve accessibility and user experience.

examples/example-vite-svelte-recs/src/dojo/createClientComponents.ts (1)

6-10: Consider adding an explicit return type annotation.

While TypeScript can infer the return type, adding an explicit return type annotation can improve code readability and serve as documentation. This is especially useful for complex return types.

Consider updating the function signature as follows:

export function createClientComponents({
  contractComponents,
}: {
  contractComponents: ContractComponents;
}): { 
  [K in keyof ContractComponents]: ReturnType<typeof overridableComponent>
} {
  // ...
}

This explicit return type accurately represents that all properties of ContractComponents are wrapped with overridableComponent.

examples/example-vite-svelte-recs/src/main.ts (1)

7-8: Remove unnecessary comment.

The comment about creating a writable store for the setup result is inconsistent with the actual implementation. The code uses predefined stores imported from ./stores instead.

Consider removing this comment to avoid confusion:

-// Create a writable store for the setup result
examples/example-vite-svelte-recs/tsconfig.json (1)

16-18: LGTM with a minor suggestion: Well-configured module options

The remaining compiler options are appropriately set for a modern TypeScript project, especially one using Svelte:

  • isolatedModules: true is good for compatibility with transpilers.
  • moduleDetection: "force" ensures consistent treatment of files as modules.
  • allowSyntheticDefaultImports: true allows for cleaner imports from various libraries.

These settings are suitable for the project. However, consider adding brief comments explaining these options, similar to the JavaScript options above, to improve maintainability for future contributors.

examples/example-vite-svelte-recs/package.json (3)

6-11: LGTM: Scripts are well-defined, with a minor suggestion.

The scripts cover all essential development tasks using Vite and include type checking for both Svelte and TypeScript files. This is a solid configuration for a Svelte project.

Consider adding a lint script to ensure code style consistency. For example:

"lint": "eslint 'src/**/*.{js,ts,svelte}'"

This would require adding ESLint to the devDependencies and configuring it for Svelte and TypeScript.


21-32: LGTM: Dependencies are appropriate for a Dojo engine project with StarkNet integration.

The dependencies section is well-configured for a game development project using the Dojo engine and integrating with the StarkNet blockchain. The use of "workspace:*" for some packages indicates a monorepo setup.

Consider adding a brief explanation in the project's README about the purpose of these dependencies, especially the @dojoengine packages and StarkNet integration. This would help new developers understand the project's architecture and requirements.


1-33: Overall, the package.json is well-configured for a Svelte starter project using Dojo engine.

The file structure, dependencies, and scripts are appropriate for the project's goals. Here are some general recommendations:

  1. Update the PR description with details about the Svelte starter template and its integration with Dojo engine.
  2. Complete the PR checklist items, especially updating documentation and adding tests.
  3. Consider creating a dedicated CI job for this new example, as mentioned in the PR checklist.
  4. Ensure that the README for this starter project includes:
    • Setup instructions
    • Explanation of the Dojo engine integration
    • Overview of the project structure
    • Any specific requirements or considerations for developers using this starter

These steps will help make the new Svelte starter more accessible and maintainable for other developers.

examples/example-vite-svelte-recs/src/app.css (4)

1-14: LGTM! Consider improving color contrast for accessibility.

The root styles are well-structured and include performance optimizations. However, the text color (rgba(255, 255, 255, 0.87)) on the dark background (#242424) might not meet WCAG 2.1 AA contrast requirements.

Consider adjusting the text color to rgba(255, 255, 255, 0.95) or #FFFFFF to improve readability and accessibility.


25-36: LGTM! Consider using relative units for improved responsiveness.

The body and heading styles are well-structured. However, using relative units for font sizes and dimensions could improve responsiveness across different device sizes.

Consider updating the h1 font size to use rem units:

h1 {
-  font-size: 3.2em;
+  font-size: 3.2rem;
  line-height: 1.1;
}

49-66: LGTM! Button styles are well-defined. Minor suggestion for consistency.

The button styles are comprehensive and provide good visual feedback. The focus styles improve accessibility for keyboard users.

For consistency with other time values in the file, consider using seconds instead of milliseconds for the transition duration:

button {
-  transition: border-color 0.25s;
+  transition: border-color 0.25s;
}

68-79: LGTM! Light mode styles are well-considered. Consider adding a transition for theme changes.

The media query for light color scheme ensures a good user experience. The color choices are appropriate for light backgrounds.

To smooth the transition between dark and light modes, consider adding a transition to the root styles:

:root {
+  transition: color 0.3s ease-in-out, background-color 0.3s ease-in-out;
  /* other styles... */
}

This will create a subtle fade effect when switching between color schemes.

examples/example-vite-svelte-recs/README.md (3)

9-22: LGTM: Informative comparison with SvelteKit

This section provides valuable context for users choosing between this template and SvelteKit. It clearly explains the benefits and use cases for each option.

Consider revising the phrase "easily-added support" to "easily added support" on line 11 to improve readability.

🧰 Tools
🪛 LanguageTool

[uncategorized] ~11-~11: Although a hyphen is possible, it is not necessary in a compound modifier in which the first word is an adverb that ends in ‘ly’.
Context: ...ort for TypeScript, SCSS, and Less, and easily-added support for mdsvex, GraphQL, PostCSS, T...

(HYPHENATED_LY_ADVERB_ADJECTIVE)


[uncategorized] ~17-~17: Possible missing comma found.
Context: ...elteKit?** - It brings its own routing solution which might not be preferable for some ...

(AI_HYDRA_LEO_MISSING_COMMA)


[style] ~20-~20: ‘taking into account’ might be wordy. Consider a shorter alternative.
Context: ... with Vite + TypeScript + Svelte, while taking into account the developer experience with regards t...

(EN_WORDINESS_PREMIUM_TAKING_INTO_ACCOUNT)


[misspelling] ~20-~20: Although “with regards to” is sometimes used in casual speech, it is typically considered a nonstandard phrase.
Context: ...g into account the developer experience with regards to HMR and intellisense. It demonstrates c...

(IN_OR_WITH_REGARDS_TO_OF)


36-40: LGTM: Helpful explanation of HMR behavior

This section addresses a common issue with Hot Module Replacement (HMR) and state preservation, providing valuable information for users who might encounter this problem.

Consider adding a brief explanation of what HMR stands for when it's first mentioned, as not all users may be familiar with the acronym. For example:
"Hot Module Replacement (HMR) state preservation comes with a number of gotchas!"


1-47: Overall: Excellent README with minor suggestions for improvement

This README file is well-structured, informative, and provides valuable guidance for users getting started with the Svelte + TypeScript + Vite template. It covers essential topics such as setup instructions, comparisons with alternatives, technical considerations, and common issues.

To further enhance the document, consider the following minor improvements:

  1. Add a brief explanation of what HMR stands for when it's first mentioned.
  2. Review the document for minor language issues, such as:
    • Revising "easily-added support" to "easily added support" (line 11)
    • Considering alternatives to the phrase "taking into account" for improved conciseness (line 20)
    • Evaluating the use of "with regards to" and potentially replacing it with "regarding" or "concerning" (line 20)

These small changes will polish an already excellent README file.

🧰 Tools
🪛 LanguageTool

[uncategorized] ~11-~11: Although a hyphen is possible, it is not necessary in a compound modifier in which the first word is an adverb that ends in ‘ly’.
Context: ...ort for TypeScript, SCSS, and Less, and easily-added support for mdsvex, GraphQL, PostCSS, T...

(HYPHENATED_LY_ADVERB_ADJECTIVE)


[uncategorized] ~17-~17: Possible missing comma found.
Context: ...elteKit?** - It brings its own routing solution which might not be preferable for some ...

(AI_HYDRA_LEO_MISSING_COMMA)


[style] ~20-~20: ‘taking into account’ might be wordy. Consider a shorter alternative.
Context: ... with Vite + TypeScript + Svelte, while taking into account the developer experience with regards t...

(EN_WORDINESS_PREMIUM_TAKING_INTO_ACCOUNT)


[misspelling] ~20-~20: Although “with regards to” is sometimes used in casual speech, it is typically considered a nonstandard phrase.
Context: ...g into account the developer experience with regards to HMR and intellisense. It demonstrates c...

(IN_OR_WITH_REGARDS_TO_OF)

packages/create-dojo/src/commands/start.ts (1)

29-32: LGTM! Consider a minor adjustment for consistency.

The new Svelte template has been added correctly and follows the existing structure. Great job on expanding the available options for users.

For consistency with other template descriptions, consider capitalizing "Basic" in the description:

 {
     value: "example-vite-svelte-recs",
-    description: "Basic svelte app using Dojo RECS",
+    description: "Basic Svelte app using Dojo RECS",
 },

This change would align the capitalization style with other template descriptions.

examples/example-vite-svelte-recs/src/dojo/componentValueStore.ts (1)

24-28: Use 'const' instead of 'let' for 'entityStore'

The variable entityStore is not reassigned after its initial declaration. It's better to declare it using const to prevent accidental reassignment and improve code readability.

Apply this diff:

- let entityStore = derived(dojoStore, ($store) =>
+ const entityStore = derived(dojoStore, ($store) =>
examples/example-vite-svelte-recs/src/dojo/setup.ts (1)

84-84: Re-evaluate exposing the entire torii module

Returning the entire torii module may not be necessary since toriiClient is already accessible from the returned object. Exposing only what's needed can help keep the API surface minimal and reduce potential misuse.

Consider removing torii from the returned object:

    toriiClient,
    eventSync,
-   torii,
    sync,
examples/example-vite-svelte-recs/src/App.svelte (1)

68-68: Handle potential undefined 'last_direction' in moves

You're displaying $moves.last_direction without checking if it's defined. If last_direction is undefined, this could cause unexpected behavior. Consider adding a check to ensure it exists before rendering.

Apply this diff to add the check:

-    <div>{$moves && $moves.last_direction}</div>
+    <div>{$moves && $moves.last_direction ? $moves.last_direction : 'No direction'}</div>
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 0530d74 and 4b4550f.

⛔ Files ignored due to path filters (3)
  • examples/example-vite-svelte-recs/bun.lockb is excluded by !**/bun.lockb
  • examples/example-vite-svelte-recs/pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
  • examples/example-vite-svelte-recs/public/vite.svg is excluded by !**/*.svg
📒 Files selected for processing (22)
  • examples/example-vite-svelte-recs/.gitignore (1 hunks)
  • examples/example-vite-svelte-recs/README.md (1 hunks)
  • examples/example-vite-svelte-recs/dojoConfig.ts (1 hunks)
  • examples/example-vite-svelte-recs/index.html (1 hunks)
  • examples/example-vite-svelte-recs/package.json (1 hunks)
  • examples/example-vite-svelte-recs/src/App.svelte (1 hunks)
  • examples/example-vite-svelte-recs/src/app.css (1 hunks)
  • examples/example-vite-svelte-recs/src/dojo/componentValueStore.ts (1 hunks)
  • examples/example-vite-svelte-recs/src/dojo/createClientComponents.ts (1 hunks)
  • examples/example-vite-svelte-recs/src/dojo/setup.ts (1 hunks)
  • examples/example-vite-svelte-recs/src/dojo/typescript/contracts.gen.ts (1 hunks)
  • examples/example-vite-svelte-recs/src/dojo/typescript/models.gen.ts (1 hunks)
  • examples/example-vite-svelte-recs/src/dojo/world.ts (1 hunks)
  • examples/example-vite-svelte-recs/src/handlers.ts (1 hunks)
  • examples/example-vite-svelte-recs/src/main.ts (1 hunks)
  • examples/example-vite-svelte-recs/src/stores.ts (1 hunks)
  • examples/example-vite-svelte-recs/src/vite-env.d.ts (1 hunks)
  • examples/example-vite-svelte-recs/svelte.config.js (1 hunks)
  • examples/example-vite-svelte-recs/tsconfig.json (1 hunks)
  • examples/example-vite-svelte-recs/tsconfig.node.json (1 hunks)
  • examples/example-vite-svelte-recs/vite.config.ts (1 hunks)
  • packages/create-dojo/src/commands/start.ts (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • examples/example-vite-svelte-recs/.gitignore
🧰 Additional context used
🪛 LanguageTool
examples/example-vite-svelte-recs/README.md

[uncategorized] ~11-~11: Although a hyphen is possible, it is not necessary in a compound modifier in which the first word is an adverb that ends in ‘ly’.
Context: ...ort for TypeScript, SCSS, and Less, and easily-added support for mdsvex, GraphQL, PostCSS, T...

(HYPHENATED_LY_ADVERB_ADJECTIVE)


[uncategorized] ~17-~17: Possible missing comma found.
Context: ...elteKit?** - It brings its own routing solution which might not be preferable for some ...

(AI_HYDRA_LEO_MISSING_COMMA)


[style] ~20-~20: ‘taking into account’ might be wordy. Consider a shorter alternative.
Context: ... with Vite + TypeScript + Svelte, while taking into account the developer experience with regards t...

(EN_WORDINESS_PREMIUM_TAKING_INTO_ACCOUNT)


[misspelling] ~20-~20: Although “with regards to” is sometimes used in casual speech, it is typically considered a nonstandard phrase.
Context: ...g into account the developer experience with regards to HMR and intellisense. It demonstrates c...

(IN_OR_WITH_REGARDS_TO_OF)

🪛 Biome
examples/example-vite-svelte-recs/src/dojo/typescript/models.gen.ts

[error] 39-39: Don't use 'String' as a type.

Use lowercase primitives for consistency.
Safe fix: Use 'string' instead

(lint/complexity/noBannedTypes)


[error] 40-40: Don't use 'BigInt' as a type.

Use lowercase primitives for consistency.
Safe fix: Use 'bigint' instead

(lint/complexity/noBannedTypes)


[error] 41-41: Don't use 'Number' as a type.

Use lowercase primitives for consistency.
Safe fix: Use 'number' instead

(lint/complexity/noBannedTypes)


[error] 51-51: Don't use 'BigInt' as a type.

Use lowercase primitives for consistency.
Safe fix: Use 'bigint' instead

(lint/complexity/noBannedTypes)


[error] 61-61: Don't use 'BigInt' as a type.

Use lowercase primitives for consistency.
Safe fix: Use 'bigint' instead

(lint/complexity/noBannedTypes)


[error] 62-62: Don't use 'Number' as a type.

Use lowercase primitives for consistency.
Safe fix: Use 'number' instead

(lint/complexity/noBannedTypes)


[error] 64-64: Don't use 'Boolean' as a type.

Use lowercase primitives for consistency.
Safe fix: Use 'boolean' instead

(lint/complexity/noBannedTypes)


[error] 75-75: Don't use 'BigInt' as a type.

Use lowercase primitives for consistency.
Safe fix: Use 'bigint' instead

(lint/complexity/noBannedTypes)


[error] 76-76: Don't use 'String' as a type.

Use lowercase primitives for consistency.
Safe fix: Use 'string' instead

(lint/complexity/noBannedTypes)


[error] 85-85: Don't use 'BigInt' as a type.

Use lowercase primitives for consistency.
Safe fix: Use 'bigint' instead

(lint/complexity/noBannedTypes)


[error] 95-95: Don't use 'Number' as a type.

Use lowercase primitives for consistency.
Safe fix: Use 'number' instead

(lint/complexity/noBannedTypes)


[error] 96-96: Don't use 'Number' as a type.

Use lowercase primitives for consistency.
Safe fix: Use 'number' instead

(lint/complexity/noBannedTypes)


[error] 105-105: Don't use 'BigInt' as a type.

Use lowercase primitives for consistency.
Safe fix: Use 'bigint' instead

(lint/complexity/noBannedTypes)

🔇 Additional comments (30)
examples/example-vite-svelte-recs/dojoConfig.ts (2)

5-7: Configuration looks good, consider additional options.

The dojoConfig export using createDojoConfig with the manifest is correct. However, there might be additional configuration options available for createDojoConfig.

Run the following script to check for additional configuration options:

#!/bin/bash
# Description: Check for additional configuration options in createDojoConfig

# Test: Search for createDojoConfig usage in the codebase
rg --type typescript -A 10 'createDojoConfig\(' | grep -v 'examples/example-vite-svelte-recs/dojoConfig.ts'

Consider adding any relevant additional options found in other usages of createDojoConfig throughout the codebase.


3-3: Verify @dojoengine/core dependency.

The createDojoConfig function is imported from "@dojoengine/core". Ensure that this package is listed in the project's dependencies (package.json) with the correct version.

Run the following script to check the dependency:

#!/bin/bash
# Description: Verify the @dojoengine/core dependency in package.json

# Test 1: Check if package.json exists and contains @dojoengine/core
if grep -q '"@dojoengine/core"' package.json; then
    echo "@dojoengine/core is listed in package.json"
    grep '"@dojoengine/core"' package.json
else
    echo "@dojoengine/core is not found in package.json"
fi

# Test 2: Check if @dojoengine/core is installed in node_modules
if [ -d "node_modules/@dojoengine/core" ]; then
    echo "@dojoengine/core is installed in node_modules"
else
    echo "@dojoengine/core is not found in node_modules"
fi
examples/example-vite-svelte-recs/src/vite-env.d.ts (1)

1-2: LGTM: Correct type references for Vite-Svelte project.

The type references for Svelte and Vite client are correctly included. These are essential for proper TypeScript support in a Vite-Svelte project.

examples/example-vite-svelte-recs/svelte.config.js (1)

1-7: LGTM! Standard Svelte configuration for Vite projects.

The configuration file is well-structured and follows best practices for a Svelte project using Vite. It correctly imports the vitePreprocess function and sets up the default export with the preprocess property. This setup will enable Vite's preprocessing capabilities for the Svelte application, which is ideal for a starter template.

examples/example-vite-svelte-recs/tsconfig.node.json (1)

11-11: LGTM: Appropriate file inclusion for Node.js environment.

The include section correctly specifies only the "vite.config.ts" file. This is appropriate for a Node.js-specific TypeScript configuration in a Vite project, as it ensures that the Vite configuration is compiled with Node.js-specific settings while allowing the rest of the project to use a separate TypeScript configuration.

examples/example-vite-svelte-recs/vite.config.ts (3)

1-4: LGTM: Imports are correct and well-organized.

The necessary modules are imported correctly, following best practices with named imports. The order is logical, starting with core Vite functionality, then Svelte, followed by additional plugins.


6-8: LGTM: Basic Vite configuration is correct.

The configuration uses defineConfig for proper type checking and includes the necessary plugins for Svelte, WebAssembly, and top-level await support.


1-8: Verify alignment with project structure and requirements.

The Vite configuration provides a solid foundation for a Svelte project with WebAssembly and top-level await support. As the project evolves, ensure that:

  1. The configuration remains in sync with the project's structure and dependencies.
  2. Any additional build or development requirements are reflected in this file.
  3. The configuration is consistent with other examples or projects within the dojo.js ecosystem.

To ensure consistency across the project, run the following script:

This will help identify any discrepancies in Vite configurations across the project.

✅ Verification successful

Adjust the shell script to correctly search TypeScript Vite configuration files.

The previous script encountered an error because rg did not recognize the typescript file type. Please run the following updated script to check plugin usage in all vite.config.ts files:


Vite configuration aligns consistently across project examples.

The vite.config.ts for the Svelte project follows the established pattern seen in other examples:

  • Utilizes wasm() and topLevelAwait() consistently.
  • Incorporates svelte() specific to the framework, analogous to how React projects use react().

This alignment ensures that as the project evolves, the configuration remains compatible and maintainable across different setups within the dojo.js ecosystem.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for other Vite configurations and compare plugin usage

# Find all vite.config.ts files
echo "Searching for vite.config.ts files:"
fd vite.config.ts

# Check plugin usage in other Vite configs
echo "\nChecking plugin usage in other Vite configs:"
rg --type typescript 'plugins.*=.*\[' -g 'vite.config.ts'

Length of output: 706


Script:

#!/bin/bash
# Description: Check plugin usage in Vite configurations for TypeScript files

echo "Checking plugin usage in Vite configurations:"
rg 'plugins\s*:\s*\[' -g 'vite.config.ts'

# Alternatively, if rg still has issues, use grep as a fallback
if [ $? -ne 0 ]; then
  echo "Using grep as a fallback to check plugin usage:"
  grep -Hn 'plugins\s*:\s*\[' $(fd vite.config.ts)
fi

Length of output: 916

examples/example-vite-svelte-recs/src/stores.ts (2)

6-6: LGTM: dojoStore is correctly defined.

The dojoStore is properly defined as a writable store with the correct type SetupResult. This aligns well with managing the setup state in a Svelte application.


7-7: LGTM: accountStore is well-defined.

The accountStore is correctly implemented as a writable store. The type Account | null is a good choice, allowing the store to represent both the presence of an account and its absence.

examples/example-vite-svelte-recs/index.html (3)

1-2: LGTM: Correct document type and language declaration.

The HTML5 doctype and language declaration are correctly implemented.


9-12: LGTM: Correct body structure for a Svelte application.

The body section is correctly structured for a Svelte application, with an appropriate mounting point and script tag.

Please verify that the "/src/main.ts" file exists in the project. Run the following script to check:

#!/bin/bash
# Description: Verify the existence of the main.ts file

# Test: Check if the main.ts file exists in the src directory
fd -t f "main.ts" src

If the file is not found, ensure that you've created the main TypeScript file for your Svelte application.


3-8: LGTM: Well-structured head section with a minor suggestion.

The head section is well-structured and includes all necessary meta tags. The title accurately reflects the project's tech stack.

Please verify that the "/vite.svg" icon file exists in the project's public directory. Run the following script to check:

If the file is not found, consider updating the icon path or adding the file to the project.

✅ Verification successful

Follow-Up Action: Verify the Existence of vite.svg in the Repository

Please run the following script to search the entire repository for the vite.svg file:

If the vite.svg file is located in a different directory or does not exist, please update the icon path in index.html accordingly or add the missing vite.svg file to the project.


Verification Successful: vite.svg Exists in Public Directory

The vite.svg icon file is present in the examples/example-vite-svelte-recs/public/ directory, ensuring the icon path in index.html is valid.

  • File Path: examples/example-vite-svelte-recs/public/vite.svg
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the existence of the vite.svg icon file

# Test: Check if the vite.svg file exists in the public directory
fd -t f "vite.svg" public

Length of output: 206


Script:

#~/CodeRabbit/scripts/verify_vite_svg.sh
#!/bin/bash
# Description: Verify the existence of the vite.svg icon file in the repository

# Test: Search for vite.svg anywhere in the repository
fd -t f "vite.svg"

Length of output: 218

examples/example-vite-svelte-recs/src/dojo/createClientComponents.ts (3)

1-4: LGTM: Imports and type alias are well-structured.

The import statements and type alias are correctly implemented. The use of a type alias for the function's return type is a good practice for type safety and code readability.


1-16: Overall, good implementation with room for minor improvements.

The createClientComponents function is well-structured and uses TypeScript features effectively. Consider the following improvements:

  1. Add an explicit return type annotation to the function for better clarity.
  2. Clarify whether all properties of contractComponents should be wrapped with overridableComponent, and if so, implement a more dynamic approach.
  3. Ensure consistent usage of overridableComponent across the project.

These changes will enhance the code's robustness and maintainability. Great job on implementing this new feature!


11-16: Clarify the wrapping of component properties.

The current implementation explicitly wraps only Position and Moves with overridableComponent. It's unclear if other properties of contractComponents should also be wrapped.

If all properties should be wrapped, consider a more dynamic approach:

return Object.fromEntries(
  Object.entries(contractComponents).map(([key, value]) => [
    key,
    overridableComponent(value)
  ])
);

This would ensure all components are consistently wrapped. Please clarify if this is the intended behavior.

To verify the current usage, we can run the following script:

This will help us understand if overridableComponent is used consistently across the project.

✅ Verification successful

Fix the file type identifier for ripgrep.

The previous script used an unrecognized file type typescript. Updating the file type to ts should allow the search to execute correctly.


**Wrapping of component properties is limited to Position and Moves, which aligns with their usage in the codebase. No additional properties require wrapping.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for other usages of overridableComponent in the codebase

# Test: Search for other usages of overridableComponent
rg --type typescript 'overridableComponent\(' --glob '!**/createClientComponents.ts'

Length of output: 121


Script:

#!/bin/bash
# Description: Check for other usages of overridableComponent in the codebase

# Test: Search for other usages of overridableComponent
rg --type ts 'overridableComponent\(' --glob '!**/createClientComponents.ts'

Length of output: 356

examples/example-vite-svelte-recs/src/main.ts (1)

1-5: LGTM: Import statements are appropriate.

The import statements cover all necessary modules for initializing the Svelte application with Dojo integration. This includes styles, the main component, setup function, configuration, and stores.

examples/example-vite-svelte-recs/tsconfig.json (4)

1-3: LGTM: Proper extension and structure

The configuration correctly extends from "@tsconfig/svelte/tsconfig.json", which is a good practice for Svelte projects. The overall structure of the file is correct and follows the JSON format.

Also applies to: 20-22


4-7: LGTM: Appropriate compiler options

The compiler options are well-configured for a modern Svelte project:

  • Using "ESNext" for both target and module ensures the latest ECMAScript features are utilized.
  • Setting useDefineForClassFields to true is correct for modern class field behavior.
  • Enabling resolveJsonModule allows for importing JSON files as modules, which can be useful in many scenarios.

8-15: LGTM: Well-documented JavaScript options

The JavaScript-related compiler options are appropriately set and well-documented:

  • Both allowJs and checkJs are enabled, allowing for the inclusion and type-checking of JavaScript files.
  • This configuration is particularly useful in a Svelte project where .svelte files may contain JavaScript.
  • The explanatory comment provides clear guidance on these options and their implications, which is excellent for maintainability.

1-22: Overall: Excellent TypeScript configuration for Svelte

This tsconfig.json file is well-structured and appropriately configured for a Svelte project using TypeScript. It extends the recommended Svelte TypeScript configuration and includes sensible compiler options that enable modern JavaScript features, proper module handling, and comprehensive type checking.

The configuration demonstrates good practices such as:

  1. Extending from a Svelte-specific base configuration.
  2. Using the latest ECMAScript features.
  3. Enabling JavaScript inclusion and type checking.
  4. Configuring module-related options for better compatibility and consistency.

The only minor suggestion is to consider adding brief explanatory comments for the less common compiler options, similar to the existing comments for JavaScript options. This would further enhance the file's maintainability.

Great job on setting up a robust TypeScript configuration for this Svelte project!

examples/example-vite-svelte-recs/package.json (1)

1-5: LGTM: Project metadata is well-configured.

The project metadata is appropriately set up for a Svelte starter project. The private flag prevents accidental publishing, and the use of ES modules is a good choice for modern JavaScript development.

examples/example-vite-svelte-recs/src/app.css (2)

16-23: LGTM! Anchor styles are well-defined.

The anchor styles are concise and provide clear visual feedback. The use of consistent color values is commendable.


38-47: LGTM! Card and app container styles are appropriate.

The card and app container styles provide a good foundation for layout. The max-width on #app ensures content readability on larger screens.

examples/example-vite-svelte-recs/README.md (3)

1-7: LGTM: Clear and concise introduction

The introduction and setup instructions are well-written and provide essential information for users getting started with this template.


24-34: LGTM: Well-explained technical considerations

This section provides clear and thorough explanations for important configuration choices, such as using global.d.ts, including .vscode/extensions.json, and enabling allowJs. These explanations will help users understand the project structure and make informed decisions when customizing the template.


42-47: LGTM: Clear example of external store usage

The provided code example effectively demonstrates how to create a simple external store for state management. This practical illustration complements the earlier explanation about HMR state preservation and offers users a concrete solution.

examples/example-vite-svelte-recs/src/dojo/componentValueStore.ts (1)

1-53: Code is well-structured and functions as intended

The implementation of componentValueStore correctly creates a Svelte store that manages component values for a specific entity. Reactive updates and cleanup are properly handled, ensuring efficient memory management and responsiveness to data changes.

examples/example-vite-svelte-recs/src/dojo/setup.ts (1)

69-70: Avoid swallowing initialization errors silently

Logging errors without proper handling can lead to issues that are hard to debug. Ensure that critical initialization errors do not fail silently.

This concern has been addressed in the previous comment about improving error handling in the catch block.

examples/example-vite-svelte-recs/src/dojo/typescript/models.gen.ts (1)

180-180: Ensure consistent type for vec in Position component

In the Position component definition, vec is typed using Vec2Definition. Ensure that this matches the data structure expected by the component and that serialization is handled correctly.

Please confirm that Vec2Definition is correctly defined and compatible with defineComponent.

@@ -0,0 +1,7 @@
import manifest from "../manifests/dev/deployment/manifest.json";
Copy link

Choose a reason for hiding this comment

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

💡 Codebase verification

@dojoengine/core dependency is missing.

The package.json does not include "@dojoengine/core", and it is not found in node_modules. Ensure that "@dojoengine/core" is listed as a dependency and properly installed to resolve import issues in dojoConfig.ts.

🔗 Analysis chain

Verify the manifest file's existence and generation process.

The manifest is imported from a relative path. Ensure that this file exists in the specified location and is correctly generated or updated during the build/deployment process.

Run the following script to check the manifest file:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the existence of the manifest file and check its content.

# Test 1: Check if the manifest file exists
if [ -f "../manifests/dev/deployment/manifest.json" ]; then
    echo "Manifest file exists."
    # Test 2: Display the first few lines of the manifest file
    head -n 5 "../manifests/dev/deployment/manifest.json"
else
    echo "Manifest file does not exist at the specified path."
fi

# Test 3: Search for any scripts that might generate or update the manifest
fd -e sh -e js -e ts --exec grep -l "manifest.json" {}

Length of output: 288

Comment on lines +2 to +10
"compilerOptions": {
"composite": true,
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
"skipLibCheck": true,
"module": "ESNext",
"moduleResolution": "bundler",
"strict": true,
"noEmit": 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

Consider enhancing compiler options for improved clarity and future-proofing.

The current compiler options are well-configured for a Vite project using Svelte and TypeScript. However, consider the following suggestions:

  1. Add "target": "ESNext" to explicitly set the ECMAScript target version.
  2. Consider adding "esModuleInterop": true for better interoperability with CommonJS modules.
  3. Add "resolveJsonModule": true to allow importing JSON files as modules.
  4. Consider adding "forceConsistentCasingInFileNames": true to ensure consistent file naming across different operating systems.

Here's a suggested update to the compiler options:

 "compilerOptions": {
   "composite": true,
   "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
   "skipLibCheck": true,
   "module": "ESNext",
+  "target": "ESNext",
   "moduleResolution": "bundler",
   "strict": true,
-  "noEmit": true
+  "noEmit": true,
+  "esModuleInterop": true,
+  "resolveJsonModule": true,
+  "forceConsistentCasingInFileNames": true
 },

These additions will make the configuration more robust and explicit, potentially preventing future issues and improving developer experience.

📝 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
"compilerOptions": {
"composite": true,
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
"skipLibCheck": true,
"module": "ESNext",
"moduleResolution": "bundler",
"strict": true,
"noEmit": true
},
"compilerOptions": {
"composite": true,
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
"skipLibCheck": true,
"module": "ESNext",
"target": "ESNext",
"moduleResolution": "bundler",
"strict": true,
"noEmit": true,
"esModuleInterop": true,
"resolveJsonModule": true,
"forceConsistentCasingInFileNames": true
},

Comment on lines +1 to +4
import { writable, derived } from "svelte/store";
import { type SetupResult } from "./dojo/setup";
import { Account } from "starknet";
import { type Burner } from "@dojoengine/create-burner";
Copy link

Choose a reason for hiding this comment

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

💡 Codebase verification

Remove unused derived import.

  • The derived import from "svelte/store" is not used in this file.
🔗 Analysis chain

Remove unused import and verify local module.

  1. The derived import from 'svelte/store' is not used in this file. Consider removing it to keep the imports clean.
  2. The import from './dojo/setup' uses a relative path. Please ensure that this local module exists and is correctly located.

To verify the local module and check for unused imports, run the following script:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify local module existence and check for unused imports

# Test 1: Check if the local module exists
echo "Checking for local module 'dojo/setup'..."
fd --type file --glob '*setup.{ts,js}' src/dojo

# Test 2: Check for unused imports
echo "Checking for unused imports..."
rg --type typescript 'derived' examples/example-vite-svelte-recs/src/stores.ts

Length of output: 429


Script:

#!/bin/bash
# Description: Re-verify local module existence and check for unused imports

# Test 1: Check if the local module 'dojo/setup' exists anywhere in the repository
echo "Re-checking for local module 'dojo/setup' across the repository..."
fd --type file --glob 'setup.{ts,js}'

# Test 2: Check for unused 'derived' import by searching its usage in TypeScript and JavaScript files
echo "Re-checking for unused 'derived' imports in TypeScript and JavaScript files..."
rg 'derived' --type-add 'custom=*.ts,*.js' --type custom examples/example-vite-svelte-recs/src/stores.ts

Length of output: 950


Script:

#!/bin/bash
# Description: Re-verify local module existence and check for unused imports with corrected rg syntax

# Test 1: Check if the local module 'dojo/setup' exists anywhere in the repository
echo "Re-checking for local module 'dojo/setup' across the repository..."
fd --type file --glob 'setup.{ts,js}'

# Test 2: Check for unused 'derived' import by searching its usage in TypeScript and JavaScript files
echo "Re-checking for unused 'derived' imports in TypeScript and JavaScript files..."
rg 'derived' --type-add 'custom:*.ts,*.js' --type custom examples/example-vite-svelte-recs/src/stores.ts

Length of output: 940

Comment on lines +9 to +23
async function initApp() {
// Update the store with the setup result
let setupRes = await setup(dojoConfig)
dojoStore.set(setupRes);
burnerStore.set(setupRes.burnerManager.list());
accountStore.set(setupRes.burnerManager.getActiveAccount())

console.log("App initialized");

const app = new App({
target: document.getElementById("app")!,
});

return app;
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Enhance error handling and type safety in initApp function.

While the function logic is sound, there are opportunities to improve error handling and type safety:

  1. Add error handling for the asynchronous setup call.
  2. Use type assertions or checks for the DOM element.
  3. Consider adding return type annotation for better type inference.

Here's a suggested implementation with these improvements:

async function initApp(): Promise<App> {
  try {
    const setupRes = await setup(dojoConfig);
    dojoStore.set(setupRes);
    burnerStore.set(setupRes.burnerManager.list());
    accountStore.set(setupRes.burnerManager.getActiveAccount());

    console.log("App initialized");

    const appElement = document.getElementById("app");
    if (!appElement) {
      throw new Error("App element not found");
    }

    return new App({
      target: appElement,
    });
  } catch (error) {
    console.error("Failed to initialize app:", error);
    throw error;
  }
}

This implementation adds error handling, ensures the DOM element exists, and provides a return type for better type inference.

return app;
}

export default initApp();
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Revise the default export to avoid potential issues.

Exporting the result of an asynchronous function call as the default export can lead to unexpected behavior. The current implementation might not work correctly in all scenarios, especially when other modules try to import and use this module.

Consider changing the export to the function itself:

export default initApp;

This allows the importing module to decide when and how to call the initialization function. If automatic initialization is desired, you could use a separate file or add an event listener for DOMContentLoaded:

document.addEventListener('DOMContentLoaded', () => {
  initApp().catch(console.error);
});

This approach provides more flexibility and ensures that the DOM is ready before initializing the app.

Comment on lines +95 to +96
x: Number;
y: Number;
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Use lowercase number in Vec2 interface

In the Vec2 interface, the properties x and y are typed as Number. Replace them with the lowercase primitive type number.

Apply the following changes:

 export interface Vec2 {
-  x: Number;
-  y: Number;
+  x: number;
+  y: number;
 }
📝 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
x: Number;
y: Number;
x: number;
y: number;
🧰 Tools
🪛 Biome

[error] 95-95: Don't use 'Number' as a type.

Use lowercase primitives for consistency.
Safe fix: Use 'number' instead

(lint/complexity/noBannedTypes)


[error] 96-96: Don't use 'Number' as a type.

Use lowercase primitives for consistency.
Safe fix: Use 'number' instead

(lint/complexity/noBannedTypes)


// Type definition for `dojo_starter::models::Position` struct
export interface Position {
player: BigInt;
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Use lowercase bigint in Position interface

The player property in the Position interface is typed as BigInt. Replace it with bigint.

Apply the following change:

 export interface Position {
-  player: BigInt;
   vec: Vec2;
+  player: bigint;
 }

Committable suggestion was skipped due to low confidence.

🧰 Tools
🪛 Biome

[error] 105-105: Don't use 'BigInt' as a type.

Use lowercase primitives for consistency.
Safe fix: Use 'bigint' instead

(lint/complexity/noBannedTypes)


// Type definition for `dojo_starter::systems::actions::actions::Moved` struct
export interface Moved {
player: BigInt;
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Use lowercase bigint in Moved interface

The player property in the Moved interface is typed as BigInt. Replace it with bigint.

Apply the following change:

 export interface Moved {
-  player: BigInt;
   direction: Direction;
+  player: bigint;
 }

Committable suggestion was skipped due to low confidence.

🧰 Tools
🪛 Biome

[error] 85-85: Don't use 'BigInt' as a type.

Use lowercase primitives for consistency.
Safe fix: Use 'bigint' instead

(lint/complexity/noBannedTypes)

world,
{
player: RecsType.BigInt,
direction: RecsType.String,
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Ensure consistent type for direction in Moved component

In the Moved component definition, direction is typed as RecsType.String, but in the Moved interface, it's typed as Direction. For consistency, consider updating direction to match the Direction type.

Apply the following change:

           {
             player: RecsType.BigInt,
-            direction: RecsType.String,
+            direction: DirectionDefinition,
           },

This ensures that the direction property accurately reflects the Direction enum type.

Committable suggestion was skipped due to low confidence.

{
player: RecsType.BigInt,
remaining: RecsType.Number,
last_direction: RecsType.String,
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Ensure consistent type for last_direction in Moves component

In the Moves component definition, last_direction is typed as RecsType.String, but in the Moves interface, it's typed as Direction, which is an enum. To maintain consistency and type safety, consider updating last_direction to match the Direction type.

Apply the following change:

           {
             player: RecsType.BigInt,
             remaining: RecsType.Number,
-            last_direction: RecsType.String,
+            last_direction: DirectionDefinition,
             can_move: RecsType.Boolean,
           },

Alternatively, if Direction should be serialized differently, ensure that both the interface and component definition are consistent.

Committable suggestion was skipped due to low confidence.

@ponderingdemocritus
Copy link
Contributor

can you re pnpm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants