yuzuha 0.2.0 → 0.3.0
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/CHANGELOG.md +29 -1
- package/README.md +22 -14
- package/VERSIONING.md +56 -7
- package/benchmarks/parser.mjs +1 -1
- package/benchmarks/run.mjs +3 -2
- package/dist/canvas/card.d.ts +10 -0
- package/dist/canvas/card.d.ts.map +1 -0
- package/dist/canvas/card.js +11 -0
- package/dist/canvas/card.js.map +1 -0
- package/dist/canvas.d.ts +30 -9
- package/dist/canvas.d.ts.map +1 -1
- package/dist/canvas.js +64 -9
- package/dist/canvas.js.map +1 -1
- package/dist/cli/config.d.ts.map +1 -1
- package/dist/cli/config.js +2 -1
- package/dist/cli/config.js.map +1 -1
- package/dist/cli/lint.d.ts.map +1 -1
- package/dist/cli/lint.js +1 -2
- package/dist/cli/lint.js.map +1 -1
- package/dist/cli/main.d.ts.map +1 -1
- package/dist/cli/main.js +8 -9
- package/dist/cli/main.js.map +1 -1
- package/dist/cli/scaffold.js +1 -1
- package/dist/cli/scaffold.js.map +1 -1
- package/dist/cli/scenarios.d.ts.map +1 -1
- package/dist/cli/scenarios.js +2 -1
- package/dist/cli/scenarios.js.map +1 -1
- package/dist/commands/context.d.ts.map +1 -1
- package/dist/commands/context.js +7 -2
- package/dist/commands/context.js.map +1 -1
- package/dist/domain/resource-batches.d.ts +6 -0
- package/dist/domain/resource-batches.d.ts.map +1 -1
- package/dist/domain/resource-batches.js +31 -0
- package/dist/domain/resource-batches.js.map +1 -1
- package/dist/framework/bot.d.ts +9 -5
- package/dist/framework/bot.d.ts.map +1 -1
- package/dist/framework/bot.js +51 -27
- package/dist/framework/bot.js.map +1 -1
- package/dist/framework/command-registry.d.ts +8 -7
- package/dist/framework/command-registry.d.ts.map +1 -1
- package/dist/framework/command-registry.js +14 -11
- package/dist/framework/command-registry.js.map +1 -1
- package/dist/framework/options.d.ts +3 -3
- package/dist/framework/options.d.ts.map +1 -1
- package/dist/framework/options.js.map +1 -1
- package/dist/{scripting → functions}/builtins/arguments.d.ts.map +1 -1
- package/dist/{scripting → functions}/builtins/arguments.js.map +1 -1
- package/dist/functions/builtins/canvas.d.ts +2 -0
- package/dist/functions/builtins/canvas.d.ts.map +1 -0
- package/dist/{scripting → functions}/builtins/canvas.js +1 -1
- package/dist/{scripting → functions}/builtins/canvas.js.map +1 -1
- package/dist/functions/builtins/context.d.ts +2 -0
- package/dist/functions/builtins/context.d.ts.map +1 -0
- package/dist/{scripting → functions}/builtins/context.js.map +1 -1
- package/dist/{scripting → functions}/builtins/definition.d.ts +1 -1
- package/dist/functions/builtins/definition.d.ts.map +1 -0
- package/dist/functions/builtins/definition.js.map +1 -0
- package/dist/functions/builtins/embeds.d.ts +3 -0
- package/dist/{scripting → functions}/builtins/embeds.d.ts.map +1 -1
- package/dist/{scripting → functions}/builtins/embeds.js +1 -1
- package/dist/functions/builtins/embeds.js.map +1 -0
- package/dist/functions/builtins/events.d.ts +2 -0
- package/dist/functions/builtins/events.d.ts.map +1 -0
- package/dist/{scripting → functions}/builtins/events.js.map +1 -1
- package/dist/functions/builtins/flow.d.ts +2 -0
- package/dist/functions/builtins/flow.d.ts.map +1 -0
- package/dist/{scripting → functions}/builtins/flow.js +2 -2
- package/dist/functions/builtins/flow.js.map +1 -0
- package/dist/functions/builtins/guards.d.ts +2 -0
- package/dist/functions/builtins/guards.d.ts.map +1 -0
- package/dist/{scripting → functions}/builtins/guards.js +1 -1
- package/dist/functions/builtins/guards.js.map +1 -0
- package/dist/functions/builtins/http.d.ts +2 -0
- package/dist/functions/builtins/http.d.ts.map +1 -0
- package/dist/{scripting → functions}/builtins/http.js +2 -2
- package/dist/functions/builtins/http.js.map +1 -0
- package/dist/functions/builtins/index.d.ts +5 -0
- package/dist/functions/builtins/index.d.ts.map +1 -0
- package/dist/functions/builtins/index.js.map +1 -0
- package/dist/functions/builtins/language/array-callbacks.d.ts +2 -0
- package/dist/functions/builtins/language/array-callbacks.d.ts.map +1 -0
- package/dist/{scripting → functions}/builtins/language/array-callbacks.js +1 -1
- package/dist/{scripting → functions}/builtins/language/array-callbacks.js.map +1 -1
- package/dist/functions/builtins/language/arrays.d.ts +2 -0
- package/dist/functions/builtins/language/arrays.d.ts.map +1 -0
- package/dist/{scripting → functions}/builtins/language/arrays.js +1 -1
- package/dist/{scripting → functions}/builtins/language/arrays.js.map +1 -1
- package/dist/{scripting → functions}/builtins/language/common.d.ts.map +1 -1
- package/dist/{scripting → functions}/builtins/language/common.js.map +1 -1
- package/dist/functions/builtins/language/decimals.d.ts +2 -0
- package/dist/functions/builtins/language/decimals.d.ts.map +1 -0
- package/dist/{scripting → functions}/builtins/language/decimals.js.map +1 -1
- package/dist/functions/builtins/language/index.d.ts +3 -0
- package/dist/functions/builtins/language/index.d.ts.map +1 -0
- package/dist/functions/builtins/language/index.js.map +1 -0
- package/dist/functions/builtins/language/loops.d.ts +4 -0
- package/dist/{scripting → functions}/builtins/language/loops.d.ts.map +1 -1
- package/dist/{scripting → functions}/builtins/language/loops.js +3 -3
- package/dist/{scripting → functions}/builtins/language/loops.js.map +1 -1
- package/dist/functions/builtins/language/numbers.d.ts +2 -0
- package/dist/functions/builtins/language/numbers.d.ts.map +1 -0
- package/dist/{scripting → functions}/builtins/language/numbers.js.map +1 -1
- package/dist/{scripting → functions}/builtins/language/objects.d.ts +1 -1
- package/dist/{scripting → functions}/builtins/language/objects.d.ts.map +1 -1
- package/dist/{scripting → functions}/builtins/language/objects.js.map +1 -1
- package/dist/functions/builtins/language/regex.d.ts +2 -0
- package/dist/functions/builtins/language/regex.d.ts.map +1 -0
- package/dist/{scripting → functions}/builtins/language/regex.js +1 -1
- package/dist/{scripting → functions}/builtins/language/regex.js.map +1 -1
- package/dist/functions/builtins/language/sort.d.ts +2 -0
- package/dist/functions/builtins/language/sort.d.ts.map +1 -0
- package/dist/{scripting → functions}/builtins/language/sort.js.map +1 -1
- package/dist/{scripting → functions}/builtins/language/state.d.ts +1 -1
- package/dist/{scripting → functions}/builtins/language/state.d.ts.map +1 -1
- package/dist/{scripting → functions}/builtins/language/state.js.map +1 -1
- package/dist/functions/builtins/language/texts.d.ts +2 -0
- package/dist/functions/builtins/language/texts.d.ts.map +1 -0
- package/dist/{scripting → functions}/builtins/language/texts.js.map +1 -1
- package/dist/functions/builtins/messages.d.ts +2 -0
- package/dist/functions/builtins/messages.d.ts.map +1 -0
- package/dist/{scripting → functions}/builtins/messages.js.map +1 -1
- package/dist/functions/builtins/moderation.d.ts +2 -0
- package/dist/functions/builtins/moderation.d.ts.map +1 -0
- package/dist/{scripting → functions}/builtins/moderation.js.map +1 -1
- package/dist/functions/builtins/native-channels.d.ts +2 -0
- package/dist/functions/builtins/native-channels.d.ts.map +1 -0
- package/dist/{scripting → functions}/builtins/native-channels.js.map +1 -1
- package/dist/functions/builtins/native-collectors.d.ts +2 -0
- package/dist/functions/builtins/native-collectors.d.ts.map +1 -0
- package/dist/{scripting → functions}/builtins/native-collectors.js.map +1 -1
- package/dist/functions/builtins/native-expressions.d.ts +2 -0
- package/dist/functions/builtins/native-expressions.d.ts.map +1 -0
- package/dist/{scripting → functions}/builtins/native-expressions.js.map +1 -1
- package/dist/functions/builtins/native-invites.d.ts +2 -0
- package/dist/functions/builtins/native-invites.d.ts.map +1 -0
- package/dist/{scripting → functions}/builtins/native-invites.js.map +1 -1
- package/dist/functions/builtins/native-messages.d.ts +2 -0
- package/dist/functions/builtins/native-messages.d.ts.map +1 -0
- package/dist/{scripting → functions}/builtins/native-messages.js.map +1 -1
- package/dist/functions/builtins/native-roles.d.ts +2 -0
- package/dist/functions/builtins/native-roles.d.ts.map +1 -0
- package/dist/{scripting → functions}/builtins/native-roles.js.map +1 -1
- package/dist/functions/builtins/native-threads.d.ts +2 -0
- package/dist/functions/builtins/native-threads.d.ts.map +1 -0
- package/dist/{scripting → functions}/builtins/native-threads.js.map +1 -1
- package/dist/functions/builtins/native-users.d.ts +2 -0
- package/dist/functions/builtins/native-users.d.ts.map +1 -0
- package/dist/{scripting → functions}/builtins/native-users.js.map +1 -1
- package/dist/functions/builtins/native-webhooks.d.ts +2 -0
- package/dist/functions/builtins/native-webhooks.d.ts.map +1 -0
- package/dist/{scripting → functions}/builtins/native-webhooks.js.map +1 -1
- package/dist/{scripting → functions}/builtins/payload.d.ts +2 -2
- package/dist/functions/builtins/payload.d.ts.map +1 -0
- package/dist/{scripting → functions}/builtins/payload.js +1 -1
- package/dist/functions/builtins/payload.js.map +1 -0
- package/dist/functions/builtins/resource-extras.d.ts +2 -0
- package/dist/functions/builtins/resource-extras.d.ts.map +1 -0
- package/dist/{scripting → functions}/builtins/resource-extras.js.map +1 -1
- package/dist/functions/builtins/schedule.d.ts +2 -0
- package/dist/functions/builtins/schedule.d.ts.map +1 -0
- package/dist/{scripting → functions}/builtins/schedule.js.map +1 -1
- package/dist/functions/builtins/storage.d.ts +2 -0
- package/dist/functions/builtins/storage.d.ts.map +1 -0
- package/dist/{scripting → functions}/builtins/storage.js.map +1 -1
- package/dist/functions/builtins/values.d.ts +2 -0
- package/dist/functions/builtins/values.d.ts.map +1 -0
- package/dist/{scripting → functions}/builtins/values.js +1 -1
- package/dist/functions/builtins/values.js.map +1 -0
- package/dist/functions/runtime/ast.d.ts.map +1 -0
- package/dist/functions/runtime/ast.js.map +1 -0
- package/dist/{scripting → functions/runtime}/canvas-execution.d.ts +1 -1
- package/dist/functions/runtime/canvas-execution.d.ts.map +1 -0
- package/dist/functions/runtime/canvas-execution.js.map +1 -0
- package/dist/functions/runtime/control-flow.d.ts.map +1 -0
- package/dist/functions/runtime/control-flow.js.map +1 -0
- package/dist/{scripting → functions/runtime}/evaluator.d.ts +1 -1
- package/dist/functions/runtime/evaluator.d.ts.map +1 -0
- package/dist/{scripting → functions/runtime}/evaluator.js +1 -1
- package/dist/functions/runtime/evaluator.js.map +1 -0
- package/dist/functions/runtime/limits.d.ts.map +1 -0
- package/dist/{scripting → functions/runtime}/limits.js +1 -1
- package/dist/functions/runtime/limits.js.map +1 -0
- package/dist/functions/runtime/parser.d.ts.map +1 -0
- package/dist/{scripting → functions/runtime}/parser.js +1 -1
- package/dist/functions/runtime/parser.js.map +1 -0
- package/dist/functions/runtime/regex.d.ts.map +1 -0
- package/dist/{scripting → functions/runtime}/regex.js +1 -1
- package/dist/functions/runtime/regex.js.map +1 -0
- package/dist/functions/runtime/registry.d.ts.map +1 -0
- package/dist/{scripting → functions/runtime}/registry.js +1 -1
- package/dist/functions/runtime/registry.js.map +1 -0
- package/dist/{scripting → functions/runtime}/runtime.d.ts +3 -1
- package/dist/functions/runtime/runtime.d.ts.map +1 -0
- package/dist/{scripting → functions/runtime}/runtime.js +3 -0
- package/dist/functions/runtime/runtime.js.map +1 -0
- package/dist/{scripting → functions/runtime}/types.d.ts +1 -1
- package/dist/functions/runtime/types.d.ts.map +1 -0
- package/dist/functions/runtime/types.js.map +1 -0
- package/dist/functions/runtime/values.d.ts.map +1 -0
- package/dist/functions/runtime/values.js.map +1 -0
- package/dist/functions.d.ts +19 -8
- package/dist/functions.d.ts.map +1 -1
- package/dist/functions.js +18 -6
- package/dist/functions.js.map +1 -1
- package/dist/index.d.ts +7 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/infrastructure/canvas/napi.d.ts +4 -0
- package/dist/infrastructure/canvas/napi.d.ts.map +1 -0
- package/dist/infrastructure/canvas/napi.js +17 -0
- package/dist/infrastructure/canvas/napi.js.map +1 -0
- package/dist/infrastructure/fluxer/resources/cache.d.ts +4 -0
- package/dist/infrastructure/fluxer/resources/cache.d.ts.map +1 -0
- package/dist/infrastructure/fluxer/resources/cache.js +68 -0
- package/dist/infrastructure/fluxer/resources/cache.js.map +1 -0
- package/dist/infrastructure/fluxer/resources/channels.d.ts +3 -2
- package/dist/infrastructure/fluxer/resources/channels.d.ts.map +1 -1
- package/dist/infrastructure/fluxer/resources/channels.js +54 -2
- package/dist/infrastructure/fluxer/resources/channels.js.map +1 -1
- package/dist/infrastructure/fluxer/resources/collectors.d.ts.map +1 -1
- package/dist/infrastructure/fluxer/resources/collectors.js +86 -4
- package/dist/infrastructure/fluxer/resources/collectors.js.map +1 -1
- package/dist/infrastructure/fluxer/resources/expressions.d.ts.map +1 -1
- package/dist/infrastructure/fluxer/resources/expressions.js +8 -1
- package/dist/infrastructure/fluxer/resources/expressions.js.map +1 -1
- package/dist/infrastructure/fluxer/resources/gateway.d.ts +4 -0
- package/dist/infrastructure/fluxer/resources/gateway.d.ts.map +1 -0
- package/dist/infrastructure/fluxer/resources/gateway.js +31 -0
- package/dist/infrastructure/fluxer/resources/gateway.js.map +1 -0
- package/dist/infrastructure/fluxer/resources/instance.d.ts +4 -0
- package/dist/infrastructure/fluxer/resources/instance.d.ts.map +1 -0
- package/dist/infrastructure/fluxer/resources/instance.js +96 -0
- package/dist/infrastructure/fluxer/resources/instance.js.map +1 -0
- package/dist/infrastructure/fluxer/resources/messages.d.ts +3 -1
- package/dist/infrastructure/fluxer/resources/messages.d.ts.map +1 -1
- package/dist/infrastructure/fluxer/resources/messages.js +91 -36
- package/dist/infrastructure/fluxer/resources/messages.js.map +1 -1
- package/dist/infrastructure/fluxer/resources/roles.d.ts.map +1 -1
- package/dist/infrastructure/fluxer/resources/roles.js +8 -0
- package/dist/infrastructure/fluxer/resources/roles.js.map +1 -1
- package/dist/infrastructure/fluxer/resources/self.d.ts +4 -0
- package/dist/infrastructure/fluxer/resources/self.d.ts.map +1 -0
- package/dist/infrastructure/fluxer/resources/self.js +36 -0
- package/dist/infrastructure/fluxer/resources/self.js.map +1 -0
- package/dist/infrastructure/fluxer/resources/threads.d.ts.map +1 -1
- package/dist/infrastructure/fluxer/resources/threads.js +15 -0
- package/dist/infrastructure/fluxer/resources/threads.js.map +1 -1
- package/dist/infrastructure/fluxer/resources/users.d.ts +5 -2
- package/dist/infrastructure/fluxer/resources/users.d.ts.map +1 -1
- package/dist/infrastructure/fluxer/resources/users.js +36 -3
- package/dist/infrastructure/fluxer/resources/users.js.map +1 -1
- package/dist/infrastructure/fluxer/resources/webhooks.d.ts.map +1 -1
- package/dist/infrastructure/fluxer/resources/webhooks.js +9 -0
- package/dist/infrastructure/fluxer/resources/webhooks.js.map +1 -1
- package/dist/infrastructure/fluxer/resources.d.ts +4 -0
- package/dist/infrastructure/fluxer/resources.d.ts.map +1 -1
- package/dist/infrastructure/fluxer/resources.js +12 -0
- package/dist/infrastructure/fluxer/resources.js.map +1 -1
- package/dist/ports/resources/cache.d.ts +74 -0
- package/dist/ports/resources/cache.d.ts.map +1 -0
- package/dist/ports/resources/cache.js +2 -0
- package/dist/ports/resources/cache.js.map +1 -0
- package/dist/ports/resources/channels.d.ts +17 -0
- package/dist/ports/resources/channels.d.ts.map +1 -1
- package/dist/ports/resources/channels.js.map +1 -1
- package/dist/ports/resources/collectors.d.ts +18 -0
- package/dist/ports/resources/collectors.d.ts.map +1 -1
- package/dist/ports/resources/collectors.js.map +1 -1
- package/dist/ports/resources/common.d.ts +2 -0
- package/dist/ports/resources/common.d.ts.map +1 -1
- package/dist/ports/resources/common.js.map +1 -1
- package/dist/ports/resources/expressions.d.ts +8 -0
- package/dist/ports/resources/expressions.d.ts.map +1 -1
- package/dist/ports/resources/expressions.js.map +1 -1
- package/dist/ports/resources/gateway.d.ts +48 -0
- package/dist/ports/resources/gateway.d.ts.map +1 -0
- package/dist/ports/resources/gateway.js +2 -0
- package/dist/ports/resources/gateway.js.map +1 -0
- package/dist/ports/resources/instance.d.ts +101 -0
- package/dist/ports/resources/instance.d.ts.map +1 -0
- package/dist/ports/resources/instance.js +2 -0
- package/dist/ports/resources/instance.js.map +1 -0
- package/dist/ports/resources/messages.d.ts +27 -0
- package/dist/ports/resources/messages.d.ts.map +1 -1
- package/dist/ports/resources/messages.js.map +1 -1
- package/dist/ports/resources/roles.d.ts +6 -0
- package/dist/ports/resources/roles.d.ts.map +1 -1
- package/dist/ports/resources/roles.js.map +1 -1
- package/dist/ports/resources/self.d.ts +30 -0
- package/dist/ports/resources/self.d.ts.map +1 -0
- package/dist/ports/resources/self.js +2 -0
- package/dist/ports/resources/self.js.map +1 -0
- package/dist/ports/resources/threads.d.ts +16 -0
- package/dist/ports/resources/threads.d.ts.map +1 -1
- package/dist/ports/resources/threads.js.map +1 -1
- package/dist/ports/resources/users.d.ts +30 -0
- package/dist/ports/resources/users.d.ts.map +1 -1
- package/dist/ports/resources/users.js.map +1 -1
- package/dist/ports/resources/webhooks.d.ts +5 -0
- package/dist/ports/resources/webhooks.d.ts.map +1 -1
- package/dist/ports/resources/webhooks.js.map +1 -1
- package/dist/ports/resources.d.ts +8 -0
- package/dist/ports/resources.d.ts.map +1 -1
- package/dist/ports/resources.js.map +1 -1
- package/dist/ports/script-engine.d.ts +45 -0
- package/dist/ports/script-engine.d.ts.map +1 -0
- package/dist/ports/script-engine.js +2 -0
- package/dist/ports/script-engine.js.map +1 -0
- package/dist/sdk/builders.d.ts +2 -0
- package/dist/sdk/builders.d.ts.map +1 -0
- package/dist/sdk/builders.js +2 -0
- package/dist/sdk/builders.js.map +1 -0
- package/dist/sdk/client.d.ts +2 -0
- package/dist/sdk/client.d.ts.map +1 -0
- package/dist/sdk/client.js +2 -0
- package/dist/sdk/client.js.map +1 -0
- package/dist/sdk/cluster.d.ts +2 -0
- package/dist/sdk/cluster.d.ts.map +1 -0
- package/dist/sdk/cluster.js +2 -0
- package/dist/sdk/cluster.js.map +1 -0
- package/dist/sdk/collection.d.ts +2 -0
- package/dist/sdk/collection.d.ts.map +1 -0
- package/dist/sdk/collection.js +2 -0
- package/dist/sdk/collection.js.map +1 -0
- package/dist/sdk/errors.d.ts +2 -0
- package/dist/sdk/errors.d.ts.map +1 -0
- package/dist/sdk/errors.js +2 -0
- package/dist/sdk/errors.js.map +1 -0
- package/dist/sdk/internal.d.ts +2 -0
- package/dist/sdk/internal.d.ts.map +1 -0
- package/dist/sdk/internal.js +2 -0
- package/dist/sdk/internal.js.map +1 -0
- package/dist/sdk/message.d.ts +2 -0
- package/dist/sdk/message.d.ts.map +1 -0
- package/dist/sdk/message.js +2 -0
- package/dist/sdk/message.js.map +1 -0
- package/dist/sdk/rest/request-manager.d.ts +2 -0
- package/dist/sdk/rest/request-manager.d.ts.map +1 -0
- package/dist/sdk/rest/request-manager.js +2 -0
- package/dist/sdk/rest/request-manager.js.map +1 -0
- package/dist/sdk/rest.d.ts +2 -0
- package/dist/sdk/rest.d.ts.map +1 -0
- package/dist/sdk/rest.js +2 -0
- package/dist/sdk/rest.js.map +1 -0
- package/dist/sdk/sharding.d.ts +2 -0
- package/dist/sdk/sharding.d.ts.map +1 -0
- package/dist/sdk/sharding.js +2 -0
- package/dist/sdk/sharding.js.map +1 -0
- package/dist/sdk/types/routes.d.ts +2 -0
- package/dist/sdk/types/routes.d.ts.map +1 -0
- package/dist/sdk/types/routes.js +2 -0
- package/dist/sdk/types/routes.js.map +1 -0
- package/dist/sdk/types.d.ts +2 -0
- package/dist/sdk/types.d.ts.map +1 -0
- package/dist/sdk/types.js +2 -0
- package/dist/sdk/types.js.map +1 -0
- package/dist/sdk/util.d.ts +2 -0
- package/dist/sdk/util.d.ts.map +1 -0
- package/dist/sdk/util.js +2 -0
- package/dist/sdk/util.js.map +1 -0
- package/dist/sdk/voice.d.ts +2 -0
- package/dist/sdk/voice.d.ts.map +1 -0
- package/dist/sdk/voice.js +2 -0
- package/dist/sdk/voice.js.map +1 -0
- package/dist/sdk/ws.d.ts +2 -0
- package/dist/sdk/ws.d.ts.map +1 -0
- package/dist/sdk/ws.js +2 -0
- package/dist/sdk/ws.js.map +1 -0
- package/dist/services/canvas-image.d.ts +12 -0
- package/dist/services/canvas-image.d.ts.map +1 -0
- package/dist/services/canvas-image.js +56 -0
- package/dist/services/canvas-image.js.map +1 -0
- package/dist/services/canvas.d.ts +12 -2
- package/dist/services/canvas.d.ts.map +1 -1
- package/dist/services/canvas.js +91 -5
- package/dist/services/canvas.js.map +1 -1
- package/dist/services/moderation.d.ts +1 -0
- package/dist/services/moderation.d.ts.map +1 -1
- package/dist/services/moderation.js +11 -0
- package/dist/services/moderation.js.map +1 -1
- package/dist/services/native-moderation.d.ts +6 -1
- package/dist/services/native-moderation.d.ts.map +1 -1
- package/dist/services/native-moderation.js +11 -1
- package/dist/services/native-moderation.js.map +1 -1
- package/dist/services/resource-authorization.d.ts.map +1 -1
- package/dist/services/resource-authorization.js +95 -3
- package/dist/services/resource-authorization.js.map +1 -1
- package/dist/testing.d.ts.map +1 -1
- package/dist/testing.js +4 -0
- package/dist/testing.js.map +1 -1
- package/docs/API.md +8 -7
- package/docs/ARCHITECTURE.md +14 -9
- package/docs/BENCHMARKS.md +1 -1
- package/docs/CANVAS.md +70 -15
- package/docs/EDITOR.md +1 -1
- package/docs/FRAMEWORK.md +2 -3
- package/docs/HTTP.md +1 -1
- package/docs/IMAGES.md +2 -1
- package/docs/NATIVE.md +45 -14
- package/docs/PARITY-MATRIX.md +853 -843
- package/docs/PARITY.md +24 -12
- package/docs/PLAN.md +14 -3
- package/docs/QUICKSTART.md +5 -5
- package/docs/README.md +7 -7
- package/docs/REPOSITORY.md +1 -1
- package/docs/SCHEDULER.md +1 -1
- package/docs/TROUBLESHOOTING.md +1 -1
- package/docs/VALIDATION.md +5 -5
- package/docs/{FUNCTION-GAPS.md → functions/FUNCTION-GAPS.md} +18 -13
- package/docs/{LANGUAGE.md → functions/LANGUAGE.md} +7 -7
- package/docs/functions/README.md +33 -0
- package/docs/tutorials/DATA.md +2 -2
- package/docs/tutorials/FUNCTION-MODE.md +2 -2
- package/examples/canvas/napi-style.ts +24 -0
- package/examples/canvas/output/napi-style.png +0 -0
- package/examples/canvas/profile.d.mts +1 -1
- package/examples/canvas/profile.mjs +2 -2
- package/examples/canvas/profile.ts +3 -3
- package/examples/canvas/ranking.d.mts +1 -1
- package/examples/canvas/ranking.mjs +2 -2
- package/examples/canvas/ranking.ts +3 -3
- package/examples/canvas/render.ts +2 -1
- package/examples/canvas/welcome.d.mts +1 -1
- package/examples/canvas/welcome.mjs +2 -2
- package/examples/canvas/welcome.ts +3 -3
- package/examples/embeds/complete-embed-functions.ts +2 -2
- package/examples/function-mode.ts +3 -3
- package/examples/yuzuha.config.js +2 -0
- package/package.json +26 -1
- package/src/canvas/card.ts +20 -0
- package/src/canvas.ts +69 -17
- package/src/cli/config.ts +2 -1
- package/src/cli/lint.ts +1 -2
- package/src/cli/main.ts +8 -9
- package/src/cli/scaffold.ts +1 -1
- package/src/cli/scenarios.ts +2 -1
- package/src/commands/context.ts +9 -2
- package/src/domain/resource-batches.ts +31 -0
- package/src/framework/bot.ts +44 -27
- package/src/framework/command-registry.ts +15 -10
- package/src/framework/options.ts +3 -3
- package/src/{scripting → functions}/builtins/canvas.ts +2 -2
- package/src/{scripting → functions}/builtins/context.ts +1 -1
- package/src/{scripting → functions}/builtins/definition.ts +1 -1
- package/src/{scripting → functions}/builtins/embeds.ts +1 -1
- package/src/{scripting → functions}/builtins/flow.ts +2 -2
- package/src/{scripting → functions}/builtins/guards.ts +1 -1
- package/src/{scripting → functions}/builtins/http.ts +2 -2
- package/src/{scripting → functions}/builtins/index.ts +2 -2
- package/src/{scripting → functions}/builtins/language/array-callbacks.ts +2 -2
- package/src/{scripting → functions}/builtins/language/arrays.ts +1 -1
- package/src/{scripting → functions}/builtins/language/index.ts +1 -1
- package/src/{scripting → functions}/builtins/language/loops.ts +4 -4
- package/src/{scripting → functions}/builtins/language/regex.ts +1 -1
- package/src/{scripting → functions}/builtins/moderation.ts +1 -1
- package/src/{scripting → functions}/builtins/native-channels.ts +1 -1
- package/src/{scripting → functions}/builtins/native-roles.ts +1 -1
- package/src/{scripting → functions}/builtins/native-users.ts +1 -1
- package/src/{scripting → functions}/builtins/payload.ts +2 -2
- package/src/{scripting → functions}/builtins/resource-extras.ts +1 -1
- package/src/{scripting → functions}/builtins/values.ts +1 -1
- package/src/{scripting → functions/runtime}/canvas-execution.ts +1 -1
- package/src/{scripting → functions/runtime}/evaluator.ts +2 -2
- package/src/{scripting → functions/runtime}/limits.ts +1 -1
- package/src/{scripting → functions/runtime}/parser.ts +1 -1
- package/src/{scripting → functions/runtime}/regex.ts +1 -1
- package/src/{scripting → functions/runtime}/registry.ts +1 -1
- package/src/{scripting → functions/runtime}/runtime.ts +6 -1
- package/src/{scripting → functions/runtime}/types.ts +1 -1
- package/src/functions.ts +28 -8
- package/src/index.ts +9 -2
- package/src/infrastructure/canvas/napi.ts +17 -0
- package/src/infrastructure/fluxer/resources/cache.ts +69 -0
- package/src/infrastructure/fluxer/resources/channels.ts +51 -3
- package/src/infrastructure/fluxer/resources/collectors.ts +87 -4
- package/src/infrastructure/fluxer/resources/expressions.ts +7 -1
- package/src/infrastructure/fluxer/resources/gateway.ts +33 -0
- package/src/infrastructure/fluxer/resources/instance.ts +105 -0
- package/src/infrastructure/fluxer/resources/messages.ts +84 -36
- package/src/infrastructure/fluxer/resources/roles.ts +8 -0
- package/src/infrastructure/fluxer/resources/self.ts +39 -0
- package/src/infrastructure/fluxer/resources/threads.ts +14 -0
- package/src/infrastructure/fluxer/resources/users.ts +40 -4
- package/src/infrastructure/fluxer/resources/webhooks.ts +9 -0
- package/src/infrastructure/fluxer/resources.ts +12 -0
- package/src/ports/resources/cache.ts +81 -0
- package/src/ports/resources/channels.ts +12 -0
- package/src/ports/resources/collectors.ts +20 -0
- package/src/ports/resources/common.ts +2 -0
- package/src/ports/resources/expressions.ts +6 -0
- package/src/ports/resources/gateway.ts +49 -0
- package/src/ports/resources/instance.ts +109 -0
- package/src/ports/resources/messages.ts +30 -0
- package/src/ports/resources/roles.ts +3 -0
- package/src/ports/resources/self.ts +30 -0
- package/src/ports/resources/threads.ts +15 -0
- package/src/ports/resources/users.ts +33 -0
- package/src/ports/resources/webhooks.ts +6 -0
- package/src/ports/resources.ts +8 -0
- package/src/ports/script-engine.ts +42 -0
- package/src/sdk/builders.ts +1 -0
- package/src/sdk/client.ts +1 -0
- package/src/sdk/cluster.ts +1 -0
- package/src/sdk/collection.ts +1 -0
- package/src/sdk/errors.ts +1 -0
- package/src/sdk/internal.ts +1 -0
- package/src/sdk/message.ts +1 -0
- package/src/sdk/rest/request-manager.ts +1 -0
- package/src/sdk/rest.ts +1 -0
- package/src/sdk/sharding.ts +1 -0
- package/src/sdk/types/routes.ts +1 -0
- package/src/sdk/types.ts +1 -0
- package/src/sdk/util.ts +1 -0
- package/src/sdk/voice.ts +1 -0
- package/src/sdk/ws.ts +1 -0
- package/src/services/canvas-image.ts +54 -0
- package/src/services/canvas.ts +89 -6
- package/src/services/moderation.ts +4 -0
- package/src/services/native-moderation.ts +11 -1
- package/src/services/resource-authorization.ts +89 -3
- package/src/testing.ts +4 -0
- package/dist/parser.d.ts +0 -3
- package/dist/parser.d.ts.map +0 -1
- package/dist/parser.js +0 -2
- package/dist/parser.js.map +0 -1
- package/dist/runtime.d.ts +0 -5
- package/dist/runtime.d.ts.map +0 -1
- package/dist/runtime.js +0 -4
- package/dist/runtime.js.map +0 -1
- package/dist/scripting/ast.d.ts.map +0 -1
- package/dist/scripting/ast.js.map +0 -1
- package/dist/scripting/builtins/canvas.d.ts +0 -2
- package/dist/scripting/builtins/canvas.d.ts.map +0 -1
- package/dist/scripting/builtins/context.d.ts +0 -2
- package/dist/scripting/builtins/context.d.ts.map +0 -1
- package/dist/scripting/builtins/definition.d.ts.map +0 -1
- package/dist/scripting/builtins/definition.js.map +0 -1
- package/dist/scripting/builtins/embeds.d.ts +0 -3
- package/dist/scripting/builtins/embeds.js.map +0 -1
- package/dist/scripting/builtins/events.d.ts +0 -2
- package/dist/scripting/builtins/events.d.ts.map +0 -1
- package/dist/scripting/builtins/flow.d.ts +0 -2
- package/dist/scripting/builtins/flow.d.ts.map +0 -1
- package/dist/scripting/builtins/flow.js.map +0 -1
- package/dist/scripting/builtins/guards.d.ts +0 -2
- package/dist/scripting/builtins/guards.d.ts.map +0 -1
- package/dist/scripting/builtins/guards.js.map +0 -1
- package/dist/scripting/builtins/http.d.ts +0 -2
- package/dist/scripting/builtins/http.d.ts.map +0 -1
- package/dist/scripting/builtins/http.js.map +0 -1
- package/dist/scripting/builtins/index.d.ts +0 -5
- package/dist/scripting/builtins/index.d.ts.map +0 -1
- package/dist/scripting/builtins/index.js.map +0 -1
- package/dist/scripting/builtins/language/array-callbacks.d.ts +0 -2
- package/dist/scripting/builtins/language/array-callbacks.d.ts.map +0 -1
- package/dist/scripting/builtins/language/arrays.d.ts +0 -2
- package/dist/scripting/builtins/language/arrays.d.ts.map +0 -1
- package/dist/scripting/builtins/language/decimals.d.ts +0 -2
- package/dist/scripting/builtins/language/decimals.d.ts.map +0 -1
- package/dist/scripting/builtins/language/index.d.ts +0 -3
- package/dist/scripting/builtins/language/index.d.ts.map +0 -1
- package/dist/scripting/builtins/language/index.js.map +0 -1
- package/dist/scripting/builtins/language/loops.d.ts +0 -4
- package/dist/scripting/builtins/language/numbers.d.ts +0 -2
- package/dist/scripting/builtins/language/numbers.d.ts.map +0 -1
- package/dist/scripting/builtins/language/regex.d.ts +0 -2
- package/dist/scripting/builtins/language/regex.d.ts.map +0 -1
- package/dist/scripting/builtins/language/sort.d.ts +0 -2
- package/dist/scripting/builtins/language/sort.d.ts.map +0 -1
- package/dist/scripting/builtins/language/texts.d.ts +0 -2
- package/dist/scripting/builtins/language/texts.d.ts.map +0 -1
- package/dist/scripting/builtins/messages.d.ts +0 -2
- package/dist/scripting/builtins/messages.d.ts.map +0 -1
- package/dist/scripting/builtins/moderation.d.ts +0 -2
- package/dist/scripting/builtins/moderation.d.ts.map +0 -1
- package/dist/scripting/builtins/native-channels.d.ts +0 -2
- package/dist/scripting/builtins/native-channels.d.ts.map +0 -1
- package/dist/scripting/builtins/native-collectors.d.ts +0 -2
- package/dist/scripting/builtins/native-collectors.d.ts.map +0 -1
- package/dist/scripting/builtins/native-expressions.d.ts +0 -2
- package/dist/scripting/builtins/native-expressions.d.ts.map +0 -1
- package/dist/scripting/builtins/native-invites.d.ts +0 -2
- package/dist/scripting/builtins/native-invites.d.ts.map +0 -1
- package/dist/scripting/builtins/native-messages.d.ts +0 -2
- package/dist/scripting/builtins/native-messages.d.ts.map +0 -1
- package/dist/scripting/builtins/native-roles.d.ts +0 -2
- package/dist/scripting/builtins/native-roles.d.ts.map +0 -1
- package/dist/scripting/builtins/native-threads.d.ts +0 -2
- package/dist/scripting/builtins/native-threads.d.ts.map +0 -1
- package/dist/scripting/builtins/native-users.d.ts +0 -2
- package/dist/scripting/builtins/native-users.d.ts.map +0 -1
- package/dist/scripting/builtins/native-webhooks.d.ts +0 -2
- package/dist/scripting/builtins/native-webhooks.d.ts.map +0 -1
- package/dist/scripting/builtins/payload.d.ts.map +0 -1
- package/dist/scripting/builtins/payload.js.map +0 -1
- package/dist/scripting/builtins/resource-extras.d.ts +0 -2
- package/dist/scripting/builtins/resource-extras.d.ts.map +0 -1
- package/dist/scripting/builtins/schedule.d.ts +0 -2
- package/dist/scripting/builtins/schedule.d.ts.map +0 -1
- package/dist/scripting/builtins/storage.d.ts +0 -2
- package/dist/scripting/builtins/storage.d.ts.map +0 -1
- package/dist/scripting/builtins/values.d.ts +0 -2
- package/dist/scripting/builtins/values.d.ts.map +0 -1
- package/dist/scripting/builtins/values.js.map +0 -1
- package/dist/scripting/canvas-execution.d.ts.map +0 -1
- package/dist/scripting/canvas-execution.js.map +0 -1
- package/dist/scripting/control-flow.d.ts.map +0 -1
- package/dist/scripting/control-flow.js.map +0 -1
- package/dist/scripting/evaluator.d.ts.map +0 -1
- package/dist/scripting/evaluator.js.map +0 -1
- package/dist/scripting/limits.d.ts.map +0 -1
- package/dist/scripting/limits.js.map +0 -1
- package/dist/scripting/parser.d.ts.map +0 -1
- package/dist/scripting/parser.js.map +0 -1
- package/dist/scripting/regex.d.ts.map +0 -1
- package/dist/scripting/regex.js.map +0 -1
- package/dist/scripting/registry.d.ts.map +0 -1
- package/dist/scripting/registry.js.map +0 -1
- package/dist/scripting/runtime.d.ts.map +0 -1
- package/dist/scripting/runtime.js.map +0 -1
- package/dist/scripting/types.d.ts.map +0 -1
- package/dist/scripting/types.js.map +0 -1
- package/dist/scripting/values.d.ts.map +0 -1
- package/dist/scripting/values.js.map +0 -1
- package/src/parser.ts +0 -2
- package/src/runtime.ts +0 -4
- /package/dist/{scripting → functions}/builtins/arguments.d.ts +0 -0
- /package/dist/{scripting → functions}/builtins/arguments.js +0 -0
- /package/dist/{scripting → functions}/builtins/context.js +0 -0
- /package/dist/{scripting → functions}/builtins/definition.js +0 -0
- /package/dist/{scripting → functions}/builtins/events.js +0 -0
- /package/dist/{scripting → functions}/builtins/index.js +0 -0
- /package/dist/{scripting → functions}/builtins/language/common.d.ts +0 -0
- /package/dist/{scripting → functions}/builtins/language/common.js +0 -0
- /package/dist/{scripting → functions}/builtins/language/decimals.js +0 -0
- /package/dist/{scripting → functions}/builtins/language/index.js +0 -0
- /package/dist/{scripting → functions}/builtins/language/numbers.js +0 -0
- /package/dist/{scripting → functions}/builtins/language/objects.js +0 -0
- /package/dist/{scripting → functions}/builtins/language/sort.js +0 -0
- /package/dist/{scripting → functions}/builtins/language/state.js +0 -0
- /package/dist/{scripting → functions}/builtins/language/texts.js +0 -0
- /package/dist/{scripting → functions}/builtins/messages.js +0 -0
- /package/dist/{scripting → functions}/builtins/moderation.js +0 -0
- /package/dist/{scripting → functions}/builtins/native-channels.js +0 -0
- /package/dist/{scripting → functions}/builtins/native-collectors.js +0 -0
- /package/dist/{scripting → functions}/builtins/native-expressions.js +0 -0
- /package/dist/{scripting → functions}/builtins/native-invites.js +0 -0
- /package/dist/{scripting → functions}/builtins/native-messages.js +0 -0
- /package/dist/{scripting → functions}/builtins/native-roles.js +0 -0
- /package/dist/{scripting → functions}/builtins/native-threads.js +0 -0
- /package/dist/{scripting → functions}/builtins/native-users.js +0 -0
- /package/dist/{scripting → functions}/builtins/native-webhooks.js +0 -0
- /package/dist/{scripting → functions}/builtins/resource-extras.js +0 -0
- /package/dist/{scripting → functions}/builtins/schedule.js +0 -0
- /package/dist/{scripting → functions}/builtins/storage.js +0 -0
- /package/dist/{scripting → functions/runtime}/ast.d.ts +0 -0
- /package/dist/{scripting → functions/runtime}/ast.js +0 -0
- /package/dist/{scripting → functions/runtime}/canvas-execution.js +0 -0
- /package/dist/{scripting → functions/runtime}/control-flow.d.ts +0 -0
- /package/dist/{scripting → functions/runtime}/control-flow.js +0 -0
- /package/dist/{scripting → functions/runtime}/limits.d.ts +0 -0
- /package/dist/{scripting → functions/runtime}/parser.d.ts +0 -0
- /package/dist/{scripting → functions/runtime}/regex-worker.mjs +0 -0
- /package/dist/{scripting → functions/runtime}/regex.d.ts +0 -0
- /package/dist/{scripting → functions/runtime}/registry.d.ts +0 -0
- /package/dist/{scripting → functions/runtime}/types.js +0 -0
- /package/dist/{scripting → functions/runtime}/values.d.ts +0 -0
- /package/dist/{scripting → functions/runtime}/values.js +0 -0
- /package/docs/{FUNCTIONS.md → functions/FUNCTIONS.md} +0 -0
- /package/docs/{LANGUAGE-EXTENSIONS.md → functions/LANGUAGE-EXTENSIONS.md} +0 -0
- /package/src/{scripting → functions}/builtins/arguments.ts +0 -0
- /package/src/{scripting → functions}/builtins/events.ts +0 -0
- /package/src/{scripting → functions}/builtins/language/common.ts +0 -0
- /package/src/{scripting → functions}/builtins/language/decimals.ts +0 -0
- /package/src/{scripting → functions}/builtins/language/numbers.ts +0 -0
- /package/src/{scripting → functions}/builtins/language/objects.ts +0 -0
- /package/src/{scripting → functions}/builtins/language/sort.ts +0 -0
- /package/src/{scripting → functions}/builtins/language/state.ts +0 -0
- /package/src/{scripting → functions}/builtins/language/texts.ts +0 -0
- /package/src/{scripting → functions}/builtins/messages.ts +0 -0
- /package/src/{scripting → functions}/builtins/native-collectors.ts +0 -0
- /package/src/{scripting → functions}/builtins/native-expressions.ts +0 -0
- /package/src/{scripting → functions}/builtins/native-invites.ts +0 -0
- /package/src/{scripting → functions}/builtins/native-messages.ts +0 -0
- /package/src/{scripting → functions}/builtins/native-threads.ts +0 -0
- /package/src/{scripting → functions}/builtins/native-webhooks.ts +0 -0
- /package/src/{scripting → functions}/builtins/schedule.ts +0 -0
- /package/src/{scripting → functions}/builtins/storage.ts +0 -0
- /package/src/{scripting → functions/runtime}/ast.ts +0 -0
- /package/src/{scripting → functions/runtime}/control-flow.ts +0 -0
- /package/src/{scripting → functions/runtime}/regex-worker.mjs +0 -0
- /package/src/{scripting → functions/runtime}/values.ts +0 -0
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { defineConfig, defineEvent } from 'yuzuha';
|
|
2
|
+
import { functions } from 'yuzuha/functions';
|
|
2
3
|
import { Events } from 'yuzuha/sdk';
|
|
3
4
|
|
|
4
5
|
export default defineConfig({
|
|
5
6
|
name: 'yuzuha-example',
|
|
6
7
|
prefix: ['!', 'y!'],
|
|
7
8
|
commands: './commands',
|
|
9
|
+
engine: functions(),
|
|
8
10
|
setup(bot) {
|
|
9
11
|
bot.plugin({
|
|
10
12
|
name: 'greetings',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yuzuha",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Fluxer bots with simple scripts and typed JavaScript/TypeScript.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -26,6 +26,10 @@
|
|
|
26
26
|
"types": "./dist/sdk.d.ts",
|
|
27
27
|
"import": "./dist/sdk.js"
|
|
28
28
|
},
|
|
29
|
+
"./sdk/*": {
|
|
30
|
+
"types": "./dist/sdk/*.d.ts",
|
|
31
|
+
"import": "./dist/sdk/*.js"
|
|
32
|
+
},
|
|
29
33
|
"./testing": {
|
|
30
34
|
"types": "./dist/testing.d.ts",
|
|
31
35
|
"import": "./dist/testing.js"
|
|
@@ -49,6 +53,10 @@
|
|
|
49
53
|
"./canvas": {
|
|
50
54
|
"types": "./dist/canvas.d.ts",
|
|
51
55
|
"import": "./dist/canvas.js"
|
|
56
|
+
},
|
|
57
|
+
"./canvas/card": {
|
|
58
|
+
"types": "./dist/canvas/card.d.ts",
|
|
59
|
+
"import": "./dist/canvas/card.js"
|
|
52
60
|
}
|
|
53
61
|
},
|
|
54
62
|
"bin": {
|
|
@@ -93,11 +101,19 @@
|
|
|
93
101
|
"package:editor": "node scripts/package-editor.mjs"
|
|
94
102
|
},
|
|
95
103
|
"dependencies": {
|
|
104
|
+
"@fluxerjs/builders": "3.0.0",
|
|
105
|
+
"@fluxerjs/collection": "3.0.0",
|
|
96
106
|
"@fluxerjs/core": "3.3.0",
|
|
107
|
+
"@fluxerjs/rest": "3.1.0",
|
|
108
|
+
"@fluxerjs/types": "3.3.0",
|
|
109
|
+
"@fluxerjs/util": "3.1.0",
|
|
110
|
+
"@fluxerjs/ws": "3.1.0",
|
|
97
111
|
"tsx": "^4.20.0",
|
|
98
112
|
"ws": "^8.22.0"
|
|
99
113
|
},
|
|
100
114
|
"devDependencies": {
|
|
115
|
+
"@fluxerjs/sharding": "^3.0.0",
|
|
116
|
+
"@fluxerjs/voice": "^3.1.0",
|
|
101
117
|
"@napi-rs/canvas": "1.0.13",
|
|
102
118
|
"@types/node": "^22.0.0",
|
|
103
119
|
"@types/vscode": "^1.140.0",
|
|
@@ -106,11 +122,15 @@
|
|
|
106
122
|
"typescript": "^5.9.0"
|
|
107
123
|
},
|
|
108
124
|
"peerDependencies": {
|
|
125
|
+
"@fluxerjs/sharding": "^3.0.0",
|
|
109
126
|
"@fluxerjs/voice": "^3.1.0",
|
|
110
127
|
"@napi-rs/canvas": "^1.0.13",
|
|
111
128
|
"sharp": "^0.35.5"
|
|
112
129
|
},
|
|
113
130
|
"peerDependenciesMeta": {
|
|
131
|
+
"@fluxerjs/sharding": {
|
|
132
|
+
"optional": true
|
|
133
|
+
},
|
|
114
134
|
"@fluxerjs/voice": {
|
|
115
135
|
"optional": true
|
|
116
136
|
},
|
|
@@ -120,5 +140,10 @@
|
|
|
120
140
|
"@napi-rs/canvas": {
|
|
121
141
|
"optional": true
|
|
122
142
|
}
|
|
143
|
+
},
|
|
144
|
+
"overrides": {
|
|
145
|
+
"@fluxerjs/sharding": {
|
|
146
|
+
"@fluxerjs/core": "3.3.0"
|
|
147
|
+
}
|
|
123
148
|
}
|
|
124
149
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { CANVAS_LIMITS } from '../domain/canvas.js';
|
|
2
|
+
import type { CanvasConfig, CanvasCreateOptions } from '../domain/canvas.js';
|
|
3
|
+
import { canvasRenderer } from '../infrastructure/canvas/render.js';
|
|
4
|
+
import { CanvasService } from '../services/canvas.js';
|
|
5
|
+
import type { CanvasBuilder, CanvasRuntimeOptions } from '../services/canvas.js';
|
|
6
|
+
|
|
7
|
+
export function createCard(
|
|
8
|
+
width: number,
|
|
9
|
+
height: number,
|
|
10
|
+
options: CanvasCreateOptions & CanvasRuntimeOptions = {},
|
|
11
|
+
): CanvasBuilder {
|
|
12
|
+
const { scale, background, signal, http, assets, fonts, timeoutMs } = options;
|
|
13
|
+
const service = new CanvasService({ renderer: canvasRenderer, signal, http, assets, fonts, timeoutMs });
|
|
14
|
+
return service.create(width, height, { scale, background });
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export { CanvasService };
|
|
18
|
+
export type { CanvasBuilder, CanvasRuntimeOptions, CanvasHostOptions, CanvasSendOptions } from '../services/canvas.js';
|
|
19
|
+
export type * from '../domain/canvas.js';
|
|
20
|
+
export { CANVAS_LIMITS };
|
package/src/canvas.ts
CHANGED
|
@@ -1,20 +1,72 @@
|
|
|
1
1
|
import { CANVAS_LIMITS } from './domain/canvas.js';
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
export
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
)
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
2
|
+
import { canvasDependency, napi } from './infrastructure/canvas/napi.js';
|
|
3
|
+
import { loadCanvasImage, registerCanvasFonts } from './services/canvas-image.js';
|
|
4
|
+
import type { CanvasLoadImageOptions, CanvasLoadImageSource } from './services/canvas-image.js';
|
|
5
|
+
import { YuzuhaError } from './shared/errors.js';
|
|
6
|
+
|
|
7
|
+
export type { CanvasLoadImageOptions };
|
|
8
|
+
export type * from '@napi-rs/canvas';
|
|
9
|
+
|
|
10
|
+
const missing = () => new Proxy(function () { throw canvasDependency(); }, {
|
|
11
|
+
get(target, property) {
|
|
12
|
+
if (property === 'prototype') return target.prototype;
|
|
13
|
+
throw canvasDependency();
|
|
14
|
+
},
|
|
15
|
+
construct() { throw canvasDependency(); },
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
export const Canvas = (napi?.Canvas ?? missing()) as typeof import('@napi-rs/canvas').Canvas;
|
|
19
|
+
export const Image = (napi?.Image ?? missing()) as typeof import('@napi-rs/canvas').Image;
|
|
20
|
+
export const Path2D = (napi?.Path2D ?? missing()) as typeof import('@napi-rs/canvas').Path2D;
|
|
21
|
+
export const ImageData = (napi?.ImageData ?? missing()) as typeof import('@napi-rs/canvas').ImageData;
|
|
22
|
+
export const DOMMatrix = (napi?.DOMMatrix ?? missing()) as typeof import('@napi-rs/canvas').DOMMatrix;
|
|
23
|
+
export const DOMRect = (napi?.DOMRect ?? missing()) as typeof import('@napi-rs/canvas').DOMRect;
|
|
24
|
+
export const DOMPoint = (napi?.DOMPoint ?? missing()) as typeof import('@napi-rs/canvas').DOMPoint;
|
|
25
|
+
export const FontKey = (napi?.FontKey ?? missing()) as typeof import('@napi-rs/canvas').FontKey;
|
|
26
|
+
export const PDFDocument = (napi?.PDFDocument ?? missing()) as typeof import('@napi-rs/canvas').PDFDocument;
|
|
27
|
+
export const GifEncoder = (napi?.GifEncoder ?? missing()) as typeof import('@napi-rs/canvas').GifEncoder;
|
|
28
|
+
export const LottieAnimation = (napi?.LottieAnimation ?? missing()) as typeof import('@napi-rs/canvas').LottieAnimation;
|
|
29
|
+
export const GlobalFonts = (napi?.GlobalFonts ?? missing()) as typeof import('@napi-rs/canvas').GlobalFonts;
|
|
30
|
+
export const PathOp = (napi?.PathOp ?? missing()) as typeof import('@napi-rs/canvas').PathOp;
|
|
31
|
+
export const FillType = (napi?.FillType ?? missing()) as typeof import('@napi-rs/canvas').FillType;
|
|
32
|
+
export const StrokeCap = (napi?.StrokeCap ?? missing()) as typeof import('@napi-rs/canvas').StrokeCap;
|
|
33
|
+
export const StrokeJoin = (napi?.StrokeJoin ?? missing()) as typeof import('@napi-rs/canvas').StrokeJoin;
|
|
34
|
+
export const SvgExportFlag = (napi?.SvgExportFlag ?? missing()) as typeof import('@napi-rs/canvas').SvgExportFlag;
|
|
35
|
+
export const GifDisposal = (napi?.GifDisposal ?? missing()) as typeof import('@napi-rs/canvas').GifDisposal;
|
|
36
|
+
export const ChromaSubsampling = (napi?.ChromaSubsampling ?? missing()) as typeof import('@napi-rs/canvas').ChromaSubsampling;
|
|
37
|
+
export const SVGCanvas: any = (napi as any)?.SVGCanvas ?? missing();
|
|
38
|
+
export const CanvasElement: any = (napi as any)?.CanvasElement ?? missing();
|
|
39
|
+
|
|
40
|
+
export function createCanvas(width: number, height: number): import('@napi-rs/canvas').Canvas;
|
|
41
|
+
export function createCanvas(width: number, height: number, svgExportFlag: import('@napi-rs/canvas').SvgExportFlag): import('@napi-rs/canvas').SvgCanvas;
|
|
42
|
+
export function createCanvas(width: number, height: number, svgExportFlag?: import('@napi-rs/canvas').SvgExportFlag) {
|
|
43
|
+
if (!Number.isSafeInteger(width) || !Number.isSafeInteger(height) || width < 1 || height < 1) {
|
|
44
|
+
throw new YuzuhaError('CANVAS_OPTIONS', 'Largura e altura devem ser inteiros positivos.');
|
|
45
|
+
}
|
|
46
|
+
if (width > CANVAS_LIMITS.maxPhysicalDimension || height > CANVAS_LIMITS.maxPhysicalDimension
|
|
47
|
+
|| width * height > CANVAS_LIMITS.maxPixels) {
|
|
48
|
+
throw new YuzuhaError('CANVAS_OPTIONS', 'Dimensões físicas excedem os limites do Canvas.');
|
|
49
|
+
}
|
|
50
|
+
if (!napi) throw canvasDependency();
|
|
51
|
+
return svgExportFlag === undefined ? napi.createCanvas(width, height) : napi.createCanvas(width, height, svgExportFlag);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export async function loadImage(source: CanvasLoadImageSource, options: CanvasLoadImageOptions = {}): Promise<import('@napi-rs/canvas').Image> {
|
|
55
|
+
if (!napi) throw canvasDependency();
|
|
56
|
+
return loadCanvasImage(napi, source, options);
|
|
15
57
|
}
|
|
16
58
|
|
|
17
|
-
export
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
59
|
+
export function clearAllCache(): void {
|
|
60
|
+
if (!napi) throw canvasDependency();
|
|
61
|
+
napi.clearAllCache();
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export function convertSVGTextToPath(svg: Buffer | string): Buffer {
|
|
65
|
+
if (!napi) throw canvasDependency();
|
|
66
|
+
return napi.convertSVGTextToPath(svg);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export function registerFonts(dir: string): number {
|
|
70
|
+
if (!napi) throw canvasDependency();
|
|
71
|
+
return registerCanvasFonts(napi, dir);
|
|
72
|
+
}
|
package/src/cli/config.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { pathToFileURL } from 'node:url';
|
|
|
4
4
|
import { parseEnv } from 'node:util';
|
|
5
5
|
import { importModule } from '../framework/module-loader.js';
|
|
6
6
|
import { Yuzuha } from '../bot.js';
|
|
7
|
+
import { functions } from '../functions.js';
|
|
7
8
|
import type { YuzuhaConfig } from '../config.js';
|
|
8
9
|
import { YuzuhaError } from '../errors.js';
|
|
9
10
|
|
|
@@ -33,7 +34,7 @@ export async function configuredBot(path: string, environment: boolean, loadComm
|
|
|
33
34
|
if (!module.default || typeof module.default !== 'object' || Array.isArray(module.default)) throw new YuzuhaError('CONFIG_INVALID', 'Config deve exportar um objeto default.');
|
|
34
35
|
const config = module.default as YuzuhaConfig;
|
|
35
36
|
if ((config.commands !== undefined && typeof config.commands !== 'string') || (config.setup !== undefined && typeof config.setup !== 'function')) throw new YuzuhaError('CONFIG_INVALID', 'commands deve ser texto e setup deve ser uma função.');
|
|
36
|
-
const bot = new Yuzuha(config);
|
|
37
|
+
const bot = new Yuzuha({ ...config, engine: config.engine ?? functions() });
|
|
37
38
|
try {
|
|
38
39
|
await config.setup?.(bot);
|
|
39
40
|
const commandsPath = resolve(directory, config.commands ?? 'commands');
|
package/src/cli/lint.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { lstat, readFile, readdir } from 'node:fs/promises';
|
|
2
2
|
import { extname, join, resolve } from 'node:path';
|
|
3
|
-
import { registerBuiltins } from '../functions.js';
|
|
4
|
-
import { Runtime } from '../runtime.js';
|
|
3
|
+
import { registerBuiltins, Runtime } from '../functions.js';
|
|
5
4
|
import { YuzuhaError } from '../errors.js';
|
|
6
5
|
import { documentDiagnostics, mergeFunctionCatalogs, parseFunctionCatalog } from '../tooling/language.js';
|
|
7
6
|
import type { FunctionMetadata, ScriptDiagnostic } from '../tooling/language.js';
|
package/src/cli/main.ts
CHANGED
|
@@ -6,8 +6,7 @@ import { stat } from 'node:fs/promises';
|
|
|
6
6
|
import { resolve } from 'node:path';
|
|
7
7
|
import { Yuzuha } from '../bot.js';
|
|
8
8
|
import { ScriptError, YuzuhaError } from '../errors.js';
|
|
9
|
-
import { registerBuiltins } from '../functions.js';
|
|
10
|
-
import { Runtime } from '../runtime.js';
|
|
9
|
+
import { functions, registerBuiltins, Runtime } from '../functions.js';
|
|
11
10
|
import { parseArguments, usage } from './arguments.js';
|
|
12
11
|
import { configuredBot, findConfig } from './config.js';
|
|
13
12
|
import { runBot } from './runner.js';
|
|
@@ -58,25 +57,25 @@ export async function main(args = process.argv.slice(2)): Promise<void> {
|
|
|
58
57
|
try {
|
|
59
58
|
if (options.config) {
|
|
60
59
|
({ bot: catalogBot } = await configuredBot(await findConfig(options.config), false, false));
|
|
61
|
-
all = catalogBot.
|
|
60
|
+
all = catalogBot.engine!.functions();
|
|
62
61
|
} else all = registerBuiltins(new Runtime()).functions();
|
|
63
62
|
} finally { if (catalogBot) { await catalogBot.destroy(); await catalogBot.options.store?.close?.(); } }
|
|
64
63
|
|
|
65
64
|
const builtinNames = options.pluginsOnly ? new Set(registerBuiltins(new Runtime()).functions().map(fn => fn.name.replace(/^\$/, '').toLowerCase())) : undefined;
|
|
66
65
|
const visible = builtinNames ? all.filter(fn => !builtinNames.has(fn.name.replace(/^\$/, '').toLowerCase())) : all;
|
|
67
|
-
let
|
|
68
|
-
if (options.category && !
|
|
66
|
+
let entries = options.category ? visible.filter(fn => fn.category === options.category) : visible;
|
|
67
|
+
if (options.category && !entries.length) throw new YuzuhaError('CATEGORY', `Categoria desconhecida. Escolha: ${[...new Set(all.map(fn => fn.category))].join(', ')}.`);
|
|
69
68
|
if (options.search !== undefined) {
|
|
70
69
|
const term = options.search.toLowerCase();
|
|
71
|
-
|
|
70
|
+
entries = entries.filter(fn => [fn.name, ...(fn.aliases ?? []), fn.description].some(value => value.toLowerCase().includes(term)));
|
|
72
71
|
}
|
|
73
|
-
const metadata =
|
|
74
|
-
console.log(options.catalog ? JSON.stringify({ version: 1, functions: metadata }, null, 2) : options.json ? JSON.stringify(metadata, null, 2) : options.search !== undefined && !
|
|
72
|
+
const metadata = entries.map(({ execute: _execute, ...value }) => value);
|
|
73
|
+
console.log(options.catalog ? JSON.stringify({ version: 1, functions: metadata }, null, 2) : options.json ? JSON.stringify(metadata, null, 2) : options.search !== undefined && !entries.length ? 'Nenhuma função encontrada.' : entries.map(fn => `${fn.usage.padEnd(52)} ${fn.description}`).join('\n'));
|
|
75
74
|
return;
|
|
76
75
|
}
|
|
77
76
|
let bot: Yuzuha, commandsPath: string;
|
|
78
77
|
if (options.action === 'check' && options.input && (await stat(resolve(options.input))).isDirectory()) {
|
|
79
|
-
bot = new Yuzuha(); commandsPath = resolve(options.input);
|
|
78
|
+
bot = new Yuzuha({ engine: functions() }); commandsPath = resolve(options.input);
|
|
80
79
|
try { await bot.load(commandsPath); } catch (error) { await bot.destroy(); throw error; }
|
|
81
80
|
} else ({ bot, commandsPath } = await configuredBot(await findConfig(options.input), options.action !== 'check'));
|
|
82
81
|
if (options.action === 'check') {
|
package/src/cli/scaffold.ts
CHANGED
|
@@ -47,7 +47,7 @@ export async function scaffold(directory: string, language: 'js' | 'ts', functio
|
|
|
47
47
|
'package.json': `${JSON.stringify(manifest, null, 2)}\n`,
|
|
48
48
|
'.env.example': 'FLUXER_BOT_TOKEN=\n',
|
|
49
49
|
'.gitignore': 'node_modules/\n.env\ndata/\n',
|
|
50
|
-
[`yuzuha.config.${language}`]: `import { defineConfig } from 'yuzuha';\n\nexport default defineConfig({\n name: ${JSON.stringify(name)},\n prefix: '!',\n commands: './commands'
|
|
50
|
+
[`yuzuha.config.${language}`]: `import { defineConfig } from 'yuzuha';\n${functions ? "import { functions } from 'yuzuha/functions';\n" : ''}\nexport default defineConfig({\n name: ${JSON.stringify(name)},\n prefix: '!',\n commands: './commands',${functions ? '\n engine: functions(),' : ''}\n});\n`,
|
|
51
51
|
'README.md': `# ${name}\n\nBot do Fluxer com Yuzuha.\n\n1. Execute \`npm install\`.\n2. Execute \`npm run check\` e \`npm test\` para validar offline.\n3. Copie \`.env.example\` para \`.env\` e preencha o token.\n4. Execute \`npm run dev\` ou \`npm start\`.\n\n${template ? templateReadme(template) : 'Comandos: `!ping`, `!hello`, `!ban @membro motivo`.'}${functions ? '\nFunction mode: `!eco texto`.' : ''}\n\n${local ? 'A dependência local aponta para a instalação que gerou este projeto. Para compartilhar, troque-a pela versão publicada no npm.' : 'A dependência do Yuzuha usa a versão do npm, permitindo instalar o projeto em outra máquina.'}\nO teste de exemplo usa \`yuzuha/testing\`, sem token nem conexão ao Fluxer.\nCasos e variáveis ficam no diretório XDG de dados do Yuzuha, sob o nome deste bot.\n`,
|
|
52
52
|
};
|
|
53
53
|
if (template) {
|
package/src/cli/scenarios.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { Yuzuha } from '../bot.js';
|
|
|
4
4
|
import type { DispatchResult } from '../framework/options.js';
|
|
5
5
|
import type { Command } from '../commands/definition.js';
|
|
6
6
|
import type { Payload } from '../domain/messages.js';
|
|
7
|
+
import { functions } from '../functions.js';
|
|
7
8
|
import { MemoryStore } from '../infrastructure/storage/memory.js';
|
|
8
9
|
import { permission } from '../domain/permissions.js';
|
|
9
10
|
import { YuzuhaError } from '../errors.js';
|
|
@@ -124,7 +125,7 @@ export async function executeScenarios(suite: ScenarioSuite): Promise<ScenarioRe
|
|
|
124
125
|
...(member.topRoleID === undefined ? {} : { topRoleID: member.topRoleID }) });
|
|
125
126
|
}
|
|
126
127
|
const bot = new Yuzuha({ prefix: scenario.prefix ?? '!', store, transport, resources: mockResources(),
|
|
127
|
-
scheduler: false, http: false, limits: { timeoutMs: 1000, calls: 10_000, output: 100_000 },
|
|
128
|
+
scheduler: false, http: false, engine: functions({ limits: { timeoutMs: 1000, calls: 10_000, output: 100_000 } }),
|
|
128
129
|
onError: error => { errors.push(error instanceof YuzuhaError ? error.code : 'ERROR'); } });
|
|
129
130
|
const result: ScenarioResult = { name: scenario.name, passed: true, messages: [] };
|
|
130
131
|
try {
|
package/src/commands/context.ts
CHANGED
|
@@ -153,7 +153,9 @@ export class CommandContext {
|
|
|
153
153
|
await this.resources.users.leaveGuild(guildID);
|
|
154
154
|
}
|
|
155
155
|
get mod(): NativeModeration {
|
|
156
|
-
return this.nativeMod ??= new NativeModeration(
|
|
156
|
+
return this.nativeMod ??= new NativeModeration(
|
|
157
|
+
(action, target, reason, options) => this.moderate(action, target, reason, options),
|
|
158
|
+
(action, targetID) => this.moderation.canModerate(action, targetID));
|
|
157
159
|
}
|
|
158
160
|
get data(): NativeData {
|
|
159
161
|
return this.nativeData ??= Object.freeze({
|
|
@@ -186,11 +188,16 @@ export class CommandContext {
|
|
|
186
188
|
const source = bindAuthorizedResources(this.nativeResources, this.transport, { guildID: this.guildID, authorID: this.authorID }), collectors = source.collectors;
|
|
187
189
|
return this.scopedResources = { users: source.users, roles: source.roles, channels: source.channels,
|
|
188
190
|
messages: source.messages, webhooks: source.webhooks, expressions: source.expressions,
|
|
189
|
-
threads: source.threads, invites: source.invites,
|
|
191
|
+
threads: source.threads, invites: source.invites, gateway: source.gateway,
|
|
192
|
+
instance: source.instance, self: source.self, cache: source.cache, collectors: {
|
|
190
193
|
awaitMessage: (channelID, input) => collectors.awaitMessage(channelID, { ...input,
|
|
191
194
|
signal: input.signal ? AbortSignal.any([this.signal, input.signal]) : this.signal }),
|
|
192
195
|
awaitReaction: (channelID, messageID, emojis, timeMs, userID, signal) => collectors.awaitReaction(
|
|
193
196
|
channelID, messageID, emojis, timeMs, userID, signal ? AbortSignal.any([this.signal, signal]) : this.signal),
|
|
197
|
+
collectMessages: (channelID, input) => collectors.collectMessages(channelID, { ...input,
|
|
198
|
+
signal: input.signal ? AbortSignal.any([this.signal, input.signal]) : this.signal }),
|
|
199
|
+
collectReactions: (channelID, input) => collectors.collectReactions(channelID, { ...input,
|
|
200
|
+
signal: input.signal ? AbortSignal.any([this.signal, input.signal]) : this.signal }),
|
|
194
201
|
} };
|
|
195
202
|
}
|
|
196
203
|
get scheduler(): Scheduler {
|
|
@@ -32,3 +32,34 @@ export function emojiBatch(input: unknown): { name: string; image: string }[] {
|
|
|
32
32
|
return { name, image };
|
|
33
33
|
});
|
|
34
34
|
}
|
|
35
|
+
|
|
36
|
+
export function stickerBatch(input: unknown): { name: string; image: string; description?: string; tags?: string[] }[] {
|
|
37
|
+
if (!Array.isArray(input) || input.length < 1 || input.length > 50) {
|
|
38
|
+
throw new YuzuhaError('STICKER_BATCH', 'Informe de 1 a 50 figurinhas.');
|
|
39
|
+
}
|
|
40
|
+
let bytes = 0;
|
|
41
|
+
const names = new Set<string>();
|
|
42
|
+
return input.map((item: unknown) => {
|
|
43
|
+
if (!item || typeof item !== 'object' || !Object.hasOwn(item, 'name') || !Object.hasOwn(item, 'image')) {
|
|
44
|
+
throw new YuzuhaError('STICKER_BATCH', 'Cada figurinha deve informar name e image em base64.');
|
|
45
|
+
}
|
|
46
|
+
const { name, image, description, tags } = item as { name: unknown; image: unknown; description: unknown; tags: unknown };
|
|
47
|
+
if (typeof name !== 'string' || name.length < 2 || name.length > 32 || names.has(name)) {
|
|
48
|
+
throw new YuzuhaError('STICKER_NAME', 'Nomes de figurinhas devem ser únicos, com 2 a 32 caracteres.');
|
|
49
|
+
}
|
|
50
|
+
names.add(name);
|
|
51
|
+
if (typeof image !== 'string' || !image || image.length > 13_333_336
|
|
52
|
+
|| image.length % 4 !== 0 || !/^[A-Za-z0-9+/]+={0,2}$/.test(image)) {
|
|
53
|
+
throw new YuzuhaError('STICKER_IMAGE', 'Imagem deve ser base64 válido, sem prefixo data:.');
|
|
54
|
+
}
|
|
55
|
+
if (description !== undefined && typeof description !== 'string') {
|
|
56
|
+
throw new YuzuhaError('STICKER_BATCH', 'description deve ser texto.');
|
|
57
|
+
}
|
|
58
|
+
if (tags !== undefined && (!Array.isArray(tags) || tags.some(tag => typeof tag !== 'string'))) {
|
|
59
|
+
throw new YuzuhaError('STICKER_BATCH', 'tags deve ser uma lista de textos.');
|
|
60
|
+
}
|
|
61
|
+
bytes += image.length / 4 * 3 - (image.endsWith('==') ? 2 : image.endsWith('=') ? 1 : 0);
|
|
62
|
+
if (bytes > 10_000_000) throw new YuzuhaError('STICKER_BATCH', 'Imagens devem somar até 10 MB.');
|
|
63
|
+
return { name, image, ...(description === undefined ? {} : { description }), ...(tags === undefined ? {} : { tags }) };
|
|
64
|
+
});
|
|
65
|
+
}
|
package/src/framework/bot.ts
CHANGED
|
@@ -12,10 +12,8 @@ import type { NativeCommandDefinition } from '../commands/definition.js';
|
|
|
12
12
|
import type { ArgumentSchema } from '../commands/builders.js';
|
|
13
13
|
import type { IncomingMessage, Store, Transport } from '../contracts.js';
|
|
14
14
|
import { GuardError, PartialModerationError, YuzuhaError } from '../errors.js';
|
|
15
|
-
import { registerBuiltins } from '../functions.js';
|
|
16
|
-
import { Runtime, defaultLimits, text } from '../runtime.js';
|
|
17
15
|
import { JsonStore, defaultDataPath } from '../store.js';
|
|
18
|
-
import { CommandRegistry } from './command-registry.js';
|
|
16
|
+
import { CommandRegistry, functionsRequired } from './command-registry.js';
|
|
19
17
|
import type { CompiledCommand } from './command-registry.js';
|
|
20
18
|
import { runMiddleware } from './middleware.js';
|
|
21
19
|
import type { DispatchResult, Middleware, YuzuhaOptions, YuzuhaPlugin } from './options.js';
|
|
@@ -32,7 +30,7 @@ import { cancellationError } from '../services/cancellation.js';
|
|
|
32
30
|
import { EventContext } from '../commands/event-context.js';
|
|
33
31
|
import { adaptScriptEvent, scriptEventNames, validateScriptEvent } from './script-events.js';
|
|
34
32
|
import type { ScriptEventDefinition } from './script-events.js';
|
|
35
|
-
import type {
|
|
33
|
+
import type { ScriptEngine } from '../ports/script-engine.js';
|
|
36
34
|
import type { MusicManager } from '../services/music.js';
|
|
37
35
|
import type { NativeVoice } from '../ports/voice.js';
|
|
38
36
|
import { canvasRenderer } from '../infrastructure/canvas/render.js';
|
|
@@ -40,6 +38,14 @@ import { canvasRenderer } from '../infrastructure/canvas/render.js';
|
|
|
40
38
|
type RoutedCommand = { compiled: CompiledCommand; input: string; prefix: string };
|
|
41
39
|
const ignored: Promise<DispatchResult> = Promise.resolve('ignored');
|
|
42
40
|
|
|
41
|
+
function assertEngine(engine: unknown): ScriptEngine {
|
|
42
|
+
const candidate = engine as Partial<Record<keyof ScriptEngine, unknown>> | null | undefined;
|
|
43
|
+
if (!candidate || (['compile', 'execute', 'functions', 'registerAll', 'fork', 'text'] as const).some(key => typeof candidate[key] !== 'function')) {
|
|
44
|
+
throw new YuzuhaError('ENGINE_INVALID', 'Engine de function mode inválido: precisa de compile, execute, functions, registerAll, fork e text.');
|
|
45
|
+
}
|
|
46
|
+
return engine as ScriptEngine;
|
|
47
|
+
}
|
|
48
|
+
|
|
43
49
|
export class Yuzuha {
|
|
44
50
|
readonly client: Client;
|
|
45
51
|
readonly transport: Transport;
|
|
@@ -49,7 +55,7 @@ export class Yuzuha {
|
|
|
49
55
|
readonly http?: HttpService;
|
|
50
56
|
readonly music?: MusicManager;
|
|
51
57
|
readonly voice?: NativeVoice;
|
|
52
|
-
|
|
58
|
+
private scriptEngine?: ScriptEngine;
|
|
53
59
|
private readonly registry: CommandRegistry;
|
|
54
60
|
private readonly middleware: Middleware[] = [];
|
|
55
61
|
private readonly plugins = new Set<string>();
|
|
@@ -59,7 +65,6 @@ export class Yuzuha {
|
|
|
59
65
|
private readonly events: NativeEvents;
|
|
60
66
|
private readonly execution = new AsyncLocalStorage<boolean>();
|
|
61
67
|
private listening = false;
|
|
62
|
-
private functionsReady = false;
|
|
63
68
|
private closing = false;
|
|
64
69
|
private closeTask?: Promise<void>;
|
|
65
70
|
private loginTask?: Promise<void>;
|
|
@@ -103,8 +108,8 @@ export class Yuzuha {
|
|
|
103
108
|
this.http = options.http === false ? undefined : options.http ?? new HttpService();
|
|
104
109
|
this.music = options.music;
|
|
105
110
|
this.voice = options.voice;
|
|
106
|
-
this.
|
|
107
|
-
this.registry = new CommandRegistry(
|
|
111
|
+
if (options.engine !== undefined) this.scriptEngine = assertEngine(options.engine);
|
|
112
|
+
this.registry = new CommandRegistry(() => this.scriptEngine, command => {
|
|
108
113
|
if (command.http) (this.http ?? new HttpService()).withPolicy(command.http);
|
|
109
114
|
});
|
|
110
115
|
this.events = new NativeEvents(this.client, work => this.scheduleEvent(work));
|
|
@@ -114,12 +119,14 @@ export class Yuzuha {
|
|
|
114
119
|
this.client.on(Events.ShardError, this.shardErrorListener);
|
|
115
120
|
}
|
|
116
121
|
|
|
117
|
-
/**
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
122
|
+
/** Engine de function mode instalado, quando presente. */
|
|
123
|
+
get engine(): ScriptEngine | undefined { return this.scriptEngine; }
|
|
124
|
+
|
|
125
|
+
/** Instala o motor de function mode; exigido por comandos com `code` e eventos de script. */
|
|
126
|
+
useEngine(engine: ScriptEngine): this {
|
|
127
|
+
if (this.closing) throw new YuzuhaError('BOT_CLOSED', 'O bot está encerrado.');
|
|
128
|
+
if (this.scriptEngine) throw new YuzuhaError('ENGINE_INSTALLED', 'O bot já tem um engine de function mode.');
|
|
129
|
+
this.scriptEngine = assertEngine(engine);
|
|
123
130
|
return this;
|
|
124
131
|
}
|
|
125
132
|
|
|
@@ -140,13 +147,15 @@ export class Yuzuha {
|
|
|
140
147
|
hasScript = typeof command.code === 'string';
|
|
141
148
|
if (Array.isArray(command.subcommands)) pending.push(...command.subcommands);
|
|
142
149
|
}
|
|
143
|
-
if (hasScript
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
const
|
|
150
|
+
if (hasScript || plugin.functions?.length) {
|
|
151
|
+
if (!this.scriptEngine) throw functionsRequired();
|
|
152
|
+
}
|
|
153
|
+
const stagedEngine = this.scriptEngine?.fork();
|
|
154
|
+
stagedEngine?.registerAll(plugin.functions ?? []);
|
|
155
|
+
const commitCommands = this.registry.prepare(plugin.commands ?? [], stagedEngine);
|
|
147
156
|
for (const event of plugin.events ?? []) this.events.validate(event);
|
|
148
|
-
const scriptEvents = (plugin.scriptEvents ?? []).map(event => this.prepareScriptEvent(event,
|
|
149
|
-
this.
|
|
157
|
+
const scriptEvents = (plugin.scriptEvents ?? []).map(event => this.prepareScriptEvent(event, stagedEngine));
|
|
158
|
+
this.scriptEngine?.registerAll(plugin.functions ?? []);
|
|
150
159
|
commitCommands();
|
|
151
160
|
this.middleware.push(...(plugin.middleware ?? []));
|
|
152
161
|
for (const event of plugin.events ?? []) this.events.add(event);
|
|
@@ -166,6 +175,12 @@ export class Yuzuha {
|
|
|
166
175
|
listCommands(): Command[] { return this.registry.list(); }
|
|
167
176
|
help(command?: string, prefix = ''): string { return this.registry.help(command, prefix); }
|
|
168
177
|
get signal(): AbortSignal { return this.shutdown.signal; }
|
|
178
|
+
isReady(): boolean { return this.client.isReady(); }
|
|
179
|
+
get uptime(): number | null { return this.client.uptime; }
|
|
180
|
+
assertReady(): void {
|
|
181
|
+
try { this.client.assertReady(); }
|
|
182
|
+
catch { throw new YuzuhaError('BOT_NOT_READY', 'O bot ainda não está pronto.'); }
|
|
183
|
+
}
|
|
169
184
|
|
|
170
185
|
on<K extends ClientEventName>(event: K, listener: NativeListener<K>): this {
|
|
171
186
|
this.events.add(defineEvent({ event, run: listener }), listener); return this;
|
|
@@ -202,18 +217,19 @@ export class Yuzuha {
|
|
|
202
217
|
|
|
203
218
|
scriptEvent(definition: ScriptEventDefinition): this {
|
|
204
219
|
if (this.closing) throw new YuzuhaError('BOT_CLOSED', 'O bot está encerrado.');
|
|
205
|
-
this.
|
|
220
|
+
if (!this.scriptEngine) throw functionsRequired();
|
|
206
221
|
this.events.add(this.prepareScriptEvent(definition));
|
|
207
222
|
return this;
|
|
208
223
|
}
|
|
209
|
-
private prepareScriptEvent(definition: ScriptEventDefinition,
|
|
224
|
+
private prepareScriptEvent(definition: ScriptEventDefinition, engine = this.scriptEngine): NativeEvent {
|
|
225
|
+
if (!engine) throw functionsRequired();
|
|
210
226
|
validateScriptEvent(definition);
|
|
211
227
|
const options = structuredClone(definition);
|
|
212
228
|
if (options.http) (this.http ?? new HttpService()).withPolicy(options.http);
|
|
213
|
-
const program =
|
|
214
|
-
return { event: options.event, once: options.once ?? false, invoke: args => this.runScriptEvent(options, program, args) };
|
|
229
|
+
const program = engine.compile(options.code, `<event:${options.event}>`);
|
|
230
|
+
return { event: options.event, once: options.once ?? false, invoke: args => this.runScriptEvent(options, program, args, engine) };
|
|
215
231
|
}
|
|
216
|
-
private async runScriptEvent(definition: ScriptEventDefinition, program:
|
|
232
|
+
private async runScriptEvent(definition: ScriptEventDefinition, program: unknown, args: unknown[], engine: ScriptEngine): Promise<void> {
|
|
217
233
|
const source = adaptScriptEvent(definition.event, args);
|
|
218
234
|
if ((definition.ignoreBots ?? true) && source.event.userBot) return;
|
|
219
235
|
const signal = this.shutdown.signal;
|
|
@@ -225,7 +241,7 @@ export class Yuzuha {
|
|
|
225
241
|
let outcome: DispatchResult = 'success';
|
|
226
242
|
try {
|
|
227
243
|
if (this.options.onLog) await emitLog(this.options, { event: 'event.start', executionID: ctx.executionID, command: ctx.command.name });
|
|
228
|
-
const output = text(await
|
|
244
|
+
const output = engine.text(await engine.execute(program, ctx)).trim();
|
|
229
245
|
if (output) {
|
|
230
246
|
if (!ctx.channelID) throw new GuardError('Defina um canal para a saída deste evento.');
|
|
231
247
|
await ctx.send(output, ctx.channelID);
|
|
@@ -394,7 +410,8 @@ export class Yuzuha {
|
|
|
394
410
|
}
|
|
395
411
|
const execute = async () => {
|
|
396
412
|
if (compiled.program) {
|
|
397
|
-
const
|
|
413
|
+
const programEngine = (compiled as { programEngine?: ScriptEngine }).programEngine ?? this.scriptEngine!;
|
|
414
|
+
const output = programEngine.text(await programEngine.execute(compiled.program, current)).trim();
|
|
398
415
|
if (output) await current.reply(output);
|
|
399
416
|
} else if (compiled.command.run) await compiled.command.run(current);
|
|
400
417
|
else throw new GuardError(`${resolved.input ? 'Subcomando desconhecido.\n' : ''}${this.help(compiled.command.name, prefix)}`);
|
|
@@ -5,15 +5,15 @@ import type { Command } from '../context.js';
|
|
|
5
5
|
import { parseDuration } from '../context.js';
|
|
6
6
|
import { YuzuhaError } from '../errors.js';
|
|
7
7
|
import { loadCommands } from '../loader.js';
|
|
8
|
-
import type { Program } from '../parser.js';
|
|
9
8
|
import { permission } from '../permissions.js';
|
|
10
|
-
import type {
|
|
9
|
+
import type { ScriptEngine } from '../ports/script-engine.js';
|
|
11
10
|
import type { HttpPolicy } from '../services/http.js';
|
|
12
11
|
|
|
13
12
|
export interface CompiledCommand {
|
|
14
13
|
command: Command;
|
|
15
14
|
definition: Command;
|
|
16
|
-
program?:
|
|
15
|
+
program?: unknown;
|
|
16
|
+
programEngine?: ScriptEngine;
|
|
17
17
|
directory?: string;
|
|
18
18
|
children: Map<string, CompiledCommand>;
|
|
19
19
|
lineage: Command[];
|
|
@@ -62,13 +62,17 @@ function inheritedHttp(parent?: HttpPolicy, child?: HttpPolicy): HttpPolicy | un
|
|
|
62
62
|
return policy;
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
+
export function functionsRequired(): YuzuhaError {
|
|
66
|
+
return new YuzuhaError('FUNCTIONS_REQUIRED', 'Function mode requer um engine. Use import { functions } from \'yuzuha/functions\' e passe engine: functions() nas opções do bot.');
|
|
67
|
+
}
|
|
68
|
+
|
|
65
69
|
export class CommandRegistry {
|
|
66
70
|
private entries = new Map<string, CompiledCommand>();
|
|
67
71
|
private loading: Promise<unknown> = Promise.resolve();
|
|
68
|
-
constructor(private readonly
|
|
72
|
+
constructor(private readonly engine: () => ScriptEngine | undefined,
|
|
69
73
|
private readonly validate: (command: Command) => void = () => {}) {}
|
|
70
74
|
|
|
71
|
-
private compile(input: Command, directory?: string,
|
|
75
|
+
private compile(input: Command, directory?: string, engine = this.engine(), ancestors: CompiledCommand[] = [], seen = new Set<Command>()): CompiledCommand {
|
|
72
76
|
if (ancestors.length >= 32 || seen.has(input)) throw new YuzuhaError('COMMAND_TREE', 'Árvore de comandos cíclica ou com mais de 32 níveis.');
|
|
73
77
|
validateMetadata(input);
|
|
74
78
|
this.validate(input);
|
|
@@ -93,12 +97,13 @@ export class CommandRegistry {
|
|
|
93
97
|
const ownGuard = { ...definition, name: command.name };
|
|
94
98
|
const entry: CompiledCommand = { command, definition, directory, children: new Map(), lineage: [...ancestors.at(-1)?.lineage ?? [], ownGuard] };
|
|
95
99
|
const visiting = new Set(seen).add(input);
|
|
96
|
-
for (const child of input.subcommands ?? []) this.insert(entry.children, this.compile(child, directory,
|
|
100
|
+
for (const child of input.subcommands ?? []) this.insert(entry.children, this.compile(child, directory, engine, [...ancestors, entry], visiting));
|
|
97
101
|
definition.subcommands = [...new Set(entry.children.values())].map(child => child.definition);
|
|
98
102
|
command.subcommands = definition.subcommands;
|
|
99
103
|
if (command.code !== undefined) {
|
|
100
|
-
|
|
101
|
-
entry.program =
|
|
104
|
+
if (!engine) throw functionsRequired();
|
|
105
|
+
entry.program = engine.compile(command.code, command.file ?? command.name);
|
|
106
|
+
entry.programEngine = engine;
|
|
102
107
|
}
|
|
103
108
|
return entry;
|
|
104
109
|
}
|
|
@@ -116,9 +121,9 @@ export class CommandRegistry {
|
|
|
116
121
|
}
|
|
117
122
|
this.insert(this.entries, entry);
|
|
118
123
|
}
|
|
119
|
-
prepare(commands: Command[],
|
|
124
|
+
prepare(commands: Command[], engine = this.engine()): () => void {
|
|
120
125
|
const next = new Map(this.entries);
|
|
121
|
-
for (const command of commands) this.insert(next, this.compile(command, undefined,
|
|
126
|
+
for (const command of commands) this.insert(next, this.compile(command, undefined, engine));
|
|
122
127
|
return () => { this.entries = next; };
|
|
123
128
|
}
|
|
124
129
|
load(directory: string, mode: 'replace' | 'append' | 'reload'): Promise<void> {
|
package/src/framework/options.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Client, ClientOptions } from '@fluxerjs/core';
|
|
2
2
|
import type { CommandContext } from '../context.js';
|
|
3
3
|
import type { IncomingMessage, Store, Transport } from '../contracts.js';
|
|
4
|
-
import type {
|
|
4
|
+
import type { ScriptEngine, ScriptFunctionDefinition } from '../ports/script-engine.js';
|
|
5
5
|
import type { Command } from '../context.js';
|
|
6
6
|
import type { Resources } from '../ports/resources.js';
|
|
7
7
|
import type { HttpService } from '../services/http.js';
|
|
@@ -17,7 +17,7 @@ export type DispatchResult = 'ignored' | 'success' | 'guarded' | 'error';
|
|
|
17
17
|
export type Middleware = (ctx: CommandContext, next: () => Promise<void>) => Promise<void>;
|
|
18
18
|
export interface YuzuhaPlugin {
|
|
19
19
|
name: string;
|
|
20
|
-
functions?:
|
|
20
|
+
functions?: ScriptFunctionDefinition[];
|
|
21
21
|
middleware?: Middleware[];
|
|
22
22
|
commands?: Command[];
|
|
23
23
|
events?: NativeEvent[];
|
|
@@ -33,7 +33,7 @@ export interface YuzuhaOptions {
|
|
|
33
33
|
name?: string;
|
|
34
34
|
/** Clock shared by cooldowns, variable TTLs and the default scheduler. */
|
|
35
35
|
now?: () => number;
|
|
36
|
-
|
|
36
|
+
engine?: ScriptEngine;
|
|
37
37
|
scheduler?: Scheduler | false;
|
|
38
38
|
http?: HttpService | false;
|
|
39
39
|
music?: MusicManager;
|