@zcomponent/html 1.3.0-beta → 1.3.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.
- package/README.md +1 -0
- package/index.js +3 -1
- package/lib/CSS.js +5 -1
- package/lib/HTMLElement.js +2 -1
- package/lib/context.d.ts +1 -0
- package/lib/context.js +1 -0
- package/package.json +61 -14
- package/lib/audio.d.ts +0 -40
- package/lib/audio.js +0 -67
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# @zcomponent/html
|
package/index.js
CHANGED
package/lib/CSS.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Component, isDesignTime, registerLoadable } from '@zcomponent/core';
|
|
2
|
+
import { HTMLContext } from './context';
|
|
2
3
|
const alreadyAdded = new Map();
|
|
3
4
|
/**
|
|
4
5
|
* The CSS component will ensure that the CSS file referenced by its `source` constructor prop is added to your page and loaded by the browser.
|
|
@@ -20,7 +21,10 @@ export class CSS extends Component {
|
|
|
20
21
|
else {
|
|
21
22
|
this._elm = [1, document.createElement('link')];
|
|
22
23
|
registerLoadable(contextManager, new Promise((resolve, reject) => {
|
|
23
|
-
this._elm[1].addEventListener('load',
|
|
24
|
+
this._elm[1].addEventListener('load', () => {
|
|
25
|
+
contextManager.get(HTMLContext).onCSSChanged.emit();
|
|
26
|
+
resolve();
|
|
27
|
+
});
|
|
24
28
|
this._elm[1].addEventListener('error', reject);
|
|
25
29
|
}));
|
|
26
30
|
this._elm[1].setAttribute('rel', 'stylesheet');
|
package/lib/HTMLElement.js
CHANGED
package/lib/context.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { Event, ContextManager, Context } from '@zcomponent/core';
|
|
|
2
2
|
export declare class HTMLContext extends Context {
|
|
3
3
|
onNodeConstructed: Event<[Node]>;
|
|
4
4
|
onNodeDisposed: Event<[Node]>;
|
|
5
|
+
onCSSChanged: Event<[]>;
|
|
5
6
|
}
|
|
6
7
|
export declare function useOnNodeConstructed(mgr: ContextManager): Event<[Node]>;
|
|
7
8
|
export declare function useOnNodeDisposed(mgr: ContextManager): Event<[Node]>;
|
package/lib/context.js
CHANGED
package/package.json
CHANGED
|
@@ -1,29 +1,76 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zcomponent/html",
|
|
3
|
-
"version": "1.3.0
|
|
4
|
-
"description": "",
|
|
3
|
+
"version": "1.3.0",
|
|
4
|
+
"description": "Mattercraft support for HTML",
|
|
5
|
+
"author": "Zappar Limited",
|
|
6
|
+
"license": "Proprietary",
|
|
5
7
|
"main": "index.js",
|
|
6
8
|
"types": "index.d.ts",
|
|
9
|
+
"zexports": [
|
|
10
|
+
"./lib/**/*"
|
|
11
|
+
],
|
|
7
12
|
"directories": {
|
|
8
13
|
"lib": "lib"
|
|
9
14
|
},
|
|
10
|
-
"scripts": {
|
|
11
|
-
"build": "tsc"
|
|
12
|
-
},
|
|
13
15
|
"files": [
|
|
14
16
|
"index.js",
|
|
15
17
|
"index.d.ts",
|
|
16
|
-
"lib/**/*"
|
|
18
|
+
"lib/**/*",
|
|
19
|
+
"public/**/*"
|
|
17
20
|
],
|
|
18
|
-
"
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
"
|
|
21
|
+
"scripts": {
|
|
22
|
+
"build": "rm -rf lib && tsc && tsc-alias",
|
|
23
|
+
"watch": "tsc -w",
|
|
24
|
+
"prepack": "npm run build",
|
|
25
|
+
"docs": "typedoc --out docs"
|
|
22
26
|
},
|
|
27
|
+
"dependencies": {},
|
|
23
28
|
"devDependencies": {
|
|
24
|
-
"
|
|
29
|
+
"@zcomponent/core": "1.x"
|
|
25
30
|
},
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
|
|
31
|
+
"peerDependencies": {
|
|
32
|
+
"@zcomponent/core": "1.x"
|
|
33
|
+
},
|
|
34
|
+
"keywords": [],
|
|
35
|
+
"release": {
|
|
36
|
+
"extends": "semantic-release-commit-filter",
|
|
37
|
+
"ci": true,
|
|
38
|
+
"branches": [
|
|
39
|
+
"main",
|
|
40
|
+
{
|
|
41
|
+
"name": "beta",
|
|
42
|
+
"channel": "beta",
|
|
43
|
+
"prerelease": "beta"
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
"name": "alpha",
|
|
47
|
+
"channel": "alpha",
|
|
48
|
+
"prerelease": "alpha"
|
|
49
|
+
}
|
|
50
|
+
],
|
|
51
|
+
"plugins": [
|
|
52
|
+
"@semantic-release/commit-analyzer",
|
|
53
|
+
"@semantic-release/release-notes-generator",
|
|
54
|
+
"@semantic-release/changelog",
|
|
55
|
+
"@semantic-release/npm",
|
|
56
|
+
"@semantic-release/gitlab",
|
|
57
|
+
"@semantic-release/git",
|
|
58
|
+
[
|
|
59
|
+
"@rimac-technology/semantic-release-s3",
|
|
60
|
+
{
|
|
61
|
+
"s3Bucket": {
|
|
62
|
+
"main": "mattercraft-api-docs/prod",
|
|
63
|
+
"beta": "mattercraft-api-docs/beta",
|
|
64
|
+
"alpha": "mattercraft-api-docs/alpha"
|
|
65
|
+
},
|
|
66
|
+
"directoryPath": "../../docs/**/*",
|
|
67
|
+
"objectACL": "",
|
|
68
|
+
"removeDirectoryRoot": true,
|
|
69
|
+
"awsAccessKeyName": "DOCS_AWS_ACCESS_KEY_ID",
|
|
70
|
+
"awsSecretAccessKeyName": "DOCS_AWS_SECRET_ACCESS_KEY"
|
|
71
|
+
}
|
|
72
|
+
]
|
|
73
|
+
],
|
|
74
|
+
"tagFormat": "@zcomponent/html@${version}"
|
|
75
|
+
}
|
|
29
76
|
}
|
package/lib/audio.d.ts
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { ContextManager, Observable, PlayOptions, Stream } from '@zcomponent/core';
|
|
2
|
-
import { HTMLElementProps, ZHTMLElement } from './HTMLElement';
|
|
3
|
-
export interface AudioConstructorProps extends HTMLElementProps {
|
|
4
|
-
/** @zprop
|
|
5
|
-
* @zvalues files *.+(mp3|wav)
|
|
6
|
-
*/
|
|
7
|
-
source: string;
|
|
8
|
-
/** @zprop
|
|
9
|
-
* @zdefault false
|
|
10
|
-
*/
|
|
11
|
-
autoplay: boolean;
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* @zcomponent
|
|
15
|
-
* @ztag html/element/audio
|
|
16
|
-
* @zgroup Media
|
|
17
|
-
* @zicon music_note
|
|
18
|
-
* @zstream
|
|
19
|
-
*/
|
|
20
|
-
export declare class Audio extends ZHTMLElement<HTMLAudioElement> implements Stream {
|
|
21
|
-
private _hadUserEvent;
|
|
22
|
-
/** @zprop
|
|
23
|
-
* @zdefault false
|
|
24
|
-
* @zgroup Audio
|
|
25
|
-
* @zgrouppriority 20
|
|
26
|
-
*/
|
|
27
|
-
muted: Observable<boolean, never>;
|
|
28
|
-
constructor(mgr: ContextManager, props: AudioConstructorProps);
|
|
29
|
-
private _updateMute;
|
|
30
|
-
/** @zprop */
|
|
31
|
-
play(opts?: PlayOptions): void;
|
|
32
|
-
/** @zprop */
|
|
33
|
-
pause(): void;
|
|
34
|
-
/** @zprop */
|
|
35
|
-
stop(): void;
|
|
36
|
-
/** @zprop */
|
|
37
|
-
seek(t: number): void;
|
|
38
|
-
length(): number | undefined;
|
|
39
|
-
dispose(): never;
|
|
40
|
-
}
|
package/lib/audio.js
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { isDesignTime, nextUserEvent, Observable, registerLoadable, started } from '@zcomponent/core';
|
|
2
|
-
import { ZHTMLElement } from './HTMLElement';
|
|
3
|
-
/**
|
|
4
|
-
* @zcomponent
|
|
5
|
-
* @ztag html/element/audio
|
|
6
|
-
* @zgroup Media
|
|
7
|
-
* @zicon music_note
|
|
8
|
-
* @zstream
|
|
9
|
-
*/
|
|
10
|
-
export class Audio extends ZHTMLElement {
|
|
11
|
-
constructor(mgr, props) {
|
|
12
|
-
const elm = document.createElement('audio');
|
|
13
|
-
elm.muted = true;
|
|
14
|
-
registerLoadable(mgr, new Promise((resolve, reject) => {
|
|
15
|
-
elm.src = props.source;
|
|
16
|
-
elm.addEventListener('canplaythrough', () => resolve());
|
|
17
|
-
elm.addEventListener('error', () => reject());
|
|
18
|
-
}));
|
|
19
|
-
super(mgr, props, elm);
|
|
20
|
-
this._hadUserEvent = false;
|
|
21
|
-
/** @zprop
|
|
22
|
-
* @zdefault false
|
|
23
|
-
* @zgroup Audio
|
|
24
|
-
* @zgrouppriority 20
|
|
25
|
-
*/
|
|
26
|
-
this.muted = new Observable(false);
|
|
27
|
-
this._updateMute = () => {
|
|
28
|
-
if (!this.element || !this._hadUserEvent)
|
|
29
|
-
return;
|
|
30
|
-
this.element.muted = this.muted.value;
|
|
31
|
-
};
|
|
32
|
-
this.register(this.muted, this._updateMute);
|
|
33
|
-
nextUserEvent(mgr).then(() => {
|
|
34
|
-
this._hadUserEvent = true;
|
|
35
|
-
this._updateMute();
|
|
36
|
-
});
|
|
37
|
-
if (!isDesignTime(this.contextManager) && props.autoplay)
|
|
38
|
-
started(mgr).then(() => this.play());
|
|
39
|
-
elm.load();
|
|
40
|
-
}
|
|
41
|
-
/** @zprop */
|
|
42
|
-
play(opts) {
|
|
43
|
-
this.element.playbackRate = opts?.speed ?? 1;
|
|
44
|
-
this.element.play();
|
|
45
|
-
}
|
|
46
|
-
/** @zprop */
|
|
47
|
-
pause() {
|
|
48
|
-
this.element.pause();
|
|
49
|
-
}
|
|
50
|
-
/** @zprop */
|
|
51
|
-
stop() {
|
|
52
|
-
this.element.pause();
|
|
53
|
-
this.element.currentTime = 0;
|
|
54
|
-
}
|
|
55
|
-
/** @zprop */
|
|
56
|
-
seek(t) {
|
|
57
|
-
this.element.currentTime = t / 1000;
|
|
58
|
-
}
|
|
59
|
-
length() {
|
|
60
|
-
return isNaN(this.element.duration) ? undefined : this.element.duration * 1000;
|
|
61
|
-
}
|
|
62
|
-
dispose() {
|
|
63
|
-
this.element.pause();
|
|
64
|
-
this.element.src = '';
|
|
65
|
-
return super.dispose();
|
|
66
|
-
}
|
|
67
|
-
}
|