hikkaku 0.1.9 → 0.1.12

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.
@@ -1,4 +1,4 @@
1
- import { _ as PrimitiveSource, h as ListReference, m as HikkakuBlock, p as CostumeSource, x as VariableReference, y as SoundSource } from "../index-p9BGSitw.mjs";
1
+ import { _ as PrimitiveSource, h as ListReference, m as HikkakuBlock, p as CostumeSource, x as VariableReference, y as SoundSource } from "../project-9x128tdR.mjs";
2
2
 
3
3
  //#region src/blocks/control.d.ts
4
4
  type StopOption = 'all' | 'this script' | 'other scripts in sprite' | 'other scripts in stage';
@@ -181,6 +181,7 @@ declare const defineProcedure: <T extends ProcedureProc[]>(proclist: T, stack?:
181
181
  * If true, the procedure will run without screen refresh until it completes.
182
182
  * This can make the procedure run faster, but the screen will not update until the procedure is done.
183
183
  */
184
+
184
185
  warp?: boolean) => HikkakuBlock;
185
186
  declare const callProcedure: (proccode: string, argumentIds: string[], inputs: Record<string, PrimitiveSource<string | number | boolean>>, warp?: boolean) => HikkakuBlock;
186
187
  declare const argumentReporterStringNumber: (reference: ProcedureStringOrNumberReference) => HikkakuBlock;
package/blocks/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { a as fromCostumeSource, i as valueBlock, o as fromPrimitiveSource, r as substack, s as fromSoundSource, t as block } from "../composer-D8CYTp4v.mjs";
1
+ import { a as fromCostumeSource, i as valueBlock, o as fromPrimitiveSource, r as substack, s as fromSoundSource, t as block } from "../composer-JWWbnKkh.mjs";
2
2
 
3
3
  //#region src/blocks/control.ts
