diff --git a/.changeset/famous-eyes-share.md b/.changeset/famous-eyes-share.md new file mode 100644 index 000000000..eb2368fde --- /dev/null +++ b/.changeset/famous-eyes-share.md @@ -0,0 +1,5 @@ +--- +"@stackflow/react": minor +--- + +change extension esm package .mjs to .js diff --git a/.changeset/funny-pears-fold.md b/.changeset/funny-pears-fold.md new file mode 100644 index 000000000..d5b2dbc2b --- /dev/null +++ b/.changeset/funny-pears-fold.md @@ -0,0 +1,5 @@ +--- +"@stackflow/react": minor +--- + +Change package to ESM Only diff --git a/.changeset/hungry-buses-do.md b/.changeset/hungry-buses-do.md new file mode 100644 index 000000000..0695ff895 --- /dev/null +++ b/.changeset/hungry-buses-do.md @@ -0,0 +1,5 @@ +--- +"@stackflow/react": minor +--- + +support esm, cjs both diff --git a/.changeset/plenty-birds-learn.md b/.changeset/plenty-birds-learn.md new file mode 100644 index 000000000..285542827 --- /dev/null +++ b/.changeset/plenty-birds-learn.md @@ -0,0 +1,5 @@ +--- +"@stackflow/react": minor +--- + +Future API diff --git a/.changeset/pre.json b/.changeset/pre.json new file mode 100644 index 000000000..98fe7e0cd --- /dev/null +++ b/.changeset/pre.json @@ -0,0 +1,30 @@ +{ + "mode": "exit", + "tag": "canary", + "initialVersions": { + "@stackflow/config": "1.0.1-canary.0", + "@stackflow/core": "1.0.13", + "@stackflow/demo": "1.3.0-canary.0", + "@stackflow/docs": "1.2.25-canary.0", + "@stackflow/compat-await-push": "1.1.11-canary.0", + "@stackflow/link": "1.4.3-canary.0", + "@stackflow/plugin-basic-ui": "1.8.3-canary.0", + "@stackflow/plugin-devtools": "0.1.10", + "@stackflow/plugin-google-analytics-4": "1.1.13-canary.0", + "@stackflow/plugin-history-sync": "1.6.0-canary.0", + "@stackflow/plugin-map-initial-activity": "1.0.9-canary.0", + "@stackflow/plugin-preload": "1.3.3-canary.0", + "@stackflow/plugin-renderer-basic": "1.1.11-canary.0", + "@stackflow/plugin-renderer-web": "1.1.11-canary.0", + "@stackflow/plugin-stack-depth-change": "1.1.4", + "@stackflow/react": "1.2.0-canary.3", + "@stackflow/esbuild-config": "1.0.3" + }, + "changesets": [ + "famous-eyes-share", + "funny-pears-fold", + "hungry-buses-do", + "plenty-birds-learn", + "sixty-spiders-teach" + ] +} diff --git a/.changeset/sixty-spiders-teach.md b/.changeset/sixty-spiders-teach.md new file mode 100644 index 000000000..c1b7d41a1 --- /dev/null +++ b/.changeset/sixty-spiders-teach.md @@ -0,0 +1,8 @@ +--- +"@stackflow/plugin-history-sync": minor +"@stackflow/react": minor +"@stackflow/demo": minor +"@stackflow/config": patch +--- + +Future API diff --git a/.changeset/twelve-lizards-join.md b/.changeset/twelve-lizards-join.md new file mode 100644 index 000000000..e79d17b0d --- /dev/null +++ b/.changeset/twelve-lizards-join.md @@ -0,0 +1,7 @@ +--- +"@stackflow/plugin-history-sync": minor +"@stackflow/react": minor +"@stackflow/config": minor +--- + +Stackflow Config and Loader API (2.0 Candidate API with `/future` namespace) diff --git a/.gitignore b/.gitignore index be3a55af7..b01eb9b10 100644 --- a/.gitignore +++ b/.gitignore @@ -29,3 +29,4 @@ coverage dist lib +vite.config.js.timestamp-** diff --git a/.pnp.cjs b/.pnp.cjs index 17c1436f6..6925c22d0 100755 --- a/.pnp.cjs +++ b/.pnp.cjs @@ -14,6 +14,10 @@ const RAW_RUNTIME_STATE = "name": "@stackflow/monorepo",\ "reference": "workspace:."\ },\ + {\ + "name": "@stackflow/config",\ + "reference": "workspace:config"\ + },\ {\ "name": "@stackflow/core",\ "reference": "workspace:core"\ @@ -83,6 +87,7 @@ const RAW_RUNTIME_STATE = "ignorePatternData": "(^(?:\\\\.yarn\\\\/sdks(?:\\\\/(?!\\\\.{1,2}(?:\\\\/|$))(?:(?:(?!(?:^|\\\\/)\\\\.{1,2}(?:\\\\/|$)).)*?)|$))$)",\ "fallbackExclusionList": [\ ["@stackflow/compat-await-push", ["virtual:413bca98ff76262f6f1f73762ccc4b7edee04a5da42f3d6b9ed2cb2d6dbc397b2094da59b50f6e828091c88e7b5f86990feff596c43f0eb50a58fc42aae64a20#workspace:extensions/compat-await-push", "workspace:extensions/compat-await-push"]],\ + ["@stackflow/config", ["workspace:config"]],\ ["@stackflow/core", ["workspace:core"]],\ ["@stackflow/demo", ["workspace:demo"]],\ ["@stackflow/docs", ["workspace:docs"]],\ @@ -3019,6 +3024,20 @@ const RAW_RUNTIME_STATE = "linkType": "SOFT"\ }]\ ]],\ + ["@stackflow/config", [\ + ["workspace:config", {\ + "packageLocation": "./config/",\ + "packageDependencies": [\ + ["@stackflow/config", "workspace:config"],\ + ["@stackflow/esbuild-config", "workspace:packages/esbuild-config"],\ + ["esbuild", "npm:0.23.0"],\ + ["rimraf", "npm:3.0.2"],\ + ["typescript", "patch:typescript@npm%3A5.5.3#optional!builtin::version=5.5.3&hash=379a07"],\ + ["ultra-runner", "npm:3.10.5"]\ + ],\ + "linkType": "SOFT"\ + }]\ + ]],\ ["@stackflow/core", [\ ["workspace:core", {\ "packageLocation": "./core/",\ @@ -3047,6 +3066,7 @@ const RAW_RUNTIME_STATE = ["@seed-design/design-token", "npm:1.0.3"],\ ["@seed-design/stylesheet", "npm:1.0.4"],\ ["@stackflow/compat-await-push", "virtual:413bca98ff76262f6f1f73762ccc4b7edee04a5da42f3d6b9ed2cb2d6dbc397b2094da59b50f6e828091c88e7b5f86990feff596c43f0eb50a58fc42aae64a20#workspace:extensions/compat-await-push"],\ + ["@stackflow/config", "workspace:config"],\ ["@stackflow/core", "workspace:core"],\ ["@stackflow/esbuild-config", "workspace:packages/esbuild-config"],\ ["@stackflow/link", "virtual:413bca98ff76262f6f1f73762ccc4b7edee04a5da42f3d6b9ed2cb2d6dbc397b2094da59b50f6e828091c88e7b5f86990feff596c43f0eb50a58fc42aae64a20#workspace:extensions/link"],\ @@ -3074,7 +3094,8 @@ const RAW_RUNTIME_STATE = ["react-lazy-load-image-component", "virtual:413bca98ff76262f6f1f73762ccc4b7edee04a5da42f3d6b9ed2cb2d6dbc397b2094da59b50f6e828091c88e7b5f86990feff596c43f0eb50a58fc42aae64a20#npm:1.6.2"],\ ["rimraf", "npm:3.0.2"],\ ["typescript", "patch:typescript@npm%3A5.5.3#optional!builtin::version=5.5.3&hash=379a07"],\ - ["vite", "virtual:2c30557d8ca5e7c67e7558d45bc44bef6c7a622b34a97fa8102f3235f92769c87777d34ed37059c12d8f3a21841ea06cf4badc5dc796697b0f765c17db6e24e5#npm:5.3.2"]\ + ["vite", "virtual:2c30557d8ca5e7c67e7558d45bc44bef6c7a622b34a97fa8102f3235f92769c87777d34ed37059c12d8f3a21841ea06cf4badc5dc796697b0f765c17db6e24e5#npm:5.3.2"],\ + ["zod", "npm:3.23.8"]\ ],\ "linkType": "SOFT"\ }]\ @@ -3288,6 +3309,7 @@ const RAW_RUNTIME_STATE = "packageLocation": "./.yarn/__virtual__/@stackflow-plugin-history-sync-virtual-991015ceb8/1/extensions/plugin-history-sync/",\ "packageDependencies": [\ ["@stackflow/plugin-history-sync", "virtual:413bca98ff76262f6f1f73762ccc4b7edee04a5da42f3d6b9ed2cb2d6dbc397b2094da59b50f6e828091c88e7b5f86990feff596c43f0eb50a58fc42aae64a20#workspace:extensions/plugin-history-sync"],\ + ["@stackflow/config", "workspace:config"],\ ["@stackflow/core", "workspace:core"],\ ["@stackflow/esbuild-config", "workspace:packages/esbuild-config"],\ ["@stackflow/react", "virtual:413bca98ff76262f6f1f73762ccc4b7edee04a5da42f3d6b9ed2cb2d6dbc397b2094da59b50f6e828091c88e7b5f86990feff596c43f0eb50a58fc42aae64a20#workspace:integrations/react"],\ @@ -3296,6 +3318,7 @@ const RAW_RUNTIME_STATE = ["@types/jest", "npm:29.5.12"],\ ["@types/node", "npm:20.14.9"],\ ["@types/react", "npm:18.3.3"],\ + ["@types/stackflow__config", null],\ ["@types/stackflow__core", null],\ ["@types/stackflow__react", null],\ ["esbuild", "npm:0.23.0"],\ @@ -3307,9 +3330,11 @@ const RAW_RUNTIME_STATE = ["url-pattern", "npm:1.0.3"]\ ],\ "packagePeers": [\ + "@stackflow/config",\ "@stackflow/core",\ "@stackflow/react",\ "@types/react",\ + "@types/stackflow__config",\ "@types/stackflow__core",\ "@types/stackflow__react",\ "react"\ @@ -3320,6 +3345,7 @@ const RAW_RUNTIME_STATE = "packageLocation": "./extensions/plugin-history-sync/",\ "packageDependencies": [\ ["@stackflow/plugin-history-sync", "workspace:extensions/plugin-history-sync"],\ + ["@stackflow/config", "workspace:config"],\ ["@stackflow/core", "workspace:core"],\ ["@stackflow/esbuild-config", "workspace:packages/esbuild-config"],\ ["@stackflow/react", "virtual:413bca98ff76262f6f1f73762ccc4b7edee04a5da42f3d6b9ed2cb2d6dbc397b2094da59b50f6e828091c88e7b5f86990feff596c43f0eb50a58fc42aae64a20#workspace:integrations/react"],\ @@ -3516,19 +3542,26 @@ const RAW_RUNTIME_STATE = "packageLocation": "./.yarn/__virtual__/@stackflow-react-virtual-eeae00ab9c/1/integrations/react/",\ "packageDependencies": [\ ["@stackflow/react", "virtual:413bca98ff76262f6f1f73762ccc4b7edee04a5da42f3d6b9ed2cb2d6dbc397b2094da59b50f6e828091c88e7b5f86990feff596c43f0eb50a58fc42aae64a20#workspace:integrations/react"],\ + ["@stackflow/config", "workspace:config"],\ ["@stackflow/core", "workspace:core"],\ ["@stackflow/esbuild-config", "workspace:packages/esbuild-config"],\ ["@types/react", "npm:18.3.3"],\ + ["@types/stackflow__config", null],\ ["@types/stackflow__core", null],\ ["esbuild", "npm:0.23.0"],\ + ["esbuild-plugin-file-path-extensions", "npm:2.1.2"],\ + ["history", "npm:5.3.0"],\ ["react", "npm:18.3.1"],\ ["react-fast-compare", "npm:3.2.2"],\ ["rimraf", "npm:3.0.2"],\ - ["typescript", "patch:typescript@npm%3A5.5.3#optional!builtin::version=5.5.3&hash=379a07"]\ + ["typescript", "patch:typescript@npm%3A5.5.3#optional!builtin::version=5.5.3&hash=379a07"],\ + ["url-pattern", "npm:1.0.3"]\ ],\ "packagePeers": [\ + "@stackflow/config",\ "@stackflow/core",\ "@types/react",\ + "@types/stackflow__config",\ "@types/stackflow__core",\ "react"\ ],\ @@ -3538,14 +3571,18 @@ const RAW_RUNTIME_STATE = "packageLocation": "./integrations/react/",\ "packageDependencies": [\ ["@stackflow/react", "workspace:integrations/react"],\ + ["@stackflow/config", "workspace:config"],\ ["@stackflow/core", "workspace:core"],\ ["@stackflow/esbuild-config", "workspace:packages/esbuild-config"],\ ["@types/react", "npm:18.3.3"],\ ["esbuild", "npm:0.23.0"],\ + ["esbuild-plugin-file-path-extensions", "npm:2.1.2"],\ + ["history", "npm:5.3.0"],\ ["react", "npm:18.3.1"],\ ["react-fast-compare", "npm:3.2.2"],\ ["rimraf", "npm:3.0.2"],\ - ["typescript", "patch:typescript@npm%3A5.5.3#optional!builtin::version=5.5.3&hash=379a07"]\ + ["typescript", "patch:typescript@npm%3A5.5.3#optional!builtin::version=5.5.3&hash=379a07"],\ + ["url-pattern", "npm:1.0.3"]\ ],\ "linkType": "SOFT"\ }]\ @@ -6185,6 +6222,15 @@ const RAW_RUNTIME_STATE = "linkType": "HARD"\ }]\ ]],\ + ["esbuild-plugin-file-path-extensions", [\ + ["npm:2.1.2", {\ + "packageLocation": "./.yarn/cache/esbuild-plugin-file-path-extensions-npm-2.1.2-775aff448b-01e00d5bb3.zip/node_modules/esbuild-plugin-file-path-extensions/",\ + "packageDependencies": [\ + ["esbuild-plugin-file-path-extensions", "npm:2.1.2"]\ + ],\ + "linkType": "HARD"\ + }]\ + ]],\ ["escalade", [\ ["npm:3.1.1", {\ "packageLocation": "./.yarn/cache/escalade-npm-3.1.1-e02da076aa-afa618e733.zip/node_modules/escalade/",\ diff --git a/.yarn/cache/esbuild-plugin-file-path-extensions-npm-2.1.2-775aff448b-01e00d5bb3.zip b/.yarn/cache/esbuild-plugin-file-path-extensions-npm-2.1.2-775aff448b-01e00d5bb3.zip new file mode 100644 index 000000000..afec78598 Binary files /dev/null and b/.yarn/cache/esbuild-plugin-file-path-extensions-npm-2.1.2-775aff448b-01e00d5bb3.zip differ diff --git a/config/CHANGELOG.md b/config/CHANGELOG.md new file mode 100644 index 000000000..ae0e37780 --- /dev/null +++ b/config/CHANGELOG.md @@ -0,0 +1,7 @@ +# @stackflow/config + +## 1.0.1-canary.0 + +### Patch Changes + +- Future API diff --git a/config/esbuild.config.js b/config/esbuild.config.js new file mode 100644 index 000000000..b84dfb4db --- /dev/null +++ b/config/esbuild.config.js @@ -0,0 +1,29 @@ +const { context } = require("esbuild"); +const config = require("@stackflow/esbuild-config"); +const pkg = require("./package.json"); + +const watch = process.argv.includes("--watch"); +const external = Object.keys({ + ...pkg.dependencies, + ...pkg.peerDependencies, +}); + +Promise.all([ + context({ + ...config({}), + format: "cjs", + external, + }).then((ctx) => + watch ? ctx.watch() : ctx.rebuild().then(() => ctx.dispose()), + ), + context({ + ...config({}), + format: "esm", + outExtension: { + ".js": ".mjs", + }, + external, + }).then((ctx) => + watch ? ctx.watch() : ctx.rebuild().then(() => ctx.dispose()), + ), +]).catch(() => process.exit(1)); diff --git a/config/package.json b/config/package.json new file mode 100644 index 000000000..7a0cefef3 --- /dev/null +++ b/config/package.json @@ -0,0 +1,49 @@ +{ + "name": "@stackflow/config", + "version": "1.0.1-canary.0", + "repository": { + "type": "git", + "url": "https://github.com/daangn/stackflow.git", + "directory": "config" + }, + "license": "MIT", + "exports": { + ".": { + "types": "./dist/index.d.ts", + "require": "./dist/index.js", + "import": "./dist/index.mjs" + } + }, + "main": "./dist/index.js", + "module": "./dist/index.mjs", + "types": "./dist/index.d.ts", + "files": [ + "dist", + "src", + "README.md" + ], + "scripts": { + "build": "yarn build:js && yarn build:dts", + "build:dts": "tsc --emitDeclarationOnly", + "build:js": "node ./esbuild.config.js", + "clean": "rimraf dist", + "dev": "yarn build:js --watch && yarn build:dts --watch", + "typecheck": "tsc --noEmit" + }, + "devDependencies": { + "@stackflow/esbuild-config": "^1.0.3", + "esbuild": "^0.23.0", + "rimraf": "^3.0.2", + "typescript": "^5.5.3", + "ultra-runner": "^3.10.5" + }, + "publishConfig": { + "access": "public" + }, + "ultra": { + "concurrent": [ + "dev", + "build" + ] + } +} diff --git a/config/src/ActivityBaseParams.ts b/config/src/ActivityBaseParams.ts new file mode 100644 index 000000000..fa8d983ba --- /dev/null +++ b/config/src/ActivityBaseParams.ts @@ -0,0 +1,3 @@ +export type ActivityBaseParams = { + [key in string]?: string; +}; diff --git a/config/src/ActivityDefinition.ts b/config/src/ActivityDefinition.ts new file mode 100644 index 000000000..c49065f24 --- /dev/null +++ b/config/src/ActivityDefinition.ts @@ -0,0 +1,6 @@ +import type { ActivityLoader } from "./ActivityLoader"; + +export interface ActivityDefinition { + name: ActivityName; + loader?: ActivityLoader; +} diff --git a/config/src/ActivityLoader.ts b/config/src/ActivityLoader.ts new file mode 100644 index 000000000..51910fec6 --- /dev/null +++ b/config/src/ActivityLoader.ts @@ -0,0 +1,6 @@ +import type { ActivityLoaderArgs } from "./ActivityLoaderArgs"; +import type { RegisteredActivityParamTypes } from "./RegisteredActivityParamTypes"; + +export type ActivityLoader< + ActivityName extends Extract, +> = (args: ActivityLoaderArgs) => any; diff --git a/config/src/ActivityLoaderArgs.ts b/config/src/ActivityLoaderArgs.ts new file mode 100644 index 000000000..ff253503a --- /dev/null +++ b/config/src/ActivityLoaderArgs.ts @@ -0,0 +1,8 @@ +import type { InferActivityParams } from "./InferActivityParams"; +import type { RegisteredActivityParamTypes } from "./RegisteredActivityParamTypes"; + +export type ActivityLoaderArgs< + ActivityName extends Extract, +> = { + params: InferActivityParams; +}; diff --git a/config/src/Config.ts b/config/src/Config.ts new file mode 100644 index 000000000..de76efa86 --- /dev/null +++ b/config/src/Config.ts @@ -0,0 +1,7 @@ +import type { ActivityDefinition } from "./ActivityDefinition"; + +export type Config> = { + activities: T[]; + transitionDuration: number; + initialActivity?: () => T["name"]; +}; diff --git a/config/src/InferActivityParams.ts b/config/src/InferActivityParams.ts new file mode 100644 index 000000000..4af31e05a --- /dev/null +++ b/config/src/InferActivityParams.ts @@ -0,0 +1,8 @@ +import type { ActivityBaseParams } from "./ActivityBaseParams"; +import type { RegisteredActivityParamTypes } from "./RegisteredActivityParamTypes"; + +export type InferActivityParams< + ActivityName extends Extract, +> = RegisteredActivityParamTypes[ActivityName] extends never + ? ActivityBaseParams + : RegisteredActivityParamTypes[ActivityName]; diff --git a/config/src/Register.ts b/config/src/Register.ts new file mode 100644 index 000000000..013b97327 --- /dev/null +++ b/config/src/Register.ts @@ -0,0 +1,2 @@ +// biome-ignore lint/suspicious/noEmptyInterface: declaration merging +export interface Register {} diff --git a/config/src/RegisteredActivityParamTypes.ts b/config/src/RegisteredActivityParamTypes.ts new file mode 100644 index 000000000..ae0bf2b4d --- /dev/null +++ b/config/src/RegisteredActivityParamTypes.ts @@ -0,0 +1,8 @@ +import type { ActivityBaseParams } from "./ActivityBaseParams"; +import type { Register } from "./Register"; + +export type RegisteredActivityParamTypes = keyof Register extends never + ? { + [key: string]: ActivityBaseParams; + } + : Register; diff --git a/config/src/defineConfig.ts b/config/src/defineConfig.ts new file mode 100644 index 000000000..5467b41b1 --- /dev/null +++ b/config/src/defineConfig.ts @@ -0,0 +1,9 @@ +import type { ActivityDefinition } from "./ActivityDefinition"; +import type { Config } from "./Config"; + +export function defineConfig< + ActivityName extends string, + Activity extends ActivityDefinition, +>(config: Config) { + return config; +} diff --git a/config/src/index.ts b/config/src/index.ts new file mode 100644 index 000000000..6e9932a1c --- /dev/null +++ b/config/src/index.ts @@ -0,0 +1,9 @@ +export * from "./defineConfig"; +export * from "./ActivityBaseParams"; +export * from "./ActivityDefinition"; +export * from "./ActivityLoader"; +export * from "./ActivityLoaderArgs"; +export * from "./Config"; +export * from "./InferActivityParams"; +export * from "./Register"; +export * from "./RegisteredActivityParamTypes"; diff --git a/config/tsconfig.json b/config/tsconfig.json new file mode 100644 index 000000000..6ce58df83 --- /dev/null +++ b/config/tsconfig.json @@ -0,0 +1,8 @@ +{ + "extends": "../tsconfig.json", + "compilerOptions": { + "baseUrl": "./src", + "outDir": "./dist" + }, + "exclude": ["./dist"] +} diff --git a/demo/CHANGELOG.md b/demo/CHANGELOG.md index 39a18574c..c7ba009c8 100644 --- a/demo/CHANGELOG.md +++ b/demo/CHANGELOG.md @@ -1,5 +1,24 @@ # @stackflow/demo +## 1.3.0-canary.0 + +### Minor Changes + +- Future API + +### Patch Changes + +- Updated dependencies + - @stackflow/plugin-history-sync@1.6.0-canary.0 + - @stackflow/react@1.2.0-canary.0 + - @stackflow/config@1.0.1-canary.0 + - @stackflow/link@1.4.3-canary.0 + - @stackflow/plugin-preload@1.3.3-canary.0 + - @stackflow/compat-await-push@1.1.11-canary.0 + - @stackflow/plugin-basic-ui@1.8.3-canary.0 + - @stackflow/plugin-map-initial-activity@1.0.9-canary.0 + - @stackflow/plugin-renderer-basic@1.1.11-canary.0 + ## 1.2.23 ### Patch Changes diff --git a/demo/esbuild.config.js b/demo/esbuild.config.js index 0493929f8..4f440124b 100644 --- a/demo/esbuild.config.js +++ b/demo/esbuild.config.js @@ -12,7 +12,8 @@ const external = Object.keys({ Promise.all([ context({ ...config({ - entryPoints: ["./src/stackflow-docs.ts"], + entryPoints: ["./src/stackflow/stackflow.docs.ts"], + outdir: "./dist/stackflow", vanillaExtractExternal: ["@seed-design"], }), format: "cjs", @@ -22,7 +23,8 @@ Promise.all([ ), context({ ...config({ - entryPoints: ["./src/stackflow-docs.ts"], + entryPoints: ["./src/stackflow/stackflow.docs.ts"], + outdir: "./dist/stackflow", vanillaExtractExternal: ["@seed-design"], }), format: "esm", diff --git a/demo/package.json b/demo/package.json index 6b93f27e9..b71da1c92 100644 --- a/demo/package.json +++ b/demo/package.json @@ -1,20 +1,20 @@ { "name": "@stackflow/demo", - "version": "1.2.23", + "version": "1.3.0-canary.0", "private": true, "license": "MIT", "type": "module", "exports": { ".": { - "types": "./dist/stackflow-docs.d.ts", - "require": "./dist/stackflow-docs.js", - "import": "./dist/stackflow-docs.mjs" + "types": "./dist/stackflow/stackflow.docs.d.ts", + "require": "./dist/stackflow/stackflow.docs.js", + "import": "./dist/stackflow/stackflow.docs.mjs" }, - "./style.css": "./dist/stackflow-docs.css" + "./style.css": "./dist/stackflow/stackflow.docs.css" }, - "main": "./dist/stackflow-docs.js", - "module": "./dist/stackflow-docs.mjs", - "types": "./dist/stackflow-docs.d.ts", + "main": "./dist/stackflow/stackflow.docs.js", + "module": "./dist/stackflow/stackflow.docs.mjs", + "types": "./dist/stackflow/stackflow.docs.d.ts", "files": [ "dist", "src" @@ -32,17 +32,18 @@ "dependencies": { "@seed-design/design-token": "^1.0.3", "@seed-design/stylesheet": "^1.0.4", - "@stackflow/compat-await-push": "^1.1.10", + "@stackflow/compat-await-push": "^1.1.11-canary.0", + "@stackflow/config": "^1.0.1-canary.0", "@stackflow/core": "^1.0.13", - "@stackflow/link": "^1.4.2", - "@stackflow/plugin-basic-ui": "^1.8.2", + "@stackflow/link": "^1.4.3-canary.0", + "@stackflow/plugin-basic-ui": "^1.8.3-canary.0", "@stackflow/plugin-devtools": "^0.1.10", - "@stackflow/plugin-history-sync": "^1.5.4", - "@stackflow/plugin-map-initial-activity": "^1.0.8", - "@stackflow/plugin-preload": "^1.3.2", - "@stackflow/plugin-renderer-basic": "^1.1.10", + "@stackflow/plugin-history-sync": "^1.6.0-canary.0", + "@stackflow/plugin-map-initial-activity": "^1.0.9-canary.0", + "@stackflow/plugin-preload": "^1.3.3-canary.0", + "@stackflow/plugin-renderer-basic": "^1.1.11-canary.0", "@stackflow/plugin-stack-depth-change": "^1.1.4", - "@stackflow/react": "^1.1.11", + "@stackflow/react": "^1.2.0-canary.0", "lorem-ipsum": "^2.0.8", "lz-string": "^1.5.0", "normalize.css": "^8.0.1", @@ -50,7 +51,8 @@ "react": "^18.3.1", "react-dom": "^18.3.1", "react-lazy-load-image-component": "^1.6.2", - "vite": "^5.3.2" + "vite": "^5.3.2", + "zod": "^3.23.8" }, "devDependencies": { "@stackflow/esbuild-config": "^1.0.3", diff --git a/demo/src/activities/Article.loader.ts b/demo/src/activities/Article.loader.ts new file mode 100644 index 000000000..9bdd81325 --- /dev/null +++ b/demo/src/activities/Article.loader.ts @@ -0,0 +1,63 @@ +import type { ActivityLoaderArgs } from "@stackflow/config"; + +export function articleLoader({ params }: ActivityLoaderArgs<"Article">) { + const imageUrl = `https://picsum.photos/800/800/?id=${params.articleId}`; + + const recommenderCards = [ + { + articleId: "25140667", + price: 41, + title: "Ran", + }, + { + articleId: "60547101", + price: 24, + title: "Rest", + }, + { + articleId: "34751776", + price: 42, + title: "Those", + }, + { + articleId: "04114554", + price: 12, + title: "Beauty", + }, + { + articleId: "81339443", + price: 3, + title: "Mighty", + }, + { + articleId: "44738871", + price: 1, + title: "Afternoon", + }, + { + articleId: "57388513", + price: 31, + title: "Brown", + }, + { + articleId: "60883443", + price: 49, + title: "Musical", + }, + { + articleId: "00932094", + price: 26, + title: "Occasionally", + }, + { + articleId: "10749683", + price: 35, + title: "Having", + }, + ]; + + return { + imageUrl, + recommenderCards, + }; +} diff --git a/demo/src/activities/Article.tsx b/demo/src/activities/Article.tsx index 96b3b6ac8..8600a2d87 100644 --- a/demo/src/activities/Article.tsx +++ b/demo/src/activities/Article.tsx @@ -1,76 +1,27 @@ -import type { ActivityComponentType } from "@stackflow/react"; -import { useActivityParams } from "@stackflow/react"; +import { + type ActivityComponentType, + useActivityParams, +} from "@stackflow/react/future"; +import { useLoaderData } from "@stackflow/react/future"; import { LazyLoadImage } from "react-lazy-load-image-component"; - import ArticleCard from "../components/ArticleCard"; import ArticleProfile from "../components/ArticleProfile"; import Layout from "../components/Layout"; import * as css from "./Article.css"; +import type { articleLoader } from "./Article.loader"; -const recommenderCard = [ - { - articleId: "25140667", - price: 41, - title: "Ran", - }, - { - articleId: "60547101", - price: 24, - title: "Rest", - }, - { - articleId: "34751776", - price: 42, - title: "Those", - }, - { - articleId: "04114554", - price: 12, - title: "Beauty", - }, - { - articleId: "81339443", - price: 3, - title: "Mighty", - }, - { - articleId: "44738871", - price: 1, - title: "Afternoon", - }, - { - articleId: "57388513", - price: 31, - title: "Brown", - }, - { - articleId: "60883443", - price: 49, - title: "Musical", - }, - { - articleId: "00932094", - price: 26, - title: "Occasionally", - }, - { - articleId: "10749683", - price: 35, - title: "Having", - }, -]; - -export interface ArticleParams { - articleId: string; - title: string; +declare module "@stackflow/config" { + interface Register { + Article: { + articleId: string; + title?: string; + }; + } } -const Article: ActivityComponentType = () => { - const { articleId, title } = useActivityParams<{ - articleId: string; - title: string; - }>(); - const imageUrl = `https://picsum.photos/800/800/?id=${articleId}`; +const Article: ActivityComponentType<"Article"> = ({ params }) => { + const { title } = useActivityParams<"Article">(); + const { imageUrl, recommenderCards } = useLoaderData(); return ( @@ -99,7 +50,7 @@ const Article: ActivityComponentType = () => {
Other Items by Emila
- {recommenderCard.map((card) => ( + {recommenderCards.map((card) => ( ))}
diff --git a/demo/src/activities/Main.css.ts b/demo/src/activities/Main.css.ts index 13b27c897..3cd79458f 100644 --- a/demo/src/activities/Main.css.ts +++ b/demo/src/activities/Main.css.ts @@ -30,9 +30,6 @@ export const appBarRight = style([ }, ]); -export const scrollable = style([ - f.flex1, - f.overflowScroll, -]); +export const scrollable = style([f.flex1, f.overflowScroll]); export const bottom = style({}); diff --git a/demo/src/activities/Main.loader.ts b/demo/src/activities/Main.loader.ts new file mode 100644 index 000000000..041c04814 --- /dev/null +++ b/demo/src/activities/Main.loader.ts @@ -0,0 +1,76 @@ +export function mainLoader() { + return { + cards: [ + { + articleId: "02542470", + price: 41, + title: "Master", + region: "Nagevan", + daysAgo: 4, + }, + { + articleId: "11257089", + price: 24, + title: "Wild", + region: "Inguima", + daysAgo: 4, + }, + { + articleId: "08407137", + price: 42, + title: "Universe", + region: "Litenego", + daysAgo: 4, + }, + { + articleId: "32979422", + price: 12, + title: "Private", + region: "Umumtaw", + daysAgo: 6, + }, + { + articleId: "37998208", + price: 3, + title: "Harbor", + region: "Gubdidgi", + daysAgo: 3, + }, + { + articleId: "01695878", + price: 1, + title: "Valuable", + region: "Jumjelewu", + daysAgo: 1, + }, + { + articleId: "09792471", + price: 31, + title: "Also", + region: "Salhega", + daysAgo: 1, + }, + { + articleId: "23939055", + price: 49, + title: "Ever", + region: "Jaifuup", + daysAgo: 9, + }, + { + articleId: "94689745", + price: 26, + title: "Production", + region: "Idcipwel", + daysAgo: 3, + }, + { + articleId: "49322156", + price: 35, + title: "Chest", + region: "Ajapaktar", + daysAgo: 7, + }, + ], + }; +} diff --git a/demo/src/activities/Main.tsx b/demo/src/activities/Main.tsx index 4e777400b..2d4ff30f1 100644 --- a/demo/src/activities/Main.tsx +++ b/demo/src/activities/Main.tsx @@ -1,4 +1,5 @@ -import type { ActivityComponentType } from "@stackflow/react"; +import type { ActivityComponentType } from "@stackflow/react/future"; +import { useLoaderData } from "@stackflow/react/future"; import IconBell from "../assets/IconBell"; import IconExpandMore from "../assets/IconExpandMore"; @@ -8,81 +9,17 @@ import BottomTab from "../components/BottomTab"; import FeedCard from "../components/FeedCard"; import Layout from "../components/Layout"; import * as css from "./Main.css"; +import type { mainLoader } from "./Main.loader"; -const cards = [ - { - articleId: "02542470", - price: 41, - title: "Master", - region: "Nagevan", - daysAgo: 4, - }, - { - articleId: "11257089", - price: 24, - title: "Wild", - region: "Inguima", - daysAgo: 4, - }, - { - articleId: "08407137", - price: 42, - title: "Universe", - region: "Litenego", - daysAgo: 4, - }, - { - articleId: "32979422", - price: 12, - title: "Private", - region: "Umumtaw", - daysAgo: 6, - }, - { - articleId: "37998208", - price: 3, - title: "Harbor", - region: "Gubdidgi", - daysAgo: 3, - }, - { - articleId: "01695878", - price: 1, - title: "Valuable", - region: "Jumjelewu", - daysAgo: 1, - }, - { - articleId: "09792471", - price: 31, - title: "Also", - region: "Salhega", - daysAgo: 1, - }, - { - articleId: "23939055", - price: 49, - title: "Ever", - region: "Jaifuup", - daysAgo: 9, - }, - { - articleId: "94689745", - price: 26, - title: "Production", - region: "Idcipwel", - daysAgo: 3, - }, - { - articleId: "49322156", - price: 35, - title: "Chest", - region: "Ajapaktar", - daysAgo: 7, - }, -]; +declare module "@stackflow/config" { + interface Register { + Main: {}; + } +} + +const Main: ActivityComponentType<"Main"> = () => { + const { cards } = useLoaderData(); -const Main: ActivityComponentType = () => { const appBarLeft = () => (
Woolston diff --git a/demo/src/components/ArticleCard.tsx b/demo/src/components/ArticleCard.tsx index 1bd4e57e7..55ab8969f 100644 --- a/demo/src/components/ArticleCard.tsx +++ b/demo/src/components/ArticleCard.tsx @@ -1,6 +1,5 @@ +import { useFlow } from "@stackflow/react/future"; import { LazyLoadImage } from "react-lazy-load-image-component"; - -import { useFlow } from "../useFlow"; import * as css from "./ArticleCard.css"; interface ArticleCardProps { diff --git a/demo/src/components/FeedCard.tsx b/demo/src/components/FeedCard.tsx index d87acc5d8..49ca122e5 100644 --- a/demo/src/components/FeedCard.tsx +++ b/demo/src/components/FeedCard.tsx @@ -1,6 +1,5 @@ +import { useFlow } from "@stackflow/react/future"; import { LazyLoadImage } from "react-lazy-load-image-component"; - -import { useFlow } from "../useFlow"; import * as css from "./FeedCard.css"; interface FeedCardProps { diff --git a/demo/src/stackflow.ts b/demo/src/stackflow.ts deleted file mode 100644 index 9012b714c..000000000 --- a/demo/src/stackflow.ts +++ /dev/null @@ -1,93 +0,0 @@ -import { vars } from "@seed-design/design-token"; -import { basicUIPlugin } from "@stackflow/plugin-basic-ui"; -import { devtoolsPlugin } from "@stackflow/plugin-devtools"; -import { historySyncPlugin } from "@stackflow/plugin-history-sync"; -import { mapInitialActivityPlugin } from "@stackflow/plugin-map-initial-activity"; -import { basicRendererPlugin } from "@stackflow/plugin-renderer-basic"; -import { stackflow } from "@stackflow/react"; -import { decompressFromEncodedURIComponent } from "lz-string"; - -import Article from "./activities/Article"; -import Main from "./activities/Main"; - -export const { Stack, activities } = stackflow({ - transitionDuration: 350, - activities: { - Main, - Article: { - component: Article, - paramsSchema: { - type: "object", - properties: { - articleId: { - type: "string", - }, - title: { - type: "string", - }, - }, - required: ["articleId", "title"], - }, - }, - }, - plugins: [ - devtoolsPlugin(), - basicRendererPlugin(), - basicUIPlugin({ - theme: "cupertino", - backgroundColor: vars.$semantic.color.paperDefault, - appBar: { - textColor: vars.$scale.color.gray900, - iconColor: vars.$scale.color.gray900, - borderColor: vars.$semantic.color.divider3, - backButton: { - ariaLabel: "뒤로 가기", - }, - closeButton: { - ariaLabel: "닫기", - }, - }, - }), - historySyncPlugin({ - routes: { - Main: "/", - Article: "/articles/:articleId", - }, - fallbackActivity: () => "Main", - }), - mapInitialActivityPlugin({ - mapper(url) { - try { - if (!url.pathname.startsWith("/.lzstring/")) { - return null; - } - - const [, encodedString] = url.pathname.split("/.lzstring/"); - - const parsed = JSON.parse( - decompressFromEncodedURIComponent(encodedString), - ); - - if (typeof parsed.activityName !== "string") { - return null; - } - if ( - typeof parsed.activityParams !== "undefined" && - typeof parsed.activityParams !== "object" - ) { - return null; - } - - return { - activityName: parsed.activityName, - activityParams: parsed.activityParams || {}, - }; - } catch { - return null; - } - }, - }), - ], -}); - -export type TypeActivities = typeof activities; diff --git a/demo/src/stackflow/Stack.ts b/demo/src/stackflow/Stack.ts new file mode 100644 index 000000000..8b5b88287 --- /dev/null +++ b/demo/src/stackflow/Stack.ts @@ -0,0 +1,40 @@ +import { vars } from "@seed-design/design-token"; +import { basicUIPlugin } from "@stackflow/plugin-basic-ui"; +import { historySyncPlugin } from "@stackflow/plugin-history-sync"; +import { basicRendererPlugin } from "@stackflow/plugin-renderer-basic"; +import { stack } from "@stackflow/react/future"; +import Article from "../activities/Article"; +import Main from "../activities/Main"; +import { config } from "./stackflow.config"; + +export const { Stack, actions } = stack({ + config, + components: { + Main, + Article, + }, + plugins: [ + basicRendererPlugin(), + basicUIPlugin({ + theme: "cupertino", + backgroundColor: vars.$semantic.color.paperDefault, + appBar: { + textColor: vars.$scale.color.gray900, + iconColor: vars.$scale.color.gray900, + borderColor: vars.$semantic.color.divider3, + backButton: { + ariaLabel: "뒤로 가기", + }, + closeButton: { + ariaLabel: "닫기", + }, + }, + }), + historySyncPlugin({ + config, + fallbackActivity: () => "Main", + }), + ], +}); + +export type Actions = typeof actions; diff --git a/demo/src/stackflow/index.ts b/demo/src/stackflow/index.ts new file mode 100644 index 000000000..92c29a03d --- /dev/null +++ b/demo/src/stackflow/index.ts @@ -0,0 +1 @@ +export * from "./Stack"; diff --git a/demo/src/stackflow/stackflow.config.ts b/demo/src/stackflow/stackflow.config.ts new file mode 100644 index 000000000..daa478073 --- /dev/null +++ b/demo/src/stackflow/stackflow.config.ts @@ -0,0 +1,20 @@ +import { defineConfig } from "@stackflow/config"; +import { articleLoader } from "../activities/Article.loader"; +import { mainLoader } from "../activities/Main.loader"; + +export const config = defineConfig({ + activities: [ + { + name: "Main", + path: "/", + loader: mainLoader, + }, + { + name: "Article", + path: "/articles/:articleId", + loader: articleLoader, + }, + ], + transitionDuration: 270, + initialActivity: () => "Main", +}); diff --git a/demo/src/stackflow-docs.ts b/demo/src/stackflow/stackflow.docs.ts similarity index 56% rename from demo/src/stackflow-docs.ts rename to demo/src/stackflow/stackflow.docs.ts index ed5b307a0..1c381251d 100644 --- a/demo/src/stackflow-docs.ts +++ b/demo/src/stackflow/stackflow.docs.ts @@ -1,14 +1,17 @@ import { vars } from "@seed-design/design-token"; import { basicUIPlugin } from "@stackflow/plugin-basic-ui"; import { basicRendererPlugin } from "@stackflow/plugin-renderer-basic"; -import { stackflow } from "@stackflow/react"; +import { stack } from "@stackflow/react/future"; +import Article from "../activities/Article"; +import Main from "../activities/Main"; +import { config } from "./stackflow.config"; -import { activities } from "./stackflow"; - -export const { Stack } = stackflow({ - transitionDuration: 350, - activities, - initialActivity: () => "Main", +export const { Stack } = stack({ + config, + components: { + Main, + Article, + }, plugins: [ basicRendererPlugin(), basicUIPlugin({ @@ -18,6 +21,12 @@ export const { Stack } = stackflow({ textColor: vars.$scale.color.gray900, iconColor: vars.$scale.color.gray900, borderColor: vars.$semantic.color.divider3, + backButton: { + ariaLabel: "뒤로 가기", + }, + closeButton: { + ariaLabel: "닫기", + }, }, }), ], diff --git a/demo/src/useFlow.ts b/demo/src/useFlow.ts deleted file mode 100644 index 93ab9bced..000000000 --- a/demo/src/useFlow.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { useActions } from "@stackflow/react"; - -import type { TypeActivities } from "./stackflow"; - -export function useFlow() { - return useActions(); -} diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 246e05262..ae3c0931c 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -1,5 +1,16 @@ # @stackflow/docs +## 1.2.25-canary.0 + +### Patch Changes + +- Updated dependencies + - @stackflow/plugin-history-sync@1.6.0-canary.0 + - @stackflow/react@1.2.0-canary.0 + - @stackflow/demo@1.3.0-canary.0 + - @stackflow/plugin-basic-ui@1.8.3-canary.0 + - @stackflow/plugin-renderer-basic@1.1.11-canary.0 + ## 1.2.24 ### Patch Changes diff --git a/docs/package.json b/docs/package.json index 9a711bb4d..63303dd7e 100644 --- a/docs/package.json +++ b/docs/package.json @@ -1,6 +1,6 @@ { "name": "@stackflow/docs", - "version": "1.2.24", + "version": "1.2.25-canary.0", "private": true, "description": "Mobile-first stack navigator framework with Composable Plugin System", "license": "MIT", @@ -12,11 +12,11 @@ "dependencies": { "@mdx-js/react": "^3.0.1", "@stackflow/core": "^1.0.13", - "@stackflow/demo": "^1.2.23", - "@stackflow/plugin-basic-ui": "^1.8.2", - "@stackflow/plugin-history-sync": "^1.5.4", - "@stackflow/plugin-renderer-basic": "^1.1.10", - "@stackflow/react": "^1.1.11", + "@stackflow/demo": "^1.3.0-canary.0", + "@stackflow/plugin-basic-ui": "^1.8.3-canary.0", + "@stackflow/plugin-history-sync": "^1.6.0-canary.0", + "@stackflow/plugin-renderer-basic": "^1.1.11-canary.0", + "@stackflow/react": "^1.2.0-canary.0", "@types/react": "^18.3.3", "next": "^14.2.4", "nextra": "^2.13.4", diff --git a/extensions/compat-await-push/CHANGELOG.md b/extensions/compat-await-push/CHANGELOG.md index d2d2666a1..aa14ff235 100644 --- a/extensions/compat-await-push/CHANGELOG.md +++ b/extensions/compat-await-push/CHANGELOG.md @@ -1,5 +1,12 @@ # @stackflow/compat-await-push +## 1.1.11-canary.0 + +### Patch Changes + +- Updated dependencies + - @stackflow/react@1.2.0-canary.0 + ## 1.1.10 ### Patch Changes diff --git a/extensions/compat-await-push/package.json b/extensions/compat-await-push/package.json index 3e1456bab..a139fae37 100644 --- a/extensions/compat-await-push/package.json +++ b/extensions/compat-await-push/package.json @@ -1,6 +1,6 @@ { "name": "@stackflow/compat-await-push", - "version": "1.1.10", + "version": "1.1.11-canary.0", "repository": { "type": "git", "url": "https://github.com/daangn/stackflow.git", @@ -33,7 +33,7 @@ "devDependencies": { "@stackflow/core": "^1.0.13", "@stackflow/esbuild-config": "^1.0.3", - "@stackflow/react": "^1.1.11", + "@stackflow/react": "^1.2.0-canary.0", "@types/react": "^18.3.3", "esbuild": "^0.23.0", "react": "^18.3.1", @@ -42,7 +42,7 @@ }, "peerDependencies": { "@stackflow/core": "^1", - "@stackflow/react": "^1", + "@stackflow/react": "^1.2.0-canary.0", "@types/react": ">=16.8.0", "react": ">=16.8.0" }, diff --git a/extensions/link/CHANGELOG.md b/extensions/link/CHANGELOG.md index 407e79d53..69b680df1 100644 --- a/extensions/link/CHANGELOG.md +++ b/extensions/link/CHANGELOG.md @@ -1,5 +1,14 @@ # @stackflow/link +## 1.4.3-canary.0 + +### Patch Changes + +- Updated dependencies + - @stackflow/plugin-history-sync@1.6.0-canary.0 + - @stackflow/react@1.2.0-canary.0 + - @stackflow/plugin-preload@1.3.3-canary.0 + ## 1.4.2 ### Patch Changes diff --git a/extensions/link/package.json b/extensions/link/package.json index cbc2eeb1b..1abcd6ced 100644 --- a/extensions/link/package.json +++ b/extensions/link/package.json @@ -1,6 +1,6 @@ { "name": "@stackflow/link", - "version": "1.4.2", + "version": "1.4.3-canary.0", "repository": { "type": "git", "url": "https://github.com/daangn/stackflow.git", @@ -33,9 +33,9 @@ "devDependencies": { "@stackflow/core": "^1.0.13", "@stackflow/esbuild-config": "^1.0.3", - "@stackflow/plugin-history-sync": "^1.5.4", - "@stackflow/plugin-preload": "^1.3.2", - "@stackflow/react": "^1.1.11", + "@stackflow/plugin-history-sync": "^1.6.0-canary.0", + "@stackflow/plugin-preload": "^1.3.3-canary.0", + "@stackflow/react": "^1.2.0-canary.0", "@types/react": "^18.3.3", "esbuild": "^0.23.0", "react": "^18.3.1", @@ -44,9 +44,9 @@ }, "peerDependencies": { "@stackflow/core": "^1", - "@stackflow/plugin-history-sync": "^1", - "@stackflow/plugin-preload": "^1", - "@stackflow/react": "^1", + "@stackflow/plugin-history-sync": "^1.6.0-canary.0", + "@stackflow/plugin-preload": "^1.3.3-canary.0", + "@stackflow/react": "^1.2.0-canary.0", "@types/react": ">=16.8.0", "react": ">=16.8.0" }, diff --git a/extensions/plugin-basic-ui/CHANGELOG.md b/extensions/plugin-basic-ui/CHANGELOG.md index 38b9ef5fe..c3c081ee9 100644 --- a/extensions/plugin-basic-ui/CHANGELOG.md +++ b/extensions/plugin-basic-ui/CHANGELOG.md @@ -1,5 +1,12 @@ # @stackflow/plugin-basic-ui +## 1.8.3-canary.0 + +### Patch Changes + +- Updated dependencies + - @stackflow/react@1.2.0-canary.0 + ## 1.8.2 ### Patch Changes diff --git a/extensions/plugin-basic-ui/package.json b/extensions/plugin-basic-ui/package.json index 65702900f..14cb0b65c 100644 --- a/extensions/plugin-basic-ui/package.json +++ b/extensions/plugin-basic-ui/package.json @@ -1,6 +1,6 @@ { "name": "@stackflow/plugin-basic-ui", - "version": "1.8.2", + "version": "1.8.3-canary.0", "repository": { "type": "git", "url": "https://github.com/daangn/stackflow.git", @@ -40,7 +40,7 @@ "devDependencies": { "@stackflow/core": "^1.0.13", "@stackflow/esbuild-config": "^1.0.3", - "@stackflow/react": "^1.1.11", + "@stackflow/react": "^1.2.0-canary.0", "@types/react": "^18.3.3", "esbuild": "^0.23.0", "react": "^18.3.1", @@ -49,7 +49,7 @@ }, "peerDependencies": { "@stackflow/core": "^1", - "@stackflow/react": "^1", + "@stackflow/react": "^1.2.0-canary.0", "@types/react": ">=16.8.0", "react": ">=16.8.0" }, diff --git a/extensions/plugin-google-analytics-4/CHANGELOG.md b/extensions/plugin-google-analytics-4/CHANGELOG.md index f306c204b..4939dd864 100644 --- a/extensions/plugin-google-analytics-4/CHANGELOG.md +++ b/extensions/plugin-google-analytics-4/CHANGELOG.md @@ -1,5 +1,12 @@ # @stackflow/plugin-google-analytics-4 +## 1.1.13-canary.0 + +### Patch Changes + +- Updated dependencies + - @stackflow/react@1.2.0-canary.0 + ## 1.1.12 ### Patch Changes diff --git a/extensions/plugin-google-analytics-4/package.json b/extensions/plugin-google-analytics-4/package.json index 38590c4aa..792ca49a2 100644 --- a/extensions/plugin-google-analytics-4/package.json +++ b/extensions/plugin-google-analytics-4/package.json @@ -1,6 +1,6 @@ { "name": "@stackflow/plugin-google-analytics-4", - "version": "1.1.12", + "version": "1.1.13-canary.0", "repository": { "type": "git", "url": "https://github.com/daangn/stackflow.git", @@ -37,7 +37,7 @@ "devDependencies": { "@stackflow/core": "^1.0.13", "@stackflow/esbuild-config": "^1.0.3", - "@stackflow/react": "^1.1.11", + "@stackflow/react": "^1.2.0-canary.0", "@types/react": "^18.3.3", "esbuild": "^0.23.0", "react": "^18.3.1", @@ -46,7 +46,7 @@ }, "peerDependencies": { "@stackflow/core": "^1", - "@stackflow/react": "^1", + "@stackflow/react": "^1.2.0-canary.0", "@types/react": ">=16.8.0", "react": ">=16.8.0" }, diff --git a/extensions/plugin-history-sync/CHANGELOG.md b/extensions/plugin-history-sync/CHANGELOG.md index e472ee912..dfba8f9f7 100644 --- a/extensions/plugin-history-sync/CHANGELOG.md +++ b/extensions/plugin-history-sync/CHANGELOG.md @@ -1,5 +1,17 @@ # @stackflow/plugin-history-sync +## 1.6.0-canary.0 + +### Minor Changes + +- Future API + +### Patch Changes + +- Updated dependencies + - @stackflow/react@1.2.0-canary.0 + - @stackflow/config@1.0.1-canary.0 + ## 1.5.4 ### Patch Changes diff --git a/extensions/plugin-history-sync/package.json b/extensions/plugin-history-sync/package.json index 455ebcde4..ac1ec89c1 100644 --- a/extensions/plugin-history-sync/package.json +++ b/extensions/plugin-history-sync/package.json @@ -1,6 +1,6 @@ { "name": "@stackflow/plugin-history-sync", - "version": "1.5.4", + "version": "1.6.0-canary.0", "repository": { "type": "git", "url": "https://github.com/daangn/stackflow.git", @@ -45,9 +45,10 @@ "url-pattern": "^1.0.3" }, "devDependencies": { + "@stackflow/config": "^1.0.1-canary.0", "@stackflow/core": "^1.0.13", "@stackflow/esbuild-config": "^1.0.3", - "@stackflow/react": "^1.1.11", + "@stackflow/react": "^1.2.0-canary.0", "@swc/core": "^1.6.6", "@swc/jest": "^0.2.36", "@types/jest": "^29.5.12", @@ -60,8 +61,9 @@ "typescript": "^5.5.3" }, "peerDependencies": { + "@stackflow/config": "^1.0.1-canary.0", "@stackflow/core": "^1", - "@stackflow/react": "^1", + "@stackflow/react": "^1.2.0-canary.0", "@types/react": ">=16.8.0", "react": ">=16.8.0" }, diff --git a/extensions/plugin-history-sync/src/historySyncPlugin.tsx b/extensions/plugin-history-sync/src/historySyncPlugin.tsx index 8d4c32cfc..363d7ed58 100644 --- a/extensions/plugin-history-sync/src/historySyncPlugin.tsx +++ b/extensions/plugin-history-sync/src/historySyncPlugin.tsx @@ -3,6 +3,7 @@ import type { StackflowReactPlugin } from "@stackflow/react"; import type { History, Listener } from "history"; import { createBrowserHistory, createMemoryHistory } from "history"; +import type { ActivityDefinition, Config } from "@stackflow/config"; import { HistoryQueueProvider } from "./HistoryQueueContext"; import type { RouteLike } from "./RouteLike"; import { RoutesProvider } from "./RoutesContext"; @@ -22,10 +23,22 @@ import { sortActivityRoutes } from "./sortActivityRoutes"; const SECOND = 1000; const MINUTE = 60 * SECOND; -type HistorySyncPluginOptions> = { - routes: { - [key in keyof T]: RouteLike; - }; +declare module "@stackflow/config" { + interface ActivityDefinition { + path: string; + } +} + +type HistorySyncPluginOptions> = ( + | { + routes: { + [key in keyof T]: RouteLike; + }; + } + | { + config: Config>; + } +) & { fallbackActivity: (args: { initialContext: any }) => K; useHash?: boolean; history?: History; @@ -45,9 +58,18 @@ export function historySyncPlugin< const { location } = history; - const activityRoutes = sortActivityRoutes( - normalizeActivityRouteMap(options.routes), - ); + const routes = + "routes" in options + ? options.routes + : options.config.activities.reduce( + (acc, a) => ({ + ...acc, + [a.name]: a.path, + }), + {}, + ); + + const activityRoutes = sortActivityRoutes(normalizeActivityRouteMap(routes)); return () => { let pushFlag = 0; diff --git a/extensions/plugin-map-initial-activity/CHANGELOG.md b/extensions/plugin-map-initial-activity/CHANGELOG.md index 29d12405a..0f0472216 100644 --- a/extensions/plugin-map-initial-activity/CHANGELOG.md +++ b/extensions/plugin-map-initial-activity/CHANGELOG.md @@ -1,5 +1,12 @@ # @stackflow/plugin-map-initial-activity +## 1.0.9-canary.0 + +### Patch Changes + +- Updated dependencies + - @stackflow/react@1.2.0-canary.0 + ## 1.0.8 ### Patch Changes diff --git a/extensions/plugin-map-initial-activity/package.json b/extensions/plugin-map-initial-activity/package.json index d73f591ba..4c4bca7ae 100644 --- a/extensions/plugin-map-initial-activity/package.json +++ b/extensions/plugin-map-initial-activity/package.json @@ -1,6 +1,6 @@ { "name": "@stackflow/plugin-map-initial-activity", - "version": "1.0.8", + "version": "1.0.9-canary.0", "repository": { "type": "git", "url": "https://github.com/daangn/stackflow.git", @@ -33,14 +33,14 @@ "devDependencies": { "@stackflow/core": "^1.0.13", "@stackflow/esbuild-config": "^1.0.3", - "@stackflow/react": "^1.1.11", + "@stackflow/react": "^1.2.0-canary.0", "esbuild": "^0.23.0", "rimraf": "^3.0.2", "typescript": "^5.5.3" }, "peerDependencies": { "@stackflow/core": "^1", - "@stackflow/react": "^1" + "@stackflow/react": "^1.2.0-canary.0" }, "publishConfig": { "access": "public" diff --git a/extensions/plugin-preload/CHANGELOG.md b/extensions/plugin-preload/CHANGELOG.md index 55d5b7737..97c1fddc5 100644 --- a/extensions/plugin-preload/CHANGELOG.md +++ b/extensions/plugin-preload/CHANGELOG.md @@ -1,5 +1,13 @@ # @stackflow/plugin-preload +## 1.3.3-canary.0 + +### Patch Changes + +- Updated dependencies + - @stackflow/plugin-history-sync@1.6.0-canary.0 + - @stackflow/react@1.2.0-canary.0 + ## 1.3.2 ### Patch Changes diff --git a/extensions/plugin-preload/package.json b/extensions/plugin-preload/package.json index df3a369de..ade35720a 100644 --- a/extensions/plugin-preload/package.json +++ b/extensions/plugin-preload/package.json @@ -1,6 +1,6 @@ { "name": "@stackflow/plugin-preload", - "version": "1.3.2", + "version": "1.3.3-canary.0", "repository": { "type": "git", "url": "https://github.com/daangn/stackflow.git", @@ -31,12 +31,12 @@ "typecheck": "tsc --noEmit" }, "dependencies": { - "@stackflow/plugin-history-sync": "^1.5.4" + "@stackflow/plugin-history-sync": "^1.6.0-canary.0" }, "devDependencies": { "@stackflow/core": "^1.0.13", "@stackflow/esbuild-config": "^1.0.3", - "@stackflow/react": "^1.1.11", + "@stackflow/react": "^1.2.0-canary.0", "@types/react": "^18.3.3", "esbuild": "^0.23.0", "react": "^18.3.1", @@ -45,7 +45,7 @@ }, "peerDependencies": { "@stackflow/core": "^1", - "@stackflow/react": "^1", + "@stackflow/react": "^1.2.0-canary.0", "@types/react": ">=16.8.0", "react": ">=16.8.0" }, diff --git a/extensions/plugin-renderer-basic/CHANGELOG.md b/extensions/plugin-renderer-basic/CHANGELOG.md index dfd819940..89eef6826 100644 --- a/extensions/plugin-renderer-basic/CHANGELOG.md +++ b/extensions/plugin-renderer-basic/CHANGELOG.md @@ -1,5 +1,12 @@ # @stackflow/plugin-renderer-basic +## 1.1.11-canary.0 + +### Patch Changes + +- Updated dependencies + - @stackflow/react@1.2.0-canary.0 + ## 1.1.10 ### Patch Changes diff --git a/extensions/plugin-renderer-basic/package.json b/extensions/plugin-renderer-basic/package.json index 5a57848dd..9ea411f9f 100644 --- a/extensions/plugin-renderer-basic/package.json +++ b/extensions/plugin-renderer-basic/package.json @@ -1,6 +1,6 @@ { "name": "@stackflow/plugin-renderer-basic", - "version": "1.1.10", + "version": "1.1.11-canary.0", "repository": { "type": "git", "url": "https://github.com/daangn/stackflow.git", @@ -33,7 +33,7 @@ "devDependencies": { "@stackflow/core": "^1.0.13", "@stackflow/esbuild-config": "^1.0.3", - "@stackflow/react": "^1.1.11", + "@stackflow/react": "^1.2.0-canary.0", "@types/react": "^18.3.3", "esbuild": "^0.23.0", "react": "^18.3.1", @@ -42,7 +42,7 @@ }, "peerDependencies": { "@stackflow/core": "^1", - "@stackflow/react": "^1", + "@stackflow/react": "^1.2.0-canary.0", "@types/react": ">=16.8.0", "react": ">=16.8.0" }, diff --git a/extensions/plugin-renderer-web/CHANGELOG.md b/extensions/plugin-renderer-web/CHANGELOG.md index 1c19addb2..16653aa86 100644 --- a/extensions/plugin-renderer-web/CHANGELOG.md +++ b/extensions/plugin-renderer-web/CHANGELOG.md @@ -1,5 +1,12 @@ # @stackflow/plugin-renderer-web +## 1.1.11-canary.0 + +### Patch Changes + +- Updated dependencies + - @stackflow/react@1.2.0-canary.0 + ## 1.1.10 ### Patch Changes diff --git a/extensions/plugin-renderer-web/package.json b/extensions/plugin-renderer-web/package.json index 50157335d..e688f85e2 100644 --- a/extensions/plugin-renderer-web/package.json +++ b/extensions/plugin-renderer-web/package.json @@ -1,6 +1,6 @@ { "name": "@stackflow/plugin-renderer-web", - "version": "1.1.10", + "version": "1.1.11-canary.0", "repository": { "type": "git", "url": "https://github.com/daangn/stackflow.git", @@ -33,7 +33,7 @@ "devDependencies": { "@stackflow/core": "^1.0.13", "@stackflow/esbuild-config": "^1.0.3", - "@stackflow/react": "^1.1.11", + "@stackflow/react": "^1.2.0-canary.0", "@types/react": "^18.3.3", "esbuild": "^0.23.0", "react": "^18.3.1", @@ -42,7 +42,7 @@ }, "peerDependencies": { "@stackflow/core": "^1", - "@stackflow/react": "^1", + "@stackflow/react": "^1.2.0-canary.0", "@types/react": ">=16.8.0", "react": ">=16.8.0" }, diff --git a/integrations/react/CHANGELOG.md b/integrations/react/CHANGELOG.md index 4651169f8..939323745 100644 --- a/integrations/react/CHANGELOG.md +++ b/integrations/react/CHANGELOG.md @@ -1,5 +1,40 @@ # @stackflow/react +## 1.2.0-canary.4 + +### Minor Changes + +- change extension esm package .mjs to .js + +## 1.2.0-canary.3 + +### Minor Changes + +- support esm, cjs both + +## 1.2.0-canary.2 + +### Minor Changes + +- Change package to ESM Only + +## 1.2.0-canary.1 + +### Minor Changes + +- Future API + +## 1.2.0-canary.0 + +### Minor Changes + +- Future API + +### Patch Changes + +- Updated dependencies + - @stackflow/config@1.0.1-canary.0 + ## 1.1.11 ### Patch Changes diff --git a/integrations/react/esbuild.config.js b/integrations/react/esbuild.config.js index c57432b7c..57f702db9 100644 --- a/integrations/react/esbuild.config.js +++ b/integrations/react/esbuild.config.js @@ -1,28 +1,30 @@ const { context } = require("esbuild"); const config = require("@stackflow/esbuild-config"); -const pkg = require("./package.json"); -const external = Object.keys({ - ...pkg.dependencies, - ...pkg.peerDependencies, -}); const watch = process.argv.includes("--watch"); Promise.all([ context({ - ...config({}), + ...config({ + entryPoints: ["./src/**/*"], + outdir: "dist/cjs", + }), + bundle: false, + sourcemap: false, + external: undefined, format: "cjs", - external, }).then((ctx) => watch ? ctx.watch() : ctx.rebuild().then(() => ctx.dispose()), ), context({ - ...config({}), + ...config({ + entryPoints: ["./src/**/*"], + outdir: "dist/esm", + }), + bundle: false, + sourcemap: false, + external: undefined, format: "esm", - outExtension: { - ".js": ".mjs", - }, - external, }).then((ctx) => watch ? ctx.watch() : ctx.rebuild().then(() => ctx.dispose()), ), diff --git a/integrations/react/package.json b/integrations/react/package.json index 6d223505e..72e0dc3e9 100644 --- a/integrations/react/package.json +++ b/integrations/react/package.json @@ -1,6 +1,6 @@ { "name": "@stackflow/react", - "version": "1.1.11", + "version": "1.2.0-canary.4", "repository": { "type": "git", "url": "https://github.com/daangn/stackflow.git", @@ -9,14 +9,24 @@ "license": "MIT", "exports": { ".": { - "types": "./dist/index.d.ts", - "require": "./dist/index.js", - "import": "./dist/index.mjs" + "types": "./dist/esm/index.d.ts", + "require": "./dist/cjs/index.js", + "import": "./dist/esm/index.js" + }, + "./stable": { + "types": "./dist/esm/stable/index.d.ts", + "require": "./dist/cjs/stable/index.js", + "import": "./dist/esm/stable/index.js" + }, + "./future": { + "types": "./dist/esm/future/index.d.ts", + "require": "./dist/cjs/future/index.js", + "import": "./dist/esm/future/index.js" } }, - "main": "./dist/index.js", - "module": "./dist/index.mjs", - "types": "./dist/index.d.ts", + "main": "./dist/cjs/index.js", + "module": "./dist/esm/index.js", + "types": "./dist/esm/index.d.ts", "files": [ "dist", "src", @@ -24,25 +34,30 @@ ], "scripts": { "build": "yarn build:js && yarn build:dts", - "build:dts": "tsc --emitDeclarationOnly", + "build:dts": "tsc --emitDeclarationOnly --outDir dist/esm && tsc --emitDeclarationOnly --outDir dist/cjs", "build:js": "node ./esbuild.config.js", "clean": "rimraf dist", "dev": "yarn build:js --watch && yarn build:dts --watch", "typecheck": "tsc --noEmit" }, "dependencies": { - "react-fast-compare": "^3.2.2" + "history": "^5.3.0", + "react-fast-compare": "^3.2.2", + "url-pattern": "^1.0.3" }, "devDependencies": { + "@stackflow/config": "^1.0.1-canary.0", "@stackflow/core": "^1.0.13", "@stackflow/esbuild-config": "^1.0.3", "@types/react": "^18.3.3", "esbuild": "^0.23.0", + "esbuild-plugin-file-path-extensions": "^2.1.2", "react": "^18.3.1", "rimraf": "^3.0.2", "typescript": "^5.5.3" }, "peerDependencies": { + "@stackflow/config": "^1.0.1-canary.0", "@stackflow/core": "^1", "@types/react": ">=16.8.0", "react": ">=16.8.0" diff --git a/integrations/react/src/activity/ActivityComponentType.tsx b/integrations/react/src/__internal__/ActivityComponentType.tsx similarity index 77% rename from integrations/react/src/activity/ActivityComponentType.tsx rename to integrations/react/src/__internal__/ActivityComponentType.tsx index 5e1f6d36d..cbe1b5591 100644 --- a/integrations/react/src/activity/ActivityComponentType.tsx +++ b/integrations/react/src/__internal__/ActivityComponentType.tsx @@ -1,2 +1,4 @@ +import type React from "react"; + export type ActivityComponentType = React.ComponentType<{ params: T }>; diff --git a/integrations/react/src/MainRenderer.tsx b/integrations/react/src/__internal__/MainRenderer.tsx similarity index 94% rename from integrations/react/src/MainRenderer.tsx rename to integrations/react/src/__internal__/MainRenderer.tsx index 6d078c24c..af4e9da46 100644 --- a/integrations/react/src/MainRenderer.tsx +++ b/integrations/react/src/__internal__/MainRenderer.tsx @@ -1,14 +1,14 @@ import { useEffect } from "react"; +import type { ActivityComponentType } from "./ActivityComponentType"; import PluginRenderer from "./PluginRenderer"; -import type { ActivityComponentType } from "./activity"; import { useCoreState } from "./core"; import { usePlugins } from "./plugins"; import type { WithRequired } from "./utils"; interface MainRendererProps { activityComponentMap: { - [key: string]: ActivityComponentType; + [key: string]: any; }; initialContext: any; } diff --git a/integrations/react/src/PluginRenderer.tsx b/integrations/react/src/__internal__/PluginRenderer.tsx similarity index 96% rename from integrations/react/src/PluginRenderer.tsx rename to integrations/react/src/__internal__/PluginRenderer.tsx index c2c550e59..b60c8330a 100644 --- a/integrations/react/src/PluginRenderer.tsx +++ b/integrations/react/src/__internal__/PluginRenderer.tsx @@ -1,5 +1,5 @@ +import type { ActivityComponentType } from "./ActivityComponentType"; import type { StackflowReactPlugin } from "./StackflowReactPlugin"; -import type { ActivityComponentType } from "./activity"; import { ActivityProvider } from "./activity"; import { useCoreState } from "./core"; import { usePlugins } from "./plugins"; diff --git a/integrations/react/src/StackflowReactPlugin.ts b/integrations/react/src/__internal__/StackflowReactPlugin.ts similarity index 97% rename from integrations/react/src/StackflowReactPlugin.ts rename to integrations/react/src/__internal__/StackflowReactPlugin.ts index 38f5de277..7a11c602e 100644 --- a/integrations/react/src/StackflowReactPlugin.ts +++ b/integrations/react/src/__internal__/StackflowReactPlugin.ts @@ -1,4 +1,5 @@ import type { Activity, Stack, StackflowPlugin } from "@stackflow/core"; +import type React from "react"; export type StackflowReactPlugin = () => { /** diff --git a/integrations/react/src/activity/ActivityProvider.tsx b/integrations/react/src/__internal__/activity/ActivityProvider.tsx similarity index 100% rename from integrations/react/src/activity/ActivityProvider.tsx rename to integrations/react/src/__internal__/activity/ActivityProvider.tsx diff --git a/integrations/react/src/activity/index.ts b/integrations/react/src/__internal__/activity/index.ts similarity index 80% rename from integrations/react/src/activity/index.ts rename to integrations/react/src/__internal__/activity/index.ts index 89e898aff..80001dcd6 100644 --- a/integrations/react/src/activity/index.ts +++ b/integrations/react/src/__internal__/activity/index.ts @@ -1,4 +1,3 @@ -export * from "./ActivityComponentType"; export * from "./ActivityProvider"; export * from "./makeActivityId"; export * from "./makeStepId"; diff --git a/integrations/react/src/activity/makeActivityId.ts b/integrations/react/src/__internal__/activity/makeActivityId.ts similarity index 100% rename from integrations/react/src/activity/makeActivityId.ts rename to integrations/react/src/__internal__/activity/makeActivityId.ts diff --git a/integrations/react/src/activity/makeStepId.ts b/integrations/react/src/__internal__/activity/makeStepId.ts similarity index 100% rename from integrations/react/src/activity/makeStepId.ts rename to integrations/react/src/__internal__/activity/makeStepId.ts diff --git a/integrations/react/src/activity/useActivity.ts b/integrations/react/src/__internal__/activity/useActivity.ts similarity index 100% rename from integrations/react/src/activity/useActivity.ts rename to integrations/react/src/__internal__/activity/useActivity.ts diff --git a/integrations/react/src/activity/useActivityParams.ts b/integrations/react/src/__internal__/activity/useActivityParams.ts similarity index 100% rename from integrations/react/src/activity/useActivityParams.ts rename to integrations/react/src/__internal__/activity/useActivityParams.ts diff --git a/integrations/react/src/core/CoreProvider.tsx b/integrations/react/src/__internal__/core/CoreProvider.tsx similarity index 100% rename from integrations/react/src/core/CoreProvider.tsx rename to integrations/react/src/__internal__/core/CoreProvider.tsx diff --git a/integrations/react/src/core/index.ts b/integrations/react/src/__internal__/core/index.ts similarity index 100% rename from integrations/react/src/core/index.ts rename to integrations/react/src/__internal__/core/index.ts diff --git a/integrations/react/src/core/useCoreActions.ts b/integrations/react/src/__internal__/core/useCoreActions.ts similarity index 100% rename from integrations/react/src/core/useCoreActions.ts rename to integrations/react/src/__internal__/core/useCoreActions.ts diff --git a/integrations/react/src/core/useCoreState.ts b/integrations/react/src/__internal__/core/useCoreState.ts similarity index 100% rename from integrations/react/src/core/useCoreState.ts rename to integrations/react/src/__internal__/core/useCoreState.ts diff --git a/integrations/react/src/plugins/PluginsProvider.tsx b/integrations/react/src/__internal__/plugins/PluginsProvider.tsx similarity index 100% rename from integrations/react/src/plugins/PluginsProvider.tsx rename to integrations/react/src/__internal__/plugins/PluginsProvider.tsx diff --git a/integrations/react/src/plugins/index.ts b/integrations/react/src/__internal__/plugins/index.ts similarity index 100% rename from integrations/react/src/plugins/index.ts rename to integrations/react/src/__internal__/plugins/index.ts diff --git a/integrations/react/src/plugins/usePlugins.ts b/integrations/react/src/__internal__/plugins/usePlugins.ts similarity index 100% rename from integrations/react/src/plugins/usePlugins.ts rename to integrations/react/src/__internal__/plugins/usePlugins.ts diff --git a/integrations/react/src/shims/index.ts b/integrations/react/src/__internal__/shims/index.ts similarity index 100% rename from integrations/react/src/shims/index.ts rename to integrations/react/src/__internal__/shims/index.ts diff --git a/integrations/react/src/shims/useDeferredValue.ts b/integrations/react/src/__internal__/shims/useDeferredValue.ts similarity index 100% rename from integrations/react/src/shims/useDeferredValue.ts rename to integrations/react/src/__internal__/shims/useDeferredValue.ts diff --git a/integrations/react/src/shims/useSyncExternalStore.ts b/integrations/react/src/__internal__/shims/useSyncExternalStore.ts similarity index 100% rename from integrations/react/src/shims/useSyncExternalStore.ts rename to integrations/react/src/__internal__/shims/useSyncExternalStore.ts diff --git a/integrations/react/src/shims/useTransition.ts b/integrations/react/src/__internal__/shims/useTransition.ts similarity index 100% rename from integrations/react/src/shims/useTransition.ts rename to integrations/react/src/__internal__/shims/useTransition.ts diff --git a/integrations/react/src/stack/StackProvider.tsx b/integrations/react/src/__internal__/stack/StackProvider.tsx similarity index 100% rename from integrations/react/src/stack/StackProvider.tsx rename to integrations/react/src/__internal__/stack/StackProvider.tsx diff --git a/integrations/react/src/stack/index.ts b/integrations/react/src/__internal__/stack/index.ts similarity index 100% rename from integrations/react/src/stack/index.ts rename to integrations/react/src/__internal__/stack/index.ts diff --git a/integrations/react/src/stack/useStack.ts b/integrations/react/src/__internal__/stack/useStack.ts similarity index 100% rename from integrations/react/src/stack/useStack.ts rename to integrations/react/src/__internal__/stack/useStack.ts diff --git a/integrations/react/src/utils/WithRequired.ts b/integrations/react/src/__internal__/utils/WithRequired.ts similarity index 100% rename from integrations/react/src/utils/WithRequired.ts rename to integrations/react/src/__internal__/utils/WithRequired.ts diff --git a/integrations/react/src/utils/index.ts b/integrations/react/src/__internal__/utils/index.ts similarity index 100% rename from integrations/react/src/utils/index.ts rename to integrations/react/src/__internal__/utils/index.ts diff --git a/integrations/react/src/utils/isBrowser.ts b/integrations/react/src/__internal__/utils/isBrowser.ts similarity index 100% rename from integrations/react/src/utils/isBrowser.ts rename to integrations/react/src/__internal__/utils/isBrowser.ts diff --git a/integrations/react/src/utils/isServer.ts b/integrations/react/src/__internal__/utils/isServer.ts similarity index 100% rename from integrations/react/src/utils/isServer.ts rename to integrations/react/src/__internal__/utils/isServer.ts diff --git a/integrations/react/src/utils/makeRef.ts b/integrations/react/src/__internal__/utils/makeRef.ts similarity index 100% rename from integrations/react/src/utils/makeRef.ts rename to integrations/react/src/__internal__/utils/makeRef.ts diff --git a/integrations/react/src/utils/noop.ts b/integrations/react/src/__internal__/utils/noop.ts similarity index 100% rename from integrations/react/src/utils/noop.ts rename to integrations/react/src/__internal__/utils/noop.ts diff --git a/integrations/react/src/utils/useMemoDeep.ts b/integrations/react/src/__internal__/utils/useMemoDeep.ts similarity index 100% rename from integrations/react/src/utils/useMemoDeep.ts rename to integrations/react/src/__internal__/utils/useMemoDeep.ts diff --git a/integrations/react/src/future/Actions.ts b/integrations/react/src/future/Actions.ts new file mode 100644 index 000000000..1105f4cb3 --- /dev/null +++ b/integrations/react/src/future/Actions.ts @@ -0,0 +1,29 @@ +import type { + InferActivityParams, + RegisteredActivityParamTypes, +} from "@stackflow/config"; + +export type Actions = { + push>( + activityName: K, + activityParams: InferActivityParams, + options?: { + animate?: boolean; + }, + ): { + activityId: string; + }; + replace>( + activityName: K, + activityParams: InferActivityParams, + options?: { + animate?: boolean; + activityId?: string; + }, + ): { + activityId: string; + }; + pop(): void; + pop(options: { animate?: boolean }): void; + pop(count: number, options?: { animate?: boolean }): void; +}; diff --git a/integrations/react/src/future/ActivityComponentType.tsx b/integrations/react/src/future/ActivityComponentType.tsx new file mode 100644 index 000000000..2368cb06f --- /dev/null +++ b/integrations/react/src/future/ActivityComponentType.tsx @@ -0,0 +1,9 @@ +import type { + InferActivityParams, + RegisteredActivityParamTypes, +} from "@stackflow/config"; +import type React from "react"; + +export type ActivityComponentType< + ActivityName extends Extract, +> = React.ComponentType<{ params: InferActivityParams }>; diff --git a/integrations/react/src/future/StackComponentType.ts b/integrations/react/src/future/StackComponentType.ts new file mode 100644 index 000000000..c3fca2fe4 --- /dev/null +++ b/integrations/react/src/future/StackComponentType.ts @@ -0,0 +1,3 @@ +export type StackComponentType = React.FC<{ + initialLoaderData?: any; +}>; diff --git a/integrations/react/src/future/StepActions.ts b/integrations/react/src/future/StepActions.ts new file mode 100644 index 000000000..c8838cf1b --- /dev/null +++ b/integrations/react/src/future/StepActions.ts @@ -0,0 +1,5 @@ +export type StepActions = { + pushStep: (params: ActivityParams, options?: {}) => void; + replaceStep: (params: ActivityParams, options?: {}) => void; + popStep: (options?: {}) => void; +}; diff --git a/integrations/react/src/future/index.ts b/integrations/react/src/future/index.ts new file mode 100644 index 000000000..11c8e6e1a --- /dev/null +++ b/integrations/react/src/future/index.ts @@ -0,0 +1,23 @@ +/** + * Stack + */ +export * from "./stack"; + +/** + * Types + */ +export * from "../__internal__/StackflowReactPlugin"; +export * from "./ActivityComponentType"; +export * from "./StackComponentType"; +export * from "./Actions"; +export * from "./StepActions"; + +/** + * Hooks + */ +export * from "../__internal__/stack/useStack"; +export * from "../__internal__/activity/useActivity"; +export * from "./useActivityParams"; +export * from "./loader/useLoaderData"; +export * from "./useFlow"; +export * from "./useStepFlow"; diff --git a/integrations/react/src/future/loader/index.ts b/integrations/react/src/future/loader/index.ts new file mode 100644 index 000000000..034f3f9e5 --- /dev/null +++ b/integrations/react/src/future/loader/index.ts @@ -0,0 +1,2 @@ +export * from "./loaderPlugin"; +export * from "./useLoaderData"; diff --git a/integrations/react/src/future/loader/loaderPlugin.tsx b/integrations/react/src/future/loader/loaderPlugin.tsx new file mode 100644 index 000000000..e5e191405 --- /dev/null +++ b/integrations/react/src/future/loader/loaderPlugin.tsx @@ -0,0 +1,100 @@ +import type { ActivityDefinition, Config } from "@stackflow/config"; +import type { StackflowReactPlugin } from "../../__internal__/StackflowReactPlugin"; + +export function loaderPlugin( + config: Config>, +): StackflowReactPlugin { + return () => ({ + key: "plugin-loader", + overrideInitialEvents({ initialEvents, initialContext }) { + if (initialEvents.length === 0) { + return []; + } + + return initialEvents.map((event) => { + if (event.name !== "Pushed") { + return event; + } + + if (initialContext.initialLoaderData) { + return { + ...event, + activityContext: { + ...event.activityContext, + loaderData: initialContext.initialLoaderData, + }, + }; + } + + const { activityName, activityParams } = event; + + const matchActivity = config.activities.find( + (activity) => activity.name === activityName, + ); + const loader = matchActivity?.loader; + + if (!loader) { + return event; + } + + const loaderData = loader({ + params: activityParams, + }); + + return { + ...event, + activityContext: { + ...event.activityContext, + loaderData, + }, + }; + }); + }, + onBeforePush({ actionParams, actions: { overrideActionParams } }) { + const { activityName, activityParams, activityContext } = actionParams; + + const loader = config.activities.find( + (activity) => activity.name === activityName, + )?.loader; + + if (!loader) { + return; + } + + const loaderData = loader({ + params: activityParams, + }); + + overrideActionParams({ + ...actionParams, + activityContext: { + ...activityContext, + loaderData, + }, + }); + }, + onBeforeReplace({ actionParams, actions: { overrideActionParams } }) { + const { activityName, activityParams, activityContext } = actionParams; + + const loader = config.activities.find( + (activity) => activity.name === activityName, + )?.loader; + + if (!loader) { + return; + } + + const loaderData = loader({ + params: activityParams, + }); + + overrideActionParams({ + ...actionParams, + activityContext: { + ...activityContext, + loaderData, + }, + }); + }, + }); +} diff --git a/integrations/react/src/future/loader/useLoaderData.ts b/integrations/react/src/future/loader/useLoaderData.ts new file mode 100644 index 000000000..74604eb3c --- /dev/null +++ b/integrations/react/src/future/loader/useLoaderData.ts @@ -0,0 +1,8 @@ +import type { ActivityLoaderArgs } from "@stackflow/config"; +import { useActivity } from "../../stable"; + +export function useLoaderData< + T extends (args: ActivityLoaderArgs) => any, +>(): ReturnType { + return (useActivity().context as any)?.loaderData; +} diff --git a/integrations/react/src/future/makeActions.ts b/integrations/react/src/future/makeActions.ts new file mode 100644 index 000000000..4ff8c188b --- /dev/null +++ b/integrations/react/src/future/makeActions.ts @@ -0,0 +1,80 @@ +import type { CoreStore } from "@stackflow/core"; +import { makeActivityId } from "../__internal__/activity"; +import type { Actions } from "./Actions"; + +function parseActionOptions(options?: { animate?: boolean }) { + if (!options) { + return { skipActiveState: false }; + } + + const isNullableAnimateOption = options.animate == null; + + if (isNullableAnimateOption) { + return { skipActiveState: false }; + } + + return { skipActiveState: !options.animate }; +} + +export function makeActions( + getCoreActions: () => CoreStore["actions"] | undefined, +): Actions { + return { + push(activityName, activityParams, options) { + const activityId = makeActivityId(); + + getCoreActions()?.push({ + activityId, + activityName, + activityParams, + skipEnterActiveState: parseActionOptions(options).skipActiveState, + }); + + return { + activityId, + }; + }, + replace(activityName, activityParams, options) { + const activityId = makeActivityId(); + + getCoreActions()?.replace({ + activityId: options?.activityId ?? makeActivityId(), + activityName, + activityParams, + skipEnterActiveState: parseActionOptions(options).skipActiveState, + }); + + return { + activityId, + }; + }, + pop( + count?: number | { animate?: boolean } | undefined, + options?: { animate?: boolean } | undefined, + ) { + let _count = 1; + let _options: { animate?: boolean } = {}; + + if (typeof count === "object") { + _options = { + ...count, + }; + } + if (typeof count === "number") { + _count = count; + } + if (options) { + _options = { + ...options, + }; + } + + for (let i = 0; i < _count; i += 1) { + getCoreActions()?.pop({ + skipExitActiveState: + i === 0 ? parseActionOptions(_options).skipActiveState : true, + }); + } + }, + }; +} diff --git a/integrations/react/src/future/makeStepActions.ts b/integrations/react/src/future/makeStepActions.ts new file mode 100644 index 000000000..41e83caaa --- /dev/null +++ b/integrations/react/src/future/makeStepActions.ts @@ -0,0 +1,30 @@ +import type { ActivityBaseParams } from "@stackflow/config"; +import type { CoreStore } from "@stackflow/core"; +import { makeStepId } from "../__internal__/activity"; +import type { StepActions } from "./StepActions"; + +export function makeStepActions( + getCoreActions: () => CoreStore["actions"] | undefined, +): StepActions { + return { + pushStep(stepParams) { + const stepId = makeStepId(); + + getCoreActions()?.stepPush({ + stepId, + stepParams, + }); + }, + replaceStep(stepParams) { + const stepId = makeStepId(); + + getCoreActions()?.stepReplace({ + stepId, + stepParams, + }); + }, + popStep() { + getCoreActions()?.stepPop({}); + }, + }; +} diff --git a/integrations/react/src/future/stack.tsx b/integrations/react/src/future/stack.tsx new file mode 100644 index 000000000..280d3bb8e --- /dev/null +++ b/integrations/react/src/future/stack.tsx @@ -0,0 +1,167 @@ +import type { + ActivityBaseParams, + ActivityDefinition, + Config, +} from "@stackflow/config"; +import { + type CoreStore, + type PushedEvent, + makeCoreStore, + makeEvent, +} from "@stackflow/core"; +import React, { useMemo } from "react"; +import MainRenderer from "../__internal__/MainRenderer"; +import { makeActivityId } from "../__internal__/activity"; +import { CoreProvider } from "../__internal__/core"; +import { PluginsProvider } from "../__internal__/plugins"; +import { isBrowser, makeRef } from "../__internal__/utils"; +import type { ActivityComponentType, StackflowReactPlugin } from "../stable"; +import type { Actions } from "./Actions"; +import type { StackComponentType } from "./StackComponentType"; +import type { StepActions } from "./StepActions"; +import { loaderPlugin } from "./loader"; +import { makeActions } from "./makeActions"; +import { makeStepActions } from "./makeStepActions"; + +export type StackflowPluginsEntry = + | StackflowReactPlugin + | StackflowPluginsEntry[]; + +export type StackInput< + T extends ActivityDefinition, + R extends { + [activityName in T["name"]]: ActivityComponentType; + }, +> = { + config: Config; + components: R; + plugins?: Array; +}; + +export type StackOutput = { + Stack: StackComponentType; + actions: Actions; + stepActions: StepActions; +}; + +export function stack< + T extends ActivityDefinition, + R extends { + [activityName in T["name"]]: ActivityComponentType; + }, +>(input: StackInput): StackOutput { + const plugins = [ + ...(input.plugins ?? []) + .flat(Number.POSITIVE_INFINITY as 0) + .map((p) => p as StackflowReactPlugin), + + /** + * `loaderPlugin()` must be placed after `historySyncPlugin()` + */ + loaderPlugin(input.config), + ]; + + const enoughPastTime = () => + new Date().getTime() - input.config.transitionDuration * 2; + + const staticCoreStore = makeCoreStore({ + initialEvents: [ + makeEvent("Initialized", { + transitionDuration: input.config.transitionDuration, + eventDate: enoughPastTime(), + }), + ...input.config.activities.map((activity) => + makeEvent("ActivityRegistered", { + activityName: activity.name, + eventDate: enoughPastTime(), + }), + ), + ], + plugins: [], + }); + + const [getCoreStore, setCoreStore] = makeRef(); + + const Stack: StackComponentType = React.memo((props) => { + const coreStore = useMemo(() => { + const prevCoreStore = getCoreStore(); + + /** + * In a browser environment, + * memoize `coreStore` so that only one `coreStore` exists throughout the entire app. + */ + if (isBrowser() && prevCoreStore) { + return prevCoreStore; + } + + const initialPushedEventsByOption = input.config.initialActivity + ? [ + makeEvent("Pushed", { + activityId: makeActivityId(), + activityName: input.config.initialActivity(), + activityParams: {}, + eventDate: enoughPastTime(), + skipEnterActiveState: false, + }), + ] + : []; + + const store = makeCoreStore({ + initialEvents: [ + ...staticCoreStore.pullEvents(), + ...initialPushedEventsByOption, + ], + initialContext: { + initialLoaderData: props.initialLoaderData, + }, + plugins, + handlers: { + onInitialActivityIgnored: (initialPushedEvents) => { + console.warn( + `Stackflow - Some plugin overrides an "initialActivity" option. The "initialActivity" option you set to "${ + (initialPushedEvents[0] as PushedEvent).activityName + }" in the "stackflow" is ignored.`, + ); + }, + onInitialActivityNotFound: () => { + console.warn( + "Stackflow -" + + " There is no initial activity." + + " If you want to set the initial activity," + + " add the `initialActivity` option of the `stackflow()` function or" + + " add a plugin that sets the initial activity. (e.g. `@stackflow/plugin-history-sync`)", + ); + }, + }, + }); + + if (isBrowser()) { + store.init(); + setCoreStore(store); + } + + return store; + }, []); + + return ( + + + + + + ); + }); + + Stack.displayName = "Stack"; + + return { + Stack, + actions: makeActions(() => getCoreStore()?.actions), + stepActions: makeStepActions(() => getCoreStore()?.actions), + }; +} diff --git a/integrations/react/src/future/useActivityParams.ts b/integrations/react/src/future/useActivityParams.ts new file mode 100644 index 000000000..214f08dc0 --- /dev/null +++ b/integrations/react/src/future/useActivityParams.ts @@ -0,0 +1,14 @@ +import { useContext } from "react"; + +import type { + InferActivityParams, + RegisteredActivityParamTypes, +} from "@stackflow/config"; +import { ActivityContext } from "../__internal__/activity/ActivityProvider"; + +export function useActivityParams< + ActivityName extends Extract, +>(): InferActivityParams { + return useContext(ActivityContext) + .params as InferActivityParams; +} diff --git a/integrations/react/src/future/useFlow.ts b/integrations/react/src/future/useFlow.ts new file mode 100644 index 000000000..c46d8aa11 --- /dev/null +++ b/integrations/react/src/future/useFlow.ts @@ -0,0 +1,12 @@ +import { useCoreActions } from "../__internal__/core"; +import type { Actions } from "./Actions"; +import { makeActions } from "./makeActions"; + +export type FlowOutput = { + useFlow: () => Actions; +}; + +export function useFlow(): Actions { + const coreActions = useCoreActions(); + return makeActions(() => coreActions); +} diff --git a/integrations/react/src/future/useStepFlow.ts b/integrations/react/src/future/useStepFlow.ts new file mode 100644 index 000000000..b294c4282 --- /dev/null +++ b/integrations/react/src/future/useStepFlow.ts @@ -0,0 +1,14 @@ +import type { + InferActivityParams, + RegisteredActivityParamTypes, +} from "@stackflow/config"; +import { useCoreActions } from "../__internal__/core"; +import type { StepActions } from "./StepActions"; +import { makeStepActions } from "./makeStepActions"; + +export function useStepFlow< + ActivityName extends Extract, +>(activityName: ActivityName): StepActions> { + const coreActions = useCoreActions(); + return makeStepActions(() => coreActions); +} diff --git a/integrations/react/src/index.ts b/integrations/react/src/index.ts index c2b9ca056..012288a39 100644 --- a/integrations/react/src/index.ts +++ b/integrations/react/src/index.ts @@ -1,11 +1 @@ -export * from "./activity/ActivityComponentType"; -export * from "./activity/useActivity"; -export * from "./activity/useActivityParams"; -export * from "./stack/useStack"; -export * from "./stackflow"; -export * from "./StackflowReactPlugin"; -export * from "./useActions"; -export * from "./useActiveEffect"; -export * from "./useEnterDoneEffect"; -export * from "./useStep"; -export * from "./useStepActions"; +export * from "./stable"; diff --git a/integrations/react/src/BaseActivities.ts b/integrations/react/src/stable/BaseActivities.ts similarity index 79% rename from integrations/react/src/BaseActivities.ts rename to integrations/react/src/stable/BaseActivities.ts index 5aed7180e..bb078148d 100644 --- a/integrations/react/src/BaseActivities.ts +++ b/integrations/react/src/stable/BaseActivities.ts @@ -1,6 +1,6 @@ import type { ActivityRegisteredEvent } from "@stackflow/core"; -import type { ActivityComponentType } from "./activity"; +import type { ActivityComponentType } from "../__internal__/ActivityComponentType"; export type BaseActivities = { [activityName: string]: diff --git a/integrations/react/src/stable/index.ts b/integrations/react/src/stable/index.ts new file mode 100644 index 000000000..4eaf37065 --- /dev/null +++ b/integrations/react/src/stable/index.ts @@ -0,0 +1,11 @@ +export * from "../__internal__/ActivityComponentType"; +export * from "../__internal__/activity/useActivity"; +export * from "../__internal__/activity/useActivityParams"; +export * from "../__internal__/stack/useStack"; +export * from "../__internal__/StackflowReactPlugin"; +export * from "./stackflow"; +export * from "./useActions"; +export * from "./useActiveEffect"; +export * from "./useEnterDoneEffect"; +export * from "./useStep"; +export * from "./useStepActions"; diff --git a/integrations/react/src/stackflow.tsx b/integrations/react/src/stable/stackflow.tsx similarity index 95% rename from integrations/react/src/stackflow.tsx rename to integrations/react/src/stable/stackflow.tsx index 74848c09f..85b69d4fd 100644 --- a/integrations/react/src/stackflow.tsx +++ b/integrations/react/src/stable/stackflow.tsx @@ -8,13 +8,14 @@ import type { import { makeCoreStore, makeEvent } from "@stackflow/core"; import { memo, useMemo } from "react"; +import type { ActivityComponentType } from "../__internal__/ActivityComponentType"; +import MainRenderer from "../__internal__/MainRenderer"; +import type { StackflowReactPlugin } from "../__internal__/StackflowReactPlugin"; +import { makeActivityId, makeStepId } from "../__internal__/activity"; +import { CoreProvider } from "../__internal__/core"; +import { PluginsProvider } from "../__internal__/plugins"; +import { isBrowser, makeRef } from "../__internal__/utils"; import type { BaseActivities } from "./BaseActivities"; -import MainRenderer from "./MainRenderer"; -import type { StackflowReactPlugin } from "./StackflowReactPlugin"; -import type { ActivityComponentType } from "./activity"; -import { makeActivityId, makeStepId } from "./activity"; -import { CoreProvider } from "./core"; -import { PluginsProvider } from "./plugins"; import type { UseActionsOutputType } from "./useActions"; import { useActions } from "./useActions"; import type { @@ -22,7 +23,6 @@ import type { UseStepActionsOutputType, } from "./useStepActions"; import { useStepActions } from "./useStepActions"; -import { isBrowser, makeRef } from "./utils"; function parseActionOptions(options?: { animate?: boolean }) { if (!options) { diff --git a/integrations/react/src/useActions.ts b/integrations/react/src/stable/useActions.ts similarity index 92% rename from integrations/react/src/useActions.ts rename to integrations/react/src/stable/useActions.ts index b22686e2e..aec7e30bc 100644 --- a/integrations/react/src/useActions.ts +++ b/integrations/react/src/stable/useActions.ts @@ -1,10 +1,10 @@ import { useMemo } from "react"; +import type { ActivityComponentType } from "../__internal__/ActivityComponentType"; +import { makeActivityId } from "../__internal__/activity"; +import { useCoreActions } from "../__internal__/core"; +import { useTransition } from "../__internal__/shims"; import type { BaseActivities } from "./BaseActivities"; -import type { ActivityComponentType } from "./activity"; -import { makeActivityId } from "./activity"; -import { useCoreActions } from "./core"; -import { useTransition } from "./shims"; function parseActionOptions(options?: { animate?: boolean }) { if (!options) { diff --git a/integrations/react/src/useActiveEffect.ts b/integrations/react/src/stable/useActiveEffect.ts similarity index 68% rename from integrations/react/src/useActiveEffect.ts rename to integrations/react/src/stable/useActiveEffect.ts index dba04673e..66c8bebba 100644 --- a/integrations/react/src/useActiveEffect.ts +++ b/integrations/react/src/stable/useActiveEffect.ts @@ -1,7 +1,7 @@ import { useEffect } from "react"; -import { useActivity } from "./activity/useActivity"; -import { noop } from "./utils"; +import { useActivity } from "../__internal__/activity/useActivity"; +import { noop } from "../__internal__/utils"; export const useActiveEffect = (effect: React.EffectCallback) => { const { isActive } = useActivity(); diff --git a/integrations/react/src/useEnterDoneEffect.ts b/integrations/react/src/stable/useEnterDoneEffect.ts similarity index 76% rename from integrations/react/src/useEnterDoneEffect.ts rename to integrations/react/src/stable/useEnterDoneEffect.ts index 603a42d2f..f78621bfa 100644 --- a/integrations/react/src/useEnterDoneEffect.ts +++ b/integrations/react/src/stable/useEnterDoneEffect.ts @@ -1,7 +1,7 @@ import { useEffect } from "react"; -import { useActivity } from "./activity/useActivity"; -import { noop } from "./utils"; +import { useActivity } from "../__internal__/activity/useActivity"; +import { noop } from "../__internal__/utils"; export const useEnterDoneEffect = ( effect: React.EffectCallback, diff --git a/integrations/react/src/useStep.ts b/integrations/react/src/stable/useStep.ts similarity index 78% rename from integrations/react/src/useStep.ts rename to integrations/react/src/stable/useStep.ts index c465580d8..2a255efec 100644 --- a/integrations/react/src/useStep.ts +++ b/integrations/react/src/stable/useStep.ts @@ -1,7 +1,7 @@ import type { ActivityStep } from "@stackflow/core"; import { useContext } from "react"; -import { ActivityContext } from "./activity/ActivityProvider"; +import { ActivityContext } from "../__internal__/activity/ActivityProvider"; /** * Get current step diff --git a/integrations/react/src/useStepActions.ts b/integrations/react/src/stable/useStepActions.ts similarity index 83% rename from integrations/react/src/useStepActions.ts rename to integrations/react/src/stable/useStepActions.ts index e348f641a..b54fd02fe 100644 --- a/integrations/react/src/useStepActions.ts +++ b/integrations/react/src/stable/useStepActions.ts @@ -1,10 +1,10 @@ import { useMemo } from "react"; +import type { ActivityComponentType } from "../__internal__/ActivityComponentType"; +import { makeStepId } from "../__internal__/activity"; +import { useCoreActions } from "../__internal__/core"; +import { useTransition } from "../__internal__/shims"; import type { BaseActivities } from "./BaseActivities"; -import type { ActivityComponentType } from "./activity"; -import { makeStepId } from "./activity"; -import { useCoreActions } from "./core"; -import { useTransition } from "./shims"; export type UseStepActionsOutputType

= { pending: boolean; diff --git a/integrations/react/tsconfig.json b/integrations/react/tsconfig.json index b1d123121..4ed7abc2b 100644 --- a/integrations/react/tsconfig.json +++ b/integrations/react/tsconfig.json @@ -2,6 +2,7 @@ "extends": "../../tsconfig.json", "compilerOptions": { "baseUrl": "./src", + "rootDir": "./src", "outDir": "./dist" }, "exclude": ["./dist"] diff --git a/package.json b/package.json index 0ca5f72aa..453390b24 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,7 @@ "license": "MIT", "workspaces": [ "docs", + "config", "core", "demo", "integrations/*", diff --git a/tsconfig.json b/tsconfig.json index c84386118..3654dee78 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,7 +2,8 @@ "compilerOptions": { "target": "ESNext", "jsx": "react-jsx", - "module": "commonjs", + "module": "ESNext", + "moduleResolution": "Bundler", "declaration": true, "declarationMap": true, "esModuleInterop": true, diff --git a/yarn.lock b/yarn.lock index 607cc7105..1fd899d35 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2272,13 +2272,13 @@ __metadata: languageName: node linkType: hard -"@stackflow/compat-await-push@npm:^1.1.10, @stackflow/compat-await-push@workspace:extensions/compat-await-push": +"@stackflow/compat-await-push@npm:^1.1.11-canary.0, @stackflow/compat-await-push@workspace:extensions/compat-await-push": version: 0.0.0-use.local resolution: "@stackflow/compat-await-push@workspace:extensions/compat-await-push" dependencies: "@stackflow/core": "npm:^1.0.13" "@stackflow/esbuild-config": "npm:^1.0.3" - "@stackflow/react": "npm:^1.1.11" + "@stackflow/react": "npm:^1.2.0-canary.0" "@types/react": "npm:^18.3.3" esbuild: "npm:^0.23.0" react: "npm:^18.3.1" @@ -2286,12 +2286,24 @@ __metadata: typescript: "npm:^5.5.3" peerDependencies: "@stackflow/core": ^1 - "@stackflow/react": ^1 + "@stackflow/react": ^1.2.0-canary.0 "@types/react": ">=16.8.0" react: ">=16.8.0" languageName: unknown linkType: soft +"@stackflow/config@npm:^1.0.1-canary.0, @stackflow/config@workspace:config": + version: 0.0.0-use.local + resolution: "@stackflow/config@workspace:config" + dependencies: + "@stackflow/esbuild-config": "npm:^1.0.3" + esbuild: "npm:^0.23.0" + rimraf: "npm:^3.0.2" + typescript: "npm:^5.5.3" + ultra-runner: "npm:^3.10.5" + languageName: unknown + linkType: soft + "@stackflow/core@npm:^1.0.13, @stackflow/core@workspace:core": version: 0.0.0-use.local resolution: "@stackflow/core@workspace:core" @@ -2310,24 +2322,25 @@ __metadata: languageName: unknown linkType: soft -"@stackflow/demo@npm:^1.2.23, @stackflow/demo@workspace:demo": +"@stackflow/demo@npm:^1.3.0-canary.0, @stackflow/demo@workspace:demo": version: 0.0.0-use.local resolution: "@stackflow/demo@workspace:demo" dependencies: "@seed-design/design-token": "npm:^1.0.3" "@seed-design/stylesheet": "npm:^1.0.4" - "@stackflow/compat-await-push": "npm:^1.1.10" + "@stackflow/compat-await-push": "npm:^1.1.11-canary.0" + "@stackflow/config": "npm:^1.0.1-canary.0" "@stackflow/core": "npm:^1.0.13" "@stackflow/esbuild-config": "npm:^1.0.3" - "@stackflow/link": "npm:^1.4.2" - "@stackflow/plugin-basic-ui": "npm:^1.8.2" + "@stackflow/link": "npm:^1.4.3-canary.0" + "@stackflow/plugin-basic-ui": "npm:^1.8.3-canary.0" "@stackflow/plugin-devtools": "npm:^0.1.10" - "@stackflow/plugin-history-sync": "npm:^1.5.4" - "@stackflow/plugin-map-initial-activity": "npm:^1.0.8" - "@stackflow/plugin-preload": "npm:^1.3.2" - "@stackflow/plugin-renderer-basic": "npm:^1.1.10" + "@stackflow/plugin-history-sync": "npm:^1.6.0-canary.0" + "@stackflow/plugin-map-initial-activity": "npm:^1.0.9-canary.0" + "@stackflow/plugin-preload": "npm:^1.3.3-canary.0" + "@stackflow/plugin-renderer-basic": "npm:^1.1.11-canary.0" "@stackflow/plugin-stack-depth-change": "npm:^1.1.4" - "@stackflow/react": "npm:^1.1.11" + "@stackflow/react": "npm:^1.2.0-canary.0" "@types/react": "npm:^18.3.3" "@types/react-dom": "npm:^18.3.0" "@types/react-lazy-load-image-component": "npm:^1.6.4" @@ -2345,6 +2358,7 @@ __metadata: rimraf: "npm:^3.0.2" typescript: "npm:^5.5.3" vite: "npm:^5.3.2" + zod: "npm:^3.23.8" languageName: unknown linkType: soft @@ -2355,11 +2369,11 @@ __metadata: "@mdx-js/react": "npm:^3.0.1" "@seed-design/stylesheet": "npm:^1.0.4" "@stackflow/core": "npm:^1.0.13" - "@stackflow/demo": "npm:^1.2.23" - "@stackflow/plugin-basic-ui": "npm:^1.8.2" - "@stackflow/plugin-history-sync": "npm:^1.5.4" - "@stackflow/plugin-renderer-basic": "npm:^1.1.10" - "@stackflow/react": "npm:^1.1.11" + "@stackflow/demo": "npm:^1.3.0-canary.0" + "@stackflow/plugin-basic-ui": "npm:^1.8.3-canary.0" + "@stackflow/plugin-history-sync": "npm:^1.6.0-canary.0" + "@stackflow/plugin-renderer-basic": "npm:^1.1.11-canary.0" + "@stackflow/react": "npm:^1.2.0-canary.0" "@types/react": "npm:^18.3.3" next: "npm:^14.2.4" nextra: "npm:^2.13.4" @@ -2379,15 +2393,15 @@ __metadata: languageName: unknown linkType: soft -"@stackflow/link@npm:^1.4.2, @stackflow/link@workspace:extensions/link": +"@stackflow/link@npm:^1.4.3-canary.0, @stackflow/link@workspace:extensions/link": version: 0.0.0-use.local resolution: "@stackflow/link@workspace:extensions/link" dependencies: "@stackflow/core": "npm:^1.0.13" "@stackflow/esbuild-config": "npm:^1.0.3" - "@stackflow/plugin-history-sync": "npm:^1.5.4" - "@stackflow/plugin-preload": "npm:^1.3.2" - "@stackflow/react": "npm:^1.1.11" + "@stackflow/plugin-history-sync": "npm:^1.6.0-canary.0" + "@stackflow/plugin-preload": "npm:^1.3.3-canary.0" + "@stackflow/react": "npm:^1.2.0-canary.0" "@types/react": "npm:^18.3.3" esbuild: "npm:^0.23.0" react: "npm:^18.3.1" @@ -2395,9 +2409,9 @@ __metadata: typescript: "npm:^5.5.3" peerDependencies: "@stackflow/core": ^1 - "@stackflow/plugin-history-sync": ^1 - "@stackflow/plugin-preload": ^1 - "@stackflow/react": ^1 + "@stackflow/plugin-history-sync": ^1.6.0-canary.0 + "@stackflow/plugin-preload": ^1.3.3-canary.0 + "@stackflow/react": ^1.2.0-canary.0 "@types/react": ">=16.8.0" react: ">=16.8.0" languageName: unknown @@ -2417,13 +2431,13 @@ __metadata: languageName: unknown linkType: soft -"@stackflow/plugin-basic-ui@npm:^1.8.2, @stackflow/plugin-basic-ui@workspace:extensions/plugin-basic-ui": +"@stackflow/plugin-basic-ui@npm:^1.8.3-canary.0, @stackflow/plugin-basic-ui@workspace:extensions/plugin-basic-ui": version: 0.0.0-use.local resolution: "@stackflow/plugin-basic-ui@workspace:extensions/plugin-basic-ui" dependencies: "@stackflow/core": "npm:^1.0.13" "@stackflow/esbuild-config": "npm:^1.0.3" - "@stackflow/react": "npm:^1.1.11" + "@stackflow/react": "npm:^1.2.0-canary.0" "@types/react": "npm:^18.3.3" "@vanilla-extract/css": "npm:^1.15.3" "@vanilla-extract/dynamic": "npm:^2.1.1" @@ -2435,7 +2449,7 @@ __metadata: typescript: "npm:^5.5.3" peerDependencies: "@stackflow/core": ^1 - "@stackflow/react": ^1 + "@stackflow/react": ^1.2.0-canary.0 "@types/react": ">=16.8.0" react: ">=16.8.0" languageName: unknown @@ -2462,7 +2476,7 @@ __metadata: dependencies: "@stackflow/core": "npm:^1.0.13" "@stackflow/esbuild-config": "npm:^1.0.3" - "@stackflow/react": "npm:^1.1.11" + "@stackflow/react": "npm:^1.2.0-canary.0" "@types/react": "npm:^18.3.3" esbuild: "npm:^0.23.0" react: "npm:^18.3.1" @@ -2471,19 +2485,20 @@ __metadata: typescript: "npm:^5.5.3" peerDependencies: "@stackflow/core": ^1 - "@stackflow/react": ^1 + "@stackflow/react": ^1.2.0-canary.0 "@types/react": ">=16.8.0" react: ">=16.8.0" languageName: unknown linkType: soft -"@stackflow/plugin-history-sync@npm:^1.5.4, @stackflow/plugin-history-sync@workspace:extensions/plugin-history-sync": +"@stackflow/plugin-history-sync@npm:^1.6.0-canary.0, @stackflow/plugin-history-sync@workspace:extensions/plugin-history-sync": version: 0.0.0-use.local resolution: "@stackflow/plugin-history-sync@workspace:extensions/plugin-history-sync" dependencies: + "@stackflow/config": "npm:^1.0.1-canary.0" "@stackflow/core": "npm:^1.0.13" "@stackflow/esbuild-config": "npm:^1.0.3" - "@stackflow/react": "npm:^1.1.11" + "@stackflow/react": "npm:^1.2.0-canary.0" "@swc/core": "npm:^1.6.6" "@swc/jest": "npm:^0.2.36" "@types/jest": "npm:^29.5.12" @@ -2497,37 +2512,38 @@ __metadata: typescript: "npm:^5.5.3" url-pattern: "npm:^1.0.3" peerDependencies: + "@stackflow/config": ^1.0.1-canary.0 "@stackflow/core": ^1 - "@stackflow/react": ^1 + "@stackflow/react": ^1.2.0-canary.0 "@types/react": ">=16.8.0" react: ">=16.8.0" languageName: unknown linkType: soft -"@stackflow/plugin-map-initial-activity@npm:^1.0.8, @stackflow/plugin-map-initial-activity@workspace:extensions/plugin-map-initial-activity": +"@stackflow/plugin-map-initial-activity@npm:^1.0.9-canary.0, @stackflow/plugin-map-initial-activity@workspace:extensions/plugin-map-initial-activity": version: 0.0.0-use.local resolution: "@stackflow/plugin-map-initial-activity@workspace:extensions/plugin-map-initial-activity" dependencies: "@stackflow/core": "npm:^1.0.13" "@stackflow/esbuild-config": "npm:^1.0.3" - "@stackflow/react": "npm:^1.1.11" + "@stackflow/react": "npm:^1.2.0-canary.0" esbuild: "npm:^0.23.0" rimraf: "npm:^3.0.2" typescript: "npm:^5.5.3" peerDependencies: "@stackflow/core": ^1 - "@stackflow/react": ^1 + "@stackflow/react": ^1.2.0-canary.0 languageName: unknown linkType: soft -"@stackflow/plugin-preload@npm:^1.3.2, @stackflow/plugin-preload@workspace:extensions/plugin-preload": +"@stackflow/plugin-preload@npm:^1.3.3-canary.0, @stackflow/plugin-preload@workspace:extensions/plugin-preload": version: 0.0.0-use.local resolution: "@stackflow/plugin-preload@workspace:extensions/plugin-preload" dependencies: "@stackflow/core": "npm:^1.0.13" "@stackflow/esbuild-config": "npm:^1.0.3" - "@stackflow/plugin-history-sync": "npm:^1.5.4" - "@stackflow/react": "npm:^1.1.11" + "@stackflow/plugin-history-sync": "npm:^1.6.0-canary.0" + "@stackflow/react": "npm:^1.2.0-canary.0" "@types/react": "npm:^18.3.3" esbuild: "npm:^0.23.0" react: "npm:^18.3.1" @@ -2535,19 +2551,19 @@ __metadata: typescript: "npm:^5.5.3" peerDependencies: "@stackflow/core": ^1 - "@stackflow/react": ^1 + "@stackflow/react": ^1.2.0-canary.0 "@types/react": ">=16.8.0" react: ">=16.8.0" languageName: unknown linkType: soft -"@stackflow/plugin-renderer-basic@npm:^1.1.10, @stackflow/plugin-renderer-basic@workspace:extensions/plugin-renderer-basic": +"@stackflow/plugin-renderer-basic@npm:^1.1.11-canary.0, @stackflow/plugin-renderer-basic@workspace:extensions/plugin-renderer-basic": version: 0.0.0-use.local resolution: "@stackflow/plugin-renderer-basic@workspace:extensions/plugin-renderer-basic" dependencies: "@stackflow/core": "npm:^1.0.13" "@stackflow/esbuild-config": "npm:^1.0.3" - "@stackflow/react": "npm:^1.1.11" + "@stackflow/react": "npm:^1.2.0-canary.0" "@types/react": "npm:^18.3.3" esbuild: "npm:^0.23.0" react: "npm:^18.3.1" @@ -2555,7 +2571,7 @@ __metadata: typescript: "npm:^5.5.3" peerDependencies: "@stackflow/core": ^1 - "@stackflow/react": ^1 + "@stackflow/react": ^1.2.0-canary.0 "@types/react": ">=16.8.0" react: ">=16.8.0" languageName: unknown @@ -2567,7 +2583,7 @@ __metadata: dependencies: "@stackflow/core": "npm:^1.0.13" "@stackflow/esbuild-config": "npm:^1.0.3" - "@stackflow/react": "npm:^1.1.11" + "@stackflow/react": "npm:^1.2.0-canary.0" "@types/react": "npm:^18.3.3" esbuild: "npm:^0.23.0" react: "npm:^18.3.1" @@ -2575,7 +2591,7 @@ __metadata: typescript: "npm:^5.5.3" peerDependencies: "@stackflow/core": ^1 - "@stackflow/react": ^1 + "@stackflow/react": ^1.2.0-canary.0 "@types/react": ">=16.8.0" react: ">=16.8.0" languageName: unknown @@ -2596,19 +2612,24 @@ __metadata: languageName: unknown linkType: soft -"@stackflow/react@npm:^1.1.11, @stackflow/react@workspace:integrations/react": +"@stackflow/react@npm:^1.2.0-canary.0, @stackflow/react@workspace:integrations/react": version: 0.0.0-use.local resolution: "@stackflow/react@workspace:integrations/react" dependencies: + "@stackflow/config": "npm:^1.0.1-canary.0" "@stackflow/core": "npm:^1.0.13" "@stackflow/esbuild-config": "npm:^1.0.3" "@types/react": "npm:^18.3.3" esbuild: "npm:^0.23.0" + esbuild-plugin-file-path-extensions: "npm:^2.1.2" + history: "npm:^5.3.0" react: "npm:^18.3.1" react-fast-compare: "npm:^3.2.2" rimraf: "npm:^3.0.2" typescript: "npm:^5.5.3" + url-pattern: "npm:^1.0.3" peerDependencies: + "@stackflow/config": ^1.0.1-canary.0 "@stackflow/core": ^1 "@types/react": ">=16.8.0" react: ">=16.8.0" @@ -4739,6 +4760,13 @@ __metadata: languageName: node linkType: hard +"esbuild-plugin-file-path-extensions@npm:^2.1.2": + version: 2.1.2 + resolution: "esbuild-plugin-file-path-extensions@npm:2.1.2" + checksum: 10/01e00d5bb35d719ebe9d1b2526278923e5790f7c3d78c9b0af05af17408be076c914135eef43a3e6021c07f715214d9c848d93c648f4d4cb3fa0605d83d2b55a + languageName: node + linkType: hard + "esbuild@npm:^0.21.3, esbuild@npm:esbuild@~0.17.6 || ~0.18.0 || ~0.19.0 || ~0.20.0 || ~0.21.0": version: 0.21.5 resolution: "esbuild@npm:0.21.5" @@ -10386,7 +10414,7 @@ __metadata: languageName: node linkType: hard -"zod@npm:^3.22.3": +"zod@npm:^3.22.3, zod@npm:^3.23.8": version: 3.23.8 resolution: "zod@npm:3.23.8" checksum: 10/846fd73e1af0def79c19d510ea9e4a795544a67d5b34b7e1c4d0425bf6bfd1c719446d94cdfa1721c1987d891321d61f779e8236fde517dc0e524aa851a6eff1