stacks 0.53.1 → 0.56.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.gitignore +4 -2
- package/README.md +71 -74
- package/api/package.json +3 -2
- package/art/logo-dark.svg +11 -0
- package/art/logo.svg +11 -0
- package/auto-imports.d.ts +1182 -841
- package/components.d.ts +7 -9
- package/core/actions/build.config.ts +181 -9
- package/core/actions/package.json +6 -8
- package/core/actions/src/build/component-libs.ts +2 -12
- package/core/actions/src/dev/index.ts +6 -5
- package/core/actions/src/generate/index.ts +2 -2
- package/core/actions/src/generate/settings.ts +1 -1
- package/core/actions/src/helpers/lib-entries.ts +43 -35
- package/core/actions/src/helpers/utils.ts +7 -9
- package/core/actions/src/lint/index.ts +14 -2
- package/core/actions/src/make.ts +7 -4
- package/core/actions/src/migrate.ts +2 -2
- package/core/actions/src/prepublish.ts +2 -2
- package/core/actions/src/release.ts +1 -1
- package/core/actions/src/seed.ts +1 -1
- package/core/actions/src/upgrade/framework.ts +1 -1
- package/core/actions/src/upgrade.ts +3 -3
- package/core/ai/build.config.ts +5 -7
- package/core/ai/package.json +5 -9
- package/core/alias/build.config.ts +5 -7
- package/core/alias/package.json +3 -6
- package/core/alias/src/index.ts +6 -7
- package/core/analytics/build.config.ts +5 -7
- package/core/analytics/package.json +6 -6
- package/core/arrays/build.config.ts +4 -7
- package/core/arrays/package.json +8 -4
- package/core/arrays/src/contains.ts +23 -0
- package/core/arrays/src/helpers.ts +206 -0
- package/core/arrays/src/index.ts +4 -226
- package/core/arrays/src/macro.ts +135 -0
- package/core/arrays/src/math.ts +19 -0
- package/core/auth/build.config.ts +4 -7
- package/core/auth/package.json +3 -3
- package/core/buddy/README.md +73 -76
- package/core/buddy/build.config.ts +1 -2
- package/core/buddy/package.json +4 -4
- package/core/buddy/src/cli.ts +10 -18
- package/core/buddy/src/commands/add.ts +2 -2
- package/core/buddy/src/commands/build.ts +23 -16
- package/core/buddy/src/commands/create.ts +2 -2
- package/core/buddy/src/commands/dev.ts +31 -30
- package/core/buddy/src/commands/example.ts +8 -14
- package/core/buddy/src/commands/generate.ts +16 -14
- package/core/buddy/src/commands/key.ts +1 -1
- package/core/buddy/src/commands/lint.ts +4 -4
- package/core/buddy/src/commands/make.ts +20 -15
- package/core/buddy/src/commands/setting.ts +2 -2
- package/core/buddy/src/commands/upgrade.ts +18 -22
- package/core/buddy/src/commands/version.ts +1 -1
- package/core/build/build.config.ts +22 -7
- package/core/build/package.json +11 -10
- package/core/build/src/desktop.ts +2 -2
- package/core/build/src/example-vue.ts +5 -4
- package/core/build/src/example-wc.ts +5 -4
- package/core/build/src/functions.ts +9 -11
- package/core/build/src/index.ts +7 -7
- package/core/build/src/stacks.ts +31 -50
- package/core/build/src/{pages.ts → views.ts} +13 -14
- package/core/build/src/vue-components.ts +73 -12
- package/core/build/src/web-components.ts +12 -11
- package/core/build/web-types.ts +3 -3
- package/core/cache/build.config.ts +7 -7
- package/core/cache/package.json +17 -17
- package/core/cache/tests/DynamoDB.test.ts +19 -33
- package/core/chat/build.config.ts +5 -7
- package/core/chat/package.json +8 -8
- package/core/cli/build.config.ts +3 -2
- package/core/cli/package.json +3 -3
- package/core/cli/src/console.ts +75 -2
- package/core/cli/src/helpers.ts +1 -1
- package/core/cli/src/parse.ts +2 -2
- package/core/cli/src/run.ts +5 -6
- package/core/cloud/build.config.ts +4 -7
- package/core/cloud/package.json +17 -3
- package/core/cloud/src/aws/index.ts +9 -0
- package/core/cloud/src/aws/logger.ts +8 -0
- package/core/cloud/src/aws/metrics.ts +8 -0
- package/core/cloud/src/aws/stack.ts +12 -0
- package/core/cloud/src/aws/tracer.ts +3 -0
- package/core/cloud/src/index.ts +1 -1
- package/core/cloud/src/runtime/nodejs/bootstrap.ts +16 -0
- package/core/cloud/src/runtime/nodejs/build.sh +1 -0
- package/core/collections/build.config.ts +3 -7
- package/core/collections/package.json +3 -3
- package/core/config/build.config.ts +33 -33
- package/core/config/package.json +4 -4
- package/core/config/src/defaults.ts +0 -3
- package/core/config/src/stacks.ts +10 -11
- package/core/database/build.config.ts +1 -2
- package/core/database/package.json +3 -3
- package/core/database/src/factory/index.ts +1 -1
- package/core/database/src/migrations/index.ts +1 -1
- package/core/datetime/build.config.ts +1 -2
- package/core/datetime/package.json +3 -3
- package/core/datetime/src/index.ts +2 -1
- package/core/desktop/build.config.ts +2 -1
- package/core/desktop/package.json +6 -6
- package/core/development/build.config.ts +15 -8
- package/core/development/package.json +11 -5
- package/core/development/src/index.ts +2 -0
- package/core/{domains → dns}/README.md +2 -2
- package/core/dns/build.config.ts +22 -0
- package/core/{domains → dns}/package.json +13 -9
- package/core/dns/src/index.ts +18 -0
- package/core/docs/build.config.ts +1 -2
- package/core/docs/package.json +4 -4
- package/core/email/build.config.ts +1 -2
- package/core/email/package.json +15 -15
- package/core/email/src/drivers/emailjs.ts +1 -1
- package/core/email/src/drivers/mailgun.ts +1 -1
- package/core/email/src/drivers/mailjet.ts +2 -2
- package/core/email/src/drivers/mandrill.ts +1 -1
- package/core/email/src/drivers/netcore.ts +1 -1
- package/core/email/src/drivers/nodemailer.ts +1 -1
- package/core/email/src/drivers/postmark.ts +1 -1
- package/core/email/src/drivers/sendgrid.ts +1 -1
- package/core/error-handling/build.config.ts +7 -2
- package/core/error-handling/package.json +6 -4
- package/core/error-handling/src/index.ts +45 -0
- package/core/events/README.md +1 -1
- package/core/events/build.config.ts +1 -2
- package/core/events/package.json +3 -3
- package/core/events/src/index.ts +8 -1
- package/core/faker/build.config.ts +3 -1
- package/core/faker/package.json +4 -4
- package/core/git/build.config.ts +3 -1
- package/core/git/package.json +4 -4
- package/core/health/build.config.ts +3 -1
- package/core/health/package.json +3 -3
- package/core/lint/build.config.ts +3 -1
- package/core/lint/package.json +6 -6
- package/core/logging/build.config.ts +5 -3
- package/core/logging/package.json +6 -6
- package/core/modules/build.config.ts +10 -7
- package/core/modules/package.json +3 -3
- package/core/notifications/README.md +1 -1
- package/core/notifications/build.config.ts +2 -1
- package/core/notifications/package.json +25 -25
- package/core/notifications/src/tailwind.config.ts +1 -1
- package/core/notifications/tests/email/Mailgun.test.ts +4 -4
- package/core/notifications/tests/email/Sendgrid.test.ts +2 -2
- package/core/objects/build.config.ts +15 -7
- package/core/objects/package.json +5 -4
- package/core/orm/build.config.ts +1 -2
- package/core/orm/package.json +3 -3
- package/core/pages/build.config.ts +4 -7
- package/core/pages/package.json +3 -3
- package/core/pages/src/index.ts +2 -2
- package/core/path/build.config.ts +1 -2
- package/core/path/package.json +4 -5
- package/core/path/src/index.ts +84 -65
- package/core/payments/build.config.ts +4 -7
- package/core/payments/package.json +5 -5
- package/core/push/build.config.ts +4 -7
- package/core/push/package.json +5 -5
- package/core/query-builder/build.config.ts +4 -7
- package/core/query-builder/package.json +7 -7
- package/core/queue/build.config.ts +4 -7
- package/core/queue/package.json +3 -3
- package/core/realtime/build.config.ts +4 -7
- package/core/realtime/package.json +3 -3
- package/core/realtime/src/index.ts +3 -1
- package/core/repl/README.md +53 -0
- package/core/repl/build.config.ts +12 -0
- package/core/repl/package.json +56 -0
- package/core/repl/src/index.ts +1 -0
- package/core/repl/tests/example.test.ts +7 -0
- package/core/router/build.config.ts +13 -7
- package/core/router/package.json +4 -4
- package/core/router/src/index.ts +2 -0
- package/core/scheduler/build.config.ts +4 -7
- package/core/scheduler/package.json +4 -4
- package/core/search-engine/build.config.ts +17 -7
- package/core/search-engine/package.json +4 -4
- package/core/search-engine/src/index.ts +2 -2
- package/core/security/build.config.ts +17 -7
- package/core/security/package.json +4 -3
- package/core/security/src/crypt.ts +11 -2
- package/core/server/build.config.ts +3 -7
- package/core/server/package.json +5 -5
- package/core/signals/README.md +2 -2
- package/core/signals/build.config.ts +4 -7
- package/core/signals/package.json +4 -4
- package/core/signals/src/index.ts +1 -1
- package/core/slug/build.config.ts +4 -7
- package/core/slug/package.json +3 -3
- package/core/slug/src/index.ts +2 -1
- package/core/sms/build.config.ts +3 -1
- package/core/sms/package.json +13 -13
- package/core/storage/build.config.ts +3 -7
- package/core/storage/package.json +5 -5
- package/core/storage/src/index.ts +2 -22
- package/core/strings/build.config.ts +1 -2
- package/core/strings/package.json +9 -3
- package/core/strings/src/case.ts +12 -0
- package/core/strings/src/index.ts +2 -1
- package/core/strings/src/is.ts +170 -0
- package/core/strings/src/macro.ts +139 -0
- package/core/strings/src/utils.ts +10 -12
- package/core/testing/build.config.ts +3 -1
- package/core/testing/package.json +8 -8
- package/core/tinker/build.config.ts +12 -0
- package/core/tinker/package.json +15 -3
- package/core/tinker/src/index.ts +1 -0
- package/core/types/build.config.ts +17 -8
- package/core/types/package.json +25 -19
- package/core/types/src/app.ts +4 -4
- package/core/types/src/cli.ts +36 -34
- package/core/types/src/cron-jobs.ts +25 -4
- package/core/types/src/database.ts +12 -3
- package/core/types/src/errors.ts +19 -1
- package/core/types/src/events.ts +13 -5
- package/core/types/src/git.ts +1 -1
- package/core/types/src/index.ts +2 -1
- package/core/types/src/library.ts +0 -7
- package/core/types/src/model.ts +21 -7
- package/core/types/src/money.ts +3 -0
- package/core/types/src/notifications.ts +9 -7
- package/core/types/src/queue.ts +34 -0
- package/core/types/src/search-engine.ts +3 -3
- package/core/types/src/stacks.ts +1 -12
- package/core/ui/build.config.ts +5 -7
- package/core/ui/package.json +7 -7
- package/core/utils/build.config.ts +32 -7
- package/core/utils/package.json +16 -16
- package/core/utils/src/config.ts +88 -49
- package/core/utils/src/currency.ts +3 -0
- package/core/utils/src/delete.ts +1 -3
- package/core/utils/src/helpers.ts +11 -5
- package/core/validation/build.config.ts +18 -8
- package/core/validation/package.json +8 -6
- package/core/validation/src/index.ts +2 -0
- package/core/validation/src/is.ts +27 -174
- package/core/validation/src/rules.ts +126 -0
- package/core/validation/src/types/env.ts +147 -0
- package/core/validation/src/types/index.ts +2 -0
- package/core/validation/src/types/money.ts +17 -0
- package/core/validation/src/validate.ts +14 -25
- package/core/vite-plugin/README.md +59 -0
- package/core/vite-plugin/build.config.ts +21 -0
- package/core/vite-plugin/package.json +51 -0
- package/core/vite-plugin/src/index.ts +23 -0
- package/core/vite-plugin/tests/example.test.ts +7 -0
- package/dictionary.txt +228 -0
- package/docs/package.json +3 -2
- package/env.d.ts +7 -0
- package/ide/jetbrains/.fleet/run.json +5 -0
- package/ide/jetbrains/.fleet/settings.json +4 -0
- package/ide/jetbrains/.idea/.gitignore +5 -0
- package/ide/jetbrains/.idea/inspectionProfiles/Project_Default.xml +6 -0
- package/ide/jetbrains/.idea/jsLibraryMappings.xml +6 -0
- package/ide/jetbrains/.idea/jsLinters/eslint.xml +7 -0
- package/ide/jetbrains/.idea/modules.xml +8 -0
- package/ide/jetbrains/.idea/stacks.iml +69 -0
- package/ide/jetbrains/.idea/vcs.xml +6 -0
- package/ide/jetbrains/.idea/webResources.xml +14 -0
- package/ide/jetbrains/.idea/workspace.xml +225 -0
- package/ide/jetbrains/IntelliJ IDEA Global Settings +0 -0
- package/ide/jetbrains/installed.txt +4 -0
- package/ide/jetbrains/options/github-copilot.xml +5 -0
- package/ide/jetbrains/options/nodejs.xml +7 -0
- package/ide/jetbrains/options/templates.xml +124 -0
- package/ide/jetbrains/templates/JavaScript.xml +6 -0
- package/ide/jetbrains/templates/Stacks.xml +8 -0
- package/ide/vscode/.vscode/README.md +23 -0
- package/ide/vscode/.vscode/extensions.json +5 -0
- package/ide/vscode/.vscode/settings.json +111 -0
- package/ide/vscode/.vscode/stacks.code-snippets +182 -0
- package/ide/vscode/README.md +42 -0
- package/ide/vscode/logo.png +0 -0
- package/ide/vscode/package.json +64 -0
- package/{components → libs/components}/vue/main.ts +1 -1
- package/{components → libs/components}/vue/package.json +1 -1
- package/{components → libs/components}/web/package.json +1 -1
- package/libs/examples/vue/App.vue +12 -0
- package/libs/examples/vue/favicon.png +0 -0
- package/libs/examples/vue/index.html +20 -0
- package/libs/examples/web/favicon.png +0 -0
- package/libs/examples/web/index.html +13 -0
- package/libs/functions/package.json +41 -0
- package/package.json +104 -98
- package/reset.d.ts +1 -0
- package/scripts/ensure.sh +33 -0
- package/scripts/publish.sh +18 -0
- package/scripts/setup.sh +540 -0
- package/stacks/dashboard/README.md +74 -0
- package/{core/domains → stacks/dashboard}/build.config.ts +1 -1
- package/stacks/dashboard/package.json +46 -0
- package/stacks/dashboard/src/index.ts +0 -0
- package/stacks/dashboard/tests/example.test.ts +7 -0
- package/stacks/tables/README.md +109 -0
- package/stacks/tables/build.config.ts +16 -0
- package/stacks/tables/examples/vue/App.vue +12 -0
- package/stacks/tables/examples/vue/favicon.png +0 -0
- package/stacks/tables/examples/vue/index.html +20 -0
- package/stacks/tables/examples/web/favicon.png +0 -0
- package/stacks/tables/examples/web/index.html +13 -0
- package/stacks/tables/index.html +13 -0
- package/stacks/tables/package.json +57 -0
- package/stacks/tables/src/App.vue +23 -0
- package/stacks/tables/src/components/Demo.vue +84 -0
- package/stacks/tables/src/components/README.md +110 -0
- package/stacks/tables/src/components/Table.vue +342 -0
- package/stacks/tables/src/components/TableBody.vue +32 -0
- package/stacks/tables/src/components/TableCellActionItems.vue +9 -0
- package/stacks/tables/src/components/TableFilters.vue +704 -0
- package/stacks/tables/src/components/TableHead.vue +60 -0
- package/stacks/tables/src/components/TablePagination.vue +131 -0
- package/stacks/tables/src/components/TableRow.vue +73 -0
- package/stacks/tables/src/components/TableSearch.vue +39 -0
- package/stacks/tables/src/components/Tooltip.vue +10 -0
- package/stacks/tables/src/config/tables.ts +1 -0
- package/stacks/tables/src/docs/index.md +0 -0
- package/stacks/tables/src/functions/README.md +8 -0
- package/stacks/tables/src/functions/dark.ts +3 -0
- package/stacks/tables/src/functions/index.ts +2 -0
- package/stacks/tables/src/functions/table.ts +207 -0
- package/stacks/tables/src/main.ts +4 -0
- package/stacks/tables/tests/example.test.ts +7 -0
- package/stacks/tables/vite.config.ts +26 -0
- package/stacks/tinker/package.json +48 -0
- package/stacks/tinker/src/index.ts +1 -0
- package/stacks/x-ray/README.md +55 -0
- package/stacks/x-ray/build.config.ts +15 -0
- package/stacks/x-ray/index.html +13 -0
- package/stacks/x-ray/package.json +55 -0
- package/stacks/x-ray/routes/index.ts +19 -0
- package/stacks/x-ray/src/client.ts +14 -0
- package/stacks/x-ray/src/desktop/api/nitro.config.ts +19 -0
- package/stacks/x-ray/src/desktop/api/routes/api/logs.ts +7 -0
- package/stacks/x-ray/src/desktop/api/routes/api/store-logs.ts +22 -0
- package/stacks/x-ray/src/desktop/api/src/types.ts +7 -0
- package/stacks/x-ray/src/desktop/api/storage/index.ts +7 -0
- package/stacks/x-ray/src/desktop/app.vue +377 -0
- package/stacks/x-ray/src/desktop/functions/http.ts +26 -0
- package/stacks/x-ray/src/desktop/functions/types.ts +7 -0
- package/stacks/x-ray/src/desktop/main.ts +14 -0
- package/stacks/x-ray/src/desktop/modules/counter/mod.vue +44 -0
- package/stacks/x-ray/src/desktop/modules/fetcher/mod.vue +63 -0
- package/stacks/x-ray/src/desktop/plugins/unified/unified-app.ts +5 -0
- package/stacks/x-ray/src/desktop/plugins/unified/unified-styles.scss +0 -0
- package/stacks/x-ray/src/desktop/services/http.ts +45 -0
- package/stacks/x-ray/src/desktop/styles/app.scss +0 -0
- package/stacks/x-ray/src/http.ts +26 -0
- package/stacks/x-ray/src/index.ts +42 -0
- package/stacks/x-ray/src/ray.config.ts +27 -0
- package/stacks/x-ray/src/types.ts +8 -0
- package/stacks/x-ray/tests/example.test.ts +7 -0
- package/stacks.d.ts +22 -0
- package/tsconfig.json +21 -12
- package/vcs/github/CODE_OF_CONDUCT.md +83 -0
- package/vcs/github/CONTRIBUTING.md +190 -0
- package/vcs/github/EXPLANATIONS.md +41 -0
- package/vcs/github/FUNDING.yml +1 -0
- package/vcs/github/ISSUE_TEMPLATE/bug_report.yml +62 -0
- package/vcs/github/ISSUE_TEMPLATE/config.yml +10 -0
- package/vcs/github/ISSUE_TEMPLATE/feature_request.yml +44 -0
- package/vcs/github/SECURITY.md +70 -0
- package/vcs/github/renovate.json +5 -0
- package/vcs/github/stale.yml +14 -0
- package/vcs/github/workflows/README.md +16 -0
- package/vcs/github/workflows/ci.yml +173 -0
- package/vcs/github/workflows/export-size.yml +32 -0
- package/vcs/github/workflows/release.yml +57 -0
- package/{pages → views}/desktop/src/Cargo.lock +363 -46
- package/{pages → views}/desktop/src/Cargo.toml +2 -2
- package/{pages → views}/web/main.ts +2 -2
- package/api/serverless.yml +0 -11
- package/core/actions/node_modules/.bin/markdown-it +0 -17
- package/core/actions/node_modules/.bin/unbuild +0 -17
- package/core/build/entries/README.md +0 -7
- package/core/build/node_modules/.bin/unbuild +0 -17
- package/core/build/node_modules/.bin/vite +0 -17
- package/core/build/node_modules/.bin/vite-ssg +0 -17
- package/core/build/node_modules/.bin/vue-docgen-web-types +0 -17
- package/core/desktop/node_modules/.bin/tauri +0 -17
- package/core/development/node_modules/.bin/tsc +0 -17
- package/core/development/node_modules/.bin/tsserver +0 -17
- package/core/development/node_modules/.bin/tsx +0 -17
- package/core/development/node_modules/.bin/unbuild +0 -17
- package/core/docs/node_modules/.bin/vitepress +0 -17
- package/core/email/node_modules/.bin/maizzle +0 -17
- package/core/git/node_modules/.bin/bumpp +0 -17
- package/core/git/node_modules/.bin/changelogen +0 -17
- package/core/git/node_modules/.bin/commitizen +0 -17
- package/core/git/node_modules/.bin/cz +0 -17
- package/core/git/node_modules/.bin/giget +0 -17
- package/core/git/node_modules/.bin/git-cz +0 -17
- package/core/git/node_modules/.bin/simple-git-hooks +0 -17
- package/core/lint/node_modules/.bin/eslint +0 -17
- package/core/lint/node_modules/.bin/lint-staged +0 -17
- package/core/lint/node_modules/.bin/publint +0 -17
- package/core/logging/node_modules/.bin/tsc +0 -17
- package/core/logging/node_modules/.bin/tsserver +0 -17
- package/core/logging/node_modules/.bin/tsx +0 -17
- package/core/logging/node_modules/.bin/unbuild +0 -17
- package/core/notifications/node_modules/.bin/maizzle +0 -17
- package/core/server/node_modules/.bin/nitro +0 -17
- package/core/server/node_modules/.bin/nitropack +0 -17
- package/core/server/node_modules/.bin/vite +0 -17
- package/core/testing/node_modules/.bin/playwright +0 -17
- package/core/testing/node_modules/.bin/tsc +0 -17
- package/core/testing/node_modules/.bin/tsserver +0 -17
- package/core/testing/node_modules/.bin/unbuild +0 -17
- package/core/testing/node_modules/.bin/vitest +0 -17
- package/core/tinker/node_modules/.bin/tsx +0 -17
- package/core/types/node_modules/.bin/markdown-it +0 -17
- package/core/types/node_modules/.bin/vite +0 -17
- package/core/types/node_modules/.bin/vite-ssg +0 -17
- package/core/types/node_modules/.bin/vitepress +0 -17
- package/core/types/src/markdown.ts +0 -198
- package/core/ui/node_modules/.bin/vue-tsc +0 -17
- package/core/utils/node_modules/.bin/rimraf +0 -17
- package/core/utils/node_modules/.bin/semver +0 -17
- package/docs/node_modules/.bin/rimraf +0 -17
- package/docs/node_modules/.bin/vitepress +0 -17
- /package/core/{domains → dns}/tests/example.test.ts +0 -0
- /package/{LICENSE.md → ide/vscode/LICENSE.md} +0 -0
- /package/{components → libs/components}/vue/index.html +0 -0
- /package/{core/domains/src → stacks/tables/src/cli}/index.ts +0 -0
- /package/{pages → views}/desktop/.gitignore +0 -0
- /package/{pages → views}/desktop/README.md +0 -0
- /package/{pages → views}/desktop/index.html +0 -0
- /package/{pages → views}/desktop/package.json +0 -0
- /package/{pages → views}/desktop/public/favicon.svg +0 -0
- /package/{pages → views}/desktop/src/.gitignore +0 -0
- /package/{pages → views}/desktop/src/build.rs +0 -0
- /package/{pages → views}/desktop/src/icons/128x128.png +0 -0
- /package/{pages → views}/desktop/src/icons/128x128@2x.png +0 -0
- /package/{pages → views}/desktop/src/icons/32x32.png +0 -0
- /package/{pages → views}/desktop/src/icons/Square107x107Logo.png +0 -0
- /package/{pages → views}/desktop/src/icons/Square142x142Logo.png +0 -0
- /package/{pages → views}/desktop/src/icons/Square150x150Logo.png +0 -0
- /package/{pages → views}/desktop/src/icons/Square284x284Logo.png +0 -0
- /package/{pages → views}/desktop/src/icons/Square30x30Logo.png +0 -0
- /package/{pages → views}/desktop/src/icons/Square310x310Logo.png +0 -0
- /package/{pages → views}/desktop/src/icons/Square44x44Logo.png +0 -0
- /package/{pages → views}/desktop/src/icons/Square71x71Logo.png +0 -0
- /package/{pages → views}/desktop/src/icons/Square89x89Logo.png +0 -0
- /package/{pages → views}/desktop/src/icons/StoreLogo.png +0 -0
- /package/{pages → views}/desktop/src/icons/icon.icns +0 -0
- /package/{pages → views}/desktop/src/icons/icon.ico +0 -0
- /package/{pages → views}/desktop/src/icons/icon.png +0 -0
- /package/{pages → views}/desktop/src/src/main.rs +0 -0
- /package/{pages → views}/desktop/src/tauri.conf.json +0 -0
- /package/{pages → views}/web/App.vue +0 -0
- /package/{pages → views}/web/index.html +0 -0
- /package/{pages → views}/web/public/_headers +0 -0
- /package/{pages → views}/web/public/favicon-dark.svg +0 -0
- /package/{pages → views}/web/public/favicon.svg +0 -0
- /package/{pages → views}/web/public/pwa-192x192.png +0 -0
- /package/{pages → views}/web/public/pwa-512x512.png +0 -0
- /package/{pages → views}/web/public/safari-pinned-tab.svg +0 -0
- /package/{pages → views}/web/styles/main.css +0 -0
- /package/{pages → views}/web/styles/markdown.css +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { intro, log, outro,
|
|
2
|
-
import
|
|
1
|
+
import { intro, log, outro, runCommand, spawn } from '@stacksjs/cli'
|
|
2
|
+
import * as storage from '@stacksjs/storage'
|
|
3
3
|
import { determineDebugLevel } from '@stacksjs/utils'
|
|
4
4
|
import { projectPath } from '@stacksjs/path'
|
|
5
5
|
import type { UpgradeOptions } from '@stacksjs/types'
|
|
@@ -20,7 +20,7 @@ export async function checkForUncommittedChanges(path = './.stacks', options: Up
|
|
|
20
20
|
// the user knows what they are doing. There is also a change that simply the deps within .stacks
|
|
21
21
|
// folder have been updated and that could produce a diff.
|
|
22
22
|
if (!options?.force) {
|
|
23
|
-
const confirmed = await prompt('We detected there are uncommitted in the ./stacks folder. Do you want to overwrite those?', {
|
|
23
|
+
const confirmed = await log.prompt('We detected there are uncommitted in the ./stacks folder. Do you want to overwrite those?', {
|
|
24
24
|
type: 'confirm',
|
|
25
25
|
})
|
|
26
26
|
|
package/core/ai/build.config.ts
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import { defineBuildConfig } from '@stacksjs/development'
|
|
1
|
+
import { alias, defineBuildConfig } from '@stacksjs/development'
|
|
2
2
|
|
|
3
3
|
export default defineBuildConfig({
|
|
4
|
+
alias,
|
|
5
|
+
|
|
4
6
|
entries: [
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
input: './src/',
|
|
8
|
-
outDir: './dist/',
|
|
9
|
-
format: 'esm',
|
|
10
|
-
},
|
|
7
|
+
'./src/drivers/openai',
|
|
8
|
+
'./src/index',
|
|
11
9
|
],
|
|
12
10
|
|
|
13
11
|
clean: true,
|
package/core/ai/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stacksjs/ai",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
5
|
-
"packageManager": "pnpm@8.5
|
|
4
|
+
"version": "0.56.3",
|
|
5
|
+
"packageManager": "pnpm@8.6.5",
|
|
6
6
|
"description": "Stacks Artificial Intelligence.",
|
|
7
7
|
"author": "Chris Breuer",
|
|
8
8
|
"license": "MIT",
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
"import": "./dist/index.mjs"
|
|
30
30
|
},
|
|
31
31
|
"./openai": {
|
|
32
|
-
"types": "./dist/
|
|
33
|
-
"import": "./dist/
|
|
32
|
+
"types": "./dist/openai.d.ts",
|
|
33
|
+
"import": "./dist/openai.mjs"
|
|
34
34
|
}
|
|
35
35
|
},
|
|
36
36
|
"module": "dist/index.mjs",
|
|
@@ -45,13 +45,9 @@
|
|
|
45
45
|
"scripts": {
|
|
46
46
|
"build": "unbuild .",
|
|
47
47
|
"dev": "unbuild --stub",
|
|
48
|
-
"prepublishOnly": "
|
|
48
|
+
"prepublishOnly": "unbuild",
|
|
49
49
|
"typecheck": "tsc --noEmit"
|
|
50
50
|
},
|
|
51
|
-
"peerDependencies": {
|
|
52
|
-
"@stacksjs/cli": "workspace:*",
|
|
53
|
-
"@stacksjs/config": "workspace:*"
|
|
54
|
-
},
|
|
55
51
|
"devDependencies": {
|
|
56
52
|
"@stacksjs/development": "workspace:*"
|
|
57
53
|
}
|
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
import { defineBuildConfig } from '
|
|
1
|
+
import { alias, defineBuildConfig } from '@stacksjs/development'
|
|
2
2
|
|
|
3
3
|
export default defineBuildConfig({
|
|
4
|
+
alias,
|
|
5
|
+
|
|
4
6
|
entries: [
|
|
5
|
-
|
|
6
|
-
builder: 'mkdist',
|
|
7
|
-
input: './src/',
|
|
8
|
-
outDir: './dist/',
|
|
9
|
-
format: 'esm',
|
|
10
|
-
},
|
|
7
|
+
'./src/index',
|
|
11
8
|
],
|
|
12
9
|
|
|
10
|
+
outDir: './dist/',
|
|
13
11
|
clean: true,
|
|
14
12
|
declaration: true,
|
|
15
13
|
})
|
package/core/alias/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stacksjs/alias",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
5
|
-
"packageManager": "pnpm@8.5
|
|
4
|
+
"version": "0.56.3",
|
|
5
|
+
"packageManager": "pnpm@8.6.5",
|
|
6
6
|
"description": "The Stacks aliases.",
|
|
7
7
|
"author": "Chris Breuer",
|
|
8
8
|
"license": "MIT",
|
|
@@ -38,13 +38,10 @@
|
|
|
38
38
|
"scripts": {
|
|
39
39
|
"build": "unbuild",
|
|
40
40
|
"dev": "unbuild --stub",
|
|
41
|
-
"prepublishOnly": "
|
|
41
|
+
"prepublishOnly": "unbuild",
|
|
42
42
|
"typecheck": "tsc --noEmit"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
45
|
"@stacksjs/path": "workspace:*"
|
|
46
|
-
},
|
|
47
|
-
"devDependencies": {
|
|
48
|
-
"@stacksjs/development": "workspace:*"
|
|
49
46
|
}
|
|
50
47
|
}
|
package/core/alias/src/index.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import { path as p } from '@stacksjs/path'
|
|
6
6
|
|
|
7
|
-
const alias: Record<string, string> = {
|
|
7
|
+
export const alias: Record<string, string> = {
|
|
8
8
|
'~/*': p.projectPath('*'),
|
|
9
9
|
'@stacksjs/ai': p.aiPath('src/index.ts'),
|
|
10
10
|
'@stacksjs/ai/*': p.aiPath('src/*'),
|
|
@@ -37,10 +37,10 @@ const alias: Record<string, string> = {
|
|
|
37
37
|
'@stacksjs/development/*': p.developmentPath('src/*'),
|
|
38
38
|
// '@stacksjs/desktop': p.desktopPath('src/index.ts'),
|
|
39
39
|
// '@stacksjs/desktop/*': p.desktopPath('src/*'),
|
|
40
|
+
'@stacksjs/dns': p.dnsPath('src/index.ts'),
|
|
41
|
+
'@stacksjs/dns/*': p.dnsPath('src/*'),
|
|
40
42
|
'@stacksjs/docs': p.docsPath('src/index.ts'),
|
|
41
43
|
'@stacksjs/docs/*': p.docsPath('src/*'),
|
|
42
|
-
'@stacksjs/domains': p.domainsPath('src/index.ts'),
|
|
43
|
-
'@stacksjs/domains/*': p.domainsPath('src/*'),
|
|
44
44
|
'@stacksjs/email': p.emailPath('src/index.ts'),
|
|
45
45
|
'@stacksjs/email/*': p.emailPath('src/*'),
|
|
46
46
|
'@stacksjs/error-handling': p.errorHandlingPath('src/index.ts'),
|
|
@@ -98,12 +98,11 @@ const alias: Record<string, string> = {
|
|
|
98
98
|
'@stacksjs/x-ray': p.xRayPath('src/index.ts'),
|
|
99
99
|
'@stacksjs/x-ray/*': p.xRayPath('src/*'),
|
|
100
100
|
'framework/*': p.frameworkPath('*'),
|
|
101
|
-
'stacks': p.frameworkPath('src/index.ts'),
|
|
101
|
+
// 'stacks': p.frameworkPath('src/index.ts'),
|
|
102
|
+
'stacks/*': p.frameworkPath('src/*'),
|
|
102
103
|
'app/*': p.appPath('*'),
|
|
103
|
-
'config/*': p.
|
|
104
|
+
'config/*': p.projectConfigPath('*'),
|
|
104
105
|
'components/*': p.componentsPath('*'),
|
|
105
106
|
'functions/*': p.functionsPath('*'),
|
|
106
107
|
'pages/*': p.pagesPath('*'),
|
|
107
108
|
}
|
|
108
|
-
|
|
109
|
-
export { alias }
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import { defineBuildConfig } from '
|
|
1
|
+
import { alias, defineBuildConfig } from '@stacksjs/development'
|
|
2
2
|
|
|
3
3
|
export default defineBuildConfig({
|
|
4
|
+
alias,
|
|
5
|
+
|
|
4
6
|
entries: [
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
input: './src/',
|
|
8
|
-
outDir: './dist/',
|
|
9
|
-
format: 'esm',
|
|
10
|
-
},
|
|
7
|
+
'./src/drivers/fathom',
|
|
8
|
+
'./src/index',
|
|
11
9
|
],
|
|
12
10
|
|
|
13
11
|
clean: true,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stacksjs/analytics",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
5
|
-
"packageManager": "pnpm@8.5
|
|
4
|
+
"version": "0.56.3",
|
|
5
|
+
"packageManager": "pnpm@8.6.5",
|
|
6
6
|
"description": "Stacks Analytics. Privacy-friendly.",
|
|
7
7
|
"author": "Chris Breuer",
|
|
8
8
|
"license": "MIT",
|
|
@@ -34,9 +34,9 @@
|
|
|
34
34
|
"types": "./dist/index.d.ts",
|
|
35
35
|
"import": "./dist/index.mjs"
|
|
36
36
|
},
|
|
37
|
-
"./
|
|
38
|
-
"types": "./dist/
|
|
39
|
-
"import": "./dist/
|
|
37
|
+
"./fathom": {
|
|
38
|
+
"types": "./dist/fathom.d.ts",
|
|
39
|
+
"import": "./dist/fathom.mjs"
|
|
40
40
|
}
|
|
41
41
|
},
|
|
42
42
|
"module": "dist/index.mjs",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"scripts": {
|
|
52
52
|
"build": "unbuild",
|
|
53
53
|
"dev": "unbuild --stub",
|
|
54
|
-
"prepublishOnly": "
|
|
54
|
+
"prepublishOnly": "unbuild",
|
|
55
55
|
"typecheck": "tsc --noEmit"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
import { defineBuildConfig } from '
|
|
1
|
+
import { alias, defineBuildConfig } from '@stacksjs/development'
|
|
2
2
|
|
|
3
3
|
export default defineBuildConfig({
|
|
4
|
+
alias,
|
|
5
|
+
|
|
4
6
|
entries: [
|
|
5
|
-
|
|
6
|
-
builder: 'mkdist',
|
|
7
|
-
input: './src/',
|
|
8
|
-
outDir: './dist/',
|
|
9
|
-
format: 'esm',
|
|
10
|
-
},
|
|
7
|
+
'./src/index',
|
|
11
8
|
],
|
|
12
9
|
|
|
13
10
|
clean: true,
|
package/core/arrays/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stacksjs/arrays",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
5
|
-
"packageManager": "pnpm@8.5
|
|
4
|
+
"version": "0.56.3",
|
|
5
|
+
"packageManager": "pnpm@8.6.5",
|
|
6
6
|
"description": "The Stacks array utilities.",
|
|
7
7
|
"author": "Chris Breuer",
|
|
8
8
|
"license": "MIT",
|
|
@@ -42,12 +42,16 @@
|
|
|
42
42
|
"scripts": {
|
|
43
43
|
"build": "unbuild",
|
|
44
44
|
"dev": "unbuild --stub",
|
|
45
|
-
"prepublishOnly": "
|
|
45
|
+
"prepublishOnly": "unbuild",
|
|
46
46
|
"typecheck": "tsc --noEmit"
|
|
47
47
|
},
|
|
48
48
|
"peerDependencies": {
|
|
49
49
|
"@stacksjs/types": "workspace:*",
|
|
50
|
-
"@stacksjs/utils": "workspace:*"
|
|
50
|
+
"@stacksjs/utils": "workspace:*",
|
|
51
|
+
"macroable": "^7.0.2"
|
|
52
|
+
},
|
|
53
|
+
"dependencies": {
|
|
54
|
+
"macroable": "^7.0.2"
|
|
51
55
|
},
|
|
52
56
|
"devDependencies": {
|
|
53
57
|
"@stacksjs/development": "workspace:*",
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export function contains(needle: string, haystack: string[]) {
|
|
2
|
+
return haystack.some(hay => needle.includes(hay))
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export function containsAll(needles: string[], haystack: string[]) {
|
|
6
|
+
return needles.every(needle => contains(needle, haystack))
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function containsAny(needles: string[], haystack: string[]) {
|
|
10
|
+
return needles.some(needle => contains(needle, haystack))
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function containsNone(needles: string[], haystack: string[]) {
|
|
14
|
+
return !containsAny(needles, haystack)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function containsOnly(needles: string[], haystack: string[]) {
|
|
18
|
+
return containsAll(haystack, needles)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function doesNotContain(needle: string, haystack: string[]) {
|
|
22
|
+
return !contains(needle, haystack)
|
|
23
|
+
}
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import type { Arrayable, Nullable } from '@stacksjs/types'
|
|
2
|
+
import { clamp } from '@stacksjs/utils'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Convert `Arrayable<T>` to `Array<T>`
|
|
6
|
+
*
|
|
7
|
+
* @category Array
|
|
8
|
+
*/
|
|
9
|
+
export function toArray<T>(array?: Nullable<Arrayable<T>>): Array<T> {
|
|
10
|
+
array = array ?? []
|
|
11
|
+
return Array.isArray(array) ? array : [array]
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Convert `Arrayable<T>` to `Array<T>` and flatten it
|
|
16
|
+
*
|
|
17
|
+
* @category Array
|
|
18
|
+
*/
|
|
19
|
+
export function flatten<T>(array?: Nullable<Arrayable<T | Array<T>>>): Array<T> {
|
|
20
|
+
return toArray(array).flat(1) as Array<T>
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Use rest arguments to merge arrays
|
|
25
|
+
*
|
|
26
|
+
* @category Array
|
|
27
|
+
*/
|
|
28
|
+
export function mergeArrayable<T>(...args: Nullable<Arrayable<T>>[]): Array<T> {
|
|
29
|
+
return args.flatMap(i => toArray(i))
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export type PartitionFilter<T> = (i: T, idx: number, arr: readonly T[]) => any
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Divide an array into two parts by a filter function
|
|
36
|
+
*
|
|
37
|
+
* @category Array
|
|
38
|
+
* @example const [odd, even] = partition([1, 2, 3, 4], i => i % 2 != 0)
|
|
39
|
+
*/
|
|
40
|
+
export function partition<T>(array: readonly T[], f1: PartitionFilter<T>): [T[], T[]]
|
|
41
|
+
export function partition<T>(array: readonly T[], f1: PartitionFilter<T>, f2: PartitionFilter<T>): [T[], T[], T[]]
|
|
42
|
+
export function partition<T>(array: readonly T[], f1: PartitionFilter<T>, f2: PartitionFilter<T>, f3: PartitionFilter<T>): [T[], T[], T[], T[]]
|
|
43
|
+
export function partition<T>(array: readonly T[], f1: PartitionFilter<T>, f2: PartitionFilter<T>, f3: PartitionFilter<T>, f4: PartitionFilter<T>): [T[], T[], T[], T[], T[]]
|
|
44
|
+
export function partition<T>(array: readonly T[], f1: PartitionFilter<T>, f2: PartitionFilter<T>, f3: PartitionFilter<T>, f4: PartitionFilter<T>, f5: PartitionFilter<T>): [T[], T[], T[], T[], T[], T[]]
|
|
45
|
+
export function partition<T>(array: readonly T[], f1: PartitionFilter<T>, f2: PartitionFilter<T>, f3: PartitionFilter<T>, f4: PartitionFilter<T>, f5: PartitionFilter<T>, f6: PartitionFilter<T>): [T[], T[], T[], T[], T[], T[], T[]]
|
|
46
|
+
export function partition<T>(array: readonly T[], ...filters: PartitionFilter<T>[]): any {
|
|
47
|
+
const result: T[][] = new Array(filters.length + 1).fill(null).map(() => [])
|
|
48
|
+
|
|
49
|
+
array.forEach((e, idx, arr) => {
|
|
50
|
+
let i = 0
|
|
51
|
+
for (const filter of filters) {
|
|
52
|
+
if (filter(e, idx, arr)) {
|
|
53
|
+
result[i].push(e)
|
|
54
|
+
return
|
|
55
|
+
}
|
|
56
|
+
i += 1
|
|
57
|
+
}
|
|
58
|
+
result[i].push(e)
|
|
59
|
+
})
|
|
60
|
+
return result
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Unique an Array
|
|
65
|
+
*
|
|
66
|
+
* @category Array
|
|
67
|
+
*/
|
|
68
|
+
export function uniq<T>(array: readonly T[]): T[] {
|
|
69
|
+
return Array.from(new Set(array))
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export function unique<T>(array: readonly T[]): T[] {
|
|
73
|
+
return uniq(array)
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Unique an Array by a custom equality function
|
|
78
|
+
*
|
|
79
|
+
* @category Array
|
|
80
|
+
*/
|
|
81
|
+
export function uniqueBy<T>(array: readonly T[], equalFn: (a: any, b: any) => boolean): T[] {
|
|
82
|
+
return array.reduce((acc: T[], cur: any) => {
|
|
83
|
+
const index = acc.findIndex((item: any) => equalFn(cur, item))
|
|
84
|
+
if (index === -1)
|
|
85
|
+
acc.push(cur)
|
|
86
|
+
return acc
|
|
87
|
+
}, [])
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Get last item
|
|
92
|
+
*
|
|
93
|
+
* @category Array
|
|
94
|
+
*/
|
|
95
|
+
export function last(array: readonly []): undefined
|
|
96
|
+
export function last<T>(array: readonly T[]): T
|
|
97
|
+
export function last<T>(array: readonly T[]): T | undefined {
|
|
98
|
+
return at(array, -1)
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Remove an item from Array
|
|
103
|
+
*
|
|
104
|
+
* @category Array
|
|
105
|
+
*/
|
|
106
|
+
export function remove<T>(array: T[], value: T) {
|
|
107
|
+
if (!array)
|
|
108
|
+
return false
|
|
109
|
+
const index = array.indexOf(value)
|
|
110
|
+
if (index >= 0) {
|
|
111
|
+
array.splice(index, 1)
|
|
112
|
+
return true
|
|
113
|
+
}
|
|
114
|
+
return false
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Get nth item of Array. Negative for backward
|
|
119
|
+
*
|
|
120
|
+
* @category Array
|
|
121
|
+
*/
|
|
122
|
+
export function at(array: readonly [], index: number): undefined
|
|
123
|
+
export function at<T>(array: readonly T[], index: number): T
|
|
124
|
+
export function at<T>(array: readonly T[] | [], index: number): T | undefined {
|
|
125
|
+
const len = array.length
|
|
126
|
+
if (!len)
|
|
127
|
+
return undefined
|
|
128
|
+
|
|
129
|
+
if (index < 0)
|
|
130
|
+
index += len
|
|
131
|
+
|
|
132
|
+
return array[index]
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Generate a range array of numbers. The `stop` is exclusive.
|
|
137
|
+
*
|
|
138
|
+
* @category Array
|
|
139
|
+
*/
|
|
140
|
+
export function range(stop: number): number[]
|
|
141
|
+
export function range(start: number, stop: number, step?: number): number[]
|
|
142
|
+
export function range(...args: any): number[] {
|
|
143
|
+
let start: number, stop: number, step: number
|
|
144
|
+
|
|
145
|
+
if (args.length === 1) {
|
|
146
|
+
start = 0
|
|
147
|
+
step = 1;
|
|
148
|
+
([stop] = args)
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
([start, stop, step = 1] = args)
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
const arr: number[] = []
|
|
155
|
+
let current = start
|
|
156
|
+
while (current < stop) {
|
|
157
|
+
arr.push(current)
|
|
158
|
+
current += step || 1
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
return arr
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Move element in an Array
|
|
166
|
+
*
|
|
167
|
+
* @category Array
|
|
168
|
+
* @param arr
|
|
169
|
+
* @param from
|
|
170
|
+
* @param to
|
|
171
|
+
*/
|
|
172
|
+
export function move<T>(arr: T[], from: number, to: number) {
|
|
173
|
+
arr.splice(to, 0, arr.splice(from, 1)[0])
|
|
174
|
+
return arr
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Clamp a number to the index range of an array.
|
|
179
|
+
*
|
|
180
|
+
* @category Array
|
|
181
|
+
*/
|
|
182
|
+
export function clampArrayRange(arr: readonly unknown[], n: number) {
|
|
183
|
+
return clamp(n, 0, arr.length - 1)
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Get random items from an array
|
|
188
|
+
*
|
|
189
|
+
* @category Array
|
|
190
|
+
*/
|
|
191
|
+
export function sample<T>(arr: T[], count: number) {
|
|
192
|
+
return Array.from({ length: count }, _ => arr[Math.round(Math.random() * (arr.length - 1))])
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Shuffle an array. This function mutates the array.
|
|
197
|
+
*
|
|
198
|
+
* @category Array
|
|
199
|
+
*/
|
|
200
|
+
export function shuffle<T>(array: T[]): T[] {
|
|
201
|
+
for (let i = array.length - 1; i > 0; i--) {
|
|
202
|
+
const j = Math.floor(Math.random() * (i + 1));
|
|
203
|
+
[array[i], array[j]] = [array[j], array[i]]
|
|
204
|
+
}
|
|
205
|
+
return array
|
|
206
|
+
}
|