Compare commits

..

32 Commits
CI ... master

Author SHA1 Message Date
github-actions[bot]
18a970541d Sync to Pumpkin-MC/pumpkin-plugin-wit@39bf330 2026-09-28 07:47:45 +00:00
Demetrius Kanios
dcd04be1bf Use componentize-qjs instead. 2026-09-22 22:06:51 -07:00
Demetrius Kanios
1a9c0d3b8b Bump version to 0.1.1 2026-09-22 17:52:57 -07:00
github-actions[bot]
0651870b4e Sync to Pumpkin-MC/pumpkin-plugin-wit@4d7a501 2026-09-21 16:20:24 +00:00
github-actions[bot]
1e006fc1b3 Sync to Pumpkin-MC/pumpkin-plugin-wit@2366bb9 2026-09-19 21:43:05 +00:00
Demetrius Kanios
fad3142000 Fix artifact renaming in CI 2026-09-04 22:49:38 -07:00
Demetrius Kanios
26fac101a6 Bump version to 0.1.0 2026-09-04 22:44:03 -07:00
github-actions[bot]
c270e277d4 Sync to Pumpkin-MC/pumpkin-plugin-wit@1ad73ff 2026-09-04 20:26:48 +00:00
Demetrius Kanios
8d9b62cd45 Add command suggestion support. 2026-09-01 21:55:38 -07:00
Demetrius Kanios
d70f151db3 Adjust name to be registerChunkGenerator 2026-09-01 21:49:32 -07:00
github-actions[bot]
a356958fde Sync to Pumpkin-MC/pumpkin-plugin-wit@f481f56 2026-08-31 16:58:22 +00:00
github-actions[bot]
7195062565 Sync to Pumpkin-MC/pumpkin-plugin-wit@a1ba8b3 2026-08-27 20:49:00 +00:00
github-actions[bot]
a922b02e0a Sync to Pumpkin-MC/pumpkin-plugin-wit@8339cbf 2026-08-18 16:50:48 +00:00
github-actions[bot]
c5f2cc2caf Sync to Pumpkin-MC/pumpkin-plugin-wit@4edc9b5 2026-08-17 19:00:11 +00:00
Demetrius Kanios
f4e1584c16 Add chunk generation export 2026-08-17 11:57:52 -07:00
github-actions[bot]
37375b5655 Sync to Pumpkin-MC/pumpkin-plugin-wit@54f158f 2026-08-17 07:45:49 +00:00
Demetrius Kanios
9c757e80e6 Relicense under MIT OR Apache-2.0 2026-08-15 10:50:26 -07:00
Demetrius Kanios
60c91447ac AI goals and IPC 2026-08-10 12:36:49 -07:00
Demetrius Kanios
1824ad9afd Use standard 7 character short hash for artifact names 2026-08-10 12:33:57 -07:00
github-actions[bot]
38acf7357c Sync to Pumpkin-MC/pumpkin-plugin-wit@160251f 2026-08-10 19:00:59 +00:00
github-actions[bot]
d5b166e0e1 Sync to Pumpkin-MC/pumpkin-plugin-wit@ab193d1 2026-08-04 19:07:24 +00:00
github-actions[bot]
94e797edc9 Sync to Pumpkin-MC/pumpkin-plugin-wit@ff6acb8 2026-08-04 17:18:14 +00:00
Demetrius Kanios
637169cc80 Use standard 7 character short hash for artifact names 2026-08-03 18:06:24 -07:00
Demetrius Kanios
5bdd9d86f2 Use workflow_run to run main after update-wit instead 2026-08-03 17:58:20 -07:00
Demetrius Kanios
9efb1ccb57 Only update release when appropriate 2026-08-03 17:47:32 -07:00
Demetrius Kanios
a62dca0239 Add example plugin build and run main from update-wit 2026-08-03 16:54:05 -07:00
github-actions[bot]
48acc19760 Sync to Pumpkin-MC/pumpkin-plugin-wit@3f5bbef 2026-08-03 19:26:48 +00:00
Demetrius Kanios
95382a2b65 Update install instructions and version 2026-08-03 10:58:05 -07:00
Demetrius Kanios
73d85af307 Use better release action 2026-08-03 10:38:31 -07:00
github-actions[bot]
f87694aa7a Sync to Pumpkin-MC/pumpkin-plugin-wit@8b875c4 2026-08-03 17:22:56 +00:00
Demetrius Kanios
4058acf68d Add update-wit workflow 2026-08-03 10:22:24 -07:00
Demetrius Kanios
b1ac8d4ec5 Adding rolling CI release 2026-08-03 09:56:06 -07:00
12 changed files with 2719 additions and 672 deletions

