From e66be8b3c02819bdca1a18323d03334ddde01398 Mon Sep 17 00:00:00 2001 From: "Github Action (authored by pmalacho-mit)" Date: Tue, 18 Jun 2024 09:55:02 -0700 Subject: [PATCH] type changes --- extensions/src/common/extension/ExtensionBase.ts | 5 ++--- .../src/common/extension/decorators/newBlocks.ts | 4 ++-- .../extension/mixins/base/scratchInfo/index.ts | 1 - extensions/src/common/package.json | 6 ++++-- extensions/src/common/pnpm-lock.yaml | 15 ++++++++++++++- extensions/src/common/types/framework/index.ts | 2 +- extensions/src/common/types/scratch/vm.ts | 3 ++- extensions/src/simple_example/index.ts | 6 ++++++ extensions/src/tsconfig.json | 3 ++- 9 files changed, 33 insertions(+), 12 deletions(-) diff --git a/extensions/src/common/extension/ExtensionBase.ts b/extensions/src/common/extension/ExtensionBase.ts index 5e9becb2b..db691e925 100644 --- a/extensions/src/common/extension/ExtensionBase.ts +++ b/extensions/src/common/extension/ExtensionBase.ts @@ -1,6 +1,5 @@ -import Runtime from "$scratch-vm/engine/runtime"; - -import { AbstractConstructor, Environment, ExlcudeFirst } from "$common/types"; +import { AbstractConstructor, Environment, ExlcudeFirst, } from "$common/types"; +import { Runtime } from "$common/types/scratch/vm"; export type ExtensionConstructorParams = ConstructorParameters; export type AuxiliaryExtensionInfoParams = ExlcudeFirst; diff --git a/extensions/src/common/extension/decorators/newBlocks.ts b/extensions/src/common/extension/decorators/newBlocks.ts index c74b5eb65..a9e4b4a19 100644 --- a/extensions/src/common/extension/decorators/newBlocks.ts +++ b/extensions/src/common/extension/decorators/newBlocks.ts @@ -22,7 +22,7 @@ export function makeDecorator(type: T): TemplateEngi type StaticBlockMetadata = BlockMetadata<(...args: any[]) => any>; const input = typeof builderOrStrings == "function" - ? (instance: ExtensionInstance) => builderOrStrings(instance, process.bind(null, type)) satisfies BlockMetadataFunction + ? (instance: ExtensionInstance) => (builderOrStrings as any)(instance, process.bind(null, type)) satisfies BlockMetadataFunction : process(type, builderOrStrings, ...args) as StaticBlockMetadata; return block(input)(target, context); @@ -68,7 +68,7 @@ interface TemplateEngine { builder: ( instance: This, tag: Utility.TaggedTemplate, BlockMetadata<(...args: Args) => Return>> - ) => BlockMetadata<(...args: Args) => Return> + ) => BlockMetadata<(...args: Args) => Return> ): TypedMethodDecorator Return)>; } diff --git a/extensions/src/common/extension/mixins/base/scratchInfo/index.ts b/extensions/src/common/extension/mixins/base/scratchInfo/index.ts index d95de0f7c..dbab3baf2 100644 --- a/extensions/src/common/extension/mixins/base/scratchInfo/index.ts +++ b/extensions/src/common/extension/mixins/base/scratchInfo/index.ts @@ -4,7 +4,6 @@ import { ArgumentType, BlockType } from "$common/types/enums"; import { BlockOperation, ValueOf, Menu, ExtensionMetadata, ExtensionBlockMetadata, ExtensionMenuMetadata, DynamicMenu, BlockMetadata, BlockUtilityWithID, } from "$common/types"; import { registerButtonCallback } from "$common/ui"; import { isString, typesafeCall, } from "$common/utils"; -import type BlockUtility from "$root/scratch-packages/scratch-vm/src/engine/block-utility"; import { menuProbe, asStaticMenu, getMenuName, convertMenuItemsToString } from "./menus"; import { Handler } from "./handlers"; import { BlockDefinition, getButtonID, isBlockGetter } from "./util"; diff --git a/extensions/src/common/package.json b/extensions/src/common/package.json index 17db01b60..141898beb 100644 --- a/extensions/src/common/package.json +++ b/extensions/src/common/package.json @@ -11,5 +11,7 @@ }, "author": "", "license": "ISC", - "devDependencies": { } -} + "devDependencies": { + "@types/events": "^3.0.3" + } +} \ No newline at end of file diff --git a/extensions/src/common/pnpm-lock.yaml b/extensions/src/common/pnpm-lock.yaml index 9b60ae178..cbc191587 100644 --- a/extensions/src/common/pnpm-lock.yaml +++ b/extensions/src/common/pnpm-lock.yaml @@ -6,4 +6,17 @@ settings: importers: - .: {} + .: + devDependencies: + '@types/events': + specifier: ^3.0.3 + version: 3.0.3 + +packages: + + '@types/events@3.0.3': + resolution: {integrity: sha512-trOc4AAUThEz9hapPtSd7wf5tiQKvTtu5b371UxXdTuqzIh0ArcRspRP0i0Viu+LXstIQ1z96t1nsPxT9ol01g==} + +snapshots: + + '@types/events@3.0.3': {} diff --git a/extensions/src/common/types/framework/index.ts b/extensions/src/common/types/framework/index.ts index 7c4eaf8e2..dbdd4abc9 100644 --- a/extensions/src/common/types/framework/index.ts +++ b/extensions/src/common/types/framework/index.ts @@ -1,6 +1,5 @@ import { Extension } from "$common/extension/GenericExtension"; import type ExtensionManager from "$scratch-vm/extension-support/extension-manager"; -import type Runtime from "$scratch-vm/engine/runtime"; import type BlockUtility from "$scratch-vm/engine/block-utility"; import type { blockIDKey } from "../../globals"; import { ExtensionBlocks } from "./blocks"; @@ -8,6 +7,7 @@ import { Language } from "../enums"; import { MethodNames, ValueOf } from "../utils"; import { ExtensionInstance } from "$common/extension"; import { Tag } from "./tags"; +import { Runtime } from "../scratch/vm"; export type BaseGenericExtension = Extension; diff --git a/extensions/src/common/types/scratch/vm.ts b/extensions/src/common/types/scratch/vm.ts index d2fbb25eb..9fa0eca59 100644 --- a/extensions/src/common/types/scratch/vm.ts +++ b/extensions/src/common/types/scratch/vm.ts @@ -1,4 +1,5 @@ import type * as VmRuntime from "$scratch-vm/engine/runtime"; import { AudioEngine } from "./audio"; +import type { EventEmitter } from "events"; -export type Runtime = Omit & { audioEngine: AudioEngine }; \ No newline at end of file +export type Runtime = Omit & { audioEngine: AudioEngine } & EventEmitter; \ No newline at end of file diff --git a/extensions/src/simple_example/index.ts b/extensions/src/simple_example/index.ts index dfd097f85..c6529d3cf 100644 --- a/extensions/src/simple_example/index.ts +++ b/extensions/src/simple_example/index.ts @@ -139,4 +139,10 @@ export default class SimpleTypescript extends extension(details, "ui", "customSa console.log(blockID); return lhs + 5 - rhs; } + + @(scratch.reporter`Sample ${"string"} async`) + sampleAsync(x: number, y: number) { + //await new Promise((resolve) => setTimeout(resolve, 1000)); + return 5; + } } \ No newline at end of file diff --git a/extensions/src/tsconfig.json b/extensions/src/tsconfig.json index 1562d4779..834fd8302 100644 --- a/extensions/src/tsconfig.json +++ b/extensions/src/tsconfig.json @@ -14,7 +14,8 @@ "lib": [ "dom", "es6", - "dom.iterable" + "dom.iterable", + "ESNext" ] }, "include": [