diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b6cdec7..b1b1fef 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,15 +22,10 @@ jobs: uses: CompeyDev/setup-rokit@v0.1.2 - name: Install dependencies - run: | - pnpm install - pnpm wally + run: pnpm install - name: Check code quality run: pnpm lint - - name: Run ESLint - run: pnpm eslint - - - name: Build model - run: rojo build -o charm.rbxm + - name: Build models + run: pnpm build diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a179663..84e6eea 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -16,10 +16,17 @@ jobs: - name: Install dependencies run: wally install - - name: Build model - run: rojo build -o charm.rbxm + - name: Build models + run: pnpm build - - uses: AButler/upload-release-assets@v3.0 + - name: Upload release assets + uses: AButler/upload-release-assets@v3.0 with: - files: "charm.rbxm" + files: "build/*" repo-token: ${{ secrets.GITHUB_TOKEN }} + + - name: Publish to NPM + run: pnpm --recursive publish --access public + + - name: Publish to Wally + run: pnpm --recursive publish:wally diff --git a/.gitignore b/.gitignore index 0c32205..d3bb80b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,11 +1,13 @@ /node_modules +/build /devpackages -/packages/**/node_modules -/packages/**/packages -/packages/**/wally.lock -/packages/**/README.md -/packages/**/LICENSE.md +/packages +/modules/**/node_modules +/modules/**/wally.lock +/modules/**/README.md +/modules/**/LICENSE.md /sourcemap.json *.tsbuildinfo *.tgz +*.rbxm .DS_Store diff --git a/.vscode/settings.json b/.vscode/settings.json index e6aa02a..055aea7 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,5 +1,4 @@ { "luau-lsp.sourcemap.rojoProjectFile": "dev.project.json", - "luau-lsp.types.definitionFiles": ["bin/testez.d.luau"], - "luau-lsp.completion.imports.requireStyle": "alwaysRelative" + "luau-lsp.types.definitionFiles": ["bin/testez.d.luau"] } diff --git a/bin/build.sh b/bin/build.sh new file mode 100644 index 0000000..ad9bd2d --- /dev/null +++ b/bin/build.sh @@ -0,0 +1,5 @@ +mkdir build +rojo build modules/charm -o build/charm.rbxm +rojo build modules/charm-sync -o build/charm-sync.rbxm +rojo build modules/react -o build/react-charm.rbxm +rojo build modules/vide -o build/vide-charm.rbxm diff --git a/bin/check.sh b/bin/check.sh index e388fe8..1da42e0 100644 --- a/bin/check.sh +++ b/bin/check.sh @@ -2,17 +2,24 @@ curl -o bin/roblox.d.luau https://raw.githubusercontent.com/JohnnyMorganz/luau-l rojo sourcemap dev.project.json -o sourcemap.json -luau-lsp analyze \ - --defs=bin/roblox.d.luau \ - --defs=bin/testez.d.luau \ - --flag:LuauFixIndexerSubtypingOrdering=true \ - --flag:LuauInstantiateInSubtyping=true \ - --flag:LuauTinyControlFlowAnalysis=true \ - --sourcemap=sourcemap.json \ - --ignore="**/_Index/**" src +check() { + echo "Checking $1" -selene src -stylua --check src -eslint src + luau-lsp analyze \ + --defs=bin/roblox.d.luau \ + --defs=bin/testez.d.luau \ + --flag:LuauFixIndexerSubtypingOrdering=true \ + --flag:LuauInstantiateInSubtyping=true \ + --sourcemap=sourcemap.json \ + --ignore="**/_Index/**" \ + $1 + + selene $1 + stylua --check $1 +} + +eslint modules +check modules/*/src +check tests rm bin/roblox.d.luau diff --git a/dev.project.json b/dev.project.json index 2114a90..e84174c 100644 --- a/dev.project.json +++ b/dev.project.json @@ -7,23 +7,23 @@ "DevPackages": { "$path": "DevPackages", "Charm": { - "$path": "packages/charm" + "$path": "modules/charm" }, "CharmSync": { - "$path": "packages/charm-sync" + "$path": "modules/charm-sync" }, "ReactCharm": { - "$path": "packages/react" + "$path": "modules/react" + }, + "VideCharm": { + "$path": "modules/vide" } } }, - "TestService": { - "$className": "TestService", - "$properties": { - "ExecuteWithStudioRun": true - }, + "ServerScriptService": { + "$className": "ServerScriptService", "Tests": { - "$path": "tests" + "$path": "Tests" } } } diff --git a/packages/charm-sync/.luaurc b/modules/charm-sync/.luaurc similarity index 100% rename from packages/charm-sync/.luaurc rename to modules/charm-sync/.luaurc diff --git a/packages/charm-sync/default.project.json b/modules/charm-sync/default.project.json similarity index 100% rename from packages/charm-sync/default.project.json rename to modules/charm-sync/default.project.json diff --git a/packages/charm-sync/package.json b/modules/charm-sync/package.json similarity index 91% rename from packages/charm-sync/package.json rename to modules/charm-sync/package.json index 6ac444d..69bb096 100644 --- a/packages/charm-sync/package.json +++ b/modules/charm-sync/package.json @@ -8,7 +8,7 @@ "types": "src/index.d.ts", "scripts": { "prepare": "cp ../../LICENSE.md . && cp ../../README.md .", - "wally:install": "wally install" + "publish:wally": "wally publish" }, "dependencies": { "@rbxts/charm": "workspace:*" diff --git a/packages/charm-sync/src/client.luau b/modules/charm-sync/src/client.luau similarity index 100% rename from packages/charm-sync/src/client.luau rename to modules/charm-sync/src/client.luau diff --git a/packages/charm-sync/src/index.d.ts b/modules/charm-sync/src/index.d.ts similarity index 100% rename from packages/charm-sync/src/index.d.ts rename to modules/charm-sync/src/index.d.ts diff --git a/packages/charm-sync/src/init.luau b/modules/charm-sync/src/init.luau similarity index 100% rename from packages/charm-sync/src/init.luau rename to modules/charm-sync/src/init.luau diff --git a/packages/charm-sync/src/interval.luau b/modules/charm-sync/src/interval.luau similarity index 100% rename from packages/charm-sync/src/interval.luau rename to modules/charm-sync/src/interval.luau diff --git a/packages/charm-sync/src/patch.luau b/modules/charm-sync/src/patch.luau similarity index 100% rename from packages/charm-sync/src/patch.luau rename to modules/charm-sync/src/patch.luau diff --git a/packages/charm-sync/src/server.luau b/modules/charm-sync/src/server.luau similarity index 100% rename from packages/charm-sync/src/server.luau rename to modules/charm-sync/src/server.luau diff --git a/packages/charm-sync/src/types.luau b/modules/charm-sync/src/types.luau similarity index 100% rename from packages/charm-sync/src/types.luau rename to modules/charm-sync/src/types.luau diff --git a/packages/charm-sync/src/validate.luau b/modules/charm-sync/src/validate.luau similarity index 100% rename from packages/charm-sync/src/validate.luau rename to modules/charm-sync/src/validate.luau diff --git a/packages/charm-sync/wally.toml b/modules/charm-sync/wally.toml similarity index 100% rename from packages/charm-sync/wally.toml rename to modules/charm-sync/wally.toml diff --git a/packages/charm/.luaurc b/modules/charm/.luaurc similarity index 100% rename from packages/charm/.luaurc rename to modules/charm/.luaurc diff --git a/packages/charm/default.project.json b/modules/charm/default.project.json similarity index 100% rename from packages/charm/default.project.json rename to modules/charm/default.project.json diff --git a/packages/charm/package.json b/modules/charm/package.json similarity index 89% rename from packages/charm/package.json rename to modules/charm/package.json index 650ca3c..772e860 100644 --- a/packages/charm/package.json +++ b/modules/charm/package.json @@ -8,6 +8,6 @@ "types": "src/index.d.ts", "scripts": { "prepare": "cp ../../LICENSE.md . && cp ../../README.md .", - "wally:install": "wally install" + "publish:wally": "wally publish" } } diff --git a/packages/charm/src/atom.luau b/modules/charm/src/atom.luau similarity index 100% rename from packages/charm/src/atom.luau rename to modules/charm/src/atom.luau diff --git a/packages/charm/src/computed.luau b/modules/charm/src/computed.luau similarity index 100% rename from packages/charm/src/computed.luau rename to modules/charm/src/computed.luau diff --git a/packages/charm/src/effect.luau b/modules/charm/src/effect.luau similarity index 100% rename from packages/charm/src/effect.luau rename to modules/charm/src/effect.luau diff --git a/packages/charm/src/index.d.ts b/modules/charm/src/index.d.ts similarity index 100% rename from packages/charm/src/index.d.ts rename to modules/charm/src/index.d.ts diff --git a/packages/charm/src/init.luau b/modules/charm/src/init.luau similarity index 94% rename from packages/charm/src/init.luau rename to modules/charm/src/init.luau index a739a13..1cb6c02 100644 --- a/packages/charm/src/init.luau +++ b/modules/charm/src/init.luau @@ -1,5 +1,3 @@ -_G[script.modules.Promise] = _G[script] - local atom = require(script.atom) local computed = require(script.computed) local effect = require(script.effect) diff --git a/packages/charm/src/mapped.luau b/modules/charm/src/mapped.luau similarity index 100% rename from packages/charm/src/mapped.luau rename to modules/charm/src/mapped.luau diff --git a/packages/charm/src/observe.luau b/modules/charm/src/observe.luau similarity index 100% rename from packages/charm/src/observe.luau rename to modules/charm/src/observe.luau diff --git a/packages/charm/src/store.luau b/modules/charm/src/store.luau similarity index 100% rename from packages/charm/src/store.luau rename to modules/charm/src/store.luau diff --git a/packages/charm/src/subscribe.luau b/modules/charm/src/subscribe.luau similarity index 100% rename from packages/charm/src/subscribe.luau rename to modules/charm/src/subscribe.luau diff --git a/packages/charm/src/types.luau b/modules/charm/src/types.luau similarity index 100% rename from packages/charm/src/types.luau rename to modules/charm/src/types.luau diff --git a/packages/charm/wally.toml b/modules/charm/wally.toml similarity index 100% rename from packages/charm/wally.toml rename to modules/charm/wally.toml diff --git a/packages/react/.luaurc b/modules/react/.luaurc similarity index 100% rename from packages/react/.luaurc rename to modules/react/.luaurc diff --git a/packages/react/default.project.json b/modules/react/default.project.json similarity index 100% rename from packages/react/default.project.json rename to modules/react/default.project.json diff --git a/packages/react/package.json b/modules/react/package.json similarity index 80% rename from packages/react/package.json rename to modules/react/package.json index c8bcefc..07a43b6 100644 --- a/packages/react/package.json +++ b/modules/react/package.json @@ -8,9 +8,12 @@ "types": "src/index.d.ts", "scripts": { "prepare": "cp ../../LICENSE.md . && cp ../../README.md .", - "wally:install": "wally install" + "publish:wally": "wally publish" }, "dependencies": { "@rbxts/charm": "workspace:*" + }, + "peerDependencies": { + "@rbxts/react": "*" } } diff --git a/packages/react/src/index.d.ts b/modules/react/src/index.d.ts similarity index 100% rename from packages/react/src/index.d.ts rename to modules/react/src/index.d.ts diff --git a/packages/react/src/init.luau b/modules/react/src/init.luau similarity index 100% rename from packages/react/src/init.luau rename to modules/react/src/init.luau diff --git a/packages/react/wally.toml b/modules/react/wally.toml similarity index 100% rename from packages/react/wally.toml rename to modules/react/wally.toml diff --git a/modules/vide/.luaurc b/modules/vide/.luaurc new file mode 100644 index 0000000..e2b625c --- /dev/null +++ b/modules/vide/.luaurc @@ -0,0 +1,3 @@ +{ + "languageMode": "strict" +} diff --git a/modules/vide/default.project.json b/modules/vide/default.project.json new file mode 100644 index 0000000..e2a35ad --- /dev/null +++ b/modules/vide/default.project.json @@ -0,0 +1,6 @@ +{ + "name": "vide-charm", + "tree": { + "$path": "src" + } +} diff --git a/modules/vide/package.json b/modules/vide/package.json new file mode 100644 index 0000000..efb9c6c --- /dev/null +++ b/modules/vide/package.json @@ -0,0 +1,19 @@ +{ + "name": "@rbxts/vide-charm", + "version": "0.1.0", + "description": "Vide bindings for Charm", + "repository": "littensy/charm", + "license": "MIT", + "main": "src/init.luau", + "types": "src/index.d.ts", + "scripts": { + "prepare": "cp ../../LICENSE.md . && cp ../../README.md .", + "publish:wally": "wally publish" + }, + "dependencies": { + "@rbxts/charm": "workspace:*" + }, + "peerDependencies": { + "@rbxts/vide": "*" + } +} diff --git a/modules/vide/src/index.d.ts b/modules/vide/src/index.d.ts new file mode 100644 index 0000000..77e8612 --- /dev/null +++ b/modules/vide/src/index.d.ts @@ -0,0 +1,9 @@ +import { Molecule } from "@rbxts/charm"; + +/** + * Subscribes to the state of an atom and returns a Vide source. + * + * @param molecule The atom or molecule to subscribe to. + * @returns The reactive source. + */ +export function useAtom(atom: Molecule): () => T; diff --git a/modules/vide/src/init.luau b/modules/vide/src/init.luau new file mode 100644 index 0000000..7146559 --- /dev/null +++ b/modules/vide/src/init.luau @@ -0,0 +1,23 @@ +local Charm = require(script.Parent.Charm) +local Vide = require(script.Parent.Vide) + +--[=[ + Subscribes to the state of an atom and returns a Vide source. + + @param molecule The atom or molecule to subscribe to. + @return The reactive source. +]=] +local function useAtom(molecule: () -> State): State + local state = Vide.source(molecule()) + local unsubscribe = Charm.subscribe(molecule, function(value) + task.spawn(state, value) + end) + + Vide.cleanup(unsubscribe) + + return state +end + +return { + useAtom = useAtom, +} diff --git a/modules/vide/wally.toml b/modules/vide/wally.toml new file mode 100644 index 0000000..ca334cb --- /dev/null +++ b/modules/vide/wally.toml @@ -0,0 +1,7 @@ +[package] +name = "littensy/vide-charm" +version = "0.1.0" +registry = "https://github.com/UpliftGames/wally-index" +realm = "shared" + +[dependencies] diff --git a/package.json b/package.json index 36d7fc4..7b463ae 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,8 @@ "private": true, "scripts": { "lint": "sh bin/check.sh", - "wally:install": "pnpm recursive run wally:install && rojo sourcemap dev.project.json --output sourcemap.json" + "build": "sh bin/build.sh", + "wally": "wally install && rojo sourcemap dev.project.json --output sourcemap.json" }, "devDependencies": { "@rbxts/compiler-types": "3.0.0-types.0", @@ -15,6 +16,6 @@ "eslint-plugin-roblox-ts": "^0.0.36", "prettier": "^3.3.3", "roblox-ts": "^3.0.0", - "typescript": "^5.6.2" + "typescript": "^5.5.3" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 42e369a..67b1ccd 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -16,10 +16,10 @@ importers: version: 1.0.809 '@typescript-eslint/eslint-plugin': specifier: ^7.18.0 - version: 7.18.0(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.6.2))(eslint@8.57.1)(typescript@5.6.2) + version: 7.18.0(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.5.3))(eslint@8.57.1)(typescript@5.5.3) '@typescript-eslint/parser': specifier: ^7.18.0 - version: 7.18.0(eslint@8.57.1)(typescript@5.6.2) + version: 7.18.0(eslint@8.57.1)(typescript@5.5.3) eslint: specifier: ^8.57.1 version: 8.57.1 @@ -39,22 +39,34 @@ importers: specifier: ^3.0.0 version: 3.0.0 typescript: - specifier: ^5.6.2 - version: 5.6.2 + specifier: ^5.5.3 + version: 5.5.3 - packages/charm: {} + modules/charm: {} - packages/charm-sync: + modules/charm-sync: dependencies: '@rbxts/charm': specifier: workspace:* version: link:../charm - packages/react: + modules/react: dependencies: '@rbxts/charm': specifier: workspace:* version: link:../charm + '@rbxts/react': + specifier: '*' + version: 17.2.1 + + modules/vide: + dependencies: + '@rbxts/charm': + specifier: workspace:* + version: link:../charm + '@rbxts/vide': + specifier: '*' + version: 0.4.6 packages: @@ -108,9 +120,18 @@ packages: '@rbxts/compiler-types@3.0.0-types.0': resolution: {integrity: sha512-VGOHJPoL7+56NTatMGqQj3K7xWuzEV+aP4QD5vZiHu+bcff3kiTmtoadaF6NkJrmwfFAvbsd4Dg764ZjWNceag==} + '@rbxts/react-vendor@17.2.1': + resolution: {integrity: sha512-7DxFweCbhhso4M4tl1pO7Kil9SZrvOl1SoZ4lnwUfoxdHvSmWgeKgaUqd+ZS3/u1E8kRraqGQ56Q8zjUEEUzlA==} + + '@rbxts/react@17.2.1': + resolution: {integrity: sha512-iu0RsVvfHroI7l+QXjwE0FiWV2rXoKMxuznDZ8vnx2BsFqrPnCqFjXuNeGYZwibibZC6jbyq7uKl+/8cz7XlsA==} + '@rbxts/types@1.0.809': resolution: {integrity: sha512-COmNdE5VKq44tU1Sqbj0b70qDcUpBY1Uu5BhNb25v1yJATwcoVjsmYTyaxmRO4EVdqOATjOUBU2jbxZa4K83uw==} + '@rbxts/vide@0.4.6': + resolution: {integrity: sha512-xYtvCS05nGq1YU7fyQVmp4z1CcvuOR+VKpKj/Y7lFPvKobQ3oHTQEzZiJFEMZ+iSeHxwZhwpzVjrP+6+e2EoQw==} + '@roblox-ts/luau-ast@2.0.0': resolution: {integrity: sha512-cmMi093IdwBOLVxwuordhM8AmtbyTIyRpsTbB0D/JauidW4SXsQRQowSwWjHo4QP0DRJBXvOIlxtqEQi50uNzQ==} @@ -375,6 +396,7 @@ packages: eslint@8.57.1: resolution: {integrity: sha512-ypowyDxpVSYpkXr9WPv2PAZCtNip1Mv5KTW0SCurXv/9iOpcrH9PaqUElksqEB6pChqHGDRCFTyrZlGhnLNGiA==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} + deprecated: This version is no longer supported. Please see https://eslint.org/version-support for other options. hasBin: true espree@9.6.1: @@ -884,8 +906,16 @@ snapshots: '@rbxts/compiler-types@3.0.0-types.0': {} + '@rbxts/react-vendor@17.2.1': {} + + '@rbxts/react@17.2.1': + dependencies: + '@rbxts/react-vendor': 17.2.1 + '@rbxts/types@1.0.809': {} + '@rbxts/vide@0.4.6': {} + '@roblox-ts/luau-ast@2.0.0': {} '@roblox-ts/path-translator@1.1.0': @@ -906,21 +936,21 @@ snapshots: '@types/semver@7.5.8': {} - '@typescript-eslint/eslint-plugin@7.18.0(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.6.2))(eslint@8.57.1)(typescript@5.6.2)': + '@typescript-eslint/eslint-plugin@7.18.0(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.5.3))(eslint@8.57.1)(typescript@5.5.3)': dependencies: '@eslint-community/regexpp': 4.11.1 - '@typescript-eslint/parser': 7.18.0(eslint@8.57.1)(typescript@5.6.2) + '@typescript-eslint/parser': 7.18.0(eslint@8.57.1)(typescript@5.5.3) '@typescript-eslint/scope-manager': 7.18.0 - '@typescript-eslint/type-utils': 7.18.0(eslint@8.57.1)(typescript@5.6.2) - '@typescript-eslint/utils': 7.18.0(eslint@8.57.1)(typescript@5.6.2) + '@typescript-eslint/type-utils': 7.18.0(eslint@8.57.1)(typescript@5.5.3) + '@typescript-eslint/utils': 7.18.0(eslint@8.57.1)(typescript@5.5.3) '@typescript-eslint/visitor-keys': 7.18.0 eslint: 8.57.1 graphemer: 1.4.0 ignore: 5.3.2 natural-compare: 1.4.0 - ts-api-utils: 1.3.0(typescript@5.6.2) + ts-api-utils: 1.3.0(typescript@5.5.3) optionalDependencies: - typescript: 5.6.2 + typescript: 5.5.3 transitivePeerDependencies: - supports-color @@ -932,16 +962,16 @@ snapshots: - supports-color - typescript - '@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.6.2)': + '@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.5.3)': dependencies: '@typescript-eslint/scope-manager': 7.18.0 '@typescript-eslint/types': 7.18.0 - '@typescript-eslint/typescript-estree': 7.18.0(typescript@5.6.2) + '@typescript-eslint/typescript-estree': 7.18.0(typescript@5.5.3) '@typescript-eslint/visitor-keys': 7.18.0 debug: 4.3.7 eslint: 8.57.1 optionalDependencies: - typescript: 5.6.2 + typescript: 5.5.3 transitivePeerDependencies: - supports-color @@ -955,15 +985,15 @@ snapshots: '@typescript-eslint/types': 7.18.0 '@typescript-eslint/visitor-keys': 7.18.0 - '@typescript-eslint/type-utils@7.18.0(eslint@8.57.1)(typescript@5.6.2)': + '@typescript-eslint/type-utils@7.18.0(eslint@8.57.1)(typescript@5.5.3)': dependencies: - '@typescript-eslint/typescript-estree': 7.18.0(typescript@5.6.2) - '@typescript-eslint/utils': 7.18.0(eslint@8.57.1)(typescript@5.6.2) + '@typescript-eslint/typescript-estree': 7.18.0(typescript@5.5.3) + '@typescript-eslint/utils': 7.18.0(eslint@8.57.1)(typescript@5.5.3) debug: 4.3.7 eslint: 8.57.1 - ts-api-utils: 1.3.0(typescript@5.6.2) + ts-api-utils: 1.3.0(typescript@5.5.3) optionalDependencies: - typescript: 5.6.2 + typescript: 5.5.3 transitivePeerDependencies: - supports-color @@ -985,7 +1015,7 @@ snapshots: transitivePeerDependencies: - supports-color - '@typescript-eslint/typescript-estree@7.18.0(typescript@5.6.2)': + '@typescript-eslint/typescript-estree@7.18.0(typescript@5.5.3)': dependencies: '@typescript-eslint/types': 7.18.0 '@typescript-eslint/visitor-keys': 7.18.0 @@ -994,9 +1024,9 @@ snapshots: is-glob: 4.0.3 minimatch: 9.0.5 semver: 7.6.3 - ts-api-utils: 1.3.0(typescript@5.6.2) + ts-api-utils: 1.3.0(typescript@5.5.3) optionalDependencies: - typescript: 5.6.2 + typescript: 5.5.3 transitivePeerDependencies: - supports-color @@ -1015,12 +1045,12 @@ snapshots: - supports-color - typescript - '@typescript-eslint/utils@7.18.0(eslint@8.57.1)(typescript@5.6.2)': + '@typescript-eslint/utils@7.18.0(eslint@8.57.1)(typescript@5.5.3)': dependencies: '@eslint-community/eslint-utils': 4.4.0(eslint@8.57.1) '@typescript-eslint/scope-manager': 7.18.0 '@typescript-eslint/types': 7.18.0 - '@typescript-eslint/typescript-estree': 7.18.0(typescript@5.6.2) + '@typescript-eslint/typescript-estree': 7.18.0(typescript@5.5.3) eslint: 8.57.1 transitivePeerDependencies: - supports-color @@ -1564,9 +1594,9 @@ snapshots: dependencies: is-number: 7.0.0 - ts-api-utils@1.3.0(typescript@5.6.2): + ts-api-utils@1.3.0(typescript@5.5.3): dependencies: - typescript: 5.6.2 + typescript: 5.5.3 tslib@1.14.1: {} diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index 924b55f..01be5ca 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -1,2 +1,2 @@ packages: - - packages/* + - modules/* diff --git a/testez-companion.toml b/testez-companion.toml index 011658d..204e049 100644 --- a/testez-companion.toml +++ b/testez-companion.toml @@ -1 +1 @@ -roots = ["TestService/Tests"] +roots = ["ServerScriptService/Tests"] diff --git a/tests/charm-sync/init.spec.luau b/tests/charm-sync/init.spec.luau index b8dbfd0..21a24c0 100644 --- a/tests/charm-sync/init.spec.luau +++ b/tests/charm-sync/init.spec.luau @@ -3,14 +3,12 @@ local ReplicatedStorage = game:GetService("ReplicatedStorage") local store = require(ReplicatedStorage.DevPackages.Charm.store) return function() - local previous = _G.__DEV__ - beforeAll(function() _G.__DEV__ = true end) afterAll(function() - _G.__DEV__ = previous + _G.__DEV__ = nil end) afterEach(function() diff --git a/tests/charm-sync/patch.spec.luau b/tests/charm-sync/patch.spec.luau index 176b694..5128954 100644 --- a/tests/charm-sync/patch.spec.luau +++ b/tests/charm-sync/patch.spec.luau @@ -79,7 +79,7 @@ return function() local patches = serdes(patch.diff(prevState, nextState)) local applied = patch.apply(prevState, patches) - assert(os.clock() - start < 1e-3, `Performance is not acceptable ({(os.clock() - start) * 1e3}ms)`) + assert(os.clock() - start < 10e-3, `Performance is not acceptable ({(os.clock() - start) * 1e3}ms)`) for index in next, prevState do expect(applied[index]).to.equal(nextState[index]) diff --git a/tests/charm/init.spec.luau b/tests/charm/init.spec.luau index f46b3cc..21a24c0 100644 --- a/tests/charm/init.spec.luau +++ b/tests/charm/init.spec.luau @@ -1,17 +1,14 @@ local ReplicatedStorage = game:GetService("ReplicatedStorage") -local Charm = require(ReplicatedStorage.DevPackages.Charm) -local store = Charm.store +local store = require(ReplicatedStorage.DevPackages.Charm.store) return function() - local previous = _G.__DEV__ - beforeAll(function() _G.__DEV__ = true end) afterAll(function() - _G.__DEV__ = previous + _G.__DEV__ = nil end) afterEach(function() diff --git a/tests/init.server.luau b/tests/init.server.luau index 6c529d8..f2d4789 100644 --- a/tests/init.server.luau +++ b/tests/init.server.luau @@ -2,4 +2,4 @@ local ReplicatedStorage = game:GetService("ReplicatedStorage") local TestEZ = require(ReplicatedStorage.DevPackages.TestEZ) -TestEZ.TestBootstrap:run({ script }, TestEZ.Reporters.TextReporter) +TestEZ.TestBootstrap:run({ script.Parent }, TestEZ.Reporters.TextReporter) diff --git a/tests/react/useAtom.spec.luau b/tests/react/useAtom.spec.luau index 7971f11..bb94715 100644 --- a/tests/react/useAtom.spec.luau +++ b/tests/react/useAtom.spec.luau @@ -8,39 +8,39 @@ local renderHook = require(script.Parent.Parent.utils.renderHook) return function() it("tracks atom state", function() - local source = atom(0) + local state = atom(0) local hook = renderHook(function() - return useAtom(source) + return useAtom(state) end) expect(hook.result).to.equal(0) - source(1) + state(1) expect(hook.result).to.equal(1) end) it("accepts a molecule", function() - local source = atom(0) + local state = atom(0) local hook = renderHook(function() return useAtom(function() - return 2 * source() + return 2 * state() end) end) expect(hook.result).to.equal(0) - source(1) + state(1) expect(hook.result).to.equal(2) end) it("tracks dependencies", function() - local source = atom(0) + local state = atom(0) local hook = renderHook(function() - return useAtom(source, { source }) + return useAtom(state, { state }) end) expect(hook.result).to.equal(0) - source(1) + state(1) expect(hook.result).to.equal(1) - source = atom(0) + state = atom(0) hook.rerender() expect(hook.result).to.equal(0) - source(1) + state(1) expect(hook.result).to.equal(1) end) end diff --git a/tests/vide/useAtom.spec.luau b/tests/vide/useAtom.spec.luau new file mode 100644 index 0000000..6b8c66a --- /dev/null +++ b/tests/vide/useAtom.spec.luau @@ -0,0 +1,36 @@ +local ReplicatedStorage = game:GetService("ReplicatedStorage") + +local Charm = require(ReplicatedStorage.DevPackages.Charm) +local atom = Charm.atom +local Vide = require(ReplicatedStorage.DevPackages.Vide) +local root = Vide.root +local VideCharm = require(ReplicatedStorage.DevPackages.VideCharm) +local useAtom = VideCharm.useAtom + +return function() + it("tracks atom state", function() + local state = atom(0) + local source + local cleanup = root(function() + source = useAtom(state) + end) + expect(source()).to.equal(0) + state(1) + expect(source()).to.equal(1) + cleanup() + end) + + it("accepts a molecule", function() + local state = atom(0) + local source + local cleanup = root(function() + source = useAtom(function() + return 2 * state() + end) + end) + expect(source()).to.equal(0) + state(1) + expect(source()).to.equal(2) + cleanup() + end) +end diff --git a/tsconfig.json b/tsconfig.json index 9da93c3..c48a682 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -18,7 +18,7 @@ "typeRoots": ["node_modules/@rbxts"], // configurable - "rootDir": "packages", + "rootDir": "modules", "outDir": "out", "incremental": true, "tsBuildInfoFile": "out/tsconfig.tsbuildinfo", diff --git a/wally.lock b/wally.lock index 441e222..c7a5a63 100644 --- a/wally.lock +++ b/wally.lock @@ -2,6 +2,11 @@ # It is not intended for manual editing. registry = "test" +[[package]] +name = "centau/vide" +version = "0.3.1" +dependencies = [] + [[package]] name = "jsdotlua/boolean" version = "1.2.6" @@ -49,27 +54,27 @@ dependencies = [] [[package]] name = "jsdotlua/react" -version = "17.1.0" -dependencies = [["luau-polyfill", "jsdotlua/luau-polyfill@1.2.6"], ["shared", "jsdotlua/shared@17.1.0"]] +version = "17.2.0" +dependencies = [["luau-polyfill", "jsdotlua/luau-polyfill@1.2.6"], ["shared", "jsdotlua/shared@17.2.0"]] [[package]] name = "jsdotlua/react-reconciler" -version = "17.1.0" -dependencies = [["luau-polyfill", "jsdotlua/luau-polyfill@1.2.6"], ["promise", "jsdotlua/promise@3.5.2"], ["react", "jsdotlua/react@17.1.0"], ["scheduler", "jsdotlua/scheduler@17.1.0"], ["shared", "jsdotlua/shared@17.1.0"]] +version = "17.2.0" +dependencies = [["luau-polyfill", "jsdotlua/luau-polyfill@1.2.6"], ["promise", "jsdotlua/promise@3.5.2"], ["react", "jsdotlua/react@17.2.0"], ["scheduler", "jsdotlua/scheduler@17.2.0"], ["shared", "jsdotlua/shared@17.2.0"]] [[package]] name = "jsdotlua/react-roblox" -version = "17.1.0" -dependencies = [["luau-polyfill", "jsdotlua/luau-polyfill@1.2.6"], ["react", "jsdotlua/react@17.1.0"], ["react-reconciler", "jsdotlua/react-reconciler@17.1.0"], ["scheduler", "jsdotlua/scheduler@17.1.0"], ["shared", "jsdotlua/shared@17.1.0"]] +version = "17.2.0" +dependencies = [["luau-polyfill", "jsdotlua/luau-polyfill@1.2.6"], ["react", "jsdotlua/react@17.2.0"], ["react-reconciler", "jsdotlua/react-reconciler@17.2.0"], ["scheduler", "jsdotlua/scheduler@17.2.0"], ["shared", "jsdotlua/shared@17.2.0"]] [[package]] name = "jsdotlua/scheduler" -version = "17.1.0" -dependencies = [["luau-polyfill", "jsdotlua/luau-polyfill@1.2.6"], ["shared", "jsdotlua/shared@17.1.0"]] +version = "17.2.0" +dependencies = [["luau-polyfill", "jsdotlua/luau-polyfill@1.2.6"], ["shared", "jsdotlua/shared@17.2.0"]] [[package]] name = "jsdotlua/shared" -version = "17.1.0" +version = "17.2.0" dependencies = [["luau-polyfill", "jsdotlua/luau-polyfill@1.2.6"]] [[package]] @@ -90,7 +95,7 @@ dependencies = [["collections", "jsdotlua/collections@1.2.6"]] [[package]] name = "littensy/charm" version = "0.1.0" -dependencies = [["React", "jsdotlua/react@17.1.0"], ["ReactRoblox", "jsdotlua/react-roblox@17.1.0"], ["TestEZ", "roblox/testez@0.4.1"]] +dependencies = [["React", "jsdotlua/react@17.2.0"], ["ReactRoblox", "jsdotlua/react-roblox@17.2.0"], ["TestEZ", "roblox/testez@0.4.1"], ["Vide", "centau/vide@0.3.1"]] [[package]] name = "roblox/testez" diff --git a/wally.toml b/wally.toml index 3db5b68..096ab3f 100644 --- a/wally.toml +++ b/wally.toml @@ -5,6 +5,7 @@ registry = "https://github.com/UpliftGames/wally-index" realm = "shared" [dev-dependencies] -React = "jsdotlua/react@17.1.0" -ReactRoblox = "jsdotlua/react-roblox@17.1.0" +React = "jsdotlua/react@17.2.0" +ReactRoblox = "jsdotlua/react-roblox@17.2.0" TestEZ = "roblox/testez@0.4.1" +Vide = "centau/vide@0.3.1"