cordo 2.2.2 → 2.2.4
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/package.json +1 -1
- package/src/components/builtin/container.ts +3 -4
- package/src/components/component.ts +8 -3
- package/src/components/modifier.ts +1 -1
- package/src/core/files/config.ts +1 -1
- package/src/core/files/error-boundary.ts +1 -1
- package/src/core/files/route.ts +1 -1
- package/src/core/interaction.ts +1 -1
- package/src/functions/funct.ts +1 -1
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@ import { ComponentType, createComponent, renderComponentList, type CordoComponen
|
|
|
2
2
|
import type { CordoModifier } from "../modifier"
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
type AllowedComponents = CordoComponent<'ActionRow' | 'Button' | 'TextDisplay' | 'Section' | 'MediaGallery' | 'Seperator' | 'File' | 'StringSelect'> | CordoModifier
|
|
5
|
+
export type AllowedComponents = CordoComponent<'ActionRow' | 'Button' | 'TextDisplay' | 'Section' | 'MediaGallery' | 'Seperator' | 'File' | 'StringSelect'> | CordoModifier
|
|
6
6
|
type AllowedComponentArray = Array<AllowedComponents | AllowedComponents[]>
|
|
7
7
|
|
|
8
8
|
export function container(...components: AllowedComponentArray) {
|
|
@@ -27,11 +27,10 @@ export function container(...components: AllowedComponentArray) {
|
|
|
27
27
|
},
|
|
28
28
|
*[Symbol.iterator]() {
|
|
29
29
|
for (const component of components) {
|
|
30
|
-
if (Array.isArray(component))
|
|
30
|
+
if (Array.isArray(component))
|
|
31
31
|
yield* component
|
|
32
|
-
|
|
32
|
+
else
|
|
33
33
|
yield component
|
|
34
|
-
}
|
|
35
34
|
}
|
|
36
35
|
}
|
|
37
36
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import defu from "defu"
|
|
2
2
|
import { row } from "./builtin/row"
|
|
3
3
|
import { readModifier, type CordoModifier } from "./modifier"
|
|
4
|
+
import type { AllowedComponents as ContainerAllowedComponents } from "./builtin/container"
|
|
4
5
|
|
|
5
6
|
|
|
6
|
-
const CordoComponentSymbol = Symbol('CordoComponent')
|
|
7
|
+
const CordoComponentSymbol = Symbol.for('CordoComponent')
|
|
7
8
|
|
|
8
9
|
export const ComponentType = {
|
|
9
10
|
ActionRow: 1,
|
|
@@ -38,7 +39,11 @@ export type CordoComponent<Type extends StringComponentType = StringComponentTyp
|
|
|
38
39
|
}
|
|
39
40
|
visible: (value: boolean) => CordoComponent<Type>
|
|
40
41
|
attributes: (attrs: Record<string, any>) => CordoComponent<Type>
|
|
41
|
-
} & (
|
|
42
|
+
} & (
|
|
43
|
+
Type extends 'Container'
|
|
44
|
+
? { [Symbol.iterator]: () => Iterator<ContainerAllowedComponents> }
|
|
45
|
+
: { [Symbol.iterator]: never }
|
|
46
|
+
)
|
|
42
47
|
export type CordoComponentPayload<Type extends StringComponentType> = CordoComponent<Type>[typeof CordoComponentSymbol]
|
|
43
48
|
|
|
44
49
|
export function createComponent<Type extends StringComponentType>(
|
|
@@ -107,7 +112,7 @@ export function renderComponentList(
|
|
|
107
112
|
|
|
108
113
|
if (!isComponent(item)) {
|
|
109
114
|
const mod = readModifier(item)
|
|
110
|
-
if (!modifiers.some(m => m.name === mod.name))
|
|
115
|
+
if (mod && !modifiers.some(m => m.name === mod.name))
|
|
111
116
|
modifiers.push(mod)
|
|
112
117
|
continue
|
|
113
118
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { CordoComponentPayload, renderComponentList, StringComponentType } from "./component"
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
const CordoModifierSymbol = Symbol('CordoModifier')
|
|
4
|
+
const CordoModifierSymbol = Symbol.for('CordoModifier')
|
|
5
5
|
|
|
6
6
|
export type CordoModifier = {
|
|
7
7
|
[CordoModifierSymbol]: {
|
package/src/core/files/config.ts
CHANGED
|
@@ -9,7 +9,7 @@ import { parseFlags as runParseFlags, type FlagOpts as RunFlagOpts } from '../..
|
|
|
9
9
|
import { parseFlags as gotoParseFlags, type FlagOpts as GotoFlagOpts } from '../../functions/impl/goto'
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
const CordoConfigSymbol = Symbol('
|
|
12
|
+
const CordoConfigSymbol = Symbol.for('CordoConfig')
|
|
13
13
|
|
|
14
14
|
type HookFor<T, Context = never> = null | ((value: T, context: Context) => Promisable<T | null>)
|
|
15
15
|
type TransformHookFor<T, Context = never> = null | ((value: T, context: Context) => T)
|
|
@@ -2,7 +2,7 @@ import { CordoError } from "../../errors"
|
|
|
2
2
|
import type { RouteRequest } from "./route"
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
const CordoErrorBoundarySymbol = Symbol('CordoErrorBoundary')
|
|
5
|
+
const CordoErrorBoundarySymbol = Symbol.for('CordoErrorBoundary')
|
|
6
6
|
|
|
7
7
|
export type CordoErrorBoundary = {
|
|
8
8
|
[CordoErrorBoundarySymbol]: typeof CordoErrorBoundarySymbol
|
package/src/core/files/route.ts
CHANGED
|
@@ -6,7 +6,7 @@ import type { CordoComponent } from "../../components/component"
|
|
|
6
6
|
import type { CordoModifier } from "../../components/modifier"
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
const CordoRouteSymbol = Symbol('CordoRoute')
|
|
9
|
+
const CordoRouteSymbol = Symbol.for('CordoRoute')
|
|
10
10
|
|
|
11
11
|
export type RouteResponse = Array<CordoComponent | CordoModifier>
|
|
12
12
|
|
package/src/core/interaction.ts
CHANGED