@playcanvas/web-components 0.8.2 → 0.10.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 (79) hide show
  1. package/README.md +18 -0
  2. package/dist/app.d.ts +13 -4
  3. package/dist/asset.d.ts +33 -3
  4. package/dist/async-element.d.ts +54 -4
  5. package/dist/components/button-component.d.ts +11 -5
  6. package/dist/components/camera-component.d.ts +10 -5
  7. package/dist/components/collision-component.d.ts +10 -5
  8. package/dist/components/component.d.ts +8 -2
  9. package/dist/components/element-component.d.ts +18 -13
  10. package/dist/components/gsplat-component.d.ts +7 -2
  11. package/dist/components/layoutchild-component.d.ts +7 -2
  12. package/dist/components/layoutgroup-component.d.ts +22 -16
  13. package/dist/components/light-component.d.ts +13 -7
  14. package/dist/components/listener-component.d.ts +6 -1
  15. package/dist/components/particlesystem-component.d.ts +7 -2
  16. package/dist/components/render-component.d.ts +14 -5
  17. package/dist/components/rigidbody-component.d.ts +10 -5
  18. package/dist/components/screen-component.d.ts +7 -2
  19. package/dist/components/script-component.d.ts +116 -16
  20. package/dist/components/script.d.ts +79 -8
  21. package/dist/components/scrollbar-component.d.ts +11 -5
  22. package/dist/components/scrollview-component.d.ts +18 -11
  23. package/dist/components/sound-component.d.ts +7 -2
  24. package/dist/components/sound-slot.d.ts +17 -4
  25. package/dist/custom-elements.json +16231 -0
  26. package/dist/entity.d.ts +45 -3
  27. package/dist/index.d.ts +3 -2
  28. package/dist/material.d.ts +976 -4
  29. package/dist/model.d.ts +6 -1
  30. package/dist/module.d.ts +15 -0
  31. package/dist/parse.d.ts +144 -0
  32. package/dist/pwc.cjs +5735 -2923
  33. package/dist/pwc.cjs.map +1 -1
  34. package/dist/pwc.js +5735 -2923
  35. package/dist/pwc.js.map +1 -1
  36. package/dist/pwc.min.js +1 -1
  37. package/dist/pwc.min.js.map +1 -1
  38. package/dist/pwc.min.mjs +2 -0
  39. package/dist/pwc.min.mjs.map +1 -0
  40. package/dist/pwc.mjs +5736 -2925
  41. package/dist/pwc.mjs.map +1 -1
  42. package/dist/scene.d.ts +15 -6
  43. package/dist/sky.d.ts +7 -1
  44. package/dist/vscode.html-custom-data.json +1795 -0
  45. package/dist/web-types.json +3592 -0
  46. package/package.json +32 -14
  47. package/src/app.ts +42 -15
  48. package/src/asset.ts +78 -8
  49. package/src/async-element.ts +89 -5
  50. package/src/components/button-component.ts +31 -24
  51. package/src/components/camera-component.ts +30 -24
  52. package/src/components/collision-component.ts +20 -14
  53. package/src/components/component.ts +33 -14
  54. package/src/components/element-component.ts +62 -56
  55. package/src/components/gsplat-component.ts +16 -9
  56. package/src/components/layoutchild-component.ts +17 -10
  57. package/src/components/layoutgroup-component.ts +39 -32
  58. package/src/components/light-component.ts +34 -32
  59. package/src/components/listener-component.ts +8 -2
  60. package/src/components/particlesystem-component.ts +10 -4
  61. package/src/components/render-component.ts +28 -12
  62. package/src/components/rigidbody-component.ts +22 -16
  63. package/src/components/screen-component.ts +16 -10
  64. package/src/components/script-component.ts +512 -125
  65. package/src/components/script.ts +123 -16
  66. package/src/components/scrollbar-component.ts +21 -14
  67. package/src/components/scrollview-component.ts +42 -34
  68. package/src/components/sound-component.ts +17 -10
  69. package/src/components/sound-slot.ts +50 -19
  70. package/src/entity.ts +84 -76
  71. package/src/index.ts +5 -2
  72. package/src/material.ts +2432 -62
  73. package/src/model.ts +8 -2
  74. package/src/module.ts +16 -0
  75. package/src/parse.ts +298 -0
  76. package/src/scene.ts +26 -13
  77. package/src/sky.ts +36 -18
  78. package/dist/utils.d.ts +0 -56
  79. package/src/utils.ts +0 -119
package/dist/entity.d.ts CHANGED
@@ -5,6 +5,24 @@ import { AsyncElement } from './async-element';
5
5
  * {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-entity/ | `<pc-entity>`} elements.
6
6
  * The EntityElement interface also inherits the properties and methods of the
7
7
  * {@link HTMLElement} interface.
