diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 05fd3e9556..75263272f0 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -12,6 +12,8 @@ jobs: steps: - uses: actions/checkout@v2 - uses: oven-sh/setup-bun@v1 + - name: Install dependencies + run: bun link - name: Install dependencies run: bun install - name: Run Prettier diff --git a/bun.lockb b/bun.lockb index 94ad39aa44..ae458e1def 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/examples/dojo-starter b/examples/dojo-starter index 93978e0857..127220e3cd 160000 --- a/examples/dojo-starter +++ b/examples/dojo-starter @@ -1 +1 @@ -Subproject commit 93978e08574d444cda5e3189ac2bf57220dbf76c +Subproject commit 127220e3cd5ee635491112c941c8a46ed088778f diff --git a/examples/react-app/src/App.tsx b/examples/react-app/src/App.tsx index cc47b7acbc..94b8e2da26 100644 --- a/examples/react-app/src/App.tsx +++ b/examples/react-app/src/App.tsx @@ -62,7 +62,6 @@ function App() { }; useEffect(() => { - // Clear message after 3 seconds if (clipboardStatus.message) { const timer = setTimeout(() => { setClipboardStatus({ message: "", isError: false }); @@ -124,7 +123,7 @@ function App() {
-
+
-
+
-
+
diff --git a/examples/react-app/src/dojo/createSystemCalls.ts b/examples/react-app/src/dojo/createSystemCalls.ts index 429378ddaa..079e9797f6 100644 --- a/examples/react-app/src/dojo/createSystemCalls.ts +++ b/examples/react-app/src/dojo/createSystemCalls.ts @@ -67,7 +67,6 @@ export function createSystemCalls( player: BigInt(entityId), vec: updatePositionWithDirection( direction, - // currently recs does not support nested values so we use any here getComponentValue(Position, entityId) as any ).vec, }, diff --git a/packages/core/package.json b/packages/core/package.json index 08de4df185..f81c4ec164 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,6 +1,6 @@ { "name": "@dojoengine/core", - "version": "0.1.55", + "version": "0.1.56", "description": "Dojo engine core providers and types", "type": "module", "scripts": { diff --git a/packages/create-burner/package.json b/packages/create-burner/package.json index 342f3bca5f..08ff608b0b 100644 --- a/packages/create-burner/package.json +++ b/packages/create-burner/package.json @@ -1,6 +1,6 @@ { "name": "@dojoengine/create-burner", - "version": "0.1.55", + "version": "0.1.56", "description": "Useful hooks and functions to create a Starknet burner wallet", "source": "src/index.ts", "main": "dist/index.js", diff --git a/packages/create-dojo/bin/index.d.ts b/packages/create-dojo/bin/index.d.ts old mode 100644 new mode 100755 diff --git a/packages/create-dojo/bin/index.js.map b/packages/create-dojo/bin/index.js.map index e371ce8e82..4db620cf1f 100644 --- a/packages/create-dojo/bin/index.js.map +++ b/packages/create-dojo/bin/index.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/index.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport https from 'https';\nimport spawn from 'cross-spawn';\nimport path from \"path\";\nimport * as fs from \"fs\";\n\nimport { input, select } from '@inquirer/prompts';\n\nconst templates = [\n {\n value: 'react-app',\n description: 'React app using Dojo',\n },\n {\n value: 'react-phaser-example',\n description: 'React/Phaser app using Dojo',\n },\n]\n\nrun();\n\nasync function run() {\n\n try {\n const { template, projectName } = await prompt();\n\n // clone template using degit into projectName directory\n console.log(`Downloading ${template}...`)\n spawn.sync(\"npx\", [\"degit\", `dojoengine/dojo.js/examples/${template}`, `${projectName}`])\n\n // rewrite package.json\n await rewritePackageJson(projectName);\n\n // clone dojo-starter\n console.log(`Downloading dojo-starter...`)\n spawn.sync(\"npx\", [\"degit\", `dojoengine/dojo-starter`, `dojo-starter`])\n\n } catch (e: any) {\n console.log(e)\n }\n\n}\n\n\nasync function rewritePackageJson(projectName: string) {\n\n const packageJsonPath = path.join(process.cwd(), projectName, 'package.json');\n const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, \"utf-8\"));\n const latestVersion = await getLatestVersion();\n\n // rename using projectName\n packageJson.name = projectName;\n\n // rewrite all link:dojo-packages/packages/... with latest version\n for (let dep of Object.keys(packageJson.dependencies)) {\n if (dep.startsWith(\"@dojoengine\") && packageJson.dependencies[dep].startsWith(\"link:\")) {\n packageJson.dependencies[dep] = latestVersion\n }\n }\n\n fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));\n\n}\n\nasync function prompt(): Promise<{ template: string, projectName: string }> {\n\n const template = await select({\n message: 'Select a template',\n choices: templates\n });\n\n const projectName = await input({\n message: \"Project name \", validate: (input: string) => {\n if (/^([A-Za-z\\-\\_\\d])+$/.test(input)) return true;\n else return 'Project name may only include letters, numbers, underscores and hashes.';\n },\n default: template\n })\n\n return { template, projectName }\n\n}\n\nasync function getLatestVersion(): Promise {\n return new Promise((resolve, reject) => {\n https\n .get(\n 'https://registry.npmjs.org/-/package/@dojoengine/core/dist-tags',\n res => {\n if (res.statusCode === 200) {\n let body = '';\n res.on('data', data => (body += data));\n res.on('end', () => {\n resolve(JSON.parse(body).latest);\n });\n } else {\n reject();\n }\n }\n )\n .on('error', () => {\n reject();\n });\n });\n}"],"mappings":";;;AAEA,OAAO,WAAW;AAClB,OAAO,WAAW;AAClB,OAAO,UAAU;AACjB,YAAY,QAAQ;AAEpB,SAAS,OAAO,cAAc;AAE9B,IAAM,YAAY;AAAA,EACd;AAAA,IACI,OAAO;AAAA,IACP,aAAa;AAAA,EACjB;AAAA,EACA;AAAA,IACI,OAAO;AAAA,IACP,aAAa;AAAA,EACjB;AACJ;AAEA,IAAI;AAEJ,eAAe,MAAM;AAEjB,MAAI;AACA,UAAM,EAAE,UAAU,YAAY,IAAI,MAAM,OAAO;AAG/C,YAAQ,IAAI,eAAe,QAAQ,KAAK;AACxC,UAAM,KAAK,OAAO,CAAC,SAAS,+BAA+B,QAAQ,IAAI,GAAG,WAAW,EAAE,CAAC;AAGxF,UAAM,mBAAmB,WAAW;AAGpC,YAAQ,IAAI,6BAA6B;AACzC,UAAM,KAAK,OAAO,CAAC,SAAS,2BAA2B,cAAc,CAAC;AAAA,EAE1E,SAAS,GAAQ;AACb,YAAQ,IAAI,CAAC;AAAA,EACjB;AAEJ;AAGA,eAAe,mBAAmB,aAAqB;AAEnD,QAAM,kBA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/env node\n\nimport https from \"https\";\nimport spawn from \"cross-spawn\";\nimport path from \"path\";\nimport * as fs from \"fs\";\n\nimport { input, select } from \"@inquirer/prompts\";\n\nconst templates = [\n {\n value: \"react-app\",\n description: \"React app using Dojo\",\n },\n {\n value: \"react-phaser-example\",\n description: \"React/Phaser app using Dojo\",\n },\n];\n\nrun();\n\nasync function run() {\n try {\n const { template, projectName } = await prompt();\n\n // clone template using degit into projectName directory\n console.log(`Downloading ${template}...`);\n spawn.sync(\"npx\", [\n \"degit\",\n `dojoengine/dojo.js/examples/${template}`,\n `${projectName}`,\n ]);\n\n // rewrite package.json\n await rewritePackageJson(projectName);\n\n // clone dojo-starter\n console.log(`Downloading dojo-starter...`);\n spawn.sync(\"npx\", [\"degit\", `dojoengine/dojo-starter`, `dojo-starter`]);\n } catch (e: any) {\n console.log(e);\n }\n}\n\nasync function rewritePackageJson(projectName: string) {\n const packageJsonPath = path.join(\n process.cwd(),\n projectName,\n \"package.json\"\n );\n const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, \"utf-8\"));\n const latestVersion = await getLatestVersion();\n\n // rename using projectName\n packageJson.name = projectName;\n\n // rewrite all link:dojo-packages/packages/... with latest version\n for (let dep of Object.keys(packageJson.dependencies)) {\n if (\n dep.startsWith(\"@dojoengine\") &&\n packageJson.dependencies[dep].startsWith(\"link:\")\n ) {\n packageJson.dependencies[dep] = latestVersion;\n }\n }\n\n fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));\n}\n\nasync function prompt(): Promise<{ template: string; projectName: string }> {\n const template = await select({\n message: \"Select a template\",\n choices: templates,\n });\n\n const projectName = await input({\n message: \"Project name \",\n validate: (input: string) => {\n if (/^([A-Za-z\\-\\_\\d])+$/.test(input)) return true;\n else\n return \"Project name may only include letters, numbers, underscores and hashes.\";\n },\n default: template,\n });\n\n return { template, projectName };\n}\n\nasync function getLatestVersion(): Promise {\n return new Promise((resolve, reject) => {\n https\n .get(\n \"https://registry.npmjs.org/-/package/@dojoengine/core/dist-tags\",\n (res) => {\n if (res.statusCode === 200) {\n let body = \"\";\n res.on(\"data\", (data) => (body += data));\n res.on(\"end\", () => {\n resolve(JSON.parse(body).latest);\n });\n } else {\n reject();\n }\n }\n )\n .on(\"error\", () => {\n reject();\n });\n });\n}\n"],"mappings":";;;AAEA,OAAO,WAAW;AAClB,OAAO,WAAW;AAClB,OAAO,UAAU;AACjB,YAAY,QAAQ;AAEpB,SAAS,OAAO,cAAc;AAE9B,IAAM,YAAY;AAAA,EACd;AAAA,IACI,OAAO;AAAA,IACP,aAAa;AAAA,EACjB;AAAA,EACA;AAAA,IACI,OAAO;AAAA,IACP,aAAa;AAAA,EACjB;AACJ;AAEA,IAAI;AAEJ,eAAe,MAAM;AACjB,MAAI;AACA,UAAM,EAAE,UAAU,YAAY,IAAI,MAAM,OAAO;AAG/C,YAAQ,IAAI,eAAe,QAAQ,KAAK;AACxC,UAAM,KAAK,OAAO;AAAA,MACd;AAAA,MACA,+BAA+B,QAAQ;AAAA,MACvC,GAAG,WAAW;AAAA,IAClB,CAAC;AAGD,UAAM,mBAAmB,WAAW;AAGpC,YAAQ,IAAI,6BAA6B;AACzC,UAAM,KAAK,OAAO,CAAC,SAAS,2BAA2B,cAAc,CAAC;AAAA,EAC1E,SAAS,GAAQ;AACb,YAAQ,IAAI,CAAC;AAAA,EACjB;AACJ;AAEA,eAAe,mBAAmB,aAAqB;AACnD,QAAM,kBAAkB,KAAK;AAAA,IACzB,QAAQ,IAAI;AAAA,IACZ;AAAA,IACA;AAAA,EACJ;AACA,QAAM,cAAc,KAAK,MAAS,gBAAa,iBAAiB,OAAO,CAAC;AACxE,QAAM,gBAAgB,MAAM,iBAAiB;AAG7C,cAAY,OAAO;AAGnB,WAAS,OAAO,OAAO,KAAK,YAAY,YAAY,GAAG;AACnD,QACI,IAAI,WAAW,aAAa,KAC5B,YAAY,aAAa,GAAG,EAAE,WAAW,OAAO,GAClD;AACE,kBAAY,aAAa,GAAG,IAAI;AAAA,IACpC;AAAA,EACJ;AAEA,EAAG,iBAAc,iBAAiB,KAAK,UAAU,aAAa,MAAM,CAAC,CAAC;AAC1E;AAEA,eAAe,SAA6D;AACxE,QAAM,WAAW,MAAM,OAAO;AAAA,IAC1B,SAAS;AAAA,IACT,SAAS;AAAA,EACb,CAAC;AAED,QAAM,cAAc,MAAM,MAAM;AAAA,IAC5B,SAAS;AAAA,IACT,UAAU,CAACA,WAAkB;AACzB,UAAI,sBAAsB,KAAKA,MAAK;AAAG,eAAO;AAAA;AAE1C,eAAO;AAAA,IACf;AAAA,IACA,SAAS;AAAA,EACb,CAAC;AAED,SAAO,EAAE,UAAU,YAAY;AACnC;AAEA,eAAe,mBAAoC;AAC/C,SAAO,IAAI,QAAQ,CAAC,SAAS,WAAW;AACpC,UACK;AAAA,MACG;AAAA,MACA,CAAC,QAAQ;AACL,YAAI,IAAI,eAAe,KAAK;AACxB,cAAI,OAAO;AACX,cAAI,GAAG,QAAQ,CAAC,SAAU,QAAQ,IAAK;AACvC,cAAI,GAAG,OAAO,MAAM;AAChB,oBAAQ,KAAK,MAAM,IAAI,EAAE,MAAM;AAAA,UACnC,CAAC;AAAA,QACL,OAAO;AACH,iBAAO;AAAA,QACX;AAAA,MACJ;AAAA,IACJ,EACC,GAAG,SAAS,MAAM;AACf,aAAO;AAAA,IACX,CAAC;AAAA,EACT,CAAC;AACL;","names":["input"]} \ No newline at end of file diff --git a/packages/create-dojo/package.json b/packages/create-dojo/package.json index ea12d000e6..be6c95993f 100644 --- a/packages/create-dojo/package.json +++ b/packages/create-dojo/package.json @@ -1,6 +1,6 @@ { "name": "@dojoengine/create-dojo", - "version": "0.1.55", + "version": "0.1.56", "description": "Scaffold Dojo project from examples", "module": "index.ts", "main": "./bin/index.js", diff --git a/packages/react/package.json b/packages/react/package.json index cc7a5084c7..01f6fb33e5 100644 --- a/packages/react/package.json +++ b/packages/react/package.json @@ -1,6 +1,6 @@ { "name": "@dojoengine/react", - "version": "0.1.55", + "version": "0.1.56", "description": "Useful React hooks for Starknet", "source": "src/index.ts", "main": "dist/index.js", diff --git a/packages/react/src/useSync.ts b/packages/react/src/useSync.ts index f836bb6b1f..33b9d07f7a 100644 --- a/packages/react/src/useSync.ts +++ b/packages/react/src/useSync.ts @@ -26,7 +26,7 @@ export function useSync( [component.metadata?.name] ); - const keys_to_strings = useMemo( + const keysToStrings = useMemo( () => keys.map((key) => key.toString()), [keys] ); @@ -44,7 +44,7 @@ export function useSync( component.schema, await client.getModelValue( componentName as string, - keys_to_strings + keysToStrings ) ) as ComponentValue ); @@ -60,19 +60,4 @@ export function useSync( isMounted = false; }; }, [client]); - - useEffect(() => { - const entity = { - model: componentName as string, - keys: keys_to_strings, - }; - - client.addEntitiesToSync([entity]); - - return () => { - client.removeEntitiesToSync([entity]).catch((error) => { - console.error("Failed to remove entities on cleanup", error); - }); - }; - }, [client]); } diff --git a/packages/torii-client/package.json b/packages/torii-client/package.json index 21357285a4..83724463f0 100644 --- a/packages/torii-client/package.json +++ b/packages/torii-client/package.json @@ -1,6 +1,6 @@ { "name": "@dojoengine/torii-client", - "version": "0.1.55", + "version": "0.1.56", "description": "", "main": "dist/index.js", "type": "module", @@ -17,7 +17,7 @@ "author": "", "license": "MIT", "dependencies": { - "@dojoengine/torii-wasm": "^0.1.42", + "@dojoengine/torii-wasm": "../torii-wasm", "starknet": "5.19.5", "typescript": "^5.0.3" }, diff --git a/packages/torii-wasm/package.json b/packages/torii-wasm/package.json index a76c1eac20..c6d3043c40 100644 --- a/packages/torii-wasm/package.json +++ b/packages/torii-wasm/package.json @@ -1,6 +1,6 @@ { "name": "@dojoengine/torii-wasm", - "version": "0.1.55", + "version": "0.1.56", "description": "", "main": "./pkg/torii_client_wasm.js", "type": "module", diff --git a/packages/utils/package.json b/packages/utils/package.json index 4b35f5c959..073554377f 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -1,6 +1,6 @@ { "name": "@dojoengine/utils", - "version": "0.1.55", + "version": "0.1.56", "description": "Helpful Dojo Utils", "type": "module", "scripts": {