@fbincon/claude-code-statusline 0.0.0-stage → 3.0.0-beta.1
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/LICENSE +21 -0
- package/LICENSE-Unicode.txt +39 -0
- package/LICENSE-Wcwidth.txt +27 -0
- package/README.md +90 -2
- package/bin/claude-statusline.js +2 -0
- package/candidate.json +1238 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/config/arguments.d.ts +35 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/config/arguments.js +228 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/config/arguments.js.map +1 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/config/backend-preferences.d.ts +6 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/config/backend-preferences.js +72 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/config/backend-preferences.js.map +1 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/config/commands.d.ts +10 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/config/commands.js +140 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/config/commands.js.map +1 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/config/host.d.ts +10 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/config/host.js +101 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/config/host.js.map +1 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/config/operations.d.ts +10 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/config/operations.js +96 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/config/operations.js.map +1 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/config/preferences.d.ts +11 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/config/preferences.js +80 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/config/preferences.js.map +1 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/config/service.d.ts +45 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/config/service.js +99 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/config/service.js.map +1 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/config/storage.d.ts +30 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/config/storage.js +134 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/config/storage.js.map +1 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/config/transfer.d.ts +3 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/config/transfer.js +89 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/config/transfer.js.map +1 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/context.d.ts +11 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/context.js +2 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/context.js.map +1 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/entry.d.ts +1 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/entry.js +3 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/entry.js.map +1 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/errors.d.ts +4 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/errors.js +8 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/errors.js.map +1 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/help.d.ts +3 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/help.js +67 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/help.js.map +1 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/integration/arguments.d.ts +10 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/integration/arguments.js +40 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/integration/arguments.js.map +1 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/integration/configure.d.ts +3 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/integration/configure.js +63 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/integration/configure.js.map +1 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/integration/doctor.d.ts +4 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/integration/doctor.js +153 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/integration/doctor.js.map +1 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/integration/editor.d.ts +14 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/integration/editor.js +3 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/integration/editor.js.map +1 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/integration/install.d.ts +6 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/integration/install.js +142 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/integration/install.js.map +1 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/integration/launcher.d.ts +15 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/integration/launcher.js +91 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/integration/launcher.js.map +1 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/integration/mod-ownership.d.ts +20 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/integration/mod-ownership.js +109 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/integration/mod-ownership.js.map +1 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/integration/model.d.ts +60 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/integration/model.js +12 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/integration/model.js.map +1 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/integration/mods.d.ts +10 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/integration/mods.js +234 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/integration/mods.js.map +1 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/integration/ownership.d.ts +8 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/integration/ownership.js +41 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/integration/ownership.js.map +1 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/integration/paths.d.ts +1 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/integration/paths.js +14 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/integration/paths.js.map +1 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/integration/plan.d.ts +13 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/integration/plan.js +92 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/integration/plan.js.map +1 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/integration/resources.d.ts +19 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/integration/resources.js +91 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/integration/resources.js.map +1 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/integration/slash-hook.d.ts +6 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/integration/slash-hook.js +94 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/integration/slash-hook.js.map +1 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/integration/transaction.d.ts +8 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/integration/transaction.js +3 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/integration/transaction.js.map +1 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/main.d.ts +22 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/main.js +197 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/main.js.map +1 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/recovery/files.d.ts +7 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/recovery/files.js +134 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/recovery/files.js.map +1 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/recovery/journal.d.ts +58 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/recovery/journal.js +144 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/recovery/journal.js.map +1 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/recovery/official.d.ts +5 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/recovery/official.js +125 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/recovery/official.js.map +1 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/recovery/service.d.ts +11 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/recovery/service.js +55 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/recovery/service.js.map +1 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/rendering/environment.d.ts +15 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/rendering/environment.js +95 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/rendering/environment.js.map +1 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/rendering/main.d.ts +6 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/rendering/main.js +48 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/rendering/main.js.map +1 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/rendering/preview.d.ts +2 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/rendering/preview.js +13 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/rendering/preview.js.map +1 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/runtime/context.d.ts +11 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/runtime/context.js +11 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/runtime/context.js.map +1 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/runtime/git.d.ts +19 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/runtime/git.js +162 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/runtime/git.js.map +1 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/runtime/hook.d.ts +3 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/runtime/hook.js +19 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/runtime/hook.js.map +1 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/runtime/io.d.ts +37 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/runtime/io.js +75 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/runtime/io.js.map +1 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/runtime/json-data.d.ts +9 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/runtime/json-data.js +241 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/runtime/json-data.js.map +1 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/runtime/live/collect.d.ts +2 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/runtime/live/collect.js +14 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/runtime/live/collect.js.map +1 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/runtime/live/durations.d.ts +15 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/runtime/live/durations.js +69 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/runtime/live/durations.js.map +1 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/runtime/live/protocol.d.ts +16 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/runtime/live/protocol.js +90 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/runtime/live/protocol.js.map +1 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/runtime/live/store.d.ts +25 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/runtime/live/store.js +80 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/runtime/live/store.js.map +1 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/runtime/registry.d.ts +4 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/runtime/registry.js +40 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/runtime/registry.js.map +1 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/runtime/tasks/collect.d.ts +5 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/runtime/tasks/collect.js +59 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/runtime/tasks/collect.js.map +1 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/runtime/tasks/service.d.ts +17 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/runtime/tasks/service.js +69 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/runtime/tasks/service.js.map +1 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/runtime/tasks/store.d.ts +17 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/runtime/tasks/store.js +70 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/runtime/tasks/store.js.map +1 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/runtime/tasks/submissions.d.ts +13 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/runtime/tasks/submissions.js +75 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/runtime/tasks/submissions.js.map +1 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/runtime/usage.d.ts +33 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/runtime/usage.js +227 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/runtime/usage.js.map +1 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/ui/protocol.d.ts +20 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/ui/protocol.js +144 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/ui/protocol.js.map +1 -0
- package/node_modules/@fbincon/statusline-cli/package.json +17 -0
- package/node_modules/@fbincon/statusline-cli/resources/statusline-config/SKILL.md +80 -0
- package/node_modules/@fbincon/statusline-cli/resources/statusline-configure/SKILL.md +19 -0
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/.claude-plugin/plugin.json +37 -0
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/hooks/hooks.json +6 -0
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/hooks/register.ts +820 -0
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/backend.ts +503 -0
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/client/forms.ts +3 -0
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/client/keys.ts +198 -0
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/client/messages.ts +101 -0
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/client/settings.ts +218 -0
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/appearance.ts +29 -0
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/draft.ts +254 -0
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/forms.ts +167 -0
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/guidance.ts +20 -0
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/import-review.ts +55 -0
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/instances.ts +30 -0
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/navigation.ts +98 -0
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/numeric.ts +42 -0
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/search.ts +114 -0
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/generated-contracts.ts +276 -0
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/generated-unicode.ts +92 -0
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/i18n/generated-locales.ts +6842 -0
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/i18n/index.ts +40 -0
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/i18n/messages.ts +33 -0
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/i18n/presentation.ts +62 -0
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/launch.ts +25 -0
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/preferences.ts +61 -0
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/preview-preferences.ts +8 -0
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/session.ts +124 -0
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/unicode.ts +121 -0
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/resource-manifest.json +47 -0
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/ui/client/draw.ts +159 -0
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/ui/client/help.ts +84 -0
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/ui/client/surface.ts +89 -0
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/ui/components/catalog.ts +23 -0
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/ui/components/preview.ts +45 -0
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/ui/components/section.ts +49 -0
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/ui/components/shortcuts.ts +83 -0
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/ui/layout.ts +49 -0
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/ui/styled-text.ts +56 -0
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/ui/text.ts +23 -0
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/ui/theme.ts +27 -0
- package/node_modules/@fbincon/statusline-cli/resources/statusline-runtime/.claude-plugin/plugin.json +49 -0
- package/node_modules/@fbincon/statusline-cli/resources/statusline-runtime/hooks/hooks.json +1 -0
- package/node_modules/@fbincon/statusline-cli/resources/statusline-runtime/hooks/observe.ts +279 -0
- package/node_modules/@fbincon/statusline-cli/resources/statusline-runtime/lib/checklists.ts +45 -0
- package/node_modules/@fbincon/statusline-cli/resources/statusline-runtime/lib/costs.ts +23 -0
- package/node_modules/@fbincon/statusline-cli/resources/statusline-runtime/lib/generated-contracts.ts +18 -0
- package/node_modules/@fbincon/statusline-cli/resources/statusline-runtime/lib/identity.ts +14 -0
- package/node_modules/@fbincon/statusline-cli/resources/statusline-runtime/lib/launch.ts +25 -0
- package/node_modules/@fbincon/statusline-cli/resources/statusline-runtime/lib/queue.ts +68 -0
- package/node_modules/@fbincon/statusline-cli/resources/statusline-runtime/lib/streams.ts +28 -0
- package/node_modules/@fbincon/statusline-cli/resources/statusline-runtime/lib/timing.ts +11 -0
- package/node_modules/@fbincon/statusline-cli/resources/statusline-runtime/resource-manifest.json +19 -0
- package/node_modules/@fbincon/statusline-core/dist/src/config/backend-preferences.d.ts +14 -0
- package/node_modules/@fbincon/statusline-core/dist/src/config/backend-preferences.js +72 -0
- package/node_modules/@fbincon/statusline-core/dist/src/config/backend-preferences.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/config/catalog-data.d.ts +86 -0
- package/node_modules/@fbincon/statusline-core/dist/src/config/catalog-data.js +3462 -0
- package/node_modules/@fbincon/statusline-core/dist/src/config/catalog-data.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/config/catalog.d.ts +10 -0
- package/node_modules/@fbincon/statusline-core/dist/src/config/catalog.js +17 -0
- package/node_modules/@fbincon/statusline-core/dist/src/config/catalog.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/config/defaults.d.ts +5 -0
- package/node_modules/@fbincon/statusline-core/dist/src/config/defaults.js +19 -0
- package/node_modules/@fbincon/statusline-core/dist/src/config/defaults.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/config/display.d.ts +13 -0
- package/node_modules/@fbincon/statusline-core/dist/src/config/display.js +232 -0
- package/node_modules/@fbincon/statusline-core/dist/src/config/display.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/config/draft.d.ts +4 -0
- package/node_modules/@fbincon/statusline-core/dist/src/config/draft.js +48 -0
- package/node_modules/@fbincon/statusline-core/dist/src/config/draft.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/config/editor-fields.d.ts +8 -0
- package/node_modules/@fbincon/statusline-core/dist/src/config/editor-fields.js +104 -0
- package/node_modules/@fbincon/statusline-core/dist/src/config/editor-fields.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/config/formatting.d.ts +11 -0
- package/node_modules/@fbincon/statusline-core/dist/src/config/formatting.js +99 -0
- package/node_modules/@fbincon/statusline-core/dist/src/config/formatting.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/config/generated-constants.d.ts +36 -0
- package/node_modules/@fbincon/statusline-core/dist/src/config/generated-constants.js +5 -0
- package/node_modules/@fbincon/statusline-core/dist/src/config/generated-constants.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/config/import-review.d.ts +4 -0
- package/node_modules/@fbincon/statusline-core/dist/src/config/import-review.js +80 -0
- package/node_modules/@fbincon/statusline-core/dist/src/config/import-review.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/config/instances.d.ts +29 -0
- package/node_modules/@fbincon/statusline-core/dist/src/config/instances.js +159 -0
- package/node_modules/@fbincon/statusline-core/dist/src/config/instances.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/config/presets.d.ts +10 -0
- package/node_modules/@fbincon/statusline-core/dist/src/config/presets.js +34 -0
- package/node_modules/@fbincon/statusline-core/dist/src/config/presets.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/config/transfer.d.ts +6 -0
- package/node_modules/@fbincon/statusline-core/dist/src/config/transfer.js +23 -0
- package/node_modules/@fbincon/statusline-core/dist/src/config/transfer.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/config/validation.d.ts +15 -0
- package/node_modules/@fbincon/statusline-core/dist/src/config/validation.js +55 -0
- package/node_modules/@fbincon/statusline-core/dist/src/config/validation.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/contracts/generated-catalog.d.ts +33 -0
- package/node_modules/@fbincon/statusline-core/dist/src/contracts/generated-catalog.js +5 -0
- package/node_modules/@fbincon/statusline-core/dist/src/contracts/generated-catalog.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/contracts/runtime.d.ts +18 -0
- package/node_modules/@fbincon/statusline-core/dist/src/contracts/runtime.js +3 -0
- package/node_modules/@fbincon/statusline-core/dist/src/contracts/runtime.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/contracts/ui.d.ts +663 -0
- package/node_modules/@fbincon/statusline-core/dist/src/contracts/ui.js +23 -0
- package/node_modules/@fbincon/statusline-core/dist/src/contracts/ui.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/editor/appearance.d.ts +5 -0
- package/node_modules/@fbincon/statusline-core/dist/src/editor/appearance.js +27 -0
- package/node_modules/@fbincon/statusline-core/dist/src/editor/appearance.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/editor/backend.d.ts +18 -0
- package/node_modules/@fbincon/statusline-core/dist/src/editor/backend.js +401 -0
- package/node_modules/@fbincon/statusline-core/dist/src/editor/backend.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/editor/draft.d.ts +73 -0
- package/node_modules/@fbincon/statusline-core/dist/src/editor/draft.js +251 -0
- package/node_modules/@fbincon/statusline-core/dist/src/editor/draft.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/editor/forms.d.ts +26 -0
- package/node_modules/@fbincon/statusline-core/dist/src/editor/forms.js +146 -0
- package/node_modules/@fbincon/statusline-core/dist/src/editor/forms.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/editor/guidance.d.ts +3 -0
- package/node_modules/@fbincon/statusline-core/dist/src/editor/guidance.js +17 -0
- package/node_modules/@fbincon/statusline-core/dist/src/editor/guidance.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/editor/import-review.d.ts +19 -0
- package/node_modules/@fbincon/statusline-core/dist/src/editor/import-review.js +53 -0
- package/node_modules/@fbincon/statusline-core/dist/src/editor/import-review.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/editor/instances.d.ts +4 -0
- package/node_modules/@fbincon/statusline-core/dist/src/editor/instances.js +36 -0
- package/node_modules/@fbincon/statusline-core/dist/src/editor/instances.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/editor/navigation.d.ts +37 -0
- package/node_modules/@fbincon/statusline-core/dist/src/editor/navigation.js +73 -0
- package/node_modules/@fbincon/statusline-core/dist/src/editor/navigation.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/editor/numeric.d.ts +11 -0
- package/node_modules/@fbincon/statusline-core/dist/src/editor/numeric.js +27 -0
- package/node_modules/@fbincon/statusline-core/dist/src/editor/numeric.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/editor/search.d.ts +22 -0
- package/node_modules/@fbincon/statusline-core/dist/src/editor/search.js +122 -0
- package/node_modules/@fbincon/statusline-core/dist/src/editor/search.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/editor/text.d.ts +2 -0
- package/node_modules/@fbincon/statusline-core/dist/src/editor/text.js +30 -0
- package/node_modules/@fbincon/statusline-core/dist/src/editor/text.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/i18n/generated-locales.d.ts +6841 -0
- package/node_modules/@fbincon/statusline-core/dist/src/i18n/generated-locales.js +6841 -0
- package/node_modules/@fbincon/statusline-core/dist/src/i18n/generated-locales.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/i18n/messages.d.ts +16 -0
- package/node_modules/@fbincon/statusline-core/dist/src/i18n/messages.js +38 -0
- package/node_modules/@fbincon/statusline-core/dist/src/i18n/messages.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/i18n/registry.d.ts +3 -0
- package/node_modules/@fbincon/statusline-core/dist/src/i18n/registry.js +4 -0
- package/node_modules/@fbincon/statusline-core/dist/src/i18n/registry.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/i18n/statusline/en.d.ts +222 -0
- package/node_modules/@fbincon/statusline-core/dist/src/i18n/statusline/en.js +224 -0
- package/node_modules/@fbincon/statusline-core/dist/src/i18n/statusline/en.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/i18n/statusline/ja.d.ts +222 -0
- package/node_modules/@fbincon/statusline-core/dist/src/i18n/statusline/ja.js +224 -0
- package/node_modules/@fbincon/statusline-core/dist/src/i18n/statusline/ja.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/i18n/statusline/ko.d.ts +222 -0
- package/node_modules/@fbincon/statusline-core/dist/src/i18n/statusline/ko.js +224 -0
- package/node_modules/@fbincon/statusline-core/dist/src/i18n/statusline/ko.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/i18n/statusline/zh-CN.d.ts +222 -0
- package/node_modules/@fbincon/statusline-core/dist/src/i18n/statusline/zh-CN.js +224 -0
- package/node_modules/@fbincon/statusline-core/dist/src/i18n/statusline/zh-CN.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/i18n/statusline/zh-Hant.d.ts +222 -0
- package/node_modules/@fbincon/statusline-core/dist/src/i18n/statusline/zh-Hant.js +224 -0
- package/node_modules/@fbincon/statusline-core/dist/src/i18n/statusline/zh-Hant.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/integration/binding.d.ts +9 -0
- package/node_modules/@fbincon/statusline-core/dist/src/integration/binding.js +27 -0
- package/node_modules/@fbincon/statusline-core/dist/src/integration/binding.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/json-equality.d.ts +2 -0
- package/node_modules/@fbincon/statusline-core/dist/src/json-equality.js +31 -0
- package/node_modules/@fbincon/statusline-core/dist/src/json-equality.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/json-read.d.ts +9 -0
- package/node_modules/@fbincon/statusline-core/dist/src/json-read.js +137 -0
- package/node_modules/@fbincon/statusline-core/dist/src/json-read.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/json-text.d.ts +9 -0
- package/node_modules/@fbincon/statusline-core/dist/src/json-text.js +56 -0
- package/node_modules/@fbincon/statusline-core/dist/src/json-text.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/json.d.ts +18 -0
- package/node_modules/@fbincon/statusline-core/dist/src/json.js +165 -0
- package/node_modules/@fbincon/statusline-core/dist/src/json.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/numbers.d.ts +4 -0
- package/node_modules/@fbincon/statusline-core/dist/src/numbers.js +47 -0
- package/node_modules/@fbincon/statusline-core/dist/src/numbers.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/ordered-record.d.ts +21 -0
- package/node_modules/@fbincon/statusline-core/dist/src/ordered-record.js +105 -0
- package/node_modules/@fbincon/statusline-core/dist/src/ordered-record.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/release.d.ts +7 -0
- package/node_modules/@fbincon/statusline-core/dist/src/release.js +14 -0
- package/node_modules/@fbincon/statusline-core/dist/src/release.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/appearance.d.ts +10 -0
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/appearance.js +73 -0
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/appearance.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/coercion.d.ts +2 -0
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/coercion.js +50 -0
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/coercion.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/colors.d.ts +3 -0
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/colors.js +36 -0
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/colors.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/components.d.ts +10 -0
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/components.js +49 -0
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/components.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/context.d.ts +36 -0
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/context.js +2 -0
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/context.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/formatters.d.ts +10 -0
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/formatters.js +58 -0
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/formatters.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/git.d.ts +7 -0
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/git.js +34 -0
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/git.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/items.d.ts +49 -0
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/items.js +399 -0
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/items.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/language.d.ts +13 -0
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/language.js +36 -0
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/language.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/layout.d.ts +19 -0
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/layout.js +176 -0
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/layout.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/live.d.ts +4 -0
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/live.js +29 -0
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/live.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/metrics.d.ts +13 -0
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/metrics.js +93 -0
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/metrics.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/numeric-format.d.ts +3 -0
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/numeric-format.js +46 -0
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/numeric-format.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/palette.d.ts +23 -0
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/palette.js +9 -0
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/palette.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/powerline.d.ts +10 -0
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/powerline.js +76 -0
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/powerline.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/preferences.d.ts +14 -0
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/preferences.js +98 -0
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/preferences.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/preview.d.ts +67 -0
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/preview.js +36 -0
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/preview.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/spans.d.ts +8 -0
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/spans.js +14 -0
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/spans.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/styles.d.ts +24 -0
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/styles.js +116 -0
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/styles.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/subagents.d.ts +13 -0
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/subagents.js +305 -0
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/subagents.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/timer.d.ts +8 -0
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/timer.js +33 -0
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/timer.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/visibility.d.ts +4 -0
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/visibility.js +52 -0
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/visibility.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/runtime/git.d.ts +9 -0
- package/node_modules/@fbincon/statusline-core/dist/src/runtime/git.js +115 -0
- package/node_modules/@fbincon/statusline-core/dist/src/runtime/git.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/runtime/live/bindings.d.ts +4 -0
- package/node_modules/@fbincon/statusline-core/dist/src/runtime/live/bindings.js +104 -0
- package/node_modules/@fbincon/statusline-core/dist/src/runtime/live/bindings.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/runtime/live/model.d.ts +27 -0
- package/node_modules/@fbincon/statusline-core/dist/src/runtime/live/model.js +196 -0
- package/node_modules/@fbincon/statusline-core/dist/src/runtime/live/model.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/runtime/live/ownership.d.ts +6 -0
- package/node_modules/@fbincon/statusline-core/dist/src/runtime/live/ownership.js +45 -0
- package/node_modules/@fbincon/statusline-core/dist/src/runtime/live/ownership.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/runtime/live/reducer.d.ts +5 -0
- package/node_modules/@fbincon/statusline-core/dist/src/runtime/live/reducer.js +228 -0
- package/node_modules/@fbincon/statusline-core/dist/src/runtime/live/reducer.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/runtime/live/requests.d.ts +24 -0
- package/node_modules/@fbincon/statusline-core/dist/src/runtime/live/requests.js +145 -0
- package/node_modules/@fbincon/statusline-core/dist/src/runtime/live/requests.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/runtime/live/snapshot.d.ts +6 -0
- package/node_modules/@fbincon/statusline-core/dist/src/runtime/live/snapshot.js +70 -0
- package/node_modules/@fbincon/statusline-core/dist/src/runtime/live/snapshot.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/runtime/live/state.d.ts +36 -0
- package/node_modules/@fbincon/statusline-core/dist/src/runtime/live/state.js +110 -0
- package/node_modules/@fbincon/statusline-core/dist/src/runtime/live/state.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/runtime/tasks/agents.d.ts +8 -0
- package/node_modules/@fbincon/statusline-core/dist/src/runtime/tasks/agents.js +75 -0
- package/node_modules/@fbincon/statusline-core/dist/src/runtime/tasks/agents.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/runtime/tasks/hooks.d.ts +10 -0
- package/node_modules/@fbincon/statusline-core/dist/src/runtime/tasks/hooks.js +121 -0
- package/node_modules/@fbincon/statusline-core/dist/src/runtime/tasks/hooks.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/runtime/tasks/model.d.ts +43 -0
- package/node_modules/@fbincon/statusline-core/dist/src/runtime/tasks/model.js +198 -0
- package/node_modules/@fbincon/statusline-core/dist/src/runtime/tasks/model.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/runtime/tasks/native.d.ts +6 -0
- package/node_modules/@fbincon/statusline-core/dist/src/runtime/tasks/native.js +192 -0
- package/node_modules/@fbincon/statusline-core/dist/src/runtime/tasks/native.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/runtime/tasks/transitions.d.ts +16 -0
- package/node_modules/@fbincon/statusline-core/dist/src/runtime/tasks/transitions.js +245 -0
- package/node_modules/@fbincon/statusline-core/dist/src/runtime/tasks/transitions.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/runtime/tasks/view.d.ts +4 -0
- package/node_modules/@fbincon/statusline-core/dist/src/runtime/tasks/view.js +28 -0
- package/node_modules/@fbincon/statusline-core/dist/src/runtime/tasks/view.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/runtime/transcript.d.ts +26 -0
- package/node_modules/@fbincon/statusline-core/dist/src/runtime/transcript.js +183 -0
- package/node_modules/@fbincon/statusline-core/dist/src/runtime/transcript.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/runtime/usage.d.ts +64 -0
- package/node_modules/@fbincon/statusline-core/dist/src/runtime/usage.js +263 -0
- package/node_modules/@fbincon/statusline-core/dist/src/runtime/usage.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/runtime/values.d.ts +18 -0
- package/node_modules/@fbincon/statusline-core/dist/src/runtime/values.js +103 -0
- package/node_modules/@fbincon/statusline-core/dist/src/runtime/values.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/terminal/key.d.ts +7 -0
- package/node_modules/@fbincon/statusline-core/dist/src/terminal/key.js +2 -0
- package/node_modules/@fbincon/statusline-core/dist/src/terminal/key.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/terminal/spans.d.ts +6 -0
- package/node_modules/@fbincon/statusline-core/dist/src/terminal/spans.js +50 -0
- package/node_modules/@fbincon/statusline-core/dist/src/terminal/spans.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/timing/sample.d.ts +8 -0
- package/node_modules/@fbincon/statusline-core/dist/src/timing/sample.js +13 -0
- package/node_modules/@fbincon/statusline-core/dist/src/timing/sample.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/timing/timer.d.ts +22 -0
- package/node_modules/@fbincon/statusline-core/dist/src/timing/timer.js +75 -0
- package/node_modules/@fbincon/statusline-core/dist/src/timing/timer.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/unicode/generated-unicode.d.ts +12 -0
- package/node_modules/@fbincon/statusline-core/dist/src/unicode/generated-unicode.js +93 -0
- package/node_modules/@fbincon/statusline-core/dist/src/unicode/generated-unicode.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/unicode/index.d.ts +5 -0
- package/node_modules/@fbincon/statusline-core/dist/src/unicode/index.js +178 -0
- package/node_modules/@fbincon/statusline-core/dist/src/unicode/index.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/package.json +8 -0
- package/node_modules/@fbincon/statusline-core/resources/i18n/languages.json +7 -0
- package/node_modules/@fbincon/statusline-core/resources/i18n/locales/en.json +1367 -0
- package/node_modules/@fbincon/statusline-core/resources/i18n/locales/ja.json +1367 -0
- package/node_modules/@fbincon/statusline-core/resources/i18n/locales/ko.json +1367 -0
- package/node_modules/@fbincon/statusline-core/resources/i18n/locales/zh-CN.json +1367 -0
- package/node_modules/@fbincon/statusline-core/resources/i18n/locales/zh-Hant.json +1367 -0
- package/node_modules/@fbincon/statusline-platform/dist/src/architecture.d.ts +15 -0
- package/node_modules/@fbincon/statusline-platform/dist/src/architecture.js +22 -0
- package/node_modules/@fbincon/statusline-platform/dist/src/architecture.js.map +1 -0
- package/node_modules/@fbincon/statusline-platform/dist/src/clocks.d.ts +4 -0
- package/node_modules/@fbincon/statusline-platform/dist/src/clocks.js +102 -0
- package/node_modules/@fbincon/statusline-platform/dist/src/clocks.js.map +1 -0
- package/node_modules/@fbincon/statusline-platform/dist/src/command.d.ts +16 -0
- package/node_modules/@fbincon/statusline-platform/dist/src/command.js +18 -0
- package/node_modules/@fbincon/statusline-platform/dist/src/command.js.map +1 -0
- package/node_modules/@fbincon/statusline-platform/dist/src/commands.d.ts +12 -0
- package/node_modules/@fbincon/statusline-platform/dist/src/commands.js +160 -0
- package/node_modules/@fbincon/statusline-platform/dist/src/commands.js.map +1 -0
- package/node_modules/@fbincon/statusline-platform/dist/src/errors.d.ts +1 -0
- package/node_modules/@fbincon/statusline-platform/dist/src/errors.js +19 -0
- package/node_modules/@fbincon/statusline-platform/dist/src/errors.js.map +1 -0
- package/node_modules/@fbincon/statusline-platform/dist/src/files.d.ts +8 -0
- package/node_modules/@fbincon/statusline-platform/dist/src/files.js +164 -0
- package/node_modules/@fbincon/statusline-platform/dist/src/files.js.map +1 -0
- package/node_modules/@fbincon/statusline-platform/dist/src/hash.d.ts +2 -0
- package/node_modules/@fbincon/statusline-platform/dist/src/hash.js +5 -0
- package/node_modules/@fbincon/statusline-platform/dist/src/hash.js.map +1 -0
- package/node_modules/@fbincon/statusline-platform/dist/src/input.d.ts +2 -0
- package/node_modules/@fbincon/statusline-platform/dist/src/input.js +14 -0
- package/node_modules/@fbincon/statusline-platform/dist/src/input.js.map +1 -0
- package/node_modules/@fbincon/statusline-platform/dist/src/launch.d.ts +12 -0
- package/node_modules/@fbincon/statusline-platform/dist/src/launch.js +21 -0
- package/node_modules/@fbincon/statusline-platform/dist/src/launch.js.map +1 -0
- package/node_modules/@fbincon/statusline-platform/dist/src/line-cursor.d.ts +2 -0
- package/node_modules/@fbincon/statusline-platform/dist/src/line-cursor.js +31 -0
- package/node_modules/@fbincon/statusline-platform/dist/src/line-cursor.js.map +1 -0
- package/node_modules/@fbincon/statusline-platform/dist/src/native.d.ts +15 -0
- package/node_modules/@fbincon/statusline-platform/dist/src/native.js +36 -0
- package/node_modules/@fbincon/statusline-platform/dist/src/native.js.map +1 -0
- package/node_modules/@fbincon/statusline-platform/dist/src/plugin-host.d.ts +17 -0
- package/node_modules/@fbincon/statusline-platform/dist/src/plugin-host.js +44 -0
- package/node_modules/@fbincon/statusline-platform/dist/src/plugin-host.js.map +1 -0
- package/node_modules/@fbincon/statusline-platform/dist/src/presentation.d.ts +4 -0
- package/node_modules/@fbincon/statusline-platform/dist/src/presentation.js +48 -0
- package/node_modules/@fbincon/statusline-platform/dist/src/presentation.js.map +1 -0
- package/node_modules/@fbincon/statusline-platform/dist/src/processes.d.ts +2 -0
- package/node_modules/@fbincon/statusline-platform/dist/src/processes.js +67 -0
- package/node_modules/@fbincon/statusline-platform/dist/src/processes.js.map +1 -0
- package/node_modules/@fbincon/statusline-platform/dist/src/terminal/bridge.d.ts +42 -0
- package/node_modules/@fbincon/statusline-platform/dist/src/terminal/bridge.js +180 -0
- package/node_modules/@fbincon/statusline-platform/dist/src/terminal/bridge.js.map +1 -0
- package/node_modules/@fbincon/statusline-platform/dist/src/terminal/input.d.ts +11 -0
- package/node_modules/@fbincon/statusline-platform/dist/src/terminal/input.js +81 -0
- package/node_modules/@fbincon/statusline-platform/dist/src/terminal/input.js.map +1 -0
- package/node_modules/@fbincon/statusline-platform/dist/src/terminal/launchers.d.ts +32 -0
- package/node_modules/@fbincon/statusline-platform/dist/src/terminal/launchers.js +157 -0
- package/node_modules/@fbincon/statusline-platform/dist/src/terminal/launchers.js.map +1 -0
- package/node_modules/@fbincon/statusline-platform/dist/src/terminal/session.d.ts +18 -0
- package/node_modules/@fbincon/statusline-platform/dist/src/terminal/session.js +150 -0
- package/node_modules/@fbincon/statusline-platform/dist/src/terminal/session.js.map +1 -0
- package/node_modules/@fbincon/statusline-platform/dist/src/terminal/windows-modes.d.ts +6 -0
- package/node_modules/@fbincon/statusline-platform/dist/src/terminal/windows-modes.js +39 -0
- package/node_modules/@fbincon/statusline-platform/dist/src/terminal/windows-modes.js.map +1 -0
- package/node_modules/@fbincon/statusline-platform/dist/src/utf8.d.ts +5 -0
- package/node_modules/@fbincon/statusline-platform/dist/src/utf8.js +82 -0
- package/node_modules/@fbincon/statusline-platform/dist/src/utf8.js.map +1 -0
- package/node_modules/@fbincon/statusline-platform/package.json +8 -0
- package/node_modules/@fbincon/statusline-tui/dist/src/drawing.d.ts +16 -0
- package/node_modules/@fbincon/statusline-tui/dist/src/drawing.js +213 -0
- package/node_modules/@fbincon/statusline-tui/dist/src/drawing.js.map +1 -0
- package/node_modules/@fbincon/statusline-tui/dist/src/layout.d.ts +30 -0
- package/node_modules/@fbincon/statusline-tui/dist/src/layout.js +34 -0
- package/node_modules/@fbincon/statusline-tui/dist/src/layout.js.map +1 -0
- package/node_modules/@fbincon/statusline-tui/dist/src/session.d.ts +28 -0
- package/node_modules/@fbincon/statusline-tui/dist/src/session.js +126 -0
- package/node_modules/@fbincon/statusline-tui/dist/src/session.js.map +1 -0
- package/node_modules/@fbincon/statusline-tui/dist/src/state.d.ts +52 -0
- package/node_modules/@fbincon/statusline-tui/dist/src/state.js +352 -0
- package/node_modules/@fbincon/statusline-tui/dist/src/state.js.map +1 -0
- package/node_modules/@fbincon/statusline-tui/package.json +16 -0
- package/node_modules/@koromix/koffi-darwin-arm64/README.md +6 -0
- package/node_modules/@koromix/koffi-darwin-arm64/darwin_arm64/koffi.node +0 -0
- package/node_modules/@koromix/koffi-darwin-arm64/index.js +1 -0
- package/node_modules/@koromix/koffi-darwin-arm64/package.json +24 -0
- package/node_modules/@koromix/koffi-darwin-x64/README.md +6 -0
- package/node_modules/@koromix/koffi-darwin-x64/darwin_x64/koffi.node +0 -0
- package/node_modules/@koromix/koffi-darwin-x64/index.js +1 -0
- package/node_modules/@koromix/koffi-darwin-x64/package.json +24 -0
- package/node_modules/@koromix/koffi-linux-x64/README.md +6 -0
- package/node_modules/@koromix/koffi-linux-x64/index.js +198 -0
- package/node_modules/@koromix/koffi-linux-x64/linux_x64/koffi.node +0 -0
- package/node_modules/@koromix/koffi-linux-x64/musl_x64/koffi.node +0 -0
- package/node_modules/@koromix/koffi-linux-x64/package.json +24 -0
- package/node_modules/@koromix/koffi-win32-x64/README.md +6 -0
- package/node_modules/@koromix/koffi-win32-x64/index.js +1 -0
- package/node_modules/@koromix/koffi-win32-x64/package.json +24 -0
- package/node_modules/@koromix/koffi-win32-x64/win32_x64/koffi.lib +0 -0
- package/node_modules/@koromix/koffi-win32-x64/win32_x64/koffi.node +0 -0
- package/node_modules/koffi/LICENSE.txt +22 -0
- package/node_modules/koffi/README.md +46 -0
- package/node_modules/koffi/index.cjs +1 -0
- package/node_modules/koffi/index.d.ts +390 -0
- package/node_modules/koffi/index.js +2 -0
- package/node_modules/koffi/indirect.cjs +1 -0
- package/node_modules/koffi/indirect.js +2 -0
- package/node_modules/koffi/package.json +73 -0
- package/node_modules/koffi/src/koffi/index.cjs +327 -0
- package/node_modules/koffi/src/koffi/index.js +312 -0
- package/node_modules/koffi/src/koffi/indirect.cjs +326 -0
- package/node_modules/koffi/src/koffi/indirect.js +311 -0
- package/node_modules/koffi/src/koffi/src/static.cjs +170 -0
- package/node_modules/koffi/src/koffi/src/static.js +173 -0
- package/node_modules/lossless-json/LICENSE.md +9 -0
- package/node_modules/lossless-json/README.md +549 -0
- package/node_modules/lossless-json/lib/esm/LosslessNumber.js +92 -0
- package/node_modules/lossless-json/lib/esm/LosslessNumber.js.map +1 -0
- package/node_modules/lossless-json/lib/esm/config.js +9 -0
- package/node_modules/lossless-json/lib/esm/config.js.map +1 -0
- package/node_modules/lossless-json/lib/esm/index.js +9 -0
- package/node_modules/lossless-json/lib/esm/index.js.map +1 -0
- package/node_modules/lossless-json/lib/esm/numberParsers.js +9 -0
- package/node_modules/lossless-json/lib/esm/numberParsers.js.map +1 -0
- package/node_modules/lossless-json/lib/esm/package.json +3 -0
- package/node_modules/lossless-json/lib/esm/parse.js +346 -0
- package/node_modules/lossless-json/lib/esm/parse.js.map +1 -0
- package/node_modules/lossless-json/lib/esm/revive.js +57 -0
- package/node_modules/lossless-json/lib/esm/revive.js.map +1 -0
- package/node_modules/lossless-json/lib/esm/reviveDate.js +10 -0
- package/node_modules/lossless-json/lib/esm/reviveDate.js.map +1 -0
- package/node_modules/lossless-json/lib/esm/stringify.js +166 -0
- package/node_modules/lossless-json/lib/esm/stringify.js.map +1 -0
- package/node_modules/lossless-json/lib/esm/types.js +2 -0
- package/node_modules/lossless-json/lib/esm/types.js.map +1 -0
- package/node_modules/lossless-json/lib/esm/utils.js +236 -0
- package/node_modules/lossless-json/lib/esm/utils.js.map +1 -0
- package/node_modules/lossless-json/lib/types/LosslessNumber.d.ts +40 -0
- package/node_modules/lossless-json/lib/types/LosslessNumber.d.ts.map +1 -0
- package/node_modules/lossless-json/lib/types/config.d.ts +13 -0
- package/node_modules/lossless-json/lib/types/config.d.ts.map +1 -0
- package/node_modules/lossless-json/lib/types/index.d.ts +9 -0
- package/node_modules/lossless-json/lib/types/index.d.ts.map +1 -0
- package/node_modules/lossless-json/lib/types/numberParsers.d.ts +4 -0
- package/node_modules/lossless-json/lib/types/numberParsers.d.ts.map +1 -0
- package/node_modules/lossless-json/lib/types/parse.d.ts +33 -0
- package/node_modules/lossless-json/lib/types/parse.d.ts.map +1 -0
- package/node_modules/lossless-json/lib/types/revive.d.ts +13 -0
- package/node_modules/lossless-json/lib/types/revive.d.ts.map +1 -0
- package/node_modules/lossless-json/lib/types/reviveDate.d.ts +5 -0
- package/node_modules/lossless-json/lib/types/reviveDate.d.ts.map +1 -0
- package/node_modules/lossless-json/lib/types/stringify.d.ts +37 -0
- package/node_modules/lossless-json/lib/types/stringify.d.ts.map +1 -0
- package/node_modules/lossless-json/lib/types/types.d.ts +61 -0
- package/node_modules/lossless-json/lib/types/types.d.ts.map +1 -0
- package/node_modules/lossless-json/lib/types/utils.d.ts +79 -0
- package/node_modules/lossless-json/lib/types/utils.d.ts.map +1 -0
- package/node_modules/lossless-json/lib/umd/lossless-json.js +1 -0
- package/node_modules/lossless-json/lib/umd/lossless-json.js.map +1 -0
- package/node_modules/lossless-json/lib/umd/package.json +3 -0
- package/node_modules/lossless-json/package.json +89 -0
- package/package.json +57 -4
|
@@ -0,0 +1,549 @@
|
|
|
1
|
+
# lossless-json
|
|
2
|
+
|
|
3
|
+
Parse JSON without risk of losing numeric information.
|
|
4
|
+
|
|
5
|
+
```js
|
|
6
|
+
import { parse, stringify } from 'lossless-json'
|
|
7
|
+
|
|
8
|
+
const text = '{"decimal":2.370,"long":9123372036854000123,"big":2.3e+500}'
|
|
9
|
+
|
|
10
|
+
// JSON.parse will lose some digits and a whole number:
|
|
11
|
+
console.log(JSON.stringify(JSON.parse(text)))
|
|
12
|
+
// '{"decimal":2.37,"long":9123372036854000000,"big":null}'
|
|
13
|
+
// WHOOPS!!!
|
|
14
|
+
|
|
15
|
+
// LosslessJSON.parse will preserve all numbers and even the formatting:
|
|
16
|
+
console.log(stringify(parse(text)))
|
|
17
|
+
// '{"decimal":2.370,"long":9123372036854000123,"big":2.3e+500}'
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
The following in-depth article explains what happens there: [Why does JSON.parse corrupt large numbers and how to solve this?](https://jsoneditoronline.org/indepth/parse/why-does-json-parse-corrupt-large-numbers/)
|
|
21
|
+
|
|
22
|
+
**How does it work?** The library works exactly the same as the native `JSON.parse` and `JSON.stringify`. The difference is that `lossless-json` preserves information of big numbers. `lossless-json` parses numeric values not as a regular number but as a `LosslessNumber`, a lightweight class which stores the numeric value as a string. One can perform regular operations with a `LosslessNumber`, and it will throw an error when this would result in losing information.
|
|
23
|
+
|
|
24
|
+
**When to use?** If you have to deal with JSON data that contains `long` values for example, coming from an application like C++, Java, or C#. The trade-off is that `lossless-json` is slower than the native `JSON.parse` and `JSON.stringify` functions, so be careful when performance is a bottleneck for you.
|
|
25
|
+
|
|
26
|
+
Features:
|
|
27
|
+
|
|
28
|
+
- No risk of losing numeric information when working with big numbers.
|
|
29
|
+
- Maintain the formatting of numbers.
|
|
30
|
+
- Parse error on duplicate keys.
|
|
31
|
+
- Built-in support for `bigint`.
|
|
32
|
+
- Built-in support for `Date` (turned off by default).
|
|
33
|
+
- Customizable: parse numeric values into any data type, like `BigNumber`, `bigint`, `number`, or a mix of them.
|
|
34
|
+
- Compatible with the native, built-in `JSON.parse` and `JSON.stringify`.
|
|
35
|
+
- Helpful error messages when parsing invalid JSON.
|
|
36
|
+
- Works in browsers and node.js.
|
|
37
|
+
- Comes with TypeScript typings included.
|
|
38
|
+
- Modular: ES module functions, only load and bundle what you use.
|
|
39
|
+
- Small: the full bundle is less than `4 kB` in size when minified and gzipped.
|
|
40
|
+
|
|
41
|
+
## Install
|
|
42
|
+
|
|
43
|
+
Install via [npm](https://www.npmjs.com/package/lossless-json):
|
|
44
|
+
|
|
45
|
+
```
|
|
46
|
+
npm install lossless-json
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Use
|
|
50
|
+
|
|
51
|
+
### Parse and stringify
|
|
52
|
+
|
|
53
|
+
Parsing and stringification works as you're used to:
|
|
54
|
+
|
|
55
|
+
```js
|
|
56
|
+
import { parse, stringify } from 'lossless-json'
|
|
57
|
+
|
|
58
|
+
const json = parse('{"foo":"bar"}') // {foo: 'bar'}
|
|
59
|
+
const text = stringify(json) // '{"foo":"bar"}'
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### LosslessNumbers
|
|
63
|
+
|
|
64
|
+
Numbers are parsed into a `LosslessNumber`, which can be used like a regular number in numeric operations. Converting to a number will throw an error when this would result in losing information due to truncation, overflow, or underflow.
|
|
65
|
+
|
|
66
|
+
```js
|
|
67
|
+
import { parse } from 'lossless-json'
|
|
68
|
+
|
|
69
|
+
const text = '{"normal":2.3,"long":123456789012345678901,"big":2.3e+500}'
|
|
70
|
+
const json = parse(text)
|
|
71
|
+
|
|
72
|
+
console.log(json.normal.isLosslessNumber) // true
|
|
73
|
+
console.log(json.normal.valueOf()) // number, 2.3
|
|
74
|
+
|
|
75
|
+
// LosslessNumbers can be used as regular numbers
|
|
76
|
+
console.log(json.normal + 2) // number, 4.3
|
|
77
|
+
|
|
78
|
+
// but the following operation will throw an error as it would result in information loss
|
|
79
|
+
console.log(json.long + 1)
|
|
80
|
+
// throws Error: Cannot safely convert LosslessNumber to number:
|
|
81
|
+
// "123456789012345678901" will be parsed as 123456789012345680000 and lose information
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### BigInt
|
|
85
|
+
|
|
86
|
+
JavaScript natively supports `bigint`: big integers that can hold a large number of digits, instead of the about 15 digits that a regular `number` can hold. It is a typical use case to want to parse integer numbers into a `bigint`, and all other values into a regular `number`. This can be achieved with a custom `numberParser`:
|
|
87
|
+
|
|
88
|
+
```js
|
|
89
|
+
import { parse, isInteger } from 'lossless-json'
|
|
90
|
+
|
|
91
|
+
const options = {
|
|
92
|
+
// parse integer values into a bigint, and use a regular number otherwise
|
|
93
|
+
numberParser: (value) => {
|
|
94
|
+
return isInteger(value) ? BigInt(value) : parseFloat(value)
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const text = '[123456789123456789123456789, 2.3, 123]'
|
|
99
|
+
const json = parse(text, null, options)
|
|
100
|
+
// output:
|
|
101
|
+
// [
|
|
102
|
+
// 123456789123456789123456789n, // bigint
|
|
103
|
+
// 2.3, // number
|
|
104
|
+
// 123n // bigint
|
|
105
|
+
// ]
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
You can adjust the logic to your liking, using utility functions like `isInteger`, `isNumber`, `isSafeNumber`. The number parser shown above is included in the library and is named `parseNumberAndBigInt`.
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
### BigInt support using native `JSON.parse`
|
|
112
|
+
|
|
113
|
+
Since some time, the reviver callback of the native `JSON.parse` function has a new parameter `context.source`. This new parameter allows to parse numeric values into any data type like `BigInt` or `BigNumber`, similar to the `numberParser` callback of `lossless-json`. So for parsing `BigInt` or `BigNumber` values, it is no longer necessary to use a special library like `lossless-json`.
|
|
114
|
+
|
|
115
|
+
> IMPORTANT: since `context.source` is quite a new JavaScript feature, it is important to check browser compatibility, see [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON#browser_compatibility) or [caniuse.com](https://caniuse.com/?search=context.source).
|
|
116
|
+
|
|
117
|
+
Stringifying `BigInt` values is not possible, unless you want to serialize them into a string with quotes. That is possible by [monkey patching a method `BigInt.prototype.toJSON`](https://github.com/GoogleChromeLabs/jsbi/issues/30#issuecomment-1006088574). However, when parsing this data again, it is not possible to know whether a string containing an integer number was intended to be a string or a bigint.
|
|
118
|
+
|
|
119
|
+
Here is a minimal example of parsing data with support for `BigInt` using the native `JSON.parse`. A similar solution can be worked out for other data types.
|
|
120
|
+
|
|
121
|
+
```js
|
|
122
|
+
function parseWithBigInt(text) {
|
|
123
|
+
const intRegex = /^-?\d+$/
|
|
124
|
+
|
|
125
|
+
return JSON.parse(text, (_key, value, context) => {
|
|
126
|
+
const isBigInt =
|
|
127
|
+
typeof value === 'number' &&
|
|
128
|
+
(value > Number.MAX_SAFE_INTEGER || value < Number.MIN_SAFE_INTEGER) &&
|
|
129
|
+
intRegex.test(context.source)
|
|
130
|
+
|
|
131
|
+
return isBigInt
|
|
132
|
+
? BigInt(context.source)
|
|
133
|
+
: value
|
|
134
|
+
})
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const text = '{"number":1.23,"int":42,"bigint":9123372036854000123}'
|
|
138
|
+
const data = parseWithBigInt(text)
|
|
139
|
+
console.log(data)
|
|
140
|
+
// {
|
|
141
|
+
// number: 1.23,
|
|
142
|
+
// int: 42,
|
|
143
|
+
// bigint: 9123372036854000123n
|
|
144
|
+
// }
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
### Validate safe numbers
|
|
148
|
+
|
|
149
|
+
If you want parse a json string into an object with regular numbers, but want to validate that no numeric information is lost, you write your own number parser and use `isSafeNumber` to validate the numbers:
|
|
150
|
+
|
|
151
|
+
```js
|
|
152
|
+
import { parse, isSafeNumber } from 'lossless-json'
|
|
153
|
+
|
|
154
|
+
const options = {
|
|
155
|
+
parseNumber: (value) => {
|
|
156
|
+
if (!isSafeNumber(value)) {
|
|
157
|
+
throw new Error(`Cannot safely convert value '${value}' into a number`)
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
return parseFloat(value)
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// will parse with success if all values can be represented with a number
|
|
165
|
+
let json = parse('[1,2,3]', undefined, options)
|
|
166
|
+
console.log(json) // [1, 2, 3] (regular numbers)
|
|
167
|
+
|
|
168
|
+
// will throw an error when some of the values are too large to represent correctly as number
|
|
169
|
+
try {
|
|
170
|
+
let json = parse('[1,2e+500,3]', undefined, options)
|
|
171
|
+
} catch (err) {
|
|
172
|
+
console.log(err) // throws Error 'Cannot safely convert value '2e+500' into a number'
|
|
173
|
+
}
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### BigNumbers
|
|
177
|
+
|
|
178
|
+
To use the library in conjunction with your favorite BigNumber library, for example [decimal.js](https://github.com/MikeMcl/decimal.js/). You have to define a custom number parser and stringifier:
|
|
179
|
+
|
|
180
|
+
```js
|
|
181
|
+
import { parse, stringify } from 'lossless-json'
|
|
182
|
+
import Decimal from 'decimal.js'
|
|
183
|
+
|
|
184
|
+
const parseDecimal = (value) => new Decimal(value)
|
|
185
|
+
|
|
186
|
+
const decimalStringifier = {
|
|
187
|
+
test: (value) => Decimal.isDecimal(value),
|
|
188
|
+
stringify: (value) => value.toString()
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
// parse JSON, operate on a Decimal value, then stringify again
|
|
192
|
+
const text = '{"value":2.3e500}'
|
|
193
|
+
const json = parse(text, undefined, { parseNumber: parseDecimal })
|
|
194
|
+
// {value: new Decimal('2.3e500')}
|
|
195
|
+
|
|
196
|
+
const output = {
|
|
197
|
+
result: json.value.times(2)
|
|
198
|
+
}
|
|
199
|
+
// {result: new Decimal('4.6e500')}
|
|
200
|
+
|
|
201
|
+
const str = stringify(output, undefined, undefined, [decimalStringifier])
|
|
202
|
+
// '{"result":4.6e500}'
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
### Reviver and replacer
|
|
206
|
+
|
|
207
|
+
The library is compatible with the native `JSON.parse` and `JSON.stringify`, and also comes with the optional `reviver` and `replacer` arguments that allow you to serialize for example data classes in a custom way. Here is an example demonstrating how you can stringify a `Date` in a different way than the built-in `reviveDate` utility function.
|
|
208
|
+
|
|
209
|
+
The following example stringifies a `Date` as an object with a `$date` key instead of a string, so it is uniquely recognizable when parsing the structure:
|
|
210
|
+
|
|
211
|
+
```js
|
|
212
|
+
import { parse, stringify } from 'lossless-json'
|
|
213
|
+
|
|
214
|
+
// stringify a Date as a unique object with a key '$date', so it is recognizable
|
|
215
|
+
function customDateReplacer(key, value) {
|
|
216
|
+
if (value instanceof Date) {
|
|
217
|
+
return {
|
|
218
|
+
$date: value.toISOString()
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
return value
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
function isJSONDateObject(value) {
|
|
226
|
+
return value && typeof value === 'object' && typeof value.$date === 'string'
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
function customDateReviver(key, value) {
|
|
230
|
+
if (isJSONDateObject(value)) {
|
|
231
|
+
return new Date(value.$date)
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
return value
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
const record = {
|
|
238
|
+
message: 'Hello World',
|
|
239
|
+
timestamp: new Date('2022-08-30T09:00:00Z')
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
const text = stringify(record, customDateReplacer)
|
|
243
|
+
console.log(text)
|
|
244
|
+
// output:
|
|
245
|
+
// '{"message":"Hello World","timestamp":{"$date":"2022-08-30T09:00:00.000Z"}}'
|
|
246
|
+
|
|
247
|
+
const parsed = parse(text, customDateReviver)
|
|
248
|
+
console.log(parsed)
|
|
249
|
+
// output:
|
|
250
|
+
// {
|
|
251
|
+
// action: 'create',
|
|
252
|
+
// timestamp: new Date('2022-08-30T09:00:00.000Z')
|
|
253
|
+
// }
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
## API
|
|
257
|
+
|
|
258
|
+
### parse(text [, reviver [, options]])
|
|
259
|
+
|
|
260
|
+
The `LosslessJSON.parse()` function parses a string as JSON, optionally transforming the value produced by parsing.
|
|
261
|
+
|
|
262
|
+
- **@param** `{string} text`
|
|
263
|
+
The string to parse as JSON. See the JSON object for a description of JSON syntax.
|
|
264
|
+
- **@param** `{(key: string, value: unknown) => unknown} [reviver]`
|
|
265
|
+
If a function, prescribes how the value originally produced by parsing is transformed, before being returned.
|
|
266
|
+
- **@param** `ParseOptions | ParseNumber [options]` Pass options to customize the way numbers are parsed and duplicate keys are handled. See description below. For backward compatibility it is possible to pass a `parseNumber` function here instead of an object with property `parseNumber`.
|
|
267
|
+
- **@returns** `{unknown}`
|
|
268
|
+
Returns the Object corresponding to the given JSON text.
|
|
269
|
+
- **@throws** Throws a SyntaxError exception if the string to parse is not valid JSON.
|
|
270
|
+
|
|
271
|
+
#### options
|
|
272
|
+
|
|
273
|
+
The `options` argument in the function `parse` is either an object with properties `{ parseNumber, onDuplicateKey }`, or it is a `parseNumber` function (for backward compatibility). It has the following properties:
|
|
274
|
+
|
|
275
|
+
- **@param** `{function(value: string) : unknown} [parseNumber]`
|
|
276
|
+
Pass an optional custom number parser. Input is a string, and the output can be any numeric value: `number`, `bigint`, `LosslessNumber`, or a custom `BigNumber` library. By default, all numeric values are parsed into a `LosslessNumber`.
|
|
277
|
+
- **@param** `{function(info: { key: string, position: number, oldValue: unknown, newValue: unknown }) : unknown | undefined} [onDuplicateKey]`
|
|
278
|
+
Customize the behavior in case of duplicate keys. By default, and error is thrown in case of duplicate keys. To alter this behavior, a custom `onDuplicateKey` callback can be provided. There are a few typical cases:
|
|
279
|
+
- Return the `oldValue` (first value) in order to keep that in case of duplicates.
|
|
280
|
+
```js
|
|
281
|
+
onDuplicateKey: ({ oldValue }) => oldValue
|
|
282
|
+
```
|
|
283
|
+
- Return the `newValue` (latest value) in order to keep that in case of duplicates:
|
|
284
|
+
```js
|
|
285
|
+
onDuplicateKey: ({ newValue }) => newValue
|
|
286
|
+
```
|
|
287
|
+
- Return `undefined` in order to ignore duplicate keys and keep the `oldValue` (first value):
|
|
288
|
+
```js
|
|
289
|
+
onDuplicateKey: () => {}
|
|
290
|
+
```
|
|
291
|
+
- Throw a custom error message. Can also be used for logging all occurrences:
|
|
292
|
+
```js
|
|
293
|
+
onDuplicateKey: ({ key, position, oldValue, newValue }) => {
|
|
294
|
+
console.error('Duplicate key error', { key, position, oldValue, newValue })
|
|
295
|
+
throw new Error(`Duplicate key ${key} at position ${position}`)
|
|
296
|
+
}
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
### stringify(value [, replacer [, space [, numberStringifiers]]])
|
|
300
|
+
|
|
301
|
+
The `LosslessJSON.stringify()` function converts a JavaScript value to a JSON string, optionally replacing values if a replacer function is specified, or optionally including only the specified properties if a replacer array is specified.
|
|
302
|
+
|
|
303
|
+
- **@param** `{unknown} value`
|
|
304
|
+
The value to convert to a JSON string.
|
|
305
|
+
- **@param** `{((key: string, value: unknown) => unknown) | Array.<string | number>} [replacer]`
|
|
306
|
+
A function that alters the behavior of the stringification process, or an array with strings or numbers that serve as a whitelist for selecting the properties of the value object to be included in the JSON string. If this value is `null` or not provided, all properties of the object are included in the resulting JSON string.
|
|
307
|
+
- **@param** `{number | string | undefined} [space]`
|
|
308
|
+
A `string` or `number` that is used to insert white space into the output JSON string for readability purposes. If this is a `number`, it indicates the number of space characters to use as white space. Values less than 1 indicate that no space should be used. If this is a `string`, the `string` is used as white space. If this parameter is not provided (or is `null`), no white space is used.
|
|
309
|
+
- **@param** `{Array<{test: (value: unknown) => boolean, stringify: (value: unknown) => string}>} [numberStringifiers]`
|
|
310
|
+
An optional list with additional number stringifiers, for example to serialize a `BigNumber`. The output of the function must be valid stringified JSON number. When `undefined` is returned, the property will be deleted from the object. The difference with using a `replacer` is that the output of a `replacer` must be JSON and will be stringified afterwards, whereas the output of the `numberStringifiers` is already stringified JSON.
|
|
311
|
+
- **@returns** `{string | undefined}`
|
|
312
|
+
Returns the string representation of the JSON object.
|
|
313
|
+
- **@throws** Throws a SyntaxError when one of the `numberStringifiers` does not return valid output.
|
|
314
|
+
|
|
315
|
+
### LosslessNumber
|
|
316
|
+
|
|
317
|
+
#### Construction
|
|
318
|
+
|
|
319
|
+
```
|
|
320
|
+
new LosslessNumber(value: number | string) : LosslessNumber
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
#### Methods
|
|
324
|
+
|
|
325
|
+
- `.valueOf(): number | bigint`
|
|
326
|
+
Convert the `LosslessNumber` into a regular `number` or `bigint`. A `number` is returned for safe numbers and decimal values that only lose some insignificant digits. A `bigint` is returned for large integer numbers. An `Error` is thrown for values that will overflow or underflow. Examples:
|
|
327
|
+
|
|
328
|
+
```js
|
|
329
|
+
// a safe number
|
|
330
|
+
console.log(new LosslessNumber('23.4').valueOf())
|
|
331
|
+
// number 23.4
|
|
332
|
+
|
|
333
|
+
// a decimal losing insignificant digits
|
|
334
|
+
console.log(new LosslessNumber('0.66666666666666666666667').valueOf())
|
|
335
|
+
// number 0.6666666666666666
|
|
336
|
+
|
|
337
|
+
// a large integer
|
|
338
|
+
console.log(new LosslessNumber('9123372036854000123').valueOf())
|
|
339
|
+
// bigint 9123372036854000123
|
|
340
|
+
|
|
341
|
+
// a value that will overflow
|
|
342
|
+
console.log(new LosslessNumber('2.3e+500').valueOf())
|
|
343
|
+
// Error: Cannot safely convert to number: the value '2.3e+500' would overflow and become Infinity
|
|
344
|
+
|
|
345
|
+
// a value that will underflow
|
|
346
|
+
console.log(new LosslessNumber('2.3e-500').valueOf())
|
|
347
|
+
// Error: Cannot safely convert to number: the value '2.3e-500' would underflow and become 0
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
Note that you can implement your own strategy for conversion by just getting the value as string via `.toString()`, and using util functions like `isInteger`, `isSafeNumber`, `getUnsafeNumberReason`, and `toSafeNumberOrThrow` to convert it to a numeric value.
|
|
351
|
+
|
|
352
|
+
- `.toString() : string`
|
|
353
|
+
Get the string representation of the lossless number.
|
|
354
|
+
|
|
355
|
+
#### Properties
|
|
356
|
+
|
|
357
|
+
- `{boolean} .isLosslessNumber : true`
|
|
358
|
+
Lossless numbers contain a property `isLosslessNumber` which can be used to
|
|
359
|
+
check whether some variable contains LosslessNumber.
|
|
360
|
+
|
|
361
|
+
### Utility functions
|
|
362
|
+
|
|
363
|
+
- `isInteger(value: string) : boolean`
|
|
364
|
+
|
|
365
|
+
Test whether a string contains an integer value, like `'2300'` or `10`.
|
|
366
|
+
|
|
367
|
+
- `isNumber(value: string) : boolean`
|
|
368
|
+
|
|
369
|
+
Test whether a string contains a numeric value, like `'2.4'` or `'1.4e+3'`.
|
|
370
|
+
|
|
371
|
+
- `isSafeNumber(value: string, config?: { approx: boolean }): boolean`
|
|
372
|
+
|
|
373
|
+
Test whether a string contains a numeric value which can be safely represented by a JavaScript `number` without losing any information. Returns false when digits would be truncated of an integer or decimal, or when the number would overflow or underflow. When passing `{ approx: true }` as config, the function will be less strict and allow losing insignificant digits of a decimal value. Examples:
|
|
374
|
+
|
|
375
|
+
```js
|
|
376
|
+
isSafeNumber('1.55e3') // true
|
|
377
|
+
isSafeNumber('2e500') // false
|
|
378
|
+
isSafeNumber('2e-500') // false
|
|
379
|
+
isSafeNumber('9123372036854000123') // false
|
|
380
|
+
isSafeNumber('0.66666666666666666667') // false
|
|
381
|
+
isSafeNumber('9123372036854000123', { approx: true }) // false
|
|
382
|
+
isSafeNumber('0.66666666666666666667', { approx: true }) // true
|
|
383
|
+
```
|
|
384
|
+
|
|
385
|
+
- `toSafeNumberOrThrow(value: string, config?: { approx: boolean }) : number`
|
|
386
|
+
|
|
387
|
+
Convert a string into a number when it is safe to do so, otherwise throw an informative error.
|
|
388
|
+
|
|
389
|
+
- `getUnsafeNumberReason(value): UnsafeNumberReason | undefined`
|
|
390
|
+
|
|
391
|
+
When the provided `value` is an unsafe number, describe what the reason is: `overflow`, `underflow`, `truncate_integer`, `truncate_float`. Returns `undefined` when the value is safe.
|
|
392
|
+
|
|
393
|
+
- `isLosslessNumber(value: unknown) : boolean`
|
|
394
|
+
|
|
395
|
+
Test whether a value is a `LosslessNumber`.
|
|
396
|
+
|
|
397
|
+
- `toLosslessNumber(value: number) : LosslessNumber`
|
|
398
|
+
|
|
399
|
+
Convert a `number` into a `LosslessNumber`. The function will throw an exception when the `number` is exceeding the maximum safe limit of 15 digits (hence being truncated itself) or is `NaN` or `Infinity`.
|
|
400
|
+
|
|
401
|
+
- `parseLosslessNumber(value: string) : LosslessNumber`
|
|
402
|
+
|
|
403
|
+
The default `numberParser` used by `parse`. Creates a `LosslessNumber` from a string containing a numeric value.
|
|
404
|
+
|
|
405
|
+
- `parseNumberAndBigInt(value: string) : number | bigint`
|
|
406
|
+
|
|
407
|
+
A custom `numberParser` that can be used by `parse`. The parser will convert integer values into `bigint`, and converts al other values into a regular `number`.
|
|
408
|
+
|
|
409
|
+
- `reviveDate(key, value)`
|
|
410
|
+
|
|
411
|
+
Revive strings containing an ISO 8601 date string into a JavaScript `Date` object. This reviver is not turned on by default because there is a small risk of parsing a text field that _accidentally_ contains a date into a `Date`. Whether `reviveDate` is safe to use depends on the use case. Usage:
|
|
412
|
+
|
|
413
|
+
```js
|
|
414
|
+
import { parse, reviveDate } from 'lossless-json'
|
|
415
|
+
|
|
416
|
+
const data = parse('["2022-08-25T09:39:19.288Z"]', reviveDate)
|
|
417
|
+
// output:
|
|
418
|
+
// [
|
|
419
|
+
// new Date('2022-08-25T09:39:19.288Z')
|
|
420
|
+
// ]
|
|
421
|
+
```
|
|
422
|
+
|
|
423
|
+
An alternative solution is to stringify a `Date` in a specific recognizable object like `{'$date':'2022-08-25T09:39:19.288Z'}`, and use a reviver and replacer to turn this object into a `Date` and vice versa.
|
|
424
|
+
|
|
425
|
+
- `splitNumber(value: string) : { sign: '-' | '', digits: string, exponent: number }`
|
|
426
|
+
|
|
427
|
+
Split a number in its sign, digits, and exponent. For example `splitNumber("23.50")` returns `{sign: '', digits: '235', exp: 1 }`. The value can be constructed again from a split number by inserting a dot at the second character of the digits if there is more than one digit, prepending it with the sign, and appending the exponent like `e${exponent}`
|
|
428
|
+
- `compareNumber(a: string, b: string) : -1 | 0 | 1`
|
|
429
|
+
|
|
430
|
+
Compare two strings containing a numeric value based on their numerical value. For example, the numeric value of `"5e3"` is larger than `"70"`, but comparing the string characters concludes otherwise. The function returns `1` when `a` is larger than `b`, `0` when they are equal, and `-1` when `a` is smaller than `b`. This method works safely for values with a large number of digits.
|
|
431
|
+
- `compareLosslessNumber(a: LosslessNumber, b: LosslessNumber) : -1 | 0 | 1`
|
|
432
|
+
|
|
433
|
+
Compare two lossless numbers numerically. The function returns `1` when `a` is larger than `b`, `0` when they are equal, and `-1` when `a` is smaller than `b`. The compare function can be used to sort an array with `LosslessNumber` for example:
|
|
434
|
+
|
|
435
|
+
```js
|
|
436
|
+
import { LosslessNumber, compareLosslessNumber } from 'lossless-json'
|
|
437
|
+
|
|
438
|
+
const values = [
|
|
439
|
+
new LosslessNumber('5e3'),
|
|
440
|
+
new LosslessNumber('70'),
|
|
441
|
+
new LosslessNumber('0.02e5')
|
|
442
|
+
]
|
|
443
|
+
|
|
444
|
+
const sorted = values.toSorted(compareLosslessNumber)
|
|
445
|
+
// sorted = [
|
|
446
|
+
// new LosslessNumber('70'),
|
|
447
|
+
// new LosslessNumber('0.02e5'),
|
|
448
|
+
// new LosslessNumber('5e3')
|
|
449
|
+
//]
|
|
450
|
+
```
|
|
451
|
+
|
|
452
|
+
## Alternatives
|
|
453
|
+
|
|
454
|
+
Similar libraries:
|
|
455
|
+
|
|
456
|
+
- https://github.com/BridgeAR/safe-stable-stringify
|
|
457
|
+
- https://github.com/nicolasparada/js-json-bigint
|
|
458
|
+
- https://github.com/Ivan-Korolenko/json-with-bigint
|
|
459
|
+
- https://github.com/sidorares/json-bigint (not actively maintained)
|
|
460
|
+
- https://github.com/jawj/json-custom-numbers
|
|
461
|
+
- https://github.com/epoberezkin/json-source-map
|
|
462
|
+
- Or: [use native `JSON.parse` with `context.source`](#bigint-support-using-native-jsonparse)
|
|
463
|
+
|
|
464
|
+
## Test
|
|
465
|
+
|
|
466
|
+
To test the library, first install dependencies once:
|
|
467
|
+
|
|
468
|
+
```
|
|
469
|
+
npm install
|
|
470
|
+
```
|
|
471
|
+
|
|
472
|
+
To run the unit tests:
|
|
473
|
+
|
|
474
|
+
```
|
|
475
|
+
npm test
|
|
476
|
+
```
|
|
477
|
+
|
|
478
|
+
To build the library and run the unit tests and integration tests:
|
|
479
|
+
|
|
480
|
+
```
|
|
481
|
+
npm run build-and-test
|
|
482
|
+
```
|
|
483
|
+
|
|
484
|
+
## Lint
|
|
485
|
+
|
|
486
|
+
Run linting:
|
|
487
|
+
|
|
488
|
+
```
|
|
489
|
+
npm run lint
|
|
490
|
+
```
|
|
491
|
+
|
|
492
|
+
Fix linting issues automatically:
|
|
493
|
+
|
|
494
|
+
```
|
|
495
|
+
npm run format
|
|
496
|
+
```
|
|
497
|
+
|
|
498
|
+
## Benchmark
|
|
499
|
+
|
|
500
|
+
To run a benchmark to compare the performance with the native `JSON` parser:
|
|
501
|
+
|
|
502
|
+
```
|
|
503
|
+
npm run benchmark
|
|
504
|
+
```
|
|
505
|
+
|
|
506
|
+
(Spoiler: `lossless-json` is much slower than native)
|
|
507
|
+
|
|
508
|
+
## Build
|
|
509
|
+
|
|
510
|
+
To build a bundled and minified library (ES5), first install the dependencies once:
|
|
511
|
+
|
|
512
|
+
```
|
|
513
|
+
npm install
|
|
514
|
+
```
|
|
515
|
+
|
|
516
|
+
Then bundle the code:
|
|
517
|
+
|
|
518
|
+
```
|
|
519
|
+
npm run build
|
|
520
|
+
```
|
|
521
|
+
|
|
522
|
+
This will generate an ES module output and an UMD bundle in the folder `./.lib` which can be executed in browsers and node.js and used in the browser.
|
|
523
|
+
|
|
524
|
+
### Release
|
|
525
|
+
|
|
526
|
+
To release a new version:
|
|
527
|
+
|
|
528
|
+
```
|
|
529
|
+
$ npm run release
|
|
530
|
+
```
|
|
531
|
+
|
|
532
|
+
This will:
|
|
533
|
+
|
|
534
|
+
- lint
|
|
535
|
+
- test
|
|
536
|
+
- build
|
|
537
|
+
- increment the version number
|
|
538
|
+
- push the changes to git, add a git version tag
|
|
539
|
+
- publish the npm package
|
|
540
|
+
|
|
541
|
+
To try the build and see the change list without actually publishing:
|
|
542
|
+
|
|
543
|
+
```
|
|
544
|
+
$ npm run release-dry-run
|
|
545
|
+
```
|
|
546
|
+
|
|
547
|
+
## License
|
|
548
|
+
|
|
549
|
+
Released under the [MIT license](LICENSE.md).
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { compareNumber, countSignificantDigits, getUnsafeNumberReason, isInteger, isNumber, UnsafeNumberReason } from './utils.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A lossless number. Stores its numeric value as string
|
|
5
|
+
*/
|
|
6
|
+
export class LosslessNumber {
|
|
7
|
+
// numeric value as string
|
|
8
|
+
|
|
9
|
+
// type information
|
|
10
|
+
isLosslessNumber = true;
|
|
11
|
+
constructor(value) {
|
|
12
|
+
if (!isNumber(value)) {
|
|
13
|
+
throw new Error(`Invalid number (value: "${value}")`);
|
|
14
|
+
}
|
|
15
|
+
this.value = value;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Get the value of the LosslessNumber as number or bigint.
|
|
20
|
+
*
|
|
21
|
+
* - a number is returned for safe numbers and decimal values that only lose some insignificant digits
|
|
22
|
+
* - a bigint is returned for big integer numbers
|
|
23
|
+
* - an Error is thrown for values that will overflow or underflow
|
|
24
|
+
*
|
|
25
|
+
* Note that you can implement your own strategy for conversion by just getting the value as string
|
|
26
|
+
* via .toString(), and using util functions like isInteger, isSafeNumber, getUnsafeNumberReason,
|
|
27
|
+
* and toSafeNumberOrThrow to convert it to a numeric value.
|
|
28
|
+
*/
|
|
29
|
+
valueOf() {
|
|
30
|
+
const unsafeReason = getUnsafeNumberReason(this.value);
|
|
31
|
+
|
|
32
|
+
// safe or truncate_float
|
|
33
|
+
if (unsafeReason === undefined || unsafeReason === UnsafeNumberReason.truncate_float) {
|
|
34
|
+
return Number.parseFloat(this.value);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// truncate_integer
|
|
38
|
+
if (isInteger(this.value)) {
|
|
39
|
+
return BigInt(this.value);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// overflow or underflow
|
|
43
|
+
throw new Error(`Cannot safely convert to number: the value '${this.value}' would ${unsafeReason} and become ${Number.parseFloat(this.value)}`);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Get the value of the LosslessNumber as string.
|
|
48
|
+
*/
|
|
49
|
+
toString() {
|
|
50
|
+
return this.value;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Note: we do NOT implement a .toJSON() method, and you should not implement
|
|
54
|
+
// or use that, it cannot safely turn the numeric value in the string into
|
|
55
|
+
// stringified JSON since it has to be parsed into a number first.
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Test whether a value is a LosslessNumber
|
|
60
|
+
*/
|
|
61
|
+
export function isLosslessNumber(value) {
|
|
62
|
+
// @ts-expect-error
|
|
63
|
+
return value && typeof value === 'object' && value.isLosslessNumber || false;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Convert a number into a LosslessNumber if this is possible in a safe way
|
|
68
|
+
* If the value has too many digits, or is NaN or Infinity, an error will be thrown
|
|
69
|
+
*/
|
|
70
|
+
export function toLosslessNumber(value) {
|
|
71
|
+
const maxDigits = 15;
|
|
72
|
+
if (countSignificantDigits(String(value)) > maxDigits) {
|
|
73
|
+
throw new Error(`Invalid number: contains more than 15 digits and is most likely truncated and unsafe by itself (value: ${value})`);
|
|
74
|
+
}
|
|
75
|
+
if (Number.isNaN(value)) {
|
|
76
|
+
throw new Error('Invalid number: NaN');
|
|
77
|
+
}
|
|
78
|
+
if (!Number.isFinite(value)) {
|
|
79
|
+
throw new Error(`Invalid number: ${value}`);
|
|
80
|
+
}
|
|
81
|
+
return new LosslessNumber(String(value));
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Compare two lossless numbers.
|
|
86
|
+
* Returns 1 when a is larger than b, 0 when they are equal,
|
|
87
|
+
* and -1 when a is smaller than b.
|
|
88
|
+
*/
|
|
89
|
+
export function compareLosslessNumber(a, b) {
|
|
90
|
+
return compareNumber(a.value, b.value);
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=LosslessNumber.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LosslessNumber.js","names":["compareNumber","countSignificantDigits","getUnsafeNumberReason","isInteger","isNumber","UnsafeNumberReason","LosslessNumber","isLosslessNumber","constructor","value","Error","valueOf","unsafeReason","undefined","truncate_float","Number","parseFloat","BigInt","toString","toLosslessNumber","maxDigits","String","isNaN","isFinite","compareLosslessNumber","a","b"],"sources":["../../src/LosslessNumber.ts"],"sourcesContent":["import {\n compareNumber,\n countSignificantDigits,\n getUnsafeNumberReason,\n isInteger,\n isNumber,\n UnsafeNumberReason\n} from './utils.js'\n\n/**\n * A lossless number. Stores its numeric value as string\n */\nexport class LosslessNumber {\n // numeric value as string\n value: string\n\n // type information\n isLosslessNumber = true\n\n constructor(value: string) {\n if (!isNumber(value)) {\n throw new Error(`Invalid number (value: \"${value}\")`)\n }\n\n this.value = value\n }\n\n /**\n * Get the value of the LosslessNumber as number or bigint.\n *\n * - a number is returned for safe numbers and decimal values that only lose some insignificant digits\n * - a bigint is returned for big integer numbers\n * - an Error is thrown for values that will overflow or underflow\n *\n * Note that you can implement your own strategy for conversion by just getting the value as string\n * via .toString(), and using util functions like isInteger, isSafeNumber, getUnsafeNumberReason,\n * and toSafeNumberOrThrow to convert it to a numeric value.\n */\n valueOf(): number | bigint {\n const unsafeReason = getUnsafeNumberReason(this.value)\n\n // safe or truncate_float\n if (unsafeReason === undefined || unsafeReason === UnsafeNumberReason.truncate_float) {\n return Number.parseFloat(this.value)\n }\n\n // truncate_integer\n if (isInteger(this.value)) {\n return BigInt(this.value)\n }\n\n // overflow or underflow\n throw new Error(\n `Cannot safely convert to number: the value '${this.value}' would ${unsafeReason} and become ${Number.parseFloat(this.value)}`\n )\n }\n\n /**\n * Get the value of the LosslessNumber as string.\n */\n toString(): string {\n return this.value\n }\n\n // Note: we do NOT implement a .toJSON() method, and you should not implement\n // or use that, it cannot safely turn the numeric value in the string into\n // stringified JSON since it has to be parsed into a number first.\n}\n\n/**\n * Test whether a value is a LosslessNumber\n */\nexport function isLosslessNumber(value: unknown): value is LosslessNumber {\n // @ts-expect-error\n return (value && typeof value === 'object' && value.isLosslessNumber) || false\n}\n\n/**\n * Convert a number into a LosslessNumber if this is possible in a safe way\n * If the value has too many digits, or is NaN or Infinity, an error will be thrown\n */\nexport function toLosslessNumber(value: number): LosslessNumber {\n const maxDigits = 15\n if (countSignificantDigits(String(value)) > maxDigits) {\n throw new Error(\n `Invalid number: contains more than 15 digits and is most likely truncated and unsafe by itself (value: ${value})`\n )\n }\n\n if (Number.isNaN(value)) {\n throw new Error('Invalid number: NaN')\n }\n\n if (!Number.isFinite(value)) {\n throw new Error(`Invalid number: ${value}`)\n }\n\n return new LosslessNumber(String(value))\n}\n\n/**\n * Compare two lossless numbers.\n * Returns 1 when a is larger than b, 0 when they are equal,\n * and -1 when a is smaller than b.\n */\nexport function compareLosslessNumber(a: LosslessNumber, b: LosslessNumber): 1 | 0 | -1 {\n return compareNumber(a.value, b.value)\n}\n"],"mappings":"AAAA,SACEA,aAAa,EACbC,sBAAsB,EACtBC,qBAAqB,EACrBC,SAAS,EACTC,QAAQ,EACRC,kBAAkB,QACb,YAAY;;AAEnB;AACA;AACA;AACA,OAAO,MAAMC,cAAc,CAAC;EAC1B;;EAGA;EACAC,gBAAgB,GAAG,IAAI;EAEvBC,WAAWA,CAACC,KAAa,EAAE;IACzB,IAAI,CAACL,QAAQ,CAACK,KAAK,CAAC,EAAE;MACpB,MAAM,IAAIC,KAAK,CAAC,2BAA2BD,KAAK,IAAI,CAAC;IACvD;IAEA,IAAI,CAACA,KAAK,GAAGA,KAAK;EACpB;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACEE,OAAOA,CAAA,EAAoB;IACzB,MAAMC,YAAY,GAAGV,qBAAqB,CAAC,IAAI,CAACO,KAAK,CAAC;;IAEtD;IACA,IAAIG,YAAY,KAAKC,SAAS,IAAID,YAAY,KAAKP,kBAAkB,CAACS,cAAc,EAAE;MACpF,OAAOC,MAAM,CAACC,UAAU,CAAC,IAAI,CAACP,KAAK,CAAC;IACtC;;IAEA;IACA,IAAIN,SAAS,CAAC,IAAI,CAACM,KAAK,CAAC,EAAE;MACzB,OAAOQ,MAAM,CAAC,IAAI,CAACR,KAAK,CAAC;IAC3B;;IAEA;IACA,MAAM,IAAIC,KAAK,CACb,+CAA+C,IAAI,CAACD,KAAK,WAAWG,YAAY,eAAeG,MAAM,CAACC,UAAU,CAAC,IAAI,CAACP,KAAK,CAAC,EAC9H,CAAC;EACH;;EAEA;AACF;AACA;EACES,QAAQA,CAAA,EAAW;IACjB,OAAO,IAAI,CAACT,KAAK;EACnB;;EAEA;EACA;EACA;AACF;;AAEA;AACA;AACA;AACA,OAAO,SAASF,gBAAgBA,CAACE,KAAc,EAA2B;EACxE;EACA,OAAQA,KAAK,IAAI,OAAOA,KAAK,KAAK,QAAQ,IAAIA,KAAK,CAACF,gBAAgB,IAAK,KAAK;AAChF;;AAEA;AACA;AACA;AACA;AACA,OAAO,SAASY,gBAAgBA,CAACV,KAAa,EAAkB;EAC9D,MAAMW,SAAS,GAAG,EAAE;EACpB,IAAInB,sBAAsB,CAACoB,MAAM,CAACZ,KAAK,CAAC,CAAC,GAAGW,SAAS,EAAE;IACrD,MAAM,IAAIV,KAAK,CACb,0GAA0GD,KAAK,GACjH,CAAC;EACH;EAEA,IAAIM,MAAM,CAACO,KAAK,CAACb,KAAK,CAAC,EAAE;IACvB,MAAM,IAAIC,KAAK,CAAC,qBAAqB,CAAC;EACxC;EAEA,IAAI,CAACK,MAAM,CAACQ,QAAQ,CAACd,KAAK,CAAC,EAAE;IAC3B,MAAM,IAAIC,KAAK,CAAC,mBAAmBD,KAAK,EAAE,CAAC;EAC7C;EAEA,OAAO,IAAIH,cAAc,CAACe,MAAM,CAACZ,KAAK,CAAC,CAAC;AAC1C;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASe,qBAAqBA,CAACC,CAAiB,EAAEC,CAAiB,EAAc;EACtF,OAAO1B,aAAa,CAACyB,CAAC,CAAChB,KAAK,EAAEiB,CAAC,CAACjB,KAAK,CAAC;AACxC","ignoreList":[]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get and/or set configuration options
|
|
3
|
+
* @deprecated There is no config anymore
|
|
4
|
+
*/
|
|
5
|
+
export function config(_options) {
|
|
6
|
+
// Backward compatibility warning for v1.x
|
|
7
|
+
throw new Error('config is deprecated, support for circularRefs is removed from the library. ' + 'If you encounter circular references in your data structures, ' + 'please rethink your datastructures: ' + 'better prevent circular references in the first place.');
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","names":["config","_options","Error"],"sources":["../../src/config.ts"],"sourcesContent":["interface ConfigOptional {\n circularRefs?: boolean\n}\n\ninterface Config extends ConfigOptional {\n circularRefs: boolean\n}\n\n/**\n * Get and/or set configuration options\n * @deprecated There is no config anymore\n */\nexport function config(_options?: ConfigOptional): Config {\n // Backward compatibility warning for v1.x\n throw new Error(\n 'config is deprecated, support for circularRefs is removed from the library. ' +\n 'If you encounter circular references in your data structures, ' +\n 'please rethink your datastructures: ' +\n 'better prevent circular references in the first place.'\n )\n}\n"],"mappings":"AAQA;AACA;AACA;AACA;AACA,OAAO,SAASA,MAAMA,CAACC,QAAyB,EAAU;EACxD;EACA,MAAM,IAAIC,KAAK,CACb,8EAA8E,GAC5E,gEAAgE,GAChE,sCAAsC,GACtC,wDACJ,CAAC;AACH","ignoreList":[]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { config } from './config.js';
|
|
2
|
+
export { compareLosslessNumber, isLosslessNumber, LosslessNumber, toLosslessNumber } from './LosslessNumber.js';
|
|
3
|
+
export { parseLosslessNumber, parseNumberAndBigInt } from './numberParsers.js';
|
|
4
|
+
export { parse } from './parse.js';
|
|
5
|
+
export { reviveDate } from './reviveDate.js';
|
|
6
|
+
export { stringify } from './stringify.js';
|
|
7
|
+
export * from './types.js';
|
|
8
|
+
export { compareNumber, getUnsafeNumberReason, isInteger, isNumber, isSafeNumber, splitNumber, toSafeNumberOrThrow, UnsafeNumberReason } from './utils.js';
|
|
9
|
+
//# sourceMappingURL=index.js.map
|