From 0f2007de2c0d3440f43eac01a06815ac596ef3eb Mon Sep 17 00:00:00 2001 From: Ketan Reddy Date: Wed, 17 Jul 2024 13:13:30 -0700 Subject: [PATCH 01/10] fix storybook builds --- docs/storybook/.storybook/main.ts | 2 +- docs/storybook/BUILD | 1 + .../src/reference-assets/Action.stories.tsx | 30 ++++++++----------- package.json | 1 + pnpm-lock.yaml | 16 ++++++++++ 5 files changed, 31 insertions(+), 19 deletions(-) diff --git a/docs/storybook/.storybook/main.ts b/docs/storybook/.storybook/main.ts index 5e86cd2aa..a78439edb 100644 --- a/docs/storybook/.storybook/main.ts +++ b/docs/storybook/.storybook/main.ts @@ -3,7 +3,7 @@ import path from "path"; const config: StorybookConfig = { stories: ["../src/**/*.@(stories.@(js|tsx|ts))", "../src/**/*.mdx"], - addons: ["@storybook/addon-docs", "@player-ui/storybook-addon-player"], + addons: ["@storybook/addon-docs", "@player-ui/storybook-addon-player", "@storybook/addon-webpack5-compiler-babel"], typescript: { reactDocgen: false, }, diff --git a/docs/storybook/BUILD b/docs/storybook/BUILD index 0caa5bfb3..8c2f33c0a 100644 --- a/docs/storybook/BUILD +++ b/docs/storybook/BUILD @@ -37,6 +37,7 @@ deps = [ "//:node_modules/raw-loader", "//:node_modules/react", "//:node_modules/react-dom", + "//:node_modules/@storybook/addon-webpack5-compiler-babel", "//:typings", "tsconfig.json", "package.json", diff --git a/docs/storybook/src/reference-assets/Action.stories.tsx b/docs/storybook/src/reference-assets/Action.stories.tsx index 47917d32f..471b07634 100644 --- a/docs/storybook/src/reference-assets/Action.stories.tsx +++ b/docs/storybook/src/reference-assets/Action.stories.tsx @@ -1,5 +1,5 @@ import type { Meta } from "@storybook/react"; -import { createDSLStory } from "@player-ui/storybook-addon-player"; +import { createDSLStory, PlayerStory } from "@player-ui/storybook-addon-player"; import { Action } from "@player-ui/reference-assets-plugin-react"; const meta: Meta = { @@ -10,29 +10,23 @@ const meta: Meta = { export default meta; export const Basic = createDSLStory( - () => - import( - "!!raw-loader!@player-ui/mocks/action/action-basic.tsx" - ), + () => import("!!raw-loader!@player-ui/mocks/action/action-basic.tsx"), ); export const Expression = createDSLStory( - () => - import( - "!!raw-loader!@player-ui/mocks/action/action-counter.tsx" - ), + () => import("!!raw-loader!@player-ui/mocks/action/action-counter.tsx"), ); export const Navigation = createDSLStory( - () => - import( - "!!raw-loader!@player-ui/mocks/action/action-navigation.tsx" - ), + () => import("!!raw-loader!@player-ui/mocks/action/action-navigation.tsx"), ); -export const TransitionToEnd = createDSLStory( - () => - import( - "!!raw-loader!@player-ui/mocks/action/action-transition-to-end.tsx" - ), +export const TransitionToEnd = () => ( + + import( + "@player-ui/mocks/action/action-transition-to-end.json" + ) + } + /> ); diff --git a/package.json b/package.json index f0afeaa27..2492a4ab6 100644 --- a/package.json +++ b/package.json @@ -46,6 +46,7 @@ "@radix-ui/react-slot": "^1.0.2", "@reduxjs/toolkit": "^1.9.5", "@storybook/addon-docs": "^7.6.10", + "@storybook/addon-webpack5-compiler-babel": "^3.0.3", "@storybook/builder-vite": "^7.6.10", "@storybook/channels": "^7.6.10", "@storybook/components": "^7.6.10", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 8a7ff0cc0..76c9a902d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -93,6 +93,9 @@ importers: '@storybook/addon-docs': specifier: ^7.6.10 version: 7.6.19(@types/react-dom@18.3.0)(@types/react@18.3.2)(react-dom@18.3.1)(react@18.3.1) + '@storybook/addon-webpack5-compiler-babel': + specifier: ^3.0.3 + version: 3.0.3(webpack@5.91.0) '@storybook/builder-vite': specifier: ^7.6.10 version: 7.6.19(typescript@5.3.2)(vite@4.5.3) @@ -527,6 +530,8 @@ importers: core/types: {} + docs/package: {} + docs/site: dependencies: '@player-ui/asset-provider-plugin-react': @@ -6278,6 +6283,17 @@ packages: - supports-color dev: false + /@storybook/addon-webpack5-compiler-babel@3.0.3(webpack@5.91.0): + resolution: {integrity: sha512-rVQTTw+oxJltbVKaejIWSHwVKOBJs3au21f/pYXhV0aiNgNhxEa3vr79t/j0j8ox8uJtzM8XYOb7FlkvGfHlwQ==, tarball: https://registry.npmjs.org/@storybook/addon-webpack5-compiler-babel/-/addon-webpack5-compiler-babel-3.0.3.tgz} + engines: {node: '>=18'} + dependencies: + '@babel/core': 7.24.5 + babel-loader: 9.1.3(@babel/core@7.24.5)(webpack@5.91.0) + transitivePeerDependencies: + - supports-color + - webpack + dev: false + /@storybook/blocks@7.6.19(@types/react-dom@18.3.0)(@types/react@18.3.2)(react-dom@18.3.1)(react@18.3.1): resolution: {integrity: sha512-/c/bVQRmyRPoviJhPrFdLfubRcrnZWTwkjxsCvrOTJ/UDOyEl0t/H8yY1mGq7KWWTdbIznnZWhAIofHnH4/Esw==, tarball: https://registry.npmjs.org/@storybook/blocks/-/blocks-7.6.19.tgz} peerDependencies: From 59934f0e4046e796d22ca31630e9419e0b3d4315 Mon Sep 17 00:00:00 2001 From: marky ercillo Date: Tue, 23 Jul 2024 09:56:11 -0700 Subject: [PATCH 02/10] WIP --- MODULE.bazel | 15 ++++++++------- Package.resolved | 16 ++++++++++++++++ WORKSPACE | 1 + WORKSPACE.bzlmod | 2 +- docs/BUILD | 28 ++++++++++++++-------------- docs/site/BUILD | 4 ++++ 6 files changed, 44 insertions(+), 22 deletions(-) create mode 100644 Package.resolved diff --git a/MODULE.bazel b/MODULE.bazel index 91032e69f..fd6352d05 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -5,13 +5,13 @@ module( bazel_dep(name = "rules_player") -archive_override( - module_name = "rules_player", - strip_prefix = "rules_player-1.0.0", - urls = ["https://github.com/player-ui/rules_player/archive/refs/tags/v1.0.0.tar.gz"], - integrity = "sha256-08MFpLzTnmwrIZhvE1cBL21cSqmjXzD6SH2HhTf8hR4=" -) -#local_path_override(module_name = "rules_player", path = "../rules_player") +# archive_override( +# module_name = "rules_player", +# strip_prefix = "rules_player-1.0.0", +# urls = ["https://github.com/player-ui/rules_player/archive/refs/tags/v1.0.0.tar.gz"], +# integrity = "sha256-08MFpLzTnmwrIZhvE1cBL21cSqmjXzD6SH2HhTf8hR4=" +# ) +local_path_override(module_name = "rules_player", path = "/Users/mercillo/Documents/Intuit/PlayerOS/rules_playerSSH/rules_player") bazel_dep(name = "aspect_bazel_lib", version = "1.39.0") bazel_dep(name = "aspect_rules_js", version = "1.34.1") @@ -19,6 +19,7 @@ bazel_dep(name = "bazel_skylib", version = "1.4.2") bazel_dep(name = "rules_pkg", version = "0.9.1") bazel_dep(name = "aspect_rules_ts", version = "2.1.0") + ####### Node.js version ######### bazel_dep(name = "rules_nodejs", version = "6.0.2") diff --git a/Package.resolved b/Package.resolved new file mode 100644 index 000000000..1aa7b5441 --- /dev/null +++ b/Package.resolved @@ -0,0 +1,16 @@ +{ + "object": { + "pins": [ + { + "package": "SwiftHooks", + "repositoryURL": "https://github.com/intuit/swift-hooks.git", + "state": { + "branch": null, + "revision": "5f3136ac2a3c27aa469e3f9a1222b15080d431d3", + "version": "0.1.0" + } + } + ] + }, + "version": 1 +} diff --git a/WORKSPACE b/WORKSPACE index 2e2014f5b..e82c08e7e 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -1 +1,2 @@ workspace(name = "player") + diff --git a/WORKSPACE.bzlmod b/WORKSPACE.bzlmod index 6aceca001..d2991a414 100644 --- a/WORKSPACE.bzlmod +++ b/WORKSPACE.bzlmod @@ -35,4 +35,4 @@ http_file( name = "android_test_services_apk", sha256 = "c6bc74268b29bdabad8da962e00e2f6fd613c24b42c69e81b258397b4819f156", url = "https://dl.google.com/android/maven2/androidx/test/services/test-services/1.4.2/test-services-1.4.2.apk" -) \ No newline at end of file +) diff --git a/docs/BUILD b/docs/BUILD index 071ea2954..28ea965b1 100644 --- a/docs/BUILD +++ b/docs/BUILD @@ -1,12 +1,13 @@ load("@bazel_tools//tools/build_defs/pkg:pkg.bzl", "pkg_tar") -# load("@rules_player//distribution/tar:stamp_tar_files.bzl", "stamp_tar_files") -# load("@rules_player//gh-pages:index.bzl", "gh_pages") +load("@rules_player//distribution/tar:stamp_tar_files.bzl", "stamp_tar_files") + + +load("@bazel_tools//tools/build_defs/pkg:pkg.bzl", "pkg_tar") genrule( name = "full_site", srcs = [ "//docs/site", - "//docs/storybook" ], outs = [ "merged_site.tar.gz" @@ -15,22 +16,21 @@ genrule( tmp_dir=$$(mktemp -d) && touch $$tmp_dir/.nojekyll && cp -LR $(location //docs/site)/** $$tmp_dir && - mkdir $$tmp_dir/storybook-demo && - cp -LR $(location //docs/storybook)/** $$tmp_dir/storybook-demo && chmod -R u+rwX,a+rX $$tmp_dir && tar -czhf $@ -C $$tmp_dir . """ ) -#stamp_tar_files( -# name = "full_site_stamped", -# tar = ":full_site", -# substitutions = { -# "NEXT_PUBLIC_GA_MEASUREMENT_ID": "{STABLE_GA_MEASUREMENT_ID}", -# "DOCS_BASE_PATH": "{STABLE_DOCS_BASE_PATH}", -# "ALGOLIA_SEARCH_API_KEY": "{STABLE_ALGOLIA_SEARCH_API_KEY}", -# }, -#) + +stamp_tar_files( + name = "full_site_stamped", + tar = ":full_site", + substitutions = { + "NEXT_PUBLIC_GA_MEASUREMENT_ID": "{STABLE_GA_MEASUREMENT_ID}", + "DOCS_BASE_PATH": "{STABLE_DOCS_BASE_PATH}", + "ALGOLIA_SEARCH_API_KEY": "{STABLE_ALGOLIA_SEARCH_API_KEY}", + } +) #gh_pages( # name="deploy_docs", diff --git a/docs/site/BUILD b/docs/site/BUILD index 2e6653356..8ad99f7b8 100644 --- a/docs/site/BUILD +++ b/docs/site/BUILD @@ -1,11 +1,15 @@ load("@npm//:defs.bzl", "npm_link_all_packages") load("@npm//:webpack-cli/package_json.bzl", webpack_bin = "bin") load("@npm//:webpack-dev-server/package_json.bzl", webpack_dev_server_bin = "bin") +# load("@build_bazel_rules_nodejs//toolchains/esbuild:esbuild_repositories.bzl", "esbuild_repositories") +# load("@aspect_rules_esbuild//esbuild/private:esbuild.bzl", "esbuild_bundle") + npm_link_all_packages( name = "node_modules", ) + srcs = glob([ "public/**/*", "pages/**/*", From 4f1f61ebcb2c44b84da59c7f33ead5bfc0d70621 Mon Sep 17 00:00:00 2001 From: marky ercillo Date: Tue, 23 Jul 2024 13:02:28 -0700 Subject: [PATCH 03/10] almost working; need to output correct file --- docs/BUILD | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/BUILD b/docs/BUILD index 28ea965b1..a14961557 100644 --- a/docs/BUILD +++ b/docs/BUILD @@ -29,7 +29,7 @@ stamp_tar_files( "NEXT_PUBLIC_GA_MEASUREMENT_ID": "{STABLE_GA_MEASUREMENT_ID}", "DOCS_BASE_PATH": "{STABLE_DOCS_BASE_PATH}", "ALGOLIA_SEARCH_API_KEY": "{STABLE_ALGOLIA_SEARCH_API_KEY}", - } + }, ) #gh_pages( From 760105d38143b99366265348acd5139c1f7abd64 Mon Sep 17 00:00:00 2001 From: marky ercillo Date: Wed, 31 Jul 2024 15:43:06 -0700 Subject: [PATCH 04/10] full_site_stamped and gh_deploy working --- docs/BUILD | 27 ++++++++++++++++----------- docs/site/BUILD | 4 ---- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/docs/BUILD b/docs/BUILD index a14961557..9f65b84e7 100644 --- a/docs/BUILD +++ b/docs/BUILD @@ -1,8 +1,6 @@ load("@bazel_tools//tools/build_defs/pkg:pkg.bzl", "pkg_tar") -load("@rules_player//distribution/tar:stamp_tar_files.bzl", "stamp_tar_files") - - -load("@bazel_tools//tools/build_defs/pkg:pkg.bzl", "pkg_tar") +load("@rules_player//distribution/tar:defs.bzl", "stamp_tar_files") +load("@rules_player//gh-pages:defs.bzl","gh_pages") genrule( name = "full_site", @@ -21,7 +19,6 @@ genrule( """ ) - stamp_tar_files( name = "full_site_stamped", tar = ":full_site", @@ -32,9 +29,17 @@ stamp_tar_files( }, ) -#gh_pages( -# name="deploy_docs", -# source_dir="$(location :full_site_stamped)", -# repo="player-ui/player-ui.github.io", -# data = [":full_site_stamped"] -#) \ No newline at end of file +genrule( + name = "get_version", + srcs = ["//:VERSION"], + outs = ["VERSION"], + cmd = "cat $(SRCS) > $@" +) + +gh_pages( + name="gh_deploy", + source_dir="$(location :full_site_stamped)", + repo="player-ui/player-ui.github.io", + data = [":full_site_stamped", ":get_version"], + version = "$(location :get_version)", +) \ No newline at end of file diff --git a/docs/site/BUILD b/docs/site/BUILD index 8ad99f7b8..2e6653356 100644 --- a/docs/site/BUILD +++ b/docs/site/BUILD @@ -1,15 +1,11 @@ load("@npm//:defs.bzl", "npm_link_all_packages") load("@npm//:webpack-cli/package_json.bzl", webpack_bin = "bin") load("@npm//:webpack-dev-server/package_json.bzl", webpack_dev_server_bin = "bin") -# load("@build_bazel_rules_nodejs//toolchains/esbuild:esbuild_repositories.bzl", "esbuild_repositories") -# load("@aspect_rules_esbuild//esbuild/private:esbuild.bzl", "esbuild_bundle") - npm_link_all_packages( name = "node_modules", ) - srcs = glob([ "public/**/*", "pages/**/*", From 4a1c97316de7b4207fdc525eebba599b8c10c836 Mon Sep 17 00:00:00 2001 From: marky ercillo Date: Wed, 31 Jul 2024 15:57:36 -0700 Subject: [PATCH 05/10] removed package.resolved file and spacing --- MODULE.bazel | 1 - Package.resolved | 16 ---------------- WORKSPACE | 3 +-- 3 files changed, 1 insertion(+), 19 deletions(-) delete mode 100644 Package.resolved diff --git a/MODULE.bazel b/MODULE.bazel index dbddc6d54..8cd22ad0d 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -19,7 +19,6 @@ bazel_dep(name = "bazel_skylib", version = "1.7.1") bazel_dep(name = "rules_pkg", version = "1.0.1") bazel_dep(name = "aspect_rules_ts", version = "2.4.2") - ####### Node.js version ######### bazel_dep(name = "rules_nodejs", version = "6.2.0") diff --git a/Package.resolved b/Package.resolved deleted file mode 100644 index 1aa7b5441..000000000 --- a/Package.resolved +++ /dev/null @@ -1,16 +0,0 @@ -{ - "object": { - "pins": [ - { - "package": "SwiftHooks", - "repositoryURL": "https://github.com/intuit/swift-hooks.git", - "state": { - "branch": null, - "revision": "5f3136ac2a3c27aa469e3f9a1222b15080d431d3", - "version": "0.1.0" - } - } - ] - }, - "version": 1 -} diff --git a/WORKSPACE b/WORKSPACE index e82c08e7e..a00b94a28 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -1,2 +1 @@ -workspace(name = "player") - +workspace(name = "player") \ No newline at end of file From 85bf31721c339449830aaee3a97e3eda7617b592 Mon Sep 17 00:00:00 2001 From: marky ercillo Date: Thu, 1 Aug 2024 16:33:00 -0700 Subject: [PATCH 06/10] script added back --- scripts/release.sh | 18 +++++++++--------- tsconfig.json | 2 -- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/scripts/release.sh b/scripts/release.sh index 77dfeca12..fcae8b579 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -37,16 +37,16 @@ bazel run @rules_player//distribution:staged-maven-deploy -- "$RELEASE_TYPE" --p # Make sure to re-stamp the outputs with the BASE_PATH so nextjs knows what to do with links # Commented out as it needs to be re-written -#if [ "$RELEASE_TYPE" == "snapshot" ] && [ "$CURRENT_BRANCH" == "main" ]; then -# STABLE_DOCS_BASE_PATH=next bazel run --verbose_failures --config=release //docs:deploy_docs -- --dest_dir next -#elif [ "$RELEASE_TYPE" == "release" ] && [ "$CURRENT_BRANCH" == "main" ]; then -# STABLE_DOCS_BASE_PATH=latest bazel run --verbose_failures --config=release //docs:deploy_docs -- --dest_dir latest -#fi +if [ "$RELEASE_TYPE" == "snapshot" ] && [ "$CURRENT_BRANCH" == "main" ]; then + STABLE_DOCS_BASE_PATH=next bazel run --verbose_failures --config=release //docs:gh_deploy -- --dest_dir next +elif [ "$RELEASE_TYPE" == "release" ] && [ "$CURRENT_BRANCH" == "main" ]; then + STABLE_DOCS_BASE_PATH=latest bazel run --verbose_failures --config=release //docs:gh_deploy -- --dest_dir latest +fi # Commented out for now due to failures to deploy # causes lots of "java.io.IOException: io.grpc.StatusRuntimeException: CANCELLED: Failed to read message." messages in the build # Also deploy to the versioned folder for main releases -# if [ "$RELEASE_TYPE" == "release" ]; then -# SEMVER_MAJOR=$(cat VERSION | cut -d. -f1) -# STABLE_DOCS_BASE_PATH=$SEMVER_MAJOR bazel run --verbose_failures --config=release //docs:deploy_docs -- --dest_dir "$SEMVER_MAJOR" -# fi +if [ "$RELEASE_TYPE" == "release" ]; then + SEMVER_MAJOR=$(cat VERSION | cut -d. -f1) + STABLE_DOCS_BASE_PATH=$SEMVER_MAJOR bazel run --verbose_failures --config=release //docs:gh_deploy -- --dest_dir "$SEMVER_MAJOR" +fi diff --git a/tsconfig.json b/tsconfig.json index f3ca31b75..fa1bbc068 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -22,7 +22,5 @@ "resolveJsonModule": true, "composite": true, "lib": ["DOM", "ES2020"], - "isolatedDeclarations": true, - "noUncheckedIndexedAccess": true, } } From 29369fc7430a712fda2296ef4fde7c22d10d94c0 Mon Sep 17 00:00:00 2001 From: marky ercillo Date: Thu, 1 Aug 2024 18:46:28 -0700 Subject: [PATCH 07/10] update rules_player to 1.1.0 --- MODULE.bazel | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MODULE.bazel b/MODULE.bazel index 8cd22ad0d..996efb493 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -7,8 +7,8 @@ bazel_dep(name = "rules_player") archive_override( module_name = "rules_player", - strip_prefix = "rules_player-1.0.1", - urls = ["https://github.com/player-ui/rules_player/archive/refs/tags/v1.0.1.tar.gz"], + strip_prefix = "rules_player-1.1.0", + urls = ["https://github.com/player-ui/rules_player/archive/refs/tags/v1.1.0.tar.gz"], integrity = "sha256-zIbxx1Bh/X4E8OwbPJz1nY9mOd2uAgmTZyf1Hs2mq+U=" ) #local_path_override(module_name = "rules_player", path = "../rules_player") From 8294fbad4fcd5075b8d750421f31d6e08ba0253d Mon Sep 17 00:00:00 2001 From: marky ercillo Date: Thu, 1 Aug 2024 19:03:53 -0700 Subject: [PATCH 08/10] removed sha for override --- MODULE.bazel | 1 - 1 file changed, 1 deletion(-) diff --git a/MODULE.bazel b/MODULE.bazel index 996efb493..05e879227 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -9,7 +9,6 @@ archive_override( module_name = "rules_player", strip_prefix = "rules_player-1.1.0", urls = ["https://github.com/player-ui/rules_player/archive/refs/tags/v1.1.0.tar.gz"], - integrity = "sha256-zIbxx1Bh/X4E8OwbPJz1nY9mOd2uAgmTZyf1Hs2mq+U=" ) #local_path_override(module_name = "rules_player", path = "../rules_player") From 6b3794487421d6cd7deef0ea58eb63786542f558 Mon Sep 17 00:00:00 2001 From: marky ercillo Date: Fri, 2 Aug 2024 08:56:59 -0700 Subject: [PATCH 09/10] added integrity back --- MODULE.bazel | 1 + 1 file changed, 1 insertion(+) diff --git a/MODULE.bazel b/MODULE.bazel index 05e879227..7bc1f78ae 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -9,6 +9,7 @@ archive_override( module_name = "rules_player", strip_prefix = "rules_player-1.1.0", urls = ["https://github.com/player-ui/rules_player/archive/refs/tags/v1.1.0.tar.gz"], + integrity = "sha256-LwCE/dbbQUtpkIZedhtgJ5MwCjn5G00XO5LFxq09i7k=" ) #local_path_override(module_name = "rules_player", path = "../rules_player") From a8a147d1afa28e28dc8855402608ee6288b514e5 Mon Sep 17 00:00:00 2001 From: marky ercillo Date: Fri, 2 Aug 2024 10:42:56 -0700 Subject: [PATCH 10/10] fixed tsconfig, defined types, added storybook modules --- docs/BUILD | 3 +++ docs/site/components/Search.tsx | 7 ++--- .../sample-flows/sample-flow-manager.tsx | 27 ++++++++++++------- docs/storybook/BUILD | 2 ++ pnpm-lock.yaml | 2 -- tsconfig.json | 2 ++ 6 files changed, 28 insertions(+), 15 deletions(-) diff --git a/docs/BUILD b/docs/BUILD index 9f65b84e7..a2ce2e989 100644 --- a/docs/BUILD +++ b/docs/BUILD @@ -6,6 +6,7 @@ genrule( name = "full_site", srcs = [ "//docs/site", + "//docs/storybook" ], outs = [ "merged_site.tar.gz" @@ -14,6 +15,8 @@ genrule( tmp_dir=$$(mktemp -d) && touch $$tmp_dir/.nojekyll && cp -LR $(location //docs/site)/** $$tmp_dir && + mkdir $$tmp_dir/storybook-demo && + cp -LR $(location //docs/storybook)/** $$tmp_dir/storybook-demo && chmod -R u+rwX,a+rX $$tmp_dir && tar -czhf $@ -C $$tmp_dir . """ diff --git a/docs/site/components/Search.tsx b/docs/site/components/Search.tsx index caeca7157..80d82c930 100644 --- a/docs/site/components/Search.tsx +++ b/docs/site/components/Search.tsx @@ -74,7 +74,8 @@ const useSearch = () => { .slice(0, 10) .map((r) => { return searchIndex.searchIndex[r.ref]; - }); + }) + .filter((e) => e !== undefined); setResults(searchResults); } @@ -103,7 +104,7 @@ const SearchResult = (props: SearchIndex) => { ); }; -export const FallbackSearchInput = () => { +export const FallbackSearchInput = (): React.JSX.Element => { const { search, results, clear } = useSearch(); const [searchActive, setSearchActive] = React.useState(false); const [query, setQuery] = React.useState(""); @@ -162,7 +163,7 @@ export const FallbackSearchInput = () => { ); }; -export const SearchInput = () => { +export const SearchInput = (): React.JSX.Element => { // Only use algolia search if we're on the /latest/ version // it's the only one that's indexed if ( diff --git a/docs/site/components/player-demo/sample-flows/sample-flow-manager.tsx b/docs/site/components/player-demo/sample-flows/sample-flow-manager.tsx index f78a99520..ed799b188 100644 --- a/docs/site/components/player-demo/sample-flows/sample-flow-manager.tsx +++ b/docs/site/components/player-demo/sample-flows/sample-flow-manager.tsx @@ -1,7 +1,12 @@ -import { FlowManager, CompletedState, Flow } from '@player-ui/react'; -import flow1 from './flow-1.json'; -import flow2 from './flow-2.json'; -import flow3 from './flow-3.json'; +import { + FlowManager, + CompletedState, + Flow, + FinalState, +} from "@player-ui/react"; +import flow1 from "./flow-1.json"; +import flow2 from "./flow-2.json"; +import flow3 from "./flow-3.json"; const basicFlows = [flow1, flow2, flow3]; @@ -16,24 +21,26 @@ export function createStaticFlowManager(flows: Array): FlowManager { return { next: async (previousResult?: CompletedState) => { if (!previousResult) { - return { value: flows[0] }; + const firstFlow = flows[0] as Flow; + return { done: false, value: firstFlow }; } const prevIndex = flows.findIndex((v) => v.id === previousResult.flow.id); const nextIndex = - prevIndex + (previousResult.endState.outcome === 'back' ? -1 : 1); + prevIndex + (previousResult.endState.outcome === "back" ? -1 : 1); if (nextIndex < 0 || nextIndex >= flows.length) { - return { done: true }; + return { done: true } as FinalState; } await delay(Math.random() * 500); - return { value: flows[nextIndex] }; + const nextFlow = flows[nextIndex] as Flow; + return { done: false, value: nextFlow }; }, }; } -export const basicFlowManager = createStaticFlowManager( - basicFlows as Array +export const basicFlowManager: FlowManager = createStaticFlowManager( + basicFlows as Array, ); diff --git a/docs/storybook/BUILD b/docs/storybook/BUILD index 865768aa4..bb6df058c 100644 --- a/docs/storybook/BUILD +++ b/docs/storybook/BUILD @@ -19,6 +19,8 @@ deps = [ "//:node_modules/@babel/preset-env", "//:node_modules/@storybook/react-webpack5", "//:node_modules/@storybook/addon-docs", + "//:node_modules/@storybook/components", + "//:node_modules/@storybook/manager-api", "//:node_modules/@types/react-redux", "//:node_modules/react-redux", "//:node_modules/redux-state-sync", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 5e8acfa93..82b8b218c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -536,8 +536,6 @@ importers: core/types: {} - docs/package: {} - docs/site: dependencies: '@player-ui/asset-provider-plugin-react': diff --git a/tsconfig.json b/tsconfig.json index fa1bbc068..f3ca31b75 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -22,5 +22,7 @@ "resolveJsonModule": true, "composite": true, "lib": ["DOM", "ES2020"], + "isolatedDeclarations": true, + "noUncheckedIndexedAccess": true, } }