@pixi-ui-editor/runtime-pixi 0.3.0 → 0.5.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.
Files changed (72) hide show
  1. package/README.md +81 -2
  2. package/dist/SceneViewport.d.ts +17 -0
  3. package/dist/SceneViewport.d.ts.map +1 -0
  4. package/dist/SceneViewport.js +35 -0
  5. package/dist/SceneViewport.js.map +1 -0
  6. package/dist/assets/bitmapFonts.d.ts +22 -0
  7. package/dist/assets/bitmapFonts.d.ts.map +1 -0
  8. package/dist/assets/bitmapFonts.js +75 -0
  9. package/dist/assets/bitmapFonts.js.map +1 -0
  10. package/dist/assets/cache.d.ts +31 -0
  11. package/dist/assets/cache.d.ts.map +1 -0
  12. package/dist/assets/cache.js +20 -0
  13. package/dist/assets/cache.js.map +1 -0
  14. package/dist/assets/fonts.d.ts +1 -1
  15. package/dist/assets/fonts.d.ts.map +1 -1
  16. package/dist/assets/fonts.js +2 -2
  17. package/dist/assets/fonts.js.map +1 -1
  18. package/dist/assets/loadTexture.d.ts +9 -0
  19. package/dist/assets/loadTexture.d.ts.map +1 -0
  20. package/dist/assets/loadTexture.js +14 -0
  21. package/dist/assets/loadTexture.js.map +1 -0
  22. package/dist/assets/textures.d.ts +4 -5
  23. package/dist/assets/textures.d.ts.map +1 -1
  24. package/dist/assets/textures.js +31 -20
  25. package/dist/assets/textures.js.map +1 -1
  26. package/dist/controls.d.ts +9 -1
  27. package/dist/controls.d.ts.map +1 -1
  28. package/dist/controls.js +23 -0
  29. package/dist/controls.js.map +1 -1
  30. package/dist/index.d.ts +10 -1
  31. package/dist/index.d.ts.map +1 -1
  32. package/dist/index.js +7 -0
  33. package/dist/index.js.map +1 -1
  34. package/dist/index.test.js +95 -3
  35. package/dist/index.test.js.map +1 -1
  36. package/dist/layout.d.ts +10 -4
  37. package/dist/layout.d.ts.map +1 -1
  38. package/dist/layout.js +13 -0
  39. package/dist/layout.js.map +1 -1
  40. package/dist/localization.d.ts +42 -0
  41. package/dist/localization.d.ts.map +1 -0
  42. package/dist/localization.js +73 -0
  43. package/dist/localization.js.map +1 -0
  44. package/dist/scene.d.ts +24 -13
  45. package/dist/scene.d.ts.map +1 -1
  46. package/dist/scene.js +66 -14
  47. package/dist/scene.js.map +1 -1
  48. package/dist/views/ButtonNodeView.d.ts +16 -3
  49. package/dist/views/ButtonNodeView.d.ts.map +1 -1
  50. package/dist/views/ButtonNodeView.js +94 -27
  51. package/dist/views/ButtonNodeView.js.map +1 -1
  52. package/dist/views/CheckboxNodeView.d.ts +47 -0
  53. package/dist/views/CheckboxNodeView.d.ts.map +1 -0
  54. package/dist/views/CheckboxNodeView.js +127 -0
  55. package/dist/views/CheckboxNodeView.js.map +1 -0
  56. package/dist/views/NodeView.d.ts +8 -0
  57. package/dist/views/NodeView.d.ts.map +1 -1
  58. package/dist/views/NodeView.js +8 -0
  59. package/dist/views/NodeView.js.map +1 -1
  60. package/dist/views/StagedButtonNodeView.d.ts +81 -0
  61. package/dist/views/StagedButtonNodeView.d.ts.map +1 -0
  62. package/dist/views/StagedButtonNodeView.js +275 -0
  63. package/dist/views/StagedButtonNodeView.js.map +1 -0
  64. package/dist/views/basic.d.ts +97 -2
  65. package/dist/views/basic.d.ts.map +1 -1
  66. package/dist/views/basic.js +273 -8
  67. package/dist/views/basic.js.map +1 -1
  68. package/dist/views/createNodeView.d.ts +1 -1
  69. package/dist/views/createNodeView.d.ts.map +1 -1
  70. package/dist/views/createNodeView.js +30 -4
  71. package/dist/views/createNodeView.js.map +1 -1
  72. package/package.json +3 -2
package/README.md CHANGED
@@ -17,12 +17,12 @@ import { loadPrefabView } from "@pixi-ui-editor/runtime-pixi";
17
17
  import { materializedPrefabNodeId } from "@pixi-ui-editor/schema";
18
18
 
19
19
  const configured = scene.nodes.find(
20
- (node) => node.type === "prefab-instance" && node.binding === "rewardCardTemplate",
20
+ (node) => node.type === "prefab-instance" && node.bindingKey === "rewardCardTemplate",
21
21
  );
22
22
  if (configured?.type !== "prefab-instance") throw new Error("Configured preset instance is missing.");
23
23
  const labelDefinitionNodeId = document.prefabs
24
24
  .find((prefab) => prefab.id === configured.prefabId)!
25
- .nodes.find((node) => node.binding === "label")!.id;
25
+ .nodes.find((node) => node.bindingKey === "label")!.id;
26
26
 
