@caperjs/core 0.7.1 → 0.7.3

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 (68) hide show
  1. package/build/assetpack.mjs +35 -3
  2. package/build/defaults.mjs +39 -1
  3. package/build/index.mjs +13 -2
  4. package/build/internal/outputMarker.mjs +52 -0
  5. package/cli/doctor.mjs +205 -2
  6. package/cli/doctor.test.mjs +522 -1
  7. package/cli/native.mjs +825 -0
  8. package/cli/native.test.mjs +1071 -0
  9. package/cli.mjs +4 -0
  10. package/extras/css/fullscreen.css +8 -0
  11. package/extras/llms.txt +27 -0
  12. package/extras/skills/caper/SKILL.md +1 -0
  13. package/lib/{CaptionsPlugin-BoMkCsJO.js → CaptionsPlugin-COrofpHN.js} +2 -2
  14. package/lib/{CaptionsPlugin-BoMkCsJO.js.map → CaptionsPlugin-COrofpHN.js.map} +1 -1
  15. package/lib/{DataAdapter-DHWHuN-y.js → DataAdapter-T-22-_D1.js} +2 -2
  16. package/lib/{DataAdapter-DHWHuN-y.js.map → DataAdapter-T-22-_D1.js.map} +1 -1
  17. package/lib/{DebugRenderer-9a3mO9kX.js → DebugRenderer-ZN692Pbg.js} +4 -4
  18. package/lib/{DebugRenderer-9a3mO9kX.js.map → DebugRenderer-ZN692Pbg.js.map} +1 -1
  19. package/lib/{DevToolsPlugin-TkcBq1js.js → DevToolsPlugin-CQXFoj1T.js} +3 -3
  20. package/lib/{DevToolsPlugin-TkcBq1js.js.map → DevToolsPlugin-CQXFoj1T.js.map} +1 -1
  21. package/lib/{GSAPPlugin-DLOiVK_m.js → GSAPPlugin-CNkncyXS.js} +2 -2
  22. package/lib/{GSAPPlugin-DLOiVK_m.js.map → GSAPPlugin-CNkncyXS.js.map} +1 -1
  23. package/lib/{LayoutPlugin-CEPcr4GU.js → LayoutPlugin-BuJgr9bd.js} +26 -26
  24. package/lib/{LayoutPlugin-CEPcr4GU.js.map → LayoutPlugin-BuJgr9bd.js.map} +1 -1
  25. package/lib/{ScreenDebugPlugin-CiT0viiF.js → ScreenDebugPlugin-kz9Mr6j1.js} +2 -2
  26. package/lib/{ScreenDebugPlugin-CiT0viiF.js.map → ScreenDebugPlugin-kz9Mr6j1.js.map} +1 -1
  27. package/lib/{SpinePlugin-kyeWILtF.js → SpinePlugin-DDzD-Qxd.js} +1099 -877
  28. package/lib/SpinePlugin-DDzD-Qxd.js.map +1 -0
  29. package/lib/{StatsPlugin-5So44eOq.js → StatsPlugin-tyFGzVjy.js} +2 -2
  30. package/lib/{StatsPlugin-5So44eOq.js.map → StatsPlugin-tyFGzVjy.js.map} +1 -1
  31. package/lib/{VoiceOverPlugin--QoLj6pc.js → VoiceOverPlugin-rTNz_9eb.js} +2 -2
  32. package/lib/{VoiceOverPlugin--QoLj6pc.js.map → VoiceOverPlugin-rTNz_9eb.js.map} +1 -1
  33. package/lib/caper.mjs +109 -109
  34. package/lib/caper.mjs.map +1 -1
  35. package/lib/{const-GLIgV4ZV.js → const-BClauBNo.js} +107 -97
  36. package/lib/const-BClauBNo.js.map +1 -0
  37. package/lib/plugins/FullScreenPlugin.d.ts +65 -0
  38. package/lib/plugins/FullScreenPlugin.d.ts.map +1 -1
  39. package/lib/plugins/spine/SpinePlugin.d.ts.map +1 -1
  40. package/lib/plugins/spine/SpinePlugin.test.d.ts +2 -0
  41. package/lib/plugins/spine/SpinePlugin.test.d.ts.map +1 -0
  42. package/lib/{registries-C5yiKJ6v.js → registries-DmNGVLAi.js} +489 -446
  43. package/lib/registries-DmNGVLAi.js.map +1 -0
  44. package/lib/ui/Button.d.ts.map +1 -1
  45. package/lib/ui/UICanvas.d.ts +10 -2
  46. package/lib/ui/UICanvas.d.ts.map +1 -1
  47. package/lib/utils/platform.d.ts +5 -0
  48. package/lib/utils/platform.d.ts.map +1 -1
  49. package/lib/utils/platform.test.d.ts +2 -0
  50. package/lib/utils/platform.test.d.ts.map +1 -0
  51. package/lib/utils/types.d.ts +1 -1
  52. package/lib/utils/types.d.ts.map +1 -1
  53. package/package.json +3 -3
  54. package/src/plugins/FullScreenPlugin.test.ts +138 -0
  55. package/src/plugins/FullScreenPlugin.ts +132 -0
  56. package/src/plugins/spine/SpinePlugin.test.ts +31 -0
  57. package/src/plugins/spine/SpinePlugin.ts +9 -2
  58. package/src/ui/Button.test.ts +22 -0
  59. package/src/ui/Button.ts +7 -0
  60. package/src/ui/UICanvas.test.ts +23 -1
  61. package/src/ui/UICanvas.ts +22 -3
  62. package/src/utils/platform.test.ts +20 -0
  63. package/src/utils/platform.ts +6 -0
  64. package/src/utils/types.ts +5 -1
  65. package/src/version.ts +2 -2
  66. package/lib/SpinePlugin-kyeWILtF.js.map +0 -1
  67. package/lib/const-GLIgV4ZV.js.map +0 -1
  68. package/lib/registries-C5yiKJ6v.js.map +0 -1
