Is it possible to use simulator extensions of another extension in own extension

I’m working on a new NeoPixel extension that supports the (easier) use of NeoPixel matrices. For that I forked the old NeoPixel extension from AdaFruit and Microsoft and extended and reworked it and handed it in publication to the Micro:Bit Foundation. They seemed to be quite happy with it but a requirement is that the extension works in its own namespace. This unfortunately seems to break the simulator part. Is there even a possiblity to work around that?

I do not fully understand how simulator extensions work. I know they are linked to an extension. I think that is the reason why changing the namespace breaks it. Removing the @parts and leaving the namespace as it is breaks it too. So I do get that the @parts and @trackArgs are linked to the simulator as well. If you could give me some hints about that I would be greatful.

This is the original namespace and code that works

namespace neopixel {
    /**
     * Create a new NeoPixel driver for `numleds` LEDs with 
     * brightness set to 128 (~50%).
     * @param pin the pin where the neopixel is connected.
     * @param numleds number of leds in the strip, eg: 24,30,60,64
     */
    //% blockId="neopixel_create" 
    //% block="NeoPixel at pin %pin|with %numleds|leds as %mode"
    //% weight=1000
    //% trackArgs=0,2
    //% blockSetVariable=strip
    //% group="Initialization"
    export function create(pin: DigitalPin, numleds: number, mode: NeoPixelMode): Strip {
        let strip = new Strip();
        let stride = mode === NeoPixelMode.RGBW ? 4 : 3;
        strip.buf = pins.createBuffer(numleds * stride);
        strip.start = 0;
        strip._length = numleds;
        strip._matrixDirection = NeoPixelMatrixDirection.LeftTopToTheRight
        strip._mode = mode || NeoPixelMode.RGB;
        strip._matrixWidth = 0;
        strip.setBrightness(128)
        strip.setPin(pin)
        return strip;
    }
// ...
}

As long as I worked inside the namespace of the other extension everything worked without any problems.

My extension can be found here: https://github.com/PasAlt/pxt-neopixel-matrix-extension

I found the solution. You have to create your own pxtparts.json inside your extension and add set your initialization function. Mine now looks like this. neopixelExtended.create is my new initialization method.

{
    "neopixel": {
        "simulationBehavior": "neopixel",
        "visual": {
            "builtIn": "neopixel",
            "width": 58,
            "height": 113,
            "pinDistance": 9,
            "pinLocations": [
                {
                    "x": 10,
                    "y": 0
                },
                {
                    "x": 19,
                    "y": 0
                },
                {
                    "x": 28,
                    "y": 0
                }
            ]
        },
        "numberOfPins": 3,
        "pinDefinitions": [
            {
                "target": {
                    "pinInstantiationIdx": 0
                },
                "style": "croc",
                "orientation": "+Z"
            },
            {
                "target": "threeVolt",
                "style": "croc",
                "orientation": "+Z"
            },
            {
                "target": "ground",
                "style": "croc",
                "orientation": "+Z"
            }
        ],
        "instantiation": {
            "kind": "function",
            "fullyQualifiedName": "neopixelExtended.create",
            "argumentRoles": [
                {
                    "pinInstantiationIdx": 0,
                    "partParameter": "pin"
                },
                {
                    "partParameter": "mode"
                }
            ]
        },
        "assembly": [
            {
                "part": true,
                "pinIndices": [
                    2
                ]
            },
            {
                "pinIndices": [
                    0,
                    1
                ]
            }
        ]
    }
}

You can find a few examples in the pxt-common-packages: https://github.com/Microsoft/pxt-common-packages/blob/master/libs/core/pxtparts.json