27
27
  const mounted = await loadPrefabView(
28
28
  document,
@@ -44,3 +44,82 @@ const labelView = mounted.nodeViews.get(
44
44
 
45
45
  Omit the last argument to instantiate the prefab definition defaults. `nodeViews` contains the outer
46
46
  instance plus deterministic instance-scoped IDs for inherited children and stable IDs for local children.
47
+
48
+ The lookup above is two-step on purpose, and it is the contract: a `bindingKey` is unique within the scope
49
+ it resolves against, not across the whole document. A key on a scene node — including a preset instance
50
+ itself — is unique within that scene. A key inside a preset definition is unique within that definition and
51
+ resolves against one instance, which is what makes it usable for presets you spawn many times: a hundred
52
+ symbol views can each carry `"spine"` without colliding. So you find the instance by its scene-level key,
53
+ then find the node inside it by its definition-level key.
54
+
55
+ ## Reuse parsed assets across loads
56
+
57
+ `loadPrefabView` and `loadSceneView` fetch and parse every asset a scene references. Spawning presets one
58
+ by one — a symbol view per reel stop, a card per deal — repeats that work for each call: the skeleton JSON
59
+ is re-parsed, the atlas is rebuilt, and every texture becomes a separate GPU upload of the same file.
60
+
61
+ Pass an `assetCache` you own to share the parsed results. Its lifetime is yours: keep one per scene session
62
+ and drop it with the scene.
63
+
64
+ ```ts
65
+ import { createSceneAssetCache, loadPrefabView } from "@pixi-ui-editor/runtime-pixi";
66
+
67
+ const assetCache = createSceneAssetCache();
68
+
69
+ const mounted = await loadPrefabView(document, prefabId, "desktop", resolveFileUrl, {
70
+ interaction: "runtime",
71
+ assetCache,
72
+ });
73
+ ```
74
+
75
+ Each map is keyed by the asset file's URI, so the same file assigned to different assets loads once. Without
76
+ `assetCache` every call starts from empty maps, which is fine for a single scene load and wasteful for
77
+ anything spawned repeatedly. The lower-level `loadSceneTextures` / `loadSceneSpines` / `loadSceneFonts` /
78
+ `loadSceneSounds` take the individual maps directly if you drive loading yourself.
79
+
80
+ ## Scene viewport
81
+
82
+ `buildSceneView` and `loadSceneView` return a runtime-owned `SceneViewport` as `root`. With
83
+ `interaction: "runtime"`, that object clips content to the authored reference viewport and owns the
84
+ only contain-fit calculation used by Preview and consuming applications:
85
+
86
+ ```ts
87
+ const { root } = await loadSceneView(document, sceneId, profile, resolveFileUrl, {
88
+ interaction: "runtime",
89
+ });
90
+
91
+ app.stage.addChild(root);
92
+ root.resize({ width: app.screen.width, height: app.screen.height });
93
+ ```
94
+
95
+ Call `root.resize(...)` after the Pixi renderer changes size. It applies one uniform scale and centers
96
+ the unchanged authored viewport; letterbox and pillarbox space never reveal off-viewport content.
97
+ Profile selection remains shared through `resolveProfileForViewport`, and crossing its breakpoint
98
+ requires building the scene again with the newly selected profile. Hosts must not reproduce the fit
99
+ formula or add their own viewport mask. Spawned prefab views stay unclipped because they are scene
100
+ content rather than player-screen boundaries.
101
+
102
+ ## Localization
103
+
104
+ `buildSceneView`, `loadSceneView`, `buildPrefabView` and `loadPrefabView` return a `SceneLocalization`
105
+ next to `root` and `nodeViews`. A `Text` node that carries a `textKey` already renders its base-locale
106
+ translation without any extra call; a document without keys behaves exactly as before.
107
+
108
+ ```ts
109
+ const { root, localization } = await loadSceneView(document, sceneId, "desktop", resolveFileUrl, {
110
+ interaction: "runtime",
111
+ });
112
+
113
+ localization.setLocale("pt-BR");
114
+ // Values ship as a flat Record<string, string> in locales/<locale>.json, so any dictionary works.
115
+ localization.setTranslate((key, { locale }) => dictionaries[locale]?.[key]);
116
+ // `{amount}` inside a translation is a runtime parameter, not a second key.
117
+ localization.setParams({ amount: 48 });
118
+ // An immutable editor/game store hands over a new document copy without rebuilding the scene.
119
+ localization.syncDocument(nextDocument);
120
+ ```
121
+
122
+ Resolution order is `translate` → requested locale → base locale → `Text.text` → the key itself; a
123
+ `translate` returning `undefined` keeps the chain going. Every call mutates the existing `TextNodeView`
124
+ objects: the scene root, `NodeView` identity and live control state are preserved, and re-rendering the
125
+ same string does no work at all.
@@ -0,0 +1,17 @@
1
+ import { Container } from "pixi.js";
2
+ import { type FittedViewport, type LayoutSize } from "./layout.js";
3
+ /**
4
+ * The single host boundary for a built scene.
5
+ *
6
+ * Runtime scenes are clipped to the authored reference viewport and can only be fitted with one
7
+ * uniform scale. Authoring scenes use the same wrapper without clipping so the editor can expose
8
+ * off-viewport content while arranging it.
9
+ */
10
+ export declare class SceneViewport extends Container {
11
+ readonly referenceViewport: LayoutSize;
12
+ readonly content: Container;
13
+ constructor(content: Container, referenceViewport: LayoutSize, clip: boolean);
14
+ /** Uniformly contains and centers this authored viewport inside the physical host. */
15
+ resize(host: LayoutSize): FittedViewport;
16
+ }
17
+ //# sourceMappingURL=SceneViewport.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SceneViewport.d.ts","sourceRoot":"","sources":["../src/SceneViewport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAY,MAAM,SAAS,CAAC;AAC9C,OAAO,EAAqB,KAAK,cAAc,EAAE,KAAK,UAAU,EAAE,MAAM,aAAa,CAAC;AAEtF;;;;;;GAMG;AACH,qBAAa,aAAc,SAAQ,SAAS;IAC1C,QAAQ,CAAC,iBAAiB,EAAE,UAAU,CAAC;IACvC,QAAQ,CAAC,OAAO,EAAE,SAAS,CAAC;gBAEhB,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,UAAU,EAAE,IAAI,EAAE,OAAO;IAiB5E,sFAAsF;IACtF,MAAM,CAAC,IAAI,EAAE,UAAU,GAAG,cAAc;CAMzC"}
@@ -0,0 +1,35 @@
1
+ import { Container, Graphics } from "pixi.js";
2
+ import { fitViewportToHost } from "./layout.js";
3
+ /**
4
+ * The single host boundary for a built scene.
5
+ *
6
+ * Runtime scenes are clipped to the authored reference viewport and can only be fitted with one
7
+ * uniform scale. Authoring scenes use the same wrapper without clipping so the editor can expose
8
+ * off-viewport content while arranging it.
9
+ */
10
+ export class SceneViewport extends Container {
11
+ referenceViewport;
12
+ content;
13
+ constructor(content, referenceViewport, clip) {
14
+ super();
15
+ this.content = content;
16
+ this.referenceViewport = { ...referenceViewport };
17
+ if (clip) {
18
+ const viewportMask = new Graphics()
19
+ .rect(0, 0, referenceViewport.width, referenceViewport.height)
20
+ .fill(0xffffff);
21
+ viewportMask.eventMode = "none";
22
+ content.mask = viewportMask;
23
+ this.addChild(viewportMask);
24
+ }
25
+ this.addChild(content);
26
+ }
27
+ /** Uniformly contains and centers this authored viewport inside the physical host. */
28
+ resize(host) {
29
+ const fitted = fitViewportToHost(this.referenceViewport, host);
30
+ this.scale.set(fitted.scale);
31
+ this.position.set(fitted.x, fitted.y);
32
+ return fitted;
33
+ }
34
+ }
35
+ //# sourceMappingURL=SceneViewport.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SceneViewport.js","sourceRoot":"","sources":["../src/SceneViewport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAwC,MAAM,aAAa,CAAC;AAEtF;;;;;;GAMG;AACH,MAAM,OAAO,aAAc,SAAQ,SAAS;IACjC,iBAAiB,CAAa;IAC9B,OAAO,CAAY;IAE5B,YAAY,OAAkB,EAAE,iBAA6B,EAAE,IAAa;QAC1E,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,iBAAiB,GAAG,EAAE,GAAG,iBAAiB,EAAE,CAAC;QAElD,IAAI,IAAI,EAAE,CAAC;YACT,MAAM,YAAY,GAAG,IAAI,QAAQ,EAAE;iBAChC,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,iBAAiB,CAAC,KAAK,EAAE,iBAAiB,CAAC,MAAM,CAAC;iBAC7D,IAAI,CAAC,QAAQ,CAAC,CAAC;YAClB,YAAY,CAAC,SAAS,GAAG,MAAM,CAAC;YAChC,OAAO,CAAC,IAAI,GAAG,YAAY,CAAC;YAC5B,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;QAC9B,CAAC;QAED,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IACzB,CAAC;IAED,sFAAsF;IACtF,MAAM,CAAC,IAAgB;QACrB,MAAM,MAAM,GAAG,iBAAiB,CAAC,IAAI,CAAC,iBAAiB,EAAE,IAAI,CAAC,CAAC;QAC/D,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC7B,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;QACtC,OAAO,MAAM,CAAC;IAChB,CAAC;CACF"}
@@ -0,0 +1,22 @@
1
+ import type { Asset, ProjectDocument } from "@pixi-ui-editor/schema";
2
+ import { BitmapFont, type Texture } from "pixi.js";
3
+ import type { FileUrlResolver } from "./textures.js";
4
+ type BitmapFontAsset = Extract<Asset, {
5
+ type: "bitmapFont";
6
+ }>;
7
+ /**
8
+ * Loads scene bitmap fonts before views are built, mirroring `loadSceneFonts`. Unlike a regular
9
+ * `FontFace`, PixiJS resolves a `BitmapText`'s font by looking up `Cache` for `${fontFamily}-bitmap`
10
+ * (see `BitmapFontManager.getFont`), so loading here means parsing the XML, building one `BitmapFont`
11
+ * from the already-fetched texture, and registering it in that cache — there is no URL-based loader
12
+ * to delegate to, since our XML and texture live at unrelated asset URIs, not a fixed relative pair.
13
+ */
14
+ export declare function loadSceneBitmapFonts(document: ProjectDocument, sceneId: string, resolveFileUrl: FileUrlResolver, cache?: Map<string, Promise<BitmapFont | undefined>>): Promise<Map<string, string>>;
15
+ /**
16
+ * Resolves one glyph's already-cropped `Texture` from a bitmap font asset, for reuse as a plain image
17
+ * asset (an Image node, a Button/Checkbox state, ...) — see `BitmapFontAsset.frames`. `BitmapFont`
18
+ * builds one `Texture` per character up front (see its constructor), so this is a lookup, not a crop.
19
+ */
20
+ export declare function loadBitmapFontGlyphTexture(asset: BitmapFontAsset, glyph: string, resolveFileUrl: FileUrlResolver, cache?: Map<string, Promise<BitmapFont | undefined>>): Promise<Texture | undefined>;
21
+ export {};
22
+ //# sourceMappingURL=bitmapFonts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bitmapFonts.d.ts","sourceRoot":"","sources":["../../src/assets/bitmapFonts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,eAAe,EAAU,MAAM,wBAAwB,CAAC;AAC7E,OAAO,EAAE,UAAU,EAAoC,KAAK,OAAO,EAAE,MAAM,SAAS,CAAC;AAMrF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAErD,KAAK,eAAe,GAAG,OAAO,CAAC,KAAK,EAAE;IAAE,IAAI,EAAE,YAAY,CAAA;CAAE,CAAC,CAAC;AAqC9D;;;;;;GAMG;AACH,wBAAsB,oBAAoB,CAAC,QAAQ,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,eAAe,EAAE,KAAK,GAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAAyB,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAYjO;AAED;;;;GAIG;AACH,wBAAsB,0BAA0B,CAAC,KAAK,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,eAAe,EAAE,KAAK,GAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAAyB,GAAG,OAAO,CAAC,OAAO,GAAG,SAAS,CAAC,CAGlO"}
@@ -0,0 +1,75 @@
1
+ import { BitmapFont, Cache, bitmapFontXMLStringParser } from "pixi.js";
2
+ import { collectRenderedNodes } from "../scene.js";
3
+ import { sharedBitmapFontCache } from "./cache.js";
4
+ import { loadTexture } from "./loadTexture.js";
5
+ const keyOf = (asset) => `${asset.files.xml.uri}#${asset.files.texture.uri}`;
6
+ /**
7
+ * The synthetic family every loaded font installs under — never whatever `<info face>` its XML
8
+ * declares. Two uploaded bitmap fonts could share the same exporter-generated face name, and the
9
+ * asset id is the only identity PixiJS's `${fontFamily}-bitmap` Cache key is guaranteed not to collide on.
10
+ */
11
+ const familyOf = (assetId) => `bitmap-font-${assetId}`;
12
+ const fromNodes = (nodes) => nodes.flatMap((node) => (node.type === "bitmap-text" ? [node.assetId] : []));
13
+ /**
14
+ * Shared by `loadSceneFonts`'s reasoning (see `sharedFontCache`): a loaded `BitmapFont` registers into
15
+ * PixiJS's own global `Cache`, so re-parsing the same asset under a caller-scoped cache would still
16
+ * collide there. `cache` defaults to that shared map but accepts a `SceneAssetCache.bitmapFonts` from
17
+ * the caller, the same override every other scene asset loader takes.
18
+ */
19
+ function loadFont(asset, resolveFileUrl, cache) {
20
+ const key = keyOf(asset);
21
+ let pending = cache.get(key);
22
+ if (pending === undefined) {
23
+ pending = (async () => {
24
+ const xmlUrl = resolveFileUrl(asset.files.xml.uri);
25
+ const textureUrl = resolveFileUrl(asset.files.texture.uri);
26
+ if (xmlUrl === undefined || textureUrl === undefined)
27
+ return undefined;
28
+ try {
29
+ const [xml, texture] = await Promise.all([fetch(xmlUrl).then((response) => response.text()), loadTexture(textureUrl)]);
30
+ const font = new BitmapFont({ data: bitmapFontXMLStringParser.parse(xml), textures: [texture] });
31
+ Cache.set(`${familyOf(asset.id)}-bitmap`, font);
32
+ return font;
33
+ }
34
+ catch (error) {
35
+ console.warn(`Unable to load bitmap font asset '${asset.id}'. Text using it will not render.`, error);
36
+ return undefined;
37
+ }
38
+ })();
39
+ cache.set(key, pending);
40
+ }
41
+ return pending;
42
+ }
43
+ /**
44
+ * Loads scene bitmap fonts before views are built, mirroring `loadSceneFonts`. Unlike a regular
45
+ * `FontFace`, PixiJS resolves a `BitmapText`'s font by looking up `Cache` for `${fontFamily}-bitmap`
46
+ * (see `BitmapFontManager.getFont`), so loading here means parsing the XML, building one `BitmapFont`
47
+ * from the already-fetched texture, and registering it in that cache — there is no URL-based loader
48
+ * to delegate to, since our XML and texture live at unrelated asset URIs, not a fixed relative pair.
49
+ */
50
+ export async function loadSceneBitmapFonts(document, sceneId, resolveFileUrl, cache = sharedBitmapFontCache) {
51
+ const scene = document.scenes.find((item) => item.id === sceneId);
52
+ if (scene === undefined)
53
+ throw new Error(`Scene '${sceneId}' does not exist in the project document.`);
54
+ const ids = new Set(fromNodes(collectRenderedNodes(document, scene)));
55
+ const fonts = new Map();
56
+ await Promise.all([...ids].map(async (id) => {
57
+ const asset = document.assets.find((item) => item.id === id);
58
+ if (asset?.type !== "bitmapFont")
59
+ return;
60
+ const font = await loadFont(asset, resolveFileUrl, cache);
61
+ if (font !== undefined)
62
+ fonts.set(id, familyOf(asset.id));
63
+ }));
64
+ return fonts;
65
+ }
66
+ /**
67
+ * Resolves one glyph's already-cropped `Texture` from a bitmap font asset, for reuse as a plain image
68
+ * asset (an Image node, a Button/Checkbox state, ...) — see `BitmapFontAsset.frames`. `BitmapFont`
69
+ * builds one `Texture` per character up front (see its constructor), so this is a lookup, not a crop.
70
+ */
71
+ export async function loadBitmapFontGlyphTexture(asset, glyph, resolveFileUrl, cache = sharedBitmapFontCache) {
72
+ const font = await loadFont(asset, resolveFileUrl, cache);
73
+ return font?.chars[glyph]?.texture;
74
+ }
75
+ //# sourceMappingURL=bitmapFonts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bitmapFonts.js","sourceRoot":"","sources":["../../src/assets/bitmapFonts.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,yBAAyB,EAAgB,MAAM,SAAS,CAAC;AACrF,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAO/C,MA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EAAE,EAAE,EAAE,EAAE;QAC1C,MAAM,KAAK,GAAG,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;QAC7D,IAAI,KAAK,EAAE,IAAI,KAAK,YAAY;YAAE,OAAO;QACzC,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,KAAK,EAAE,cAAc,EAAE,KAAK,CAAC,CAAC;QAC1D,IAAI,IAAI,KAAK,SAAS;YAAE,KAAK,CAAC,GAAG,CAAC,EAAE,EAAE,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC;IAC5D,CAAC,CAAC,CAAC,CAAC;IACJ,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,0BAA0B,CAAC,KAAsB,EAAE,KAAa,EAAE,cAA+B,EAAE,QAAsD,qBAAqB;IAClM,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,KAAK,EAAE,cAAc,EAAE,KAAK,CAAC,CAAC;IAC1D,OAAO,IAAI,EAAE,KAAK,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;AACrC,CAAC"}
@@ -0,0 +1,31 @@
1
+ import type { SkeletonData } from "@esotericsoftware/spine-pixi-v8";
2
+ import type { Sound } from "@pixi/sound";
3
+ import type { BitmapFont, Spritesheet, Texture } from "pixi.js";
4
+ /**
5
+ * Разобранные ассеты, переиспользуемые между загрузками сцен и пресетов. Каждая карта ключуется URI
6
+ * файла ассета, а не его id: один и тот же файл, назначенный разным ассетам, скачивается и парсится один раз.
7
+ *
8
+ * Владелец кэша — вызывающая сторона: время жизни задаёт она (сессия сцены в игре, открытый проект в
9
+ * редакторе), поэтому глобального состояния и скрытого сброса здесь нет.
10
+ */
11
+ export interface SceneAssetCache {
12
+ textures: Map<string, Texture>;
13
+ spritesheets: Map<string, Spritesheet>;
14
+ spines: Map<string, SkeletonData>;
15
+ /** Обещание, а не готовое имя family: параллельные загрузки одного файла должны ждать один и тот же `FontFace.load()`. */
16
+ fonts: Map<string, Promise<string | undefined>>;
17
+ /** Обещание, а не готовый `BitmapFont`: по той же причине, что `fonts` — см. ниже. */
18
+ bitmapFonts: Map<string, Promise<BitmapFont | undefined>>;
19
+ sounds: Map<string, Sound>;
20
+ }
21
+ /**
22
+ * Шрифты кэшируются глобально, потому что `loadSceneFonts` регистрирует `FontFace` в общем для документа
23
+ * `document.fonts`: повторная загрузка того же файла добавила бы туда дубликат, независимо от того, чей
24
+ * это кэш. Остальные ассеты живут в GPU-памяти вызывающей стороны и такого общего реестра не имеют.
25
+ */
26
+ export declare const sharedFontCache: Map<string, Promise<string | undefined>>;
27
+ /** Та же причина, что у `sharedFontCache`: `loadSceneBitmapFonts` регистрирует шрифт в общем PixiJS `Cache`. */
28
+ export declare const sharedBitmapFontCache: Map<string, Promise<BitmapFont | undefined>>;
29
+ /** Создаёт пустой кэш ассетов. Шрифты по умолчанию разделяются со всеми остальными кэшами — см. `sharedFontCache`. */
30
+ export declare function createSceneAssetCache(): SceneAssetCache;
31
+ //# sourceMappingURL=cache.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../../src/assets/cache.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAEhE;;;;;;GAMG;AACH,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IACvC,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IAClC,0HAA0H;IAC1H,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC;IAChD,sFAAsF;IACtF,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAAC,CAAC;IAC1D,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;CAC5B;AAED;;;;GAIG;AACH,eAAO,MAAM,eAAe,0CAAiD,CAAC;AAE9E,gHAAgH;AAChH,eAAO,MAAM,qBAAqB,8CAAqD,CAAC;AAExF,sHAAsH;AACtH,wBAAgB,qBAAqB,IAAI,eAAe,CASvD"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Шрифты кэшируются глобально, потому что `loadSceneFonts` регистрирует `FontFace` в общем для документа
3
+ * `document.fonts`: повторная загрузка того же файла добавила бы туда дубликат, независимо от того, чей
4
+ * это кэш. Остальные ассеты живут в GPU-памяти вызывающей стороны и такого общего реестра не имеют.
5
+ */
6
+ export const sharedFontCache = new Map();
7
+ /** Та же причина, что у `sharedFontCache`: `loadSceneBitmapFonts` регистрирует шрифт в общем PixiJS `Cache`. */
8
+ export const sharedBitmapFontCache = new Map();
9
+ /** Создаёт пустой кэш ассетов. Шрифты по умолчанию разделяются со всеми остальными кэшами — см. `sharedFontCache`. */
10
+ export function createSceneAssetCache() {
11
+ return {
12
+ textures: new Map(),
13
+ spritesheets: new Map(),
14
+ spines: new Map(),
15
+ fonts: sharedFontCache,
16
+ bitmapFonts: sharedBitmapFontCache,
17
+ sounds: new Map(),
18
+ };
19
+ }
20
+ //# sourceMappingURL=cache.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cache.js","sourceRoot":"","sources":["../../src/assets/cache.ts"],"names":[],"mappings":"AAsBA;;;;GAIG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,GAAG,EAAuC,CAAC;AAE9E,gHAAgH;AAChH,MAAM,CAAC,MAAM,qBAAqB,GAAG,IAAI,GAAG,EAA2C,CAAC;AAExF,sHAAsH;AACtH,MAAM,UAAU,qBAAqB;IACnC,OAAO;QACL,QAAQ,EAAE,IAAI,GAAG,EAAE;QACnB,YAAY,EAAE,IAAI,GAAG,EAAE;QACvB,MAAM,EAAE,IAAI,GAAG,EAAE;QACjB,KAAK,EAAE,eAAe;QACtB,WAAW,EAAE,qBAAqB;QAClC,MAAM,EAAE,IAAI,GAAG,EAAE;KAClB,CAAC;AACJ,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import type { ProjectDocument } from "@pixi-ui-editor/schema";
2
2
  import type { FileUrlResolver } from "./textures.js";
3
3
  /** Loads scene fonts before views are built. A load failure is a warning and keeps system fallback usable. */
4
- export declare function loadSceneFonts(document: ProjectDocument, sceneId: string, resolveFileUrl: FileUrlResolver): Promise<Map<string, string>>;
4
+ export declare function loadSceneFonts(document: ProjectDocument, sceneId: string, resolveFileUrl: FileUrlResolver, cache?: Map<string, Promise<string | undefined>>): Promise<Map<string, string>>;
5
5
  //# sourceMappingURL=fonts.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"fonts.d.ts","sourceRoot":"","sources":["../../src/assets/fonts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAS,eAAe,EAAU,MAAM,wBAAwB,CAAC;AAC7E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAYrD,8GAA8G;AAC9G,wBAAsB,cAAc,CAAC,QAAQ,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,eAAe,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAsB9I"}
1
+ {"version":3,"file":"fonts.d.ts","sourceRoot":"","sources":["../../src/assets/fonts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAS,eAAe,EAAU,MAAM,wBAAwB,CAAC;AAC7E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAYrD,8GAA8G;AAC9G,wBAAsB,cAAc,CAClC,QAAQ,EAAE,eAAe,EACzB,OAAO,EAAE,MAAM,EACf,cAAc,EAAE,eAAe,EAC/B,KAAK,GAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAmB,GAChE,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAsB9B"}
@@ -1,5 +1,5 @@
1
+ import { sharedFontCache } from "./cache.js";
1
2
  import { collectRenderedNodes } from "../scene.js";
2
- const cache = new Map();
3
3
  const keyOf = (asset) => `${asset.source.uri}#${asset.source.version ?? ""}`;
4
4
  const fromNodes = (nodes) => nodes.flatMap((node) => {
5
5
  if (node.type === "text" && node.style?.fontAssetId)
@@ -11,7 +11,7 @@ const fromNodes = (nodes) => nodes.flatMap((node) => {
11
11
  return [];
12
12
  });
13
13
  /** Loads scene fonts before views are built. A load failure is a warning and keeps system fallback usable. */
14
- export async function loadSceneFonts(document, sceneId, resolveFileUrl) {
14
+ export async function loadSceneFonts(document, sceneId, resolveFileUrl, cache = sharedFontCache) {
15
15
  const scene = document.scenes.find((item) => item.id === sceneId);
16
16
  if (scene === undefined)
17
17
  throw new Error(`Scene '${sceneId}' does not exist in the project document.`);
@@ -1 +1 @@
1
- {"version":3,"file":"fonts.js","sourceRoot":"","sources":["../../src/assets/fonts.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAEnD,MAAM,KAAK,GAAG,IAAI,GAAG,EAAuC,CAAC;AAC7D,MAAM,KAAK,GAAG,CAAC,KAAuC,EAAE,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC,GAAG,IAAI,KAAK,CAAC,MAAM,CAAC,OAAO,IAAI,EAAE,EAAE,CAAC;AAC/G,MAAM,SAAS,GAAG,CAAC,KAAe,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CA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AAC;oBAAC,UAAU,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;oBAAC,OAAO,KAAK,CAAC,MAAM,CAAC;gBAAC,CAAC;gBAC1M,OAAO,KAAK,EAAE,CAAC;oBAAC,OAAO,CAAC,IAAI,CAAC,8BAA8B,KAAK,CAAC,EAAE,2BAA2B,EAAE,KAAK,CAAC,CAAC;oBAAC,OAAO,SAAS,CAAC;gBAAC,CAAC;YAC7H,CAAC,CAAC,EAAE,CAAC;YACL,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;QAC1B,CAAC;QACD,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC;QAAC,IAAI,MAAM,KAAK,SAAS;YAAE,KAAK,CAAC,GAAG,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;IAChF,CAAC,CAAC,CAAC,CAAC;IACJ,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { Texture } from "pixi.js";
2
+ /**
3
+ * Its own module (not `textures.ts`) so `textures.ts` and `bitmapFonts.ts` can both depend on it
4
+ * without importing from each other: `textures.ts` resolves bitmap font glyph frames through
5
+ * `bitmapFonts.ts`, which itself needs this same texture loader.
6
+ */
7
+ /** Loads one texture from a data URI or a regular URL. */
8
+ export declare function loadTexture(url: string): Promise<Texture>;
9
+ //# sourceMappingURL=loadTexture.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loadTexture.d.ts","sourceRoot":"","sources":["../../src/assets/loadTexture.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAElC;;;;GAIG;AAEH,0DAA0D;AAC1D,wBAAsB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAK/D"}
@@ -0,0 +1,14 @@
1
+ import { Texture } from "pixi.js";
2
+ /**
3
+ * Its own module (not `textures.ts`) so `textures.ts` and `bitmapFonts.ts` can both depend on it
4
+ * without importing from each other: `textures.ts` resolves bitmap font glyph frames through
5
+ * `bitmapFonts.ts`, which itself needs this same texture loader.
6
+ */
7
+ /** Loads one texture from a data URI or a regular URL. */
8
+ export async function loadTexture(url) {
9
+ const image = new Image();
10
+ image.src = url;
11
+ await image.decode();
12
+ return Texture.from(image);
13
+ }
14
+ //# sourceMappingURL=loadTexture.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loadTexture.js","sourceRoot":"","sources":["../../src/assets/loadTexture.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAElC;;;;GAIG;AAEH,0DAA0D;AAC1D,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,GAAW;IAC3C,MAAM,KAAK,GAAG,IAAI,KAAK,EAAE,CAAC;IAC1B,KAAK,CAAC,GAAG,GAAG,GAAG,CAAC;IAChB,MAAM,KAAK,CAAC,MAAM,EAAE,CAAC;IACrB,OAAO,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAC7B,CAAC"}
@@ -1,15 +1,14 @@
1
1
  import { type Asset, type ProjectDocument } from "@pixi-ui-editor/schema";
2
- import { Spritesheet, Texture } from "pixi.js";
2
+ import { Spritesheet, type BitmapFont, type Texture } from "pixi.js";
3
+ import { loadTexture } from "./loadTexture.js";
3
4
  export type AssetUrlResolver = (asset: Asset) => string | undefined;
4
5
  export type FileUrlResolver = (uri: string) => string | undefined;
5
6
  type AtlasAsset = Extract<Asset, {
6
7
  type: "atlas";
7
8
  }>;
8
- /** Loads one texture from a data URI or a regular URL. */
9
- export declare function loadTexture(url: string): Promise<Texture>;
9
+ export { loadTexture };
10
10
  /** Loads and parses one atlas's Spritesheet, sharing the parse by the JSON file's URI. */
11
11
  export declare function loadAtlasSpritesheet(asset: AtlasAsset, resolveFileUrl: FileUrlResolver, cache?: Map<string, Spritesheet>): Promise<Spritesheet>;
12
12
  /** Loads textures for image nodes in a scene, resolving atlas frame ids through their Spritesheet. Leaves failed assets for placeholder rendering. */
13
- export declare function loadSceneTextures(document: ProjectDocument, sceneId: string, resolveAssetUrl: AssetUrlResolver, resolveFileUrl: FileUrlResolver, cache?: Map<string, Texture>, spritesheetCache?: Map<string, Spritesheet>): Promise<Map<string, Texture>>;
14
- export {};
13
+ export declare function loadSceneTextures(document: ProjectDocument, sceneId: string, resolveAssetUrl: AssetUrlResolver, resolveFileUrl: FileUrlResolver, cache?: Map<string, Texture>, spritesheetCache?: Map<string, Spritesheet>, bitmapFontCache?: Map<string, Promise<BitmapFont | undefined>>): Promise<Map<string, Texture>>;
15
14
  //# sourceMappingURL=textures.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"textures.d.ts","sourceRoot":"","sources":["../../src/assets/textures.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyB,KAAK,KAAK,EAAE,KAAK,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACjG,OAAO,EAAE,WAAW,EAAE,OAAO,EAAwB,MAAM,SAAS,CAAC;AAIrE,MAAM,MAAM,gBAAgB,GAAG,CAAC,KAAK,EAAE,KAAK,KAAK,MAAM,GAAG,SAAS,CAAC;AACpE,MAAM,MAAM,eAAe,GAAG,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAAC;AAClE,KAAK,UAAU,GAAG,OAAO,CAAC,KAAK,EAAE;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,CAAC,CAAC;AAEpD,0DAA0D;AAC1D,wBAAsB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAK/D;AAED,0FAA0F;AAC1F,wBAAsB,oBAAoB,CACxC,KAAK,EAAE,UAAU,EACjB,cAAc,EAAE,eAAe,EAC/B,KAAK,GAAE,GAAG,CAAC,MAAM,EAAE,WAAW,CAAa,GAC1C,OAAO,CAAC,WAAW,CAAC,CAgBtB;AAED,sJAAsJ;AACtJ,wBAAsB,iBAAiB,CACrC,Q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O,CAAa,EACvC,gBAAgB,GAAE,GAAG,CAAC,MAAM,EAAE,WAAW,CAAa,EACtD,eAAe,GAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAAyB,GACpF,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAsD/B"}
@@ -1,14 +1,11 @@
1
1
  import { collectEffectAssetIds } from "@pixi-ui-editor/schema";
2
- import { Spritesheet, Texture } from "pixi.js";
2
+ import { Spritesheet } from "pixi.js";
3
3
  import { collectRenderedNodes } from "../scene.js";
4
4
  import { collectNodeAssetIds } from "../views/createNodeView.js";
5
- /** Loads one texture from a data URI or a regular URL. */
6
- export async function loadTexture(url) {
7
- const image = new Image();
8
- image.src = url;
9
- await image.decode();
10
- return Texture.from(image);
11
- }
5
+ import { loadBitmapFontGlyphTexture } from "./bitmapFonts.js";
6
+ import { sharedBitmapFontCache } from "./cache.js";
7
+ import { loadTexture } from "./loadTexture.js";
8
+ export { loadTexture };
12
9
  /** Loads and parses one atlas's Spritesheet, sharing the parse by the JSON file's URI. */
13
10
  export async function loadAtlasSpritesheet(asset, resolveFileUrl, cache = new Map()) {
14
11
  const cached = cache.get(asset.files.json.uri);
@@ -28,17 +25,21 @@ export async function loadAtlasSpritesheet(asset, resolveFileUrl, cache = new Ma
28
25
  return sheet;
29
26
  }
30
27
  /** Loads textures for image nodes in a scene, resolving atlas frame ids through their Spritesheet. Leaves failed assets for placeholder rendering. */
31
- export async function loadSceneTextures(document, sceneId, resolveAssetUrl, resolveFileUrl, cache = new Map(), spritesheetCache = new Map()) {
28
+ export async function loadSceneTextures(document, sceneId, resolveAssetUrl, resolveFileUrl, cache = new Map(), spritesheetCache = new Map(), bitmapFontCache = sharedBitmapFontCache) {
32
29
  const scene = document.scenes.find((candidate) => candidate.id === sceneId);
33
30
  if (scene === undefined)
34
31
  throw new Error(`Scene '${sceneId}' does not exist in the project document.`);
35
32
  const assetsById = new Map(document.assets.map((asset) => [asset.id, asset]));
36
33
  const framesById = new Map();
37
34
  for (const asset of document.assets) {
38
- if (asset.type !== "atlas")
39
- continue;
40
- for (const [frameName, frameId] of Object.entries(asset.frames))
41
- framesById.set(frameId, { atlas: asset, frameName });
35
+ if (asset.type === "atlas") {
36
+ for (const [frameName, frameId] of Object.entries(asset.frames))
37
+ framesById.set(frameId, { kind: "atlas", atlas: asset, frameName });
38
+ }
39
+ else if (asset.type === "bitmapFont") {
40
+ for (const [frameName, frameId] of Object.entries(asset.frames ?? {}))
41
+ framesById.set(frameId, { kind: "bitmapFont", bitmapFont: asset, frameName });
42
+ }
42
43
  }
43
44
  const textures = new Map();
44
45
  for (const node of collectRenderedNodes(document, scene)) {
@@ -68,16 +69,26 @@ export async function loadSceneTextures(document, sceneId, resolveAssetUrl, reso
68
69
  if (frame === undefined)
69
70
  continue;
70
71
  try {
71
- const sheet = await loadAtlasSpritesheet(frame.atlas, resolveFileUrl, spritesheetCache);
72
- const frameTexture = sheet.textures[frame.frameName];
73
- if (frameTexture === undefined) {
74
- console.warn(`Atlas '${frame.atlas.id}' has no frame '${frame.frameName}'.`);
75
- continue;
72
+ if (frame.kind === "atlas") {
73
+ const sheet = await loadAtlasSpritesheet(frame.atlas, resolveFileUrl, spritesheetCache);
74
+ const frameTexture = sheet.textures[frame.frameName];
75
+ if (frameTexture === undefined) {
76
+ console.warn(`Atlas '${frame.atlas.id}' has no frame '${frame.frameName}'.`);
77
+ continue;
78
+ }
79
+ textures.set(assetId, frameTexture);
80
+ }
81
+ else {
82
+ const glyphTexture = await loadBitmapFontGlyphTexture(frame.bitmapFont, frame.frameName, resolveFileUrl, bitmapFontCache);
83
+ if (glyphTexture === undefined) {
84
+ console.warn(`Bitmap font '${frame.bitmapFont.id}' has no glyph '${frame.frameName}'.`);
85
+ continue;
86
+ }
87
+ textures.set(assetId, glyphTexture);
76
88
  }
77
- textures.set(assetId, frameTexture);
78
89
  }
79
90
  catch (error) {
80
- console.warn(`Unable to load atlas frame texture for '${assetId}'.`, error);
91
+ console.warn(`Unable to load frame texture for '${assetId}'.`, error);
81
92
  }
82
93
  }
83
94
  }
@@ -1 +1 @@
1
- {"version":3,"file":"textures.js","sourceRoot":"","sources":["../../src/assets/textures.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAoC,MAAM,wBAAwB,CAAC;AACjG,OAAO,EAAE,WAAW,EAAE,OAAO,EAAwB,MAAM,SAAS,CAAC;AACrE,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAMjE,0DAA0D;AAC1D,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,GAAW;IAC3C,MAAM,KAAK,GAAG,IAAI,KAAK,EAAE,CAAC;IAC1B,KAAK,CAAC,GAAG,GAAG,GAAG,CAAC;IAChB,MAAM,KAAK,CAAC,MAAM,EAAE,CAAC;IACrB,OAAO,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAC7B,CAAC;AAED,0FAA0F;AAC1F,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,KAAiB,EACjB,cAA+B,EAC/B,QAAkC,IAAI,GAAG,EAAE;IAE3C,MAAM,MAAM,GAAG,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC/C,IAAI,MAAM,KAAK,SAAS;QAAE,OAAO,MAAM,CAAC;IAExC,MAAM,OAAO,GAAG,cAAc,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACrD,MAAM,UAAU,GAAG,cAAc,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAC3D,IAAI,OAAO,KAAK,SAAS,IAAI,UAAU,KAAK,SAAS;QAAE,MAAM,IAAI,KAAK,CAAC,gDAAgD,KAAK,CAAC,EAAE,IAAI,CAAC,CA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EAAE,mBAAmB,KAAK,CAAC,SAAS,IAAI,CAAC,CAAC;wBAAC,SAAS;oBAAC,CAAC;oBACtI,QAAQ,CAAC,GAAG,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;gBACtC,CAAC;YACH,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,OAAO,CAAC,IAAI,CAAC,qCAAqC,OAAO,IAAI,EAAE,KAAK,CAAC,CAAC;YACxE,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import { type SkeletonData } from "@esotericsoftware/spine-pixi-v8";
2
- import { type ButtonStateKey } from "@pixi-ui-editor/schema";
2
+ import { type ButtonStateKey, type LayoutPadding } from "@pixi-ui-editor/schema";
3
3
  import { Container } from "pixi.js";
4
4
  /** Reads the current 1-based animation frame for an editor Spine node. */
5
5
  export declare function getSpineViewPlayback(view: Container, skeletonData: SkeletonData, animation: string): {
@@ -10,6 +10,14 @@ export declare function getSpineViewPlayback(view: Container, skeletonData: Skel
10
10
  export declare function setSpineViewFrame(view: Container, frame: number, skeletonData: SkeletonData, animation: string): void;
11
11
  /** Forces an editor-only button state; the node's serialized `enabled` and states stay untouched. */
12
12
  export declare function setButtonViewState(view: Container, state: ButtonStateKey): void;
13
+ /** Forces an editor-only checkbox checked state; the node's serialized `defaultChecked` stays untouched. */
14
+ export declare function setCheckboxViewChecked(view: Container, checked: boolean): void;
15
+ /** Forces an editor-only staged button preview stage; the document's `stages`/current stage stay untouched. */
16
+ export declare function setStagedButtonViewStage(view: Container, index: number): void;
17
+ /** Forces an editor-only staged button visual state; the node's serialized `enabled` stays untouched. */
18
+ export declare function setStagedButtonViewState(view: Container, state: ButtonStateKey): void;
19
+ /** Live-previews nine-slice border edits while dragging the canvas gizmo; commits only on release. */
20
+ export declare function previewNineSlice(view: Container, nineSlice: LayoutPadding): void;
13
21
  /** Applies an editor-only slider preview value without touching the document. */
14
22
  export declare function setSliderViewValue(view: Container, value: number): void;
15
23
  /** Applies an editor-only progress preview without touching the document. */
@@ -1 +1 @@
1
- {"version":3,"file":"controls.d.ts","sourceRoot":"","sources":["../src/controls.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAS,MAAM,iCAAiC,CAAC;AAC3E,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAUpC,0EAA0E;AAC1E,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,SAAS,EAAE,YAAY,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,CASnJ;AAED,kHAAkH;AAClH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,CASrH;AAED,qGAAqG;AACrG,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,cAAc,GAAG,IAAI,CAE/E;AAED,iFAAiF;AACjF,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAEvE;AAED,6EAA6E;AAC7E,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAElF;AAED,+FAA+F;AAC/F,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,OAAO,GAAG,IAAI,CAG7E"}
1
+ {"version":3,"file":"controls.d.ts","sourceRoot":"","sources":["../src/controls.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAS,MAAM,iCAAiC,CAAC;AAC3E,OAAO,EAAE,KAAK,cAAc,EAAE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