82
.github/workflows/main.yml vendored Normal file
View File

@ -0,0 +1,82 @@
name: Main
on:
push:
pull_request:
workflow_dispatch:
workflow_run:
types:
- completed
workflows:
- "Update WIT"
permissions:
contents: write
pull-requests: write
jobs:
main:
name: Build, test, and release
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
with:
submodules: true
- name: Set up Node
uses: actions/setup-node@v6
with:
node-version: 24
package-manager-cache: false
- name: Install dependencies
run: npm install -D
- name: Build
run: npm pack
- name: Build example plugin to test
run: |
set -eux
cd example
npm install ../*.tgz
npm run build
- name: Set GITHUB_RELEASE_TAG & ARTIFACT_ID
run: |
set -eux
if [[ '${{ github.ref }}' = refs/tags/v* ]]; then
tag='${{ github.ref }}'
tag="${tag:10}"
artifactID="${tag:1}"
else
tag=CI
artifactID='${{ github.sha }}'
artifactID="${artifactID:0:7}"
fi
echo "GITHUB_RELEASE_TAG=$tag" >> $GITHUB_ENV
echo "ARTIFACT_ID=$artifactID" >> $GITHUB_ENV
- name: Rename artifacts
run: |
mv pumpkinmc-pumpkin-api-ts-*.tgz pumpkinmc-pumpkin-api-ts.tgz
mv pumpkinmc-pumpkin-api-ts.tgz pumpkinmc-pumpkin-api-ts-${ARTIFACT_ID}.tgz
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
path: pumpkinmc-pumpkin-api-ts-*.tgz
- name: Upload artifacts to release
if: startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/master'
uses: ncipollo/release-action@v1
with:
tag: ${{ env.GITHUB_RELEASE_TAG }}
artifacts: pumpkinmc-pumpkin-api-ts-*.tgz
allowUpdates: true
omitPrereleaseDuringUpdate: true
omitName: true
omitBody: true
omitDraftDuringUpdate: true
removeArtifacts: true

View File

@ -1,47 +0,0 @@
name: Release
on:
push:
tags:
- "v*"
workflow_dispatch:
permissions:
contents: write
pull-requests: write
jobs:
release:
name: Build and release
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
with:
submodules: true
- name: Set up Node
uses: actions/setup-node@v6
with:
node-version: 24
package-manager-cache: false
- name: Install dependencies
run: npm install -D
- name: Build
run: npm pack
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
path: pumpkinmc-pumpkin-api-ts-*.tgz
- name: Upload artifacts to release
if: startsWith(github.ref, 'refs/tags/v')
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ github.ref }}
file: pumpkinmc-pumpkin-api-ts-*.tgz
overwrite: true
file_glob: true

39
.github/workflows/update-wit.yml vendored Normal file
View File

@ -0,0 +1,39 @@
name: Update WIT
on:
workflow_dispatch:
permissions:
contents: write
jobs:
update-wit:
name: Update WIT
runs-on: ubuntu-slim
steps:
- name: Checkout
uses: actions/checkout@v6
with:
submodules: true
- name: Update submodule
id: update_submodule
run: |
set -eux
cd wit
git fetch origin master
git checkout FETCH_HEAD
echo "wit_commit=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- name: Commit
run: |
set -eux
witCommit='${{ steps.update_submodule.outputs.wit_commit }}'
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add wit
git commit -m "Sync to Pumpkin-MC/pumpkin-plugin-wit@${witCommit}"
git push

176
LICENSE-APACHE Normal file
View File

@ -0,0 +1,176 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or exemplary damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS

21
LICENSE-MIT Normal file
View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2024-2026 Pumpkin Contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -10,8 +10,20 @@ This package provides the TypeScript bindings for building [Pumpkin](https://git
## Installation
You'll want to download the latest version of the bindings from the [CI release](https://github.com/Pumpkin-MC/pumpkin-api-ts/releases/tag/CI).
We don't have stable versions as Pumpkin and its API is still pre-release.
Then `npm install` the downloaded `.tgz`. e.g.
```bash
npm install @pumpkinmc/pumpkin-api-ts
npm install pumpkinmc-pumpkin-api-ts-50917277.tgz
```
You may also choose to install directly from the download URL (after determining it; commit hash changes)
```bash
npm install https://github.com/Pumpkin-MC/pumpkin-api-ts/releases/download/CI/pumpkinmc-pumpkin-api-ts-XXXXXXXX.tgz
```
## Creating a Plugin
@ -22,6 +34,7 @@ npm install @pumpkinmc/pumpkin-api-ts
4. Add `export * from "@pumpkinmc/pumpkin-api-ts";` at the end.
Example:
```typescript
import { Plugin, registerPlugin } from "@pumpkinmc/pumpkin-api-ts";
@ -39,7 +52,7 @@ class MyPlugin extends Plugin {
authors: ["alex"],
description: "A sample plugin written in TypeScript",
dependencies: [],
permissions: []
permissions: [],
};
}
onLoad(ctx: Context): void {
@ -79,11 +92,13 @@ To build your plugin into a `.wasm` component, use the provided build script:
```
Example:
```bash
./node_modules/.bin/pumpkin-plugin-build my-plugin.ts build/my-plugin.wasm
```
For convience, it's recommended to add a scripts section to your `package.json`
```json
{
"scripts": {
@ -94,4 +109,5 @@ For convience, it's recommended to add a scripts section to your `package.json`
}
}
```
Execute with `npm run build`

148
dist/index.ts vendored
View File

@ -3,13 +3,21 @@
import {
Command,
CommandSender,
CommandSuggestions,
ConsumedArgs,
SuggestionRequest,
} from "pumpkin:plugin/command@0.1.0";
import { Context } from "pumpkin:plugin/context@0.1.0";
import { Event, EventType, EventPriority } from "pumpkin:plugin/event@0.1.0";
import { IpcMessage, PluginId } from "pumpkin:plugin/ipc@0.1.0";
import { PluginMetadata } from "pumpkin:plugin/metadata@0.1.0";
import * as scheduler from "pumpkin:plugin/scheduler@0.1.0";
import { Server } from "pumpkin:plugin/server@0.1.0";
import {
ChunkBuffer,
Entity,
GenerationPhase,
} from "pumpkin:plugin/world@0.1.0";
export type EventHandler<T = any> = (srv: Server, evt: T) => T | void;
export type CommandHandler = (
@ -17,12 +25,31 @@ export type CommandHandler = (
srv: Server,
args: ConsumedArgs,
) => number;
export type CommandSuggestionHandler = (
sender: CommandSender,
srv: Server,
request: SuggestionRequest,
) => CommandSuggestions;
export type TaskHandler = (srv: Server) => void;
export interface AiGoal {
canStart: (server: Server, entity: Entity) => boolean;
shouldContinue: (server: Server, entity: Entity) => boolean;
start: (server: Server, entity: Entity) => void;
tick: (server: Server, entity: Entity) => void;
stop: (server: Server, entity: Entity) => void;
}
export type ChunkGenerator = (
phase: GenerationPhase,
chunk: ChunkBuffer,
) => void;
let pluginInstance: Plugin | null = null;
const eventHandlers = new Map<number, EventHandler>();
const commandHandlers = new Map<number, CommandHandler>();
const commandSuggestionHandlers = new Map<number, CommandSuggestionHandler>();
const taskHandlers = new Map<number, TaskHandler>();
const generators = new Map<number, ChunkGenerator>();
const aiGoals = new Map<number, AiGoal>();
let nextHandlerId = 0;
function getNextHandlerId(): number {
@ -48,6 +75,10 @@ export abstract class Plugin {
onUnload(_ctx: Context): void {}
handleIpcMessage(sender: PluginId, message: IpcMessage): IpcMessage {
throw "This plugin cannot recieve messages";
}
registerEvent(
ctx: Context,
eventType: EventType,
@ -72,6 +103,12 @@ export abstract class Plugin {
ctx.registerCommand(cmd, permission);
}
registerCommandSuggestionHandler(handler: CommandSuggestionHandler): number {
const handlerId = getNextHandlerId();
commandSuggestionHandlers.set(handlerId, handler);
return handlerId;
}
scheduleDelayedTask(
delayTicks: number | bigint,
handler: TaskHandler,
@ -94,6 +131,18 @@ export abstract class Plugin {
BigInt(periodTicks),
);
}
registerAiGoal(goal: AiGoal): number {
const aiGoalId = getNextHandlerId();
aiGoals.set(aiGoalId, goal);
return aiGoalId;
}
registerChunkGenerator(generator: ChunkGenerator): number {
const generatorId = getNextHandlerId();
generators.set(generatorId, generator);
return generatorId;
}
}
export function registerPlugin(plugin: Plugin) {
@ -139,6 +188,19 @@ export function handleCommand(
throw new Error(`No handler for command ID ${commandId}`);
}
export function handleCommandSuggestion(
handlerId: number,
sender: CommandSender,
srv: Server,
request: SuggestionRequest,
): CommandSuggestions {
const handler = commandSuggestionHandlers.get(handlerId);
if (handler) {
return handler(sender, srv, request);
}
throw new Error(`No command suggestion handler registered for ID ${handler}`);
}
export function handleTask(handlerId: number, srv: Server): void {
const handler = taskHandlers.get(handlerId);
if (handler) {
@ -146,6 +208,92 @@ export function handleTask(handlerId: number, srv: Server): void {
}
}
export function handleIpcMessage(
sender: PluginId,
message: IpcMessage,
): IpcMessage {
if (pluginInstance) {
return pluginInstance.handleIpcMessage(sender, message);
}
throw new Error("No plugin instance available?");
}
export function handleAiGoalCanStart(
goalId: number,
server: Server,
entity: Entity,
): boolean {
const aiGoal = aiGoals.get(goalId);
if (aiGoal) {
return aiGoal.canStart(server, entity);
}
throw new Error(`No AI goal registered for ID ${goalId}`);
}
export function handleAiGoalShouldContinue(
goalId: number,
server: Server,
entity: Entity,
): boolean {
const aiGoal = aiGoals.get(goalId);
if (aiGoal) {
return aiGoal.shouldContinue(server, entity);
}
throw new Error(`No AI goal registered for ID ${goalId}`);
}
export function handleAiGoalStart(
goalId: number,
server: Server,
entity: Entity,
): void {
const aiGoal = aiGoals.get(goalId);
if (aiGoal) {
aiGoal.start(server, entity);
return;
}
throw new Error(`No AI goal registered for ID ${goalId}`);
}
export function handleAiGoalTick(
goalId: number,
server: Server,
entity: Entity,
): void {
const aiGoal = aiGoals.get(goalId);
if (aiGoal) {
aiGoal.tick(server, entity);
return;
}
throw new Error(`No AI goal registered for ID ${goalId}`);
}
export function handleAiGoalStop(
goalId: number,
server: Server,
entity: Entity,
): void {
const aiGoal = aiGoals.get(goalId);
if (aiGoal) {
aiGoal.stop(server, entity);
return;
}
throw new Error(`No AI goal registered for ID ${goalId}`);
}
export function handleGeneratePhase(
generatorId: number,
phase: GenerationPhase,
chunk: ChunkBuffer,
): void {
const generator = generators.get(generatorId);
if (generator) {
generator(phase, chunk);
return;
}
throw new Error(`No generator registered for ID ${generatorId}`);
}
export const metadata = {
getMetadata(): PluginMetadata {
if (pluginInstance) {

5
example/package.json Normal file
View File

@ -0,0 +1,5 @@
{
"scripts": {
"build": "pumpkin-plugin-build my-plugin.ts build/plugin.wasm"
}
}

2825
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,8 @@
{
"name": "@pumpkinmc/pumpkin-api-ts",
"version": "0.1.0-dev6",
"version": "0.1.1",
"description": "Pumpkin plugin API for TypeScript",
"license": "MIT OR Apache-2.0",
"main": "dist/index.ts",
"types": "dist/index.ts",
"files": [
@ -19,10 +20,10 @@
"prepare": "jco guest-types wit/v0.1 -n plugin -o dist/bindings --name index"
},
"dependencies": {
"@bytecodealliance/componentize-js": "^0.21.0",
"esbuild": "^0.28.0"
"componentize-qjs": "^0.4.5",
"esbuild": "^0.28.2"
},
"devDependencies": {
"@bytecodealliance/jco": "^1.19.0"
"@bytecodealliance/jco": "^1.34.0"
}
}

View File

@ -1,10 +1,7 @@
#! /usr/bin/env node
import * as esbuild from "esbuild";
import {
componentize,
version as componentize_version,
} from "@bytecodealliance/componentize-js";
import { componentize } from "componentize-qjs";
import * as path from "node:path";
import * as fs from "node:fs";
@ -22,14 +19,14 @@ async function buildPlugin(entryPath, outputPath, witDir) {
external: ["pumpkin:plugin/*"],
});
console.log(
`2. Running through \`componentize-js\` ` + componentize_version + `...`,
);
console.log(`2. Running through \`componentize-qjs\`...`);
try {
const { component } = await componentize({
worldName: "plugin",
witPath: witDir,
sourcePath: tempJs
jsSource: fs.readFileSync(tempJs, "utf8"),
optSize: true,
minify: true,
});
fs.writeFileSync(outputPath, component);
@ -54,9 +51,7 @@ if (args.length < 2) {
const entry = args[0];
const output = args[1];
const wit =
args[2] ||
path.join(import.meta.dirname, "../wit/v0.1");
const wit = args[2] || path.join(import.meta.dirname, "../wit/v0.1");
buildPlugin(entry, output, wit).catch((err) => {
console.error(err);

2
wit

@ -1 +1 @@
Subproject commit 2aacac1f07848b6273b30a0390818e87ef1259e9
Subproject commit 39bf330fa6aefc91c8ac61bd07d0fdbd5a5b95ac