@playcanvas/web-components 0.11.0 → 0.12.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 (82) hide show
  1. package/README.md +1 -1
  2. package/dist/app.d.ts +31 -49
  3. package/dist/asset.d.ts +152 -12
  4. package/dist/async-element.d.ts +26 -9
  5. package/dist/components/button-component.d.ts +3 -7
  6. package/dist/components/camera-component.d.ts +3 -7
  7. package/dist/components/collision-component.d.ts +19 -7
  8. package/dist/components/component.d.ts +41 -4
  9. package/dist/components/element-component.d.ts +4 -8
  10. package/dist/components/gsplat-component.d.ts +2 -7
  11. package/dist/components/layoutchild-component.d.ts +2 -7
  12. package/dist/components/layoutgroup-component.d.ts +3 -7
  13. package/dist/components/light-component.d.ts +3 -7
  14. package/dist/components/listener-component.d.ts +1 -6
  15. package/dist/components/particlesystem-component.d.ts +2 -7
  16. package/dist/components/render-component.d.ts +2 -7
  17. package/dist/components/rigidbody-component.d.ts +3 -7
  18. package/dist/components/screen-component.d.ts +3 -7
  19. package/dist/components/script-component.d.ts +8 -20
  20. package/dist/components/script.d.ts +2 -22
  21. package/dist/components/scrollbar-component.d.ts +2 -7
  22. package/dist/components/scrollview-component.d.ts +3 -7
  23. package/dist/components/sound-component.d.ts +2 -7
  24. package/dist/components/sound-slot.d.ts +8 -6
  25. package/dist/custom-elements.json +5824 -10581
  26. package/dist/entity-base.d.ts +67 -0
  27. package/dist/entity.d.ts +7 -48
  28. package/dist/index.d.ts +41 -1
  29. package/dist/material.d.ts +14 -13
  30. package/dist/model.d.ts +43 -5
  31. package/dist/module.d.ts +0 -6
  32. package/dist/node.d.ts +253 -0
  33. package/dist/parse.d.ts +2 -1
  34. package/dist/pwc.cjs +1830 -274
  35. package/dist/pwc.cjs.map +1 -1
  36. package/dist/pwc.js +1830 -274
  37. package/dist/pwc.js.map +1 -1
  38. package/dist/pwc.min.js +1 -1
  39. package/dist/pwc.min.js.map +1 -1
  40. package/dist/pwc.min.mjs +1 -1
  41. package/dist/pwc.min.mjs.map +1 -1
  42. package/dist/pwc.mjs +1830 -276
  43. package/dist/pwc.mjs.map +1 -1
  44. package/dist/scene.d.ts +4 -7
  45. package/dist/sky.d.ts +13 -5
  46. package/dist/vscode.html-custom-data.json +148 -26
  47. package/dist/web-types.json +894 -581
  48. package/package.json +9 -8
  49. package/src/app.ts +163 -88
  50. package/src/asset.ts +472 -36
  51. package/src/async-element.ts +39 -12
  52. package/src/components/button-component.ts +5 -9
  53. package/src/components/camera-component.ts +24 -10
  54. package/src/components/collision-component.ts +61 -15
  55. package/src/components/component.ts +151 -11
  56. package/src/components/element-component.ts +26 -30
  57. package/src/components/gsplat-component.ts +4 -9
  58. package/src/components/layoutchild-component.ts +4 -9
  59. package/src/components/layoutgroup-component.ts +14 -9
  60. package/src/components/light-component.ts +42 -12
  61. package/src/components/listener-component.ts +1 -7
  62. package/src/components/particlesystem-component.ts +7 -15
  63. package/src/components/render-component.ts +5 -10
  64. package/src/components/rigidbody-component.ts +23 -16
  65. package/src/components/screen-component.ts +5 -9
  66. package/src/components/script-component.ts +108 -46
  67. package/src/components/script.ts +38 -33
  68. package/src/components/scrollbar-component.ts +6 -16
  69. package/src/components/scrollview-component.ts +16 -11
  70. package/src/components/sound-component.ts +10 -15
  71. package/src/components/sound-slot.ts +30 -20
  72. package/src/entity-base.ts +136 -0
  73. package/src/entity.ts +47 -118
  74. package/src/index.ts +50 -1
  75. package/src/loading-bar.ts +8 -8
  76. package/src/material.ts +65 -39
  77. package/src/model.ts +140 -17
  78. package/src/module.ts +8 -7
  79. package/src/node.ts +715 -0
  80. package/src/parse.ts +62 -17
  81. package/src/scene.ts +12 -9
  82. package/src/sky.ts +50 -10
