stacks 0.49.1 → 0.49.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (99) hide show
  1. package/README.md +2 -2
  2. package/buddy/README.md +2 -2
  3. package/buddy/package.json +3 -3
  4. package/buddy/src/commands/dev.ts +15 -2
  5. package/buddy/src/commands/fresh.ts +1 -1
  6. package/buddy/src/commands/lint.ts +2 -2
  7. package/buddy/src/commands/release.ts +8 -0
  8. package/components/vue/package.json +1 -1
  9. package/components/web/package.json +1 -1
  10. package/core/actions/package.json +3 -3
  11. package/core/actions/src/dev.ts +0 -2
  12. package/core/actions/src/helpers/utils.ts +2 -2
  13. package/core/actions/src/lint-fix.ts +1 -1
  14. package/core/ai/package.json +3 -3
  15. package/core/alias/package.json +3 -3
  16. package/core/arrays/package.json +3 -3
  17. package/core/arrays/src/index.ts +14 -0
  18. package/core/auth/package.json +3 -3
  19. package/core/build/package.json +3 -3
  20. package/core/cache/package.json +7 -5
  21. package/core/cache/src/drivers/memcached.ts +1 -1
  22. package/core/cache/src/drivers/upstash.ts +2 -0
  23. package/core/cache/src/index.ts +1 -0
  24. package/core/chat/package.json +3 -4
  25. package/core/cli/README.md +1 -1
  26. package/core/cli/package.json +3 -3
  27. package/core/cli/src/actions/run.ts +4 -1
  28. package/core/cli/src/helpers.ts +1 -1
  29. package/core/cloud/package.json +3 -3
  30. package/core/collections/package.json +3 -3
  31. package/core/config/package.json +3 -3
  32. package/core/dashboard/package.json +3 -3
  33. package/core/database/package.json +4 -4
  34. package/core/datetime/package.json +3 -3
  35. package/core/desktop/node_modules/.bin/tauri +2 -2
  36. package/core/desktop/package.json +4 -4
  37. package/core/docs/node_modules/.bin/vitepress +2 -2
  38. package/core/docs/package.json +4 -4
  39. package/core/domains/package.json +3 -3
  40. package/core/drivers/package.json +3 -3
  41. package/core/email/package.json +4 -4
  42. package/core/error-handling/package.json +3 -3
  43. package/core/events/package.json +3 -3
  44. package/core/git/node_modules/.bin/commitizen +2 -2
  45. package/core/git/node_modules/.bin/cz +2 -2
  46. package/core/git/node_modules/.bin/git-cz +2 -2
  47. package/core/git/package.json +3 -3
  48. package/core/health/package.json +3 -3
  49. package/core/lint/package.json +3 -3
  50. package/core/logging/package.json +3 -3
  51. package/core/modules/package.json +3 -3
  52. package/core/notifications/README.md +3 -0
  53. package/core/notifications/build.config.ts +1 -0
  54. package/core/notifications/package.json +6 -5
  55. package/core/notifications/src/index.ts +2 -2
  56. package/core/objects/package.json +3 -3
  57. package/core/objects/src/index.ts +17 -1
  58. package/core/path/package.json +3 -3
  59. package/core/payments/package.json +3 -3
  60. package/core/push/package.json +3 -4
  61. package/core/queue/README.md +59 -0
  62. package/core/{chat/node_modules/.bin/maizzle → queue/node_modules/.bin/mkdist} +2 -2
  63. package/core/{push/node_modules/.bin/maizzle → queue/node_modules/.bin/tsc} +2 -2
  64. package/core/{sms/node_modules/.bin/maizzle → queue/node_modules/.bin/tsserver} +2 -2
  65. package/core/queue/package.json +54 -0
  66. package/core/queue/src/index.ts +1 -0
  67. package/core/queue/tests/example.test.ts +7 -0
  68. package/core/realtime/package.json +3 -3
  69. package/core/router/package.json +3 -3
  70. package/core/search-engine/package.json +4 -4
  71. package/core/search-engine/src/index.ts +0 -1
  72. package/core/security/package.json +3 -3
  73. package/core/server/package.json +3 -3
  74. package/core/sms/package.json +3 -5
  75. package/core/storage/package.json +3 -3
  76. package/core/storage/src/index.ts +1 -3
  77. package/core/strings/package.json +3 -3
  78. package/core/tables/dist/index.html +15 -0
  79. package/core/tables/package.json +2 -2
  80. package/core/tables/vite.config.ts +1 -1
  81. package/core/testing/node_modules/.bin/vitest +2 -2
  82. package/core/testing/package.json +6 -6
  83. package/core/types/node_modules/.bin/vitepress +2 -2
  84. package/core/types/package.json +5 -5
  85. package/core/types/src/cli.ts +5 -5
  86. package/core/types/src/notifications.ts +2 -2
  87. package/core/ui/package.json +4 -4
  88. package/core/utils/node_modules/.bin/rimraf +2 -2
  89. package/core/utils/package.json +7 -7
  90. package/core/utils/src/base.ts +14 -5
  91. package/core/utils/src/equal.ts +27 -0
  92. package/core/utils/src/helpers.ts +2 -1
  93. package/core/utils/src/index.ts +5 -4
  94. package/core/utils/src/is.ts +11 -9
  95. package/core/utils/src/p.ts +4 -3
  96. package/core/utils/src/promise.ts +50 -17
  97. package/core/x-ray/package.json +3 -3
  98. package/functions/package.json +1 -1
  99. package/package.json +4 -4
