@raubjo/architect 0.5.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.
Files changed (68) hide show
  1. package/README.md +860 -0
  2. package/package.json +121 -0
  3. package/src/cache/cache.ts +46 -0
  4. package/src/cache/contract.ts +9 -0
  5. package/src/cache/manager.ts +110 -0
  6. package/src/cache/provider.ts +11 -0
  7. package/src/config/contract.ts +63 -0
  8. package/src/config/discovery.ts +99 -0
  9. package/src/config/env.global.d.ts +6 -0
  10. package/src/config/env.ts +68 -0
  11. package/src/config/index.ts +5 -0
  12. package/src/config/provider.ts +17 -0
  13. package/src/config/repository.ts +164 -0
  14. package/src/container/adapters/builtin.ts +323 -0
  15. package/src/container/contract.ts +43 -0
  16. package/src/container/runtime.ts +29 -0
  17. package/src/events/bus.ts +174 -0
  18. package/src/events/concerns/dispatchable.ts +10 -0
  19. package/src/events/provider.ts +9 -0
  20. package/src/events/types.ts +9 -0
  21. package/src/foundation/application.ts +136 -0
  22. package/src/foundation/current-application.ts +20 -0
  23. package/src/index.ts +58 -0
  24. package/src/log/contract.ts +21 -0
  25. package/src/log/drivers/console.ts +54 -0
  26. package/src/log/drivers/null.ts +23 -0
  27. package/src/log/drivers/stack.ts +46 -0
  28. package/src/log/manager.ts +76 -0
  29. package/src/log/provider.ts +11 -0
  30. package/src/react.ts +2 -0
  31. package/src/renderers/adapters/react.tsx +25 -0
  32. package/src/renderers/adapters/solid.tsx +26 -0
  33. package/src/renderers/adapters/svelte.ts +73 -0
  34. package/src/renderers/adapters/vue.ts +22 -0
  35. package/src/renderers/contract.ts +12 -0
  36. package/src/runtimes/react.tsx +81 -0
  37. package/src/runtimes/solid.tsx +47 -0
  38. package/src/runtimes/svelte.ts +17 -0
  39. package/src/runtimes/vue.ts +34 -0
  40. package/src/solid.ts +2 -0
  41. package/src/store/adapters/contract.ts +11 -0
  42. package/src/store/adapters/indexed-db.ts +187 -0
  43. package/src/store/adapters/local-storage.ts +48 -0
  44. package/src/store/adapters/memory.ts +35 -0
  45. package/src/store/manager.ts +68 -0
  46. package/src/store/provider.ts +10 -0
  47. package/src/store/store.ts +1 -0
  48. package/src/support/arr.ts +372 -0
  49. package/src/support/collection.ts +889 -0
  50. package/src/support/facades/cache.ts +6 -0
  51. package/src/support/facades/config.ts +6 -0
  52. package/src/support/facades/event.ts +6 -0
  53. package/src/support/facades/facade.ts +146 -0
  54. package/src/support/facades/index.ts +5 -0
  55. package/src/support/facades/log.ts +6 -0
  56. package/src/support/facades/store.ts +6 -0
  57. package/src/support/fluent.ts +56 -0
  58. package/src/support/globals.ts +8 -0
  59. package/src/support/lazy-collection.ts +341 -0
  60. package/src/support/manager.ts +53 -0
  61. package/src/support/num.ts +50 -0
  62. package/src/support/pipeline.ts +29 -0
  63. package/src/support/service-provider.ts +19 -0
  64. package/src/support/str.ts +682 -0
  65. package/src/svelte.ts +2 -0
  66. package/src/types/peer-deps.d.ts +10 -0
  67. package/src/vue.ts +2 -0
  68. package/tsconfig.json +15 -0
@@ -0,0 +1,50 @@
1
+ export function format(value: number, precision?: number, locale?: string): string {
2
+ return new Intl.NumberFormat(locale, {
3
+ minimumFractionDigits: precision,
4
+ maximumFractionDigits: precision,
5
+ }).format(value)
6
+ }
7
+
8
+ export function percentage(value: number, precision = 0, locale?: string): string {
9
+ return new Intl.NumberFormat(locale, {
10
+ style: "percent",
11
+ minimumFractionDigits: precision,
12
+ maximumFractionDigits: precision,
13
+ }).format(value / 100)
14
+ }
15
+
16
+ export function currency(value: number, currencyCode = "USD", locale?: string): string {
17
+ return new Intl.NumberFormat(locale, {
18
+ style: "currency",
19
+ currency: currencyCode,
20
+ }).format(value)
21
+ }
22
+
23
+ export function fileSize(bytes: number, precision = 0): string {
24
+ const units = ["B", "KB", "MB", "GB", "TB"]
25
+ let size = bytes
26
+ let unit = 0
27
+ while (size >= 1024 && unit < units.length - 1) {
28
+ size /= 1024
29
+ unit++
30
+ }
31
+ return `${size.toFixed(precision)} ${units[unit]}`
32
+ }
33
+
34
+ export function abbreviate(value: number, precision = 0, locale?: string): string {
35
+ const abs = Math.abs(value)
36
+ if (abs >= 1_000_000_000) return `${format(value / 1_000_000_000, precision, locale)}B`
37
+ if (abs >= 1_000_000) return `${format(value / 1_000_000, precision, locale)}M`
38
+ if (abs >= 1_000) return `${format(value / 1_000, precision, locale)}K`
39
+ return format(value, precision, locale)
40
+ }
41
+
42
+ export function clamp(value: number, min: number, max: number): number {
43
+ return Math.min(Math.max(value, min), max)
44
+ }
45
+
46
+ export function between(value: number, min: number, max: number): boolean {
47
+ return value >= min && value <= max
48
+ }
49
+
50
+ export const Num = { format, percentage, currency, fileSize, abbreviate, clamp, between }
@@ -0,0 +1,29 @@
1
+ type Pipe<T> = (passable: T, next: (passable: T) => T) => T
2
+
3
+ class PipelineRunner<T> {
4
+ passable!: T
5
+ pipes: Pipe<T>[] = []
6
+
7
+ through(pipes: Pipe<T>[]): this {
8
+ this.pipes = [...pipes]
9
+ return this
10
+ }
11
+
12
+ // biome-ignore lint/suspicious/noThenProperty: this is thenable
13
+ then(destination: (passable: T) => T): T {
14
+ const fn = [...this.pipes]
15
+ .reverse()
16
+ .reduce<(passable: T) => T>((next, pipe) => (passable) => pipe(passable, next), destination)
17
+ return fn(this.passable)
18
+ }
19
+
20
+ thenReturn(): T {
21
+ return this.then((passable) => passable)
22
+ }
23
+ }
24
+
25
+ export function send<T>(passable: T): PipelineRunner<T> {
26
+ const runner = new PipelineRunner<T>()
27
+ runner.passable = passable
28
+ return runner
29
+ }
@@ -0,0 +1,19 @@
1
+ import type { ContainerContract } from "../container/contract"
2
+
3
+ export type Cleanup = () => void
4
+
5
+ export type ServiceProviderContext = {
6
+ container: ContainerContract
7
+ }
8
+
9
+ export default class ServiceProvider {
10
+ register(_context: ServiceProviderContext): void | Cleanup {}
11
+
12
+ boot(_context: ServiceProviderContext): void | Cleanup {}
13
+ }
14
+
15
+ export class DeferrableServiceProvider extends ServiceProvider {
16
+ provides(): Array<string> {
17
+ return []
18
+ }
19
+ }