@@ -1,4 +1,5 @@
1
- import { LayoutGroupComponent, Vec2, Vec4 } from 'playcanvas';
1
+ import type { LayoutGroupComponent } from 'playcanvas';
2
+ import { Vec2, Vec4 } from 'playcanvas';
2
3
  import { ComponentElement } from './component';
3
4
  /**
4
5
  * The LayoutGroupComponentElement interface provides properties and methods for manipulating
@@ -20,7 +21,7 @@ declare class LayoutGroupComponentElement extends ComponentElement {
20
21
  private _wrap;
21
22
  /** @ignore */
22
23
  constructor();
23
- getInitialComponentData(): {
24
+ protected getInitialComponentData(): {
24
25
  orientation: number | undefined;
25
26
  reverseX: boolean;
26
27
  reverseY: boolean;
@@ -132,9 +133,4 @@ declare class LayoutGroupComponentElement extends ComponentElement {
132
133
  static get observedAttributes(): string[];
133
134
  attributeChangedCallback(name: string, _oldValue: string | null, newValue: string | null): void;
134
135
  }
135
- declare global {
136
- interface HTMLElementTagNameMap {
137
- 'pc-layoutgroup': LayoutGroupComponentElement;
138
- }
139
- }
140
136
  export { LayoutGroupComponentElement };
@@ -1,4 +1,5 @@
1
- import { Color, LightComponent } from 'playcanvas';
1
+ import type { LightComponent } from 'playcanvas';
2
+ import { Color } from 'playcanvas';
2
3
  import { ComponentElement } from './component';
3
4
  /**
4
5
  * The LightComponentElement interface provides properties and methods for manipulating
@@ -30,7 +31,7 @@ declare class LightComponentElement extends ComponentElement {
30
31
  private _shadowBlockerSamples;
31
32
  /** @ignore */
32
33
  constructor();
33
- getInitialComponentData(): {
34
+ protected getInitialComponentData(): {
34
35
  castShadows: boolean;
35
36
  color: Color;
36
37
  innerConeAngle: number;
@@ -260,9 +261,4 @@ declare class LightComponentElement extends ComponentElement {
260
261
  static get observedAttributes(): string[];
261
262
  attributeChangedCallback(name: string, _oldValue: string | null, newValue: string | null): void;
262
263
  }
263
- declare global {
264
- interface HTMLElementTagNameMap {
265
- 'pc-light': LightComponentElement;
266
- }
267
- }
268
264
  export { LightComponentElement };
@@ -1,4 +1,4 @@
1
- import { AudioListenerComponent } from 'playcanvas';
1
+ import type { AudioListenerComponent } from 'playcanvas';
2
2
  import { ComponentElement } from './component';
3
3
  /**
4
4
  * The ListenerComponentElement interface provides properties and methods for manipulating
@@ -17,9 +17,4 @@ declare class ListenerComponentElement extends ComponentElement {
17
17
  */
18
18
  get component(): AudioListenerComponent;
19
19
  }
20
- declare global {
21
- interface HTMLElementTagNameMap {
22
- 'pc-listener': ListenerComponentElement;
23
- }
24
- }
25
20
  export { ListenerComponentElement };
@@ -1,4 +1,4 @@
1
- import { ParticleSystemComponent } from 'playcanvas';
1
+ import type { ParticleSystemComponent } from 'playcanvas';
2
2
  import { ComponentElement } from './component';
3
3
  /**
4
4
  * The ParticleSystemComponentElement interface provides properties and methods for manipulating
@@ -12,7 +12,7 @@ declare class ParticleSystemComponentElement extends ComponentElement {
12
12
  private _asset;
13
13
  /** @ignore */
14
14
  constructor();
15
- getInitialComponentData(): object;
15
+ protected getInitialComponentData(): object;
16
16
  /**
17
17
  * Gets the underlying PlayCanvas particle system component.
18
18
  * @returns The particle system component.
@@ -49,9 +49,4 @@ declare class ParticleSystemComponentElement extends ComponentElement {
49
49
  static get observedAttributes(): string[];
50
50
  attributeChangedCallback(name: string, _oldValue: string | null, newValue: string | null): void;
51
51
  }
52
- declare global {
53
- interface HTMLElementTagNameMap {
54
- 'pc-particles': ParticleSystemComponentElement;
55
- }
56
- }
57
52
  export { ParticleSystemComponentElement };
@@ -1,4 +1,4 @@
1
- import { RenderComponent, StandardMaterial } from 'playcanvas';
1
+ import type { RenderComponent, StandardMaterial } from 'playcanvas';
2
2
  import { ComponentElement } from './component';
3
3
  /**
4
4
  * The RenderComponentElement interface provides properties and methods for manipulating
@@ -19,7 +19,7 @@ declare class RenderComponentElement extends ComponentElement {
19
19
  private _type;
20
20
  /** @ignore */
21
21
  constructor();
22
- getInitialComponentData(): {
22
+ protected getInitialComponentData(): {
23
23
  type: "box" | "capsule" | "cone" | "cylinder" | "sphere" | "plane";
24
24
  castShadows: boolean;
25
25
  material: StandardMaterial | null | undefined;
@@ -73,9 +73,4 @@ declare class RenderComponentElement extends ComponentElement {
73
73
  static get observedAttributes(): string[];
74
74
  attributeChangedCallback(name: string, _oldValue: string | null, newValue: string | null): void;
75
75
  }
76
- declare global {
77
- interface HTMLElementTagNameMap {
78
- 'pc-render': RenderComponentElement;
79
- }
80
- }
81
76
  export { RenderComponentElement };
@@ -1,4 +1,5 @@
1
- import { RigidBodyComponent, Vec3 } from 'playcanvas';
1
+ import type { RigidBodyComponent } from 'playcanvas';
2
+ import { Vec3 } from 'playcanvas';
2
3
  import { ComponentElement } from './component';
3
4
  /**
4
5
  * The RigidBodyComponentElement interface provides properties and methods for manipulating
@@ -47,7 +48,7 @@ declare class RigidBodyComponentElement extends ComponentElement {
47
48
  private _type;
48
49
  /** @ignore */
49
50
  constructor();
50
- getInitialComponentData(): {
51
+ protected getInitialComponentData(): {
51
52
  angularDamping: number;
52
53
  angularFactor: Vec3;
53
54
  friction: number;
@@ -84,9 +85,4 @@ declare class RigidBodyComponentElement extends ComponentElement {
84
85
  static get observedAttributes(): string[];
85
86
  attributeChangedCallback(name: string, _oldValue: string | null, newValue: string | null): void;
86
87
  }
87
- declare global {
88
- interface HTMLElementTagNameMap {
89
- 'pc-rigidbody': RigidBodyComponentElement;
90
- }
91
- }
92
88
  export { RigidBodyComponentElement };
@@ -1,4 +1,5 @@
1
- import { ScreenComponent, Vec2 } from 'playcanvas';
1
+ import type { ScreenComponent } from 'playcanvas';
2
+ import { Vec2 } from 'playcanvas';
2
3
  import { ComponentElement } from './component';
3
4
  /**
4
5
  * The ScreenComponentElement interface provides properties and methods for manipulating
@@ -17,7 +18,7 @@ declare class ScreenComponentElement extends ComponentElement {
17
18
  private _scaleBlend;
18
19
  /** @ignore */
19
20
  constructor();
20
- getInitialComponentData(): {
21
+ protected getInitialComponentData(): {
21
22
  priority: number;
22
23
  referenceResolution: Vec2;
23
24
  resolution: Vec2;
@@ -66,9 +67,4 @@ declare class ScreenComponentElement extends ComponentElement {
66
67
  static get observedAttributes(): string[];
67
68
  attributeChangedCallback(name: string, _oldValue: string | null, newValue: string | null): void;
68
69
  }
69
- declare global {
70
- interface HTMLElementTagNameMap {
71
- 'pc-screen': ScreenComponentElement;
72
- }
73
- }
74
70
  export { ScreenComponentElement };
@@ -1,28 +1,21 @@
1
- import { ScriptComponent } from 'playcanvas';
1
+ import type { ScriptComponent } from 'playcanvas';
2
2
  import { ComponentElement } from './component';
3
- interface ScriptAttributesChangeEvent extends CustomEvent {
3
+ export type ScriptAttributesChangeEvent = {
4
4
  detail: {
5
5
  attributes: Record<string, any>;
6
6
  };
7
- }
8
- interface ScriptEnableChangeEvent extends CustomEvent {
7
+ } & CustomEvent;
8
+ export type ScriptEnableChangeEvent = {
9
9
  detail: {
10
10
  enabled: boolean;
11
11
  };
12
- }
13
- interface ScriptNameChangeEvent extends CustomEvent {
12
+ } & CustomEvent;
13
+ export type ScriptNameChangeEvent = {
14
14
  detail: {
15
15
  oldName: string;
16
16
  newName: string;
17
17
  };
18
- }
19
- declare global {
20
- interface HTMLElementEventMap {
21
- 'scriptattributeschange': ScriptAttributesChangeEvent;
22
- 'scriptenablechange': ScriptEnableChangeEvent;
23
- 'scriptnamechange': ScriptNameChangeEvent;
24
- }
25
- }
18
+ } & CustomEvent;
26
19
  /**
27
20
  * The ScriptComponentElement interface provides properties and methods for manipulating
28
21
  * {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-scripts/ | `<pc-scripts>`} elements.
@@ -36,7 +29,7 @@ declare class ScriptComponentElement extends ComponentElement {
36
29
  /** @ignore */
37
30
  constructor();
38
31
  connectedCallback(): Promise<void>;
39
- initComponent(): void;
32
+ protected initComponent(): void;
40
33
  /**
41
34
  * Recursively converts raw attribute data into proper PlayCanvas types. Supported conversions:
42
35
  * - "asset:id" → the Asset created by the `pc-asset` element with that id
@@ -167,9 +160,4 @@ declare class ScriptComponentElement extends ComponentElement {
167
160
  */
168
161
  get component(): ScriptComponent;
169
162
  }
170
- declare global {
171
- interface HTMLElementTagNameMap {
172
- 'pc-scripts': ScriptComponentElement;
173
- }
174
- }
175
163
  export { ScriptComponentElement };
@@ -1,4 +1,4 @@
1
- import { Script } from 'playcanvas';
1
+ import type { Script } from 'playcanvas';
2
2
  import { AsyncElement } from '../async-element';
3
3
  /**
4
4
  * The ScriptElement interface provides properties and methods for manipulating
@@ -36,17 +36,6 @@ import { AsyncElement } from '../async-element';
36
36
  declare class ScriptElement extends AsyncElement {
37
37
  private _attributes;
38
38
  private _enabled;
39
- /**
40
- * Whether readiness has been signalled. Creation can happen more than once over an
41
- * element's life (a runtime `name` change recreates the instance), but `ready` is a
42
- * one-shot signal, so only the first successful creation fires it.
43
- */
44
- private _readySignalled;
45
- /**
46
- * The Script instance created for this element by its parent `<pc-scripts>` element.
47
- * @ignore
48
- */
49
- _script: Script | null;
50
39
  /**
51
40
  * Sets the attributes of the script as an object. Values are converted with the same rules
52
41
  * as the `attributes` attribute: `asset:`/`entity:` references and `vec2:`/`vec3:`/`vec4:`/
@@ -98,17 +87,8 @@ declare class ScriptElement extends AsyncElement {
98
87
  */
99
88
  get script(): Script | null;
100
89
  connectedCallback(): void;
101
- /**
102
- * Called by the parent `<pc-scripts>` element when the script instance has been created.
103
- * @ignore
104
- */
105
- _onScriptCreated(): void;
90
+ disconnectedCallback(): void;
106
91
  static get observedAttributes(): string[];
107
92
  attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
108
93
  }
109
- declare global {
110
- interface HTMLElementTagNameMap {
111
- 'pc-script': ScriptElement;
112
- }
113
- }
114
94
  export { ScriptElement };
@@ -1,4 +1,4 @@
1
- import { ScrollbarComponent } from 'playcanvas';
1
+ import type { ScrollbarComponent } from 'playcanvas';
2
2
  import { ComponentElement } from './component';
3
3
  /**
4
4
  * The ScrollbarComponentElement interface provides properties and methods for manipulating
@@ -15,7 +15,7 @@ declare class ScrollbarComponentElement extends ComponentElement {
15
15
  private _handle;
16
16
  /** @ignore */
17
17
  constructor();
18
- getInitialComponentData(): Record<string, any>;
18
+ protected getInitialComponentData(): Record<string, any>;
19
19
  /**
20
20
  * Gets the underlying PlayCanvas scrollbar component.
21
21
  * @returns The scrollbar component.
@@ -66,9 +66,4 @@ declare class ScrollbarComponentElement extends ComponentElement {
66
66
  static get observedAttributes(): string[];
67
67
  attributeChangedCallback(name: string, _oldValue: string | null, newValue: string | null): void;
68
68
  }
69
- declare global {
70
- interface HTMLElementTagNameMap {
71
- 'pc-scrollbar': ScrollbarComponentElement;
72
- }
73
- }
74
69
  export { ScrollbarComponentElement };
@@ -1,4 +1,5 @@
1
- import { ScrollViewComponent, Vec2 } from 'playcanvas';
1
+ import type { ScrollViewComponent } from 'playcanvas';
2
+ import { Vec2 } from 'playcanvas';
2
3
  import { ComponentElement } from './component';
3
4
  /**
4
5
  * The ScrollViewComponentElement interface provides properties and methods for manipulating
@@ -24,7 +25,7 @@ declare class ScrollViewComponentElement extends ComponentElement {
24
25
  private _verticalScrollbar;
25
26
  /** @ignore */
26
27
  constructor();
27
- getInitialComponentData(): Record<string, any>;
28
+ protected getInitialComponentData(): Record<string, any>;
28
29
  /**
29
30
  * Gets the underlying PlayCanvas scroll view component.
30
31
  * @returns The scroll view component.
@@ -174,9 +175,4 @@ declare class ScrollViewComponentElement extends ComponentElement {
174
175
  static get observedAttributes(): string[];
175
176
  attributeChangedCallback(name: string, _oldValue: string | null, newValue: string | null): void;
176
177
  }
177
- declare global {
178
- interface HTMLElementTagNameMap {
179
- 'pc-scrollview': ScrollViewComponentElement;
180
- }
181
- }
182
178
  export { ScrollViewComponentElement };
@@ -1,4 +1,4 @@
1
- import { SoundComponent } from 'playcanvas';
1
+ import type { SoundComponent } from 'playcanvas';
2
2
  import { ComponentElement } from './component';
3
3
  /**
4
4
  * The SoundComponentElement interface provides properties and methods for manipulating
@@ -18,7 +18,7 @@ declare class SoundComponentElement extends ComponentElement {
18
18
  private _volume;
19
19
  /** @ignore */
20
20
  constructor();
21
- getInitialComponentData(): {
21
+ protected getInitialComponentData(): {
22
22
  distanceModel: "linear" | "exponential" | "inverse";
23
23
  maxDistance: number;
24
24
  pitch: number;
@@ -105,9 +105,4 @@ declare class SoundComponentElement extends ComponentElement {
105
105
  static get observedAttributes(): string[];
106
106
  attributeChangedCallback(name: string, _oldValue: string | null, newValue: string | null): void;
107
107
  }
108
- declare global {
109
- interface HTMLElementTagNameMap {
110
- 'pc-sounds': SoundComponentElement;
111
- }
112
- }
113
108
  export { SoundComponentElement };
@@ -1,4 +1,4 @@
1
- import { SoundSlot } from 'playcanvas';
1
+ import type { SoundSlot } from 'playcanvas';
2
2
  import { AsyncElement } from '../async-element';
3
3
  import { SoundComponentElement } from './sound-component';
4
4
  /**
@@ -24,6 +24,13 @@ declare class SoundSlotElement extends AsyncElement {
24
24
  * emit a misleading "must be a direct child" warning for what is an ordinary removal.
25
25
  */
26
26
  private _soundElement;
27
+ /**
28
+ * Incremented on every connect and disconnect, and captured by connectedCallback on entry —
29
+ * a resume from an await abandons itself if the value has moved on, so a stale callback can
30
+ * neither act on a torn-down tree nor add its slot alongside a re-inserted element's own
31
+ * callback.
32
+ */
33
+ private _connectionGeneration;
27
34
  /**
28
35
  * The sound slot.
29
36
  */
@@ -124,9 +131,4 @@ declare class SoundSlotElement extends AsyncElement {
124
131
  static get observedAttributes(): string[];
125
132
  attributeChangedCallback(name: string, _oldValue: string | null, newValue: string | null): void;
126
133
  }
127
- declare global {
128
- interface HTMLElementTagNameMap {
129
- 'pc-sound': SoundSlotElement;
130
- }
131
- }
132
134
  export { SoundSlotElement };