@@ -1,12 +1,14 @@
1
- // import { toString } from './base'
1
+ import { toString } from './base'
2
2
 
3
- // export const isDef = <T = any>(val?: T): val is T => typeof val !== 'undefined'
4
- // export const isBoolean = (val: any): val is boolean => typeof val === 'boolean'
5
- // export const isFunction = <T extends Function> (val: any): val is T => typeof val === 'function'
6
- // export const isNumber = (val: any): val is number => typeof val === 'number'
7
- // export const isString = (val: unknown): val is string => typeof val === 'string'
8
- // export const isObject = (val: any): val is object => toString(val) === '[object Object]'
9
-
10
- // export const isWindow = (val: any): boolean => typeof window !== 'undefined' && toString(val) === '[object Window]'
3
+ export const isDef = <T = any>(val?: T): val is T => typeof val !== 'undefined'
4
+ export const isBoolean = (val: any): val is boolean => typeof val === 'boolean'
5
+ export const isFunction = <T extends Function> (val: any): val is T => typeof val === 'function'
6
+ export const isNumber = (val: any): val is number => typeof val === 'number'
7
+ export const isString = (val: unknown): val is string => typeof val === 'string'
8
+ export const isObject = (val: any): val is object => toString(val) === '[object Object]'
9
+ export const isWindow = (val: any): boolean => typeof window !== 'undefined' && toString(val) === '[object Window]'
11
10
  export const isBrowser = typeof window !== 'undefined'
12
11
  export const isServer = typeof document === 'undefined' // https://remix.run/docs/en/v1/pages/gotchas#typeof-window-checks