4
4
  const repeat = (times, handler) => {
package/client/index.mjs CHANGED
@@ -4,8 +4,8 @@ const findDOMAppRoot = () => {
4
4
  for (const el of probably) if (el && "_reactRootContainer" in el) return el;
5
5
  throw new Error("Could not find root DOM node. Make sure you are running this in a Scratch environment.");
6
6
  };
7
- function getSpecifiedFiber(root$1, cond) {
8
- const stack = [root$1];
7
+ function getSpecifiedFiber(root, cond) {
8
+ const stack = [root];
9
9
  while (true) {
10
10
  const fiber = stack.pop();
11
11
  if (!fiber) return null;
@@ -14,16 +14,16 @@ function getSpecifiedFiber(root$1, cond) {
14
14
  if (fiber.sibling) stack.push(fiber.sibling);
15
15
  }
16
16
  }
17
- const getAppFiberNode = (root$1) => {
18
- let cur = root$1.child;
17
+ const getAppFiberNode = (root) => {
18
+ let cur = root.child;
19
19
  while (cur) {
20
20
  if ("memoizedProps" in cur && "store" in cur.memoizedProps) return cur;
21
21
  cur = cur.child;
22
22
  }
23
23
  throw new Error("Could not find app fiber node.");
24
24
  };
25
- const getScratchInternalStates = (root$1) => {
26
- const rootFiberNode = root$1._reactRootContainer._internalRoot.current;
25
+ const getScratchInternalStates = (root) => {
26
+ const rootFiberNode = root._reactRootContainer._internalRoot.current;
27
27
  const reduxState = getAppFiberNode(rootFiberNode).memoizedProps.store.getState();
28
28
  const vm = reduxState.scratchGui.vm;
29
29
  const scratchBlocksFiber = getSpecifiedFiber(rootFiberNode, (fiber) => {
@@ -52,11 +52,15 @@ globalThis.hk = {
52
52
  getModeForResolutionAtIndex: state.reduxState,
53
53
  getJSON: () => state.vm.toJSON()
54
54
  };
55
+ let isFirstLoad = true;
55
56
  import.meta.hot?.on("hikkaku:project", async (project) => {
57
+ if (isFirstLoad) {
58
+ await new Promise((resolve) => setTimeout(resolve, 500));
59
+ isFirstLoad = false;
60
+ }
56
61
  console.log("Received updated project:", project);
57
62
  await state.vm.loadProject(project).catch(console.error);
58
63
  console.log("Project loaded.");
59
- setTimeout(() => {}, 100);
60
64
  });
61
65
 
62
66
  //#endregion
package/index.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- import { _ as PrimitiveSource, a as block, b as VariableBase, c as valueBlock, d as fromSoundSource, f as CostumeReference, g as PrimitiveAvailableOnScratch, h as ListReference, i as Handler, l as fromCostumeSource, m as HikkakuBlock, n as Target, o as createBlocks, p as CostumeSource, r as BlockInit, s as substack, t as Project, u as fromPrimitiveSource, v as SoundReference, x as VariableReference, y as SoundSource } from "./index-p9BGSitw.mjs";
1
+ import { _ as PrimitiveSource, a as block, b as VariableBase, c as valueBlock, d as fromSoundSource, f as CostumeReference, g as PrimitiveAvailableOnScratch, h as ListReference, i as Handler, l as fromCostumeSource, m as HikkakuBlock, n as Target, o as createBlocks, p as CostumeSource, r as BlockInit, s as substack, t as Project, u as fromPrimitiveSource, v as SoundReference, x as VariableReference, y as SoundSource } from "./project-9x128tdR.mjs";
2
2
  export { BlockInit, CostumeReference, CostumeSource, Handler, HikkakuBlock, ListReference, PrimitiveAvailableOnScratch, PrimitiveSource, Project, SoundReference, SoundSource, Target, VariableBase, VariableReference, block, createBlocks, fromCostumeSource, fromPrimitiveSource, fromSoundSource, substack, valueBlock };
package/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { a as fromCostumeSource, i as valueBlock, n as createBlocks, o as fromPrimitiveSource, r as substack, s as fromSoundSource, t as block } from "./composer-D8CYTp4v.mjs";
1
+ import { a as fromCostumeSource, i as valueBlock, n as createBlocks, o as fromPrimitiveSource, r as substack, s as fromSoundSource, t as block } from "./composer-JWWbnKkh.mjs";
2
2
 
3
3
  //#region src/core/project.ts
4
4
  let nextAssetId = 0;
@@ -15,14 +15,14 @@ const coreOpcodePrefixes = new Set([
15
15
  "sensing",
16
16
  "sound"
17
17
  ]);
18
- const isBlockObject = (block$1) => {
19
- return typeof block$1 === "object" && block$1 !== null && "opcode" in block$1;
18
+ const isBlockObject = (block) => {
19
+ return typeof block === "object" && block !== null && "opcode" in block;
20
20
  };
21
21
  const collectExtensions = (targets) => {
22
22
  const extensions = /* @__PURE__ */ new Set();
23
- for (const target of targets) for (const block$1 of Object.values(target.blocks)) {
24
- if (!isBlockObject(block$1)) continue;
25
- const [prefix] = block$1.opcode.split("_");
23
+ for (const target of targets) for (const block of Object.values(target.blocks)) {
24
+ if (!isBlockObject(block)) continue;
25
+ const [prefix] = block.opcode.split("_");
26
26
  if (prefix && !coreOpcodePrefixes.has(prefix)) extensions.add(prefix);
27
27
  }
28
28
  return Array.from(extensions).sort();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hikkaku",
3
- "version": "0.1.9",
3
+ "version": "0.1.12",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "exports": {
@@ -33,7 +33,7 @@
33
33
  "typescript": "^5"
34
34
  },
35
35
  "dependencies": {
36
- "@pnsk-lab/sb3-types": "npm:@jsr/pnsk-lab__sb3-types@0.1.8",
36
+ "sb3-types": "0.1.10",
37
37
  "vite": "8.0.0-beta.8"
38
38
  },
39
39
  "repository": {
@@ -1,4 +1,4 @@
1
- import * as sb3 from "@pnsk-lab/sb3-types";
1
+ import * as sb3 from "sb3-types";
2
2
 
3
3
  //#region src/core/types.d.ts
4
4
  type PrimitiveAvailableOnScratch = number | boolean | string;
package/vite/index.mjs CHANGED
@@ -38,7 +38,7 @@ function hikkaku(init) {
38
38
  });
39
39
  server.middlewares.use(async (req, res, next) => {
40
40
  if (req.url === "/") {
41
- const html = (await fetch(BASE_URL).then((res$1) => res$1.text())).replace("gui.js", "https://scratchfoundation.github.io/scratch-gui/gui.js").replace("</head>", "<script src=\"/@vite/client\" type=\"module\"><\/script><script type=\"module\" src=\"/@virtual/hikkaku-client\"><\/script></head>");
41
+ const html = (await fetch(BASE_URL).then((res) => res.text())).replace("gui.js", "https://scratchfoundation.github.io/scratch-gui/gui.js").replace("</head>", "<script src=\"/@vite/client\" type=\"module\"><\/script><script type=\"module\" src=\"/@virtual/hikkaku-client\"><\/script></head>");
42
42
  res.setHeader("Content-Type", "text/html");
43
43
  res.end(html);
44
44
  return;