@@ -23,7 +23,7 @@ vi.mock('../core/Application', async () => {
23
23
  // constructed. See importOrder.containerFirst.test.ts.
24
24
  import '../mixins/factory/const';
25
25
  import { Signal } from '../signals';
26
- import { computeEffectivePadding, UICanvas } from './UICanvas';
26
+ import { computeEffectivePadding, resolveSafeArea, UICanvas } from './UICanvas';
27
27
 
28
28
  const zero = { top: 0, right: 0, bottom: 0, left: 0 };
29
29
 
@@ -51,6 +51,28 @@ describe('computeEffectivePadding', () => {
51
51
  });
52
52
  });
53
53
 
54
+ describe('resolveSafeArea', () => {
55
+ const insets = { top: 51, right: 4, bottom: 34, left: 4 };
56
+
57
+ it('keeps every inset when useSafeArea is true', () => {
58
+ expect(resolveSafeArea(insets, true)).toEqual(insets);
59
+ });
60
+
61
+ it('drops every inset when useSafeArea is false', () => {
62
+ expect(resolveSafeArea(insets, false)).toEqual(zero);
63
+ });
64
+
65
+ it('drops only the edges set to false, keeping the ones left out', () => {
66
+ expect(resolveSafeArea(insets, { top: false })).toEqual({ top: 0, right: 4, bottom: 34, left: 4 });
67
+ expect(resolveSafeArea(insets, { top: false, bottom: true, left: false })).toEqual({
68
+ top: 0,
69
+ right: 4,
70
+ bottom: 34,
71
+ left: 0,
72
+ });
73
+ });
74
+ });
75
+
54
76
  describe('UICanvas element reordering', () => {
55
77
  let app: any;
56
78
  let originalAppDescriptor: PropertyDescriptor | undefined;
@@ -73,11 +73,18 @@ export type UICanvasConfig = {
73
73
  padding: Padding;
74
74
  size: Size;
75
75
  useAppSize: boolean;
76
- useSafeArea: boolean;
76
+ useSafeArea: UICanvasSafeArea;
77
77
  layout?: Omit<LayoutOptions, 'target'> | null | boolean;
78
78
  autoLayoutChildren?: boolean;
79
79
  };
80
80
 
81
+ /**
82
+ * Which device safe-area insets the canvas pads by: `true` (all four, the default), `false`
83
+ * (none), or per edge, where an edge left out stays on. `{ top: false }` lets top-row UI sit
84
+ * in the camera strip of a punch-hole phone while the bottom still clears the gesture bar.
85
+ */
86
+ export type UICanvasSafeArea = boolean | Partial<Record<keyof Padding, boolean>>;
87
+
81
88
  export const UICanvasConfigKeys: (keyof UICanvasConfig)[] = [
82
89
  'debug',
83
90
  'padding',
@@ -92,7 +99,7 @@ export type UICanvasProps = {
92
99
  padding: Partial<Padding> | PointLike;
93
100
  size?: SizeLike;
94
101
  useAppSize?: boolean;
95
- useSafeArea?: boolean;
102
+ useSafeArea?: UICanvasSafeArea;
96
103
  layout?: Omit<LayoutOptions, 'target'> | null | boolean;
97
104
  autoLayoutChildren?: boolean;
98
105
  };
@@ -113,6 +120,18 @@ export function computeEffectivePadding(padding: Padding, safeArea: Padding): Pa
113
120
  };
114
121
  }
115
122
 
123
+ /** The safe-area insets `useSafeArea` keeps: all, none, or the edges not set to `false`. */
124
+ export function resolveSafeArea(safeArea: Padding, useSafeArea: UICanvasSafeArea): Padding {
125
+ if (useSafeArea === true) return { ...safeArea };
126
+ if (useSafeArea === false) return { ...zeroPadding };
127
+ return {
128
+ top: useSafeArea.top === false ? 0 : safeArea.top,
129
+ right: useSafeArea.right === false ? 0 : safeArea.right,
130
+ bottom: useSafeArea.bottom === false ? 0 : safeArea.bottom,
131
+ left: useSafeArea.left === false ? 0 : safeArea.left,
132
+ };
133
+ }
134
+
116
135
  const defaultLayout = {
117
136
  flexGrow: 0,
118
137
  flexShrink: 0,
@@ -449,7 +468,7 @@ export class UICanvas extends _UICanvas {
449
468
  private _applyPadding() {
450
469
  const padding = computeEffectivePadding(
451
470
  this.config.padding,
452
- this.config.useSafeArea ? this.app.safeArea : zeroPadding,
471
+ resolveSafeArea(this.app.safeArea, this.config.useSafeArea),
453
472
  );
454
473
  this.layout = {
455
474
  paddingLeft: padding.left,
@@ -0,0 +1,20 @@
1
+ import { beforeEach, describe, expect, it, vi } from 'vitest';
2
+
3
+ describe('isTauri', () => {
4
+ beforeEach(() => {
5
+ delete (window as unknown as { __TAURI_INTERNALS__?: unknown }).__TAURI_INTERNALS__;
6
+ vi.resetModules();
7
+ });
8
+
9
+ it('is false in the default test env', async () => {
10
+ const { isTauri } = await import('./platform');
11
+ expect(isTauri).toBe(false);
12
+ });
13
+
14
+ it('is true when window.__TAURI_INTERNALS__ is defined before a fresh import', async () => {
15
+ (window as unknown as { __TAURI_INTERNALS__?: unknown }).__TAURI_INTERNALS__ = {};
16
+ vi.resetModules();
17
+ const { isTauri } = await import('./platform');
18
+ expect(isTauri).toBe(true);
19
+ });
20
+ });
@@ -23,6 +23,12 @@ export const isTouch: boolean =
23
23
  ? 'ontouchstart' in window || navigator.maxTouchPoints > 0
24
24
  : false;
25
25
 
26
+ /**
27
+ * Check if we're running inside a Tauri webview (the native app shell), as
28
+ * opposed to a plain browser tab.
29
+ */
30
+ export const isTauri: boolean = typeof window !== 'undefined' ? '__TAURI_INTERNALS__' in window : false;
31
+
26
32
  /**
27
33
  * Checks if the device is a mobile device.
28
34
  * This uses the `isMobile` function from the `@pixi/utils` package.
@@ -286,7 +286,11 @@ export type KeyboardKey =
286
286
  | 'IntlBackslash'
287
287
  | 'MetaLeft'
288
288
  | 'MetaRight'
289
- | 'ContextMenu';
289
+ | 'ContextMenu'
290
+ // Navigation keys sent by Android's back button/gesture (delivered by
291
+ // @caperjs/plugin-tauri), TV remotes, and some Android browsers.
292
+ | 'GoBack'
293
+ | 'BrowserBack';
290
294
 
291
295
  export type { Spine } from '../plugins/spine/pixi-spine';
292
296
 
package/src/version.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  // This file is auto-generated during the build process.
2
- export const version: string = '0.7.1';
3
- export const pixiVersion: string = '8.21.0';
2
+ export const version: string = '0.7.3';
3
+ export const pixiVersion: string = '8.22.0';