12
+ export const isMap = (val: any): val is Map<any, any> => toString(val) === '[object Map]'
13
+ export const isSet = (val: any): val is Set<any> => toString(val) === '[object Set]'
14
+ export const isPromise = <T = any>(val: any): val is Promise<T> => isObject(val) && isFunction(val.then) && isFunction(val.catch)
@@ -81,10 +81,11 @@ class PInstance<T = any> extends Promise<Awaited<T>[]> {
81
81
 
82
82
  then(fn?: () => PromiseLike<any>) {
83
83
  const p = this.promise
84
+
84
85
  if (fn)
85
86
  return p.then(fn)
86
- else
87
- return p
87
+
88
+ return p
88
89
  }
89
90
 
90
91
  catch(fn?: (err: unknown) => PromiseLike<any>) {
@@ -103,7 +104,7 @@ class PInstance<T = any> extends Promise<Awaited<T>[]> {
103
104
  * @category Promise
104
105
  * @example
105
106
  * ```
106
- * import { p } from '@antfu/utils'
107
+ * import { p } from '@stacksjs/utils'
107
108
  *
108
109
  * const items = [1, 2, 3, 4, 5]
109
110
  *
@@ -1,22 +1,48 @@
1
1
  import { remove } from '@stacksjs/arrays'
2
2
  import type { Fn } from '@stacksjs/types'
3
3
 
4
+ export interface SingletonPromiseReturn<T> {
5
+ (): Promise<T>
6
+ /**
7
+ * Reset current staled promise.
8
+ * Await it to have proper shutdown.
9
+ */
10
+ reset: () => Promise<void>
11
+ }
12
+
4
13
  /**
5
- * Promised `setTimeout`
14
+ * Promise with `resolve` and `reject` methods of itself
15
+ */
16
+ export interface ControlledPromise<T = void> extends Promise<T> {
17
+ resolve(value: T | PromiseLike<T>): void
18
+ reject(reason?: any): void
19
+ }
20
+
21
+ /**
22
+ * Create singleton promise function.
6
23
  *
7
24
  * @category Promise
8
25
  */
9
- export function sleep(ms: number, callback?: Fn<any>) {
10
- return new Promise<void>(resolve =>
11
- setTimeout(async () => {
12
- await callback?.()
13
- resolve()
14
- }, ms),
15
- )
26
+ export function createSingletonPromise<T>(fn: () => Promise<T>): SingletonPromiseReturn<T> {
27
+ let _promise: Promise<T> | undefined
28
+
29
+ function wrapper() {
30
+ if (!_promise)
31
+ _promise = fn()
32
+ return _promise
33
+ }
34
+ wrapper.reset = async () => {
35
+ const _prev = _promise
36
+ _promise = undefined
37
+ if (_prev)
38
+ await _prev
39
+ }
40
+
41
+ return wrapper
16
42
  }
17
43
 
18
44
  /**
19
- * Create a promise lock
45
+ * Create a promise lock.
20
46
  *
21
47
  * @category Promise
22
48
  * @example
@@ -57,14 +83,6 @@ export function createPromiseLock() {
57
83
  }
58
84
  }
59
85
 
60
- /**
61
- * Promise with `resolve` and `reject` methods of itself
62
- */
63
- export interface ControlledPromise<T = void> extends Promise<T> {
64
- resolve(value: T | PromiseLike<T>): void
65
- reject(reason?: any): void
66
- }
67
-
68
86
  /**
69
87
  * Return a Promise with `resolve` and `reject` methods
70
88
  *
@@ -89,3 +107,18 @@ export function createControlledPromise<T>(): ControlledPromise<T> {
89
107
  promise.reject = reject
90
108
  return promise
91
109
  }
110
+
111
+ /**
112
+ * Promised `setTimeout`.
113
+ *
114
+ * @category Promise
115
+ */
116
+ export function sleep(ms: number, callback?: Fn<any>) {
117
+ return new Promise<void>(resolve =>
118
+
119
+ setTimeout(async () => {
120
+ await callback?.()
121
+ resolve()
122
+ }, ms),
123
+ )
124
+ }
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@stacksjs/x-ray",
3
3
  "type": "module",
4
- "version": "0.49.1",
5
- "packageManager": "pnpm@7.25.0",
4
+ "version": "0.49.3",
5
+ "packageManager": "pnpm@7.25.1",
6
6
  "description": "All you need to debug, log & analyze.",
7
7
  "author": "Chris Breuer",
8
8
  "license": "MIT",
@@ -39,7 +39,7 @@
39
39
  ],
40
40
  "engines": {
41
41
  "node": ">=v18.13.0",
42
- "pnpm": ">=7.25.0"
42
+ "pnpm": ">=7.25.1"
43
43
  },
44
44
  "scripts": {
45
45
  "build": "echo 'wip'",
@@ -2,7 +2,7 @@
2
2
  "name": "hello-world-fx",
3
3
  "type": "module",
4
4
  "version": "",
5
- "packageManager": "pnpm@7.25.0",
5
+ "packageManager": "pnpm@7.25.1",
6
6
  "description": "Your function library description.",
7
7
  "author": "Chris Breuer",
8
8
  "license": "MIT",
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "stacks",
3
3
  "type": "module",
4
- "version": "0.49.1",
5
- "packageManager": "pnpm@7.25.0",
4
+ "version": "0.49.3",
5
+ "packageManager": "pnpm@7.25.1",
6
6
  "description": "The Stacks framework.",
7
7
  "author": "Chris Breuer",
8
8
  "license": "MIT",
@@ -61,11 +61,11 @@
61
61
  ],
62
62
  "engines": {
63
63
  "node": ">=v18.13.0",
64
- "pnpm": ">=7.25.0"
64
+ "pnpm": ">=7.25.1"
65
65
  },
66
66
  "web-types": "./web-types.json",
67
67
  "dependencies": {
68
- "@stacksjs/buddy": "0.49.1"
68
+ "@stacksjs/buddy": "0.49.3"
69
69
  },
70
70
  "scripts": {
71
71
  "buddy": "esno ./buddy/src/cli.ts",