8
+ *
9
+ * The pointer events below are dispatched by the containing `<pc-app>` element when the pointer
10
+ * intersects this entity's geometry. They are only generated while the entity has a listener for
11
+ * them, registered either with {@link addEventListener} or with the matching inline `onpointer*`
12
+ * attribute.
13
+ *
14
+ * @attribute {string} onpointerenter - Script to run when the pointer moves onto the entity.
15
+ * @attribute {string} onpointerleave - Script to run when the pointer moves off the entity.
16
+ * @attribute {string} onpointermove - Script to run when the pointer moves over the entity.
17
+ * @attribute {string} onpointerdown - Script to run when a pointer button is pressed over the
18
+ * entity.
19
+ * @attribute {string} onpointerup - Script to run when a pointer button is released over the
20
+ * entity.
21
+ * @fires {PointerEvent} pointerenter - Fired when the pointer moves onto the entity.
22
+ * @fires {PointerEvent} pointerleave - Fired when the pointer moves off the entity.
23
+ * @fires {PointerEvent} pointermove - Fired when the pointer moves over the entity.
24
+ * @fires {PointerEvent} pointerdown - Fired when a pointer button is pressed over the entity.
25
+ * @fires {PointerEvent} pointerup - Fired when a pointer button is released over the entity.
8
26
  */
9
27
  declare class EntityElement extends AsyncElement {
10
28
  /**
@@ -35,14 +53,21 @@ declare class EntityElement extends AsyncElement {
35
53
  * The pointer event listeners for the entity.
36
54
  */
37
55
  private _listeners;
56
+ /**
57
+ * The event types for which an inline `onpointer*` attribute is currently present.
58
+ */
59
+ private _inlineHandlerTypes;
38
60
  /**
39
61
  * Whether the hierarchy has been built for this entity.
40
62
  */
41
63
  private _built;
64
+ private _entity;
42
65
  /**
43
- * The PlayCanvas entity instance.
66
+ * The PlayCanvas entity instance. Available once the element is ready — await
67
+ * {@link whenReady} or the element's `ready()` promise before accessing it.
68
+ * @returns The entity instance.
44
69
  */
45
- entity: Entity | null;
70
+ get entity(): Entity;
46
71
  createEntity(app: AppBase): void;
47
72
  buildHierarchy(app: AppBase): void;
48
73
  connectedCallback(): void;
@@ -107,10 +132,27 @@ declare class EntityElement extends AsyncElement {
107
132
  * @returns The tags of the entity.
108
133
  */
109
134
  get tags(): string[];
135
+ /**
136
+ * Tracks whether an inline `onpointer*` attribute is present. The browser itself compiles and
137
+ * runs these attributes — they are standard `GlobalEventHandlers`, so setting one replaces
138
+ * the previous handler and removing it removes the handler, exactly like `onclick` on any
139
+ * HTML element. But because they bypass {@link addEventListener}, the connect/disconnect
140
+ * bookkeeping that lets the application lazily attach its canvas pointer handlers must be
141
+ * kept in sync here.
142
+ *
143
+ * @param name - The attribute name (e.g. 'onpointerdown').
144
+ * @param value - The attribute value, or `null` when the attribute has been removed.
145
+ */
146
+ private _updateInlineHandler;
110
147
  static get observedAttributes(): string[];
111
- attributeChangedCallback(name: string, _oldValue: string, newValue: string): void;
148
+ attributeChangedCallback(name: string, _oldValue: string | null, newValue: string | null): void;
112
149
  addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void;
113
150
  removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void;
114
151
  hasListeners(type: string): boolean;
115
152
  }
153
+ declare global {
154
+ interface HTMLElementTagNameMap {
155
+ 'pc-entity': EntityElement;
156
+ }
157
+ }
116
158
  export { EntityElement };
package/dist/index.d.ts CHANGED
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * @module EngineWebComponents
8
8
  */
9
- import { AsyncElement } from './async-element';
9
+ import { AsyncElement, whenReady } from './async-element';
10
10
  import { ModuleElement } from './module';
11
11
  import { AppElement } from './app';
12
12
  import { EntityElement } from './entity';
@@ -35,4 +35,5 @@ import { MaterialElement } from './material';
35
35
  import { ModelElement } from './model';
36
36
  import { SceneElement } from './scene';
37
37
  import { SkyElement } from './sky';
38
- export { AsyncElement, ModuleElement, AppElement, EntityElement, AssetElement, ButtonComponentElement, CameraComponentElement, CollisionComponentElement, ComponentElement, ElementComponentElement, LayoutChildComponentElement, LayoutGroupComponentElement, ParticleSystemComponentElement, LightComponentElement, ListenerComponentElement, RenderComponentElement, RigidBodyComponentElement, ScreenComponentElement, ScrollbarComponentElement, ScrollViewComponentElement, ScriptComponentElement, ScriptElement, SoundComponentElement, SoundSlotElement, GSplatComponentElement, MaterialElement, ModelElement, SceneElement, SkyElement };
38
+ export { AsyncElement, ModuleElement, AppElement, EntityElement, AssetElement, ButtonComponentElement, CameraComponentElement, CollisionComponentElement, ComponentElement, ElementComponentElement, LayoutChildComponentElement, LayoutGroupComponentElement, ParticleSystemComponentElement, LightComponentElement, ListenerComponentElement, RenderComponentElement, RigidBodyComponentElement, ScreenComponentElement, ScrollbarComponentElement, ScrollViewComponentElement, ScriptComponentElement, ScriptElement, SoundComponentElement, SoundSlotElement, GSplatComponentElement, MaterialElement, ModelElement, SceneElement, SkyElement, whenReady };
39
+ export type { AsyncElementTagName } from './async-element';