@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.
- package/README.md +860 -0
- package/package.json +121 -0
- package/src/cache/cache.ts +46 -0
- package/src/cache/contract.ts +9 -0
- package/src/cache/manager.ts +110 -0
- package/src/cache/provider.ts +11 -0
- package/src/config/contract.ts +63 -0
- package/src/config/discovery.ts +99 -0
- package/src/config/env.global.d.ts +6 -0
- package/src/config/env.ts +68 -0
- package/src/config/index.ts +5 -0
- package/src/config/provider.ts +17 -0
- package/src/config/repository.ts +164 -0
- package/src/container/adapters/builtin.ts +323 -0
- package/src/container/contract.ts +43 -0
- package/src/container/runtime.ts +29 -0
- package/src/events/bus.ts +174 -0
- package/src/events/concerns/dispatchable.ts +10 -0
- package/src/events/provider.ts +9 -0
- package/src/events/types.ts +9 -0
- package/src/foundation/application.ts +136 -0
- package/src/foundation/current-application.ts +20 -0
- package/src/index.ts +58 -0
- package/src/log/contract.ts +21 -0
- package/src/log/drivers/console.ts +54 -0
- package/src/log/drivers/null.ts +23 -0
- package/src/log/drivers/stack.ts +46 -0
- package/src/log/manager.ts +76 -0
- package/src/log/provider.ts +11 -0
- package/src/react.ts +2 -0
- package/src/renderers/adapters/react.tsx +25 -0
- package/src/renderers/adapters/solid.tsx +26 -0
- package/src/renderers/adapters/svelte.ts +73 -0
- package/src/renderers/adapters/vue.ts +22 -0
- package/src/renderers/contract.ts +12 -0
- package/src/runtimes/react.tsx +81 -0
- package/src/runtimes/solid.tsx +47 -0
- package/src/runtimes/svelte.ts +17 -0
- package/src/runtimes/vue.ts +34 -0
- package/src/solid.ts +2 -0
- package/src/store/adapters/contract.ts +11 -0
- package/src/store/adapters/indexed-db.ts +187 -0
- package/src/store/adapters/local-storage.ts +48 -0
- package/src/store/adapters/memory.ts +35 -0
- package/src/store/manager.ts +68 -0
- package/src/store/provider.ts +10 -0
- package/src/store/store.ts +1 -0
- package/src/support/arr.ts +372 -0
- package/src/support/collection.ts +889 -0
- package/src/support/facades/cache.ts +6 -0
- package/src/support/facades/config.ts +6 -0
- package/src/support/facades/event.ts +6 -0
- package/src/support/facades/facade.ts +146 -0
- package/src/support/facades/index.ts +5 -0
- package/src/support/facades/log.ts +6 -0
- package/src/support/facades/store.ts +6 -0
- package/src/support/fluent.ts +56 -0
- package/src/support/globals.ts +8 -0
- package/src/support/lazy-collection.ts +341 -0
- package/src/support/manager.ts +53 -0
- package/src/support/num.ts +50 -0
- package/src/support/pipeline.ts +29 -0
- package/src/support/service-provider.ts +19 -0
- package/src/support/str.ts +682 -0
- package/src/svelte.ts +2 -0
- package/src/types/peer-deps.d.ts +10 -0
- package/src/vue.ts +2 -0
- 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
|
+
}
|