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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cordo",
3
- "version": "2.2.2",
3
+ "version": "2.2.4",
4
4
  "description": "A framework for handling complex discord api interactions",
5
5
  "exports": {
6
6
  ".": "./src/index.ts",
@@ -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
- } else {
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
- } & (Type extends 'Container' ? { [Symbol.iterator]: () => Iterator<CordoComponent<StringComponentType>> } : { [Symbol.iterator]: never })
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]: {
@@ -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('CordoConfigSymbol')
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
@@ -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
 
@@ -1,7 +1,7 @@
1
1
  import type { APIInteraction } from "discord-api-types/v10"
2
2
 
3
3
 
4
- const CordoInteractionSymbol = Symbol('CordoInteraction')
4
+ const CordoInteractionSymbol = Symbol.for('CordoInteraction')
5
5
 
6
6
  export type CordoInteraction = {
7
7
  [CordoInteractionSymbol]: {
@@ -3,7 +3,7 @@ import { evalGoto } from "./impl/goto"
3
3
  import { evalRun } from "./impl/run"
4
4
 
5
5
 
6
- const CordoFunctSymbol = Symbol('CordoFunct')
6
+ const CordoFunctSymbol = Symbol.for('CordoFunct')
7
7
 
8
8
  export type CordoFunctRun = CordoFunct[]
9
9