@zcomponent/core 1.29.0 → 2.0.0-alpha.2
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/css/zcomponent.css +121 -122
- package/index.js +0 -3
- package/lib/actionbehavior.d.ts +3 -3
- package/lib/actionbehavior.js +20 -19
- package/lib/animation/animation.d.ts +13 -6
- package/lib/animation/animation.js +56 -43
- package/lib/animation/bezier.d.ts +6 -0
- package/lib/animation/bezier.js +8 -2
- package/lib/animation/clips/clip.d.ts +13 -1
- package/lib/animation/clips/clip.js +34 -14
- package/lib/animation/index.d.ts +4 -4
- package/lib/animation/index.js +4 -4
- package/lib/animation/layer.d.ts +9 -0
- package/lib/animation/layer.js +28 -12
- package/lib/animation/layerclip.d.ts +21 -0
- package/lib/animation/layerclip.js +82 -45
- package/lib/animation/tracks/cliptrack.d.ts +18 -0
- package/lib/animation/tracks/cliptrack.js +27 -6
- package/lib/animation/tracks/functiontrack.d.ts +9 -0
- package/lib/animation/tracks/functiontrack.js +16 -3
- package/lib/animation/tracks/propertytrack.d.ts +20 -1
- package/lib/animation/tracks/propertytrack.js +48 -11
- package/lib/animation/tracks/streamtrack.d.ts +18 -0
- package/lib/animation/tracks/streamtrack.js +32 -6
- package/lib/animation/tracks/track.d.ts +8 -2
- package/lib/animation/tracks/track.js +3 -2
- package/lib/behavior.js +13 -10
- package/lib/behaviors/ActivateState.d.ts +22 -24
- package/lib/behaviors/ActivateState.js +145 -35
- package/lib/behaviors/CallFunction.d.ts +2 -4
- package/lib/behaviors/CallFunction.js +69 -11
- package/lib/behaviors/ChangeRootScene.d.ts +35 -0
- package/lib/behaviors/ChangeRootScene.js +123 -0
- package/lib/behaviors/ConsoleLog.d.ts +6 -5
- package/lib/behaviors/ConsoleLog.js +95 -12
- package/lib/behaviors/DownloadSnapshot.d.ts +7 -12
- package/lib/behaviors/DownloadSnapshot.js +70 -19
- package/lib/behaviors/EmitComponentPropEvent.d.ts +1 -3
- package/lib/behaviors/EmitComponentPropEvent.js +80 -12
- package/lib/behaviors/LaunchURL.d.ts +5 -5
- package/lib/behaviors/LaunchURL.js +92 -10
- package/lib/behaviors/LogAnalyticsEvent.d.ts +10 -4
- package/lib/behaviors/LogAnalyticsEvent.js +88 -7
- package/lib/behaviors/PauseLayerClip.d.ts +7 -9
- package/lib/behaviors/PauseLayerClip.js +89 -21
- package/lib/behaviors/PlayLayerClip.d.ts +35 -32
- package/lib/behaviors/PlayLayerClip.js +202 -48
- package/lib/behaviors/PlaySound.d.ts +19 -25
- package/lib/behaviors/PlaySound.js +122 -28
- package/lib/behaviors/SetLayerOff.d.ts +7 -9
- package/lib/behaviors/SetLayerOff.js +88 -21
- package/lib/behaviors/ShareSnapshot.d.ts +5 -9
- package/lib/behaviors/ShareSnapshot.js +70 -17
- package/lib/behaviors/ShowTextAlert.d.ts +16 -29
- package/lib/behaviors/ShowTextAlert.js +116 -48
- package/lib/behaviors/TakeSnapshot.d.ts +22 -26
- package/lib/behaviors/TakeSnapshot.js +131 -56
- package/lib/behaviors/ToggleLayerClips.d.ts +45 -62
- package/lib/behaviors/ToggleLayerClips.js +233 -64
- package/lib/behaviors/stream/PauseStream.d.ts +5 -16
- package/lib/behaviors/stream/PauseStream.js +94 -34
- package/lib/behaviors/stream/PlayStream.d.ts +14 -27
- package/lib/behaviors/stream/PlayStream.js +123 -34
- package/lib/behaviors/stream/SeekStream.d.ts +8 -18
- package/lib/behaviors/stream/SeekStream.js +97 -31
- package/lib/behaviors/stream/StopStream.d.ts +6 -15
- package/lib/behaviors/stream/StopStream.js +89 -27
- package/lib/component.d.ts +36 -13
- package/lib/component.js +237 -151
- package/lib/components/AnimatedLoader.d.ts +51 -0
- package/lib/components/AnimatedLoader.js +159 -0
- package/lib/components/Audio.d.ts +35 -37
- package/lib/components/Audio.js +264 -151
- package/lib/components/AudioLayerSettings.d.ts +13 -11
- package/lib/components/AudioLayerSettings.js +76 -18
- package/lib/components/Children.d.ts +2 -1
- package/lib/components/Children.js +66 -13
- package/lib/components/ConditionalConstruct.d.ts +44 -0
- package/lib/components/ConditionalConstruct.js +142 -0
- package/lib/components/DefaultCookieConsent.d.ts +53 -73
- package/lib/components/DefaultCookieConsent.js +382 -264
- package/lib/components/DefaultLoader.d.ts +40 -28
- package/lib/components/DefaultLoader.js +198 -46
- package/lib/components/Gamepad.d.ts +5 -26
- package/lib/components/Gamepad.js +201 -65
- package/lib/components/LoaderScope.d.ts +15 -0
- package/lib/components/LoaderScope.js +71 -0
- package/lib/components/LongLoad.d.ts +11 -15
- package/lib/components/LongLoad.js +89 -34
- package/lib/components/SnapshotUI.d.ts +19 -24
- package/lib/components/SnapshotUI.js +202 -105
- package/lib/context.d.ts +23 -5
- package/lib/context.js +12 -6
- package/lib/contexts/analyticscontext.d.ts +12 -2
- package/lib/contexts/analyticscontext.js +68 -10
- package/lib/contexts/audiocontextcontext.d.ts +1 -1
- package/lib/contexts/audiocontextcontext.js +9 -8
- package/lib/contexts/canvascontext.d.ts +32 -18
- package/lib/contexts/canvascontext.js +195 -120
- package/lib/contexts/cookieconsentcontext.d.ts +38 -28
- package/lib/contexts/cookieconsentcontext.js +35 -32
- package/lib/contexts/documentflagmanager.js +15 -11
- package/lib/contexts/environmentcontext.d.ts +22 -6
- package/lib/contexts/environmentcontext.js +135 -21
- package/lib/contexts/gamepadcontext.d.ts +29 -26
- package/lib/contexts/gamepadcontext.js +46 -46
- package/lib/contexts/gesturecontext.d.ts +31 -6
- package/lib/contexts/gesturecontext.js +110 -85
- package/lib/contexts/globaltagcontext.d.ts +1 -1
- package/lib/contexts/globaltagcontext.js +8 -11
- package/lib/contexts/loadcontext.d.ts +45 -8
- package/lib/contexts/loadcontext.js +232 -82
- package/lib/contexts/orientationcontext.d.ts +13 -15
- package/lib/contexts/orientationcontext.js +150 -67
- package/lib/contexts/rootcomponentscontext.d.ts +16 -0
- package/lib/contexts/rootcomponentscontext.js +65 -0
- package/lib/contexts/snapshotContext.d.ts +0 -3
- package/lib/contexts/snapshotContext.js +78 -23
- package/lib/contexts/tagcontext.d.ts +5 -5
- package/lib/contexts/tagcontext.js +16 -16
- package/lib/contexts/textalertcontext.d.ts +1 -5
- package/lib/contexts/textalertcontext.js +1 -5
- package/lib/contexts/usereventcontext.d.ts +1 -1
- package/lib/contexts/usereventcontext.js +12 -12
- package/lib/data/animation.d.ts +10 -2
- package/lib/data/change.d.ts +1 -1
- package/lib/data/change.js +7 -0
- package/lib/data/core.d.ts +9 -1
- package/lib/data/index.d.ts +1 -1
- package/lib/data/index.js +1 -1
- package/lib/decorators.d.ts +348 -0
- package/lib/decorators.js +239 -0
- package/lib/decoratorutils.d.ts +3 -0
- package/lib/decoratorutils.js +8 -0
- package/lib/emitter.d.ts +15 -2
- package/lib/emitter.js +15 -6
- package/lib/entity.d.ts +43 -25
- package/lib/entity.js +104 -71
- package/lib/event.d.ts +2 -1
- package/lib/event.js +1 -4
- package/lib/groups.d.ts +18 -0
- package/lib/groups.js +19 -0
- package/lib/icons.d.ts +3372 -0
- package/lib/icons.js +1 -0
- package/lib/index.d.ts +18 -13
- package/lib/index.js +17 -13
- package/lib/inflate.d.ts +7 -7
- package/lib/inflate.js +5 -5
- package/lib/observable.d.ts +9 -2
- package/lib/observable.js +5 -4
- package/lib/observe.d.ts +18 -0
- package/lib/observe.js +177 -0
- package/lib/profile.d.ts +9 -5
- package/lib/profile.js +27 -17
- package/lib/selectors.d.ts +1 -1
- package/lib/selectors.js +5 -4
- package/lib/types.d.ts +161 -19
- package/lib/types.js +22 -1
- package/lib/values/values.d.ts +7 -8
- package/lib/values/values.js +1 -2
- package/lib/values/valuesmutator.d.ts +4 -1
- package/lib/values/valuesmutator.js +10 -8
- package/lib/zcomponent.d.ts +21 -10
- package/lib/zcomponent.js +717 -540
- package/package.json +22 -5
- package/lib/behaviors/ChangeCursor.d.ts +0 -39
- package/lib/behaviors/ChangeCursor.js +0 -44
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { Observable } from '..';
|
|
2
1
|
import { ImageFormat } from '../behaviors/TakeSnapshot';
|
|
3
2
|
import { Component, ConstructorProps } from '../component';
|
|
4
3
|
import { ContextManager } from '../context';
|
|
5
4
|
import { Event } from '../event';
|
|
5
|
+
import { ValueOf } from '../types';
|
|
6
6
|
export interface SnapshotUIConstructorProps extends ConstructorProps {
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
9
|
-
* @
|
|
8
|
+
*
|
|
9
|
+
* @default true
|
|
10
10
|
*/
|
|
11
11
|
allowShare: boolean;
|
|
12
12
|
}
|
|
@@ -17,52 +17,47 @@ export interface SnapshotUIConstructorProps extends ConstructorProps {
|
|
|
17
17
|
* It includes observable properties to customize snapshot format, quality, file name, and sharing text or title.
|
|
18
18
|
* Events are emitted for save and share actions.
|
|
19
19
|
* @zcomponent
|
|
20
|
-
* @zgroup Social Sharing
|
|
21
20
|
* @zicon photo_camera
|
|
21
|
+
* @zgroup Social Sharing
|
|
22
22
|
*/
|
|
23
23
|
export declare class SnapshotUI extends Component {
|
|
24
24
|
private captureButton;
|
|
25
25
|
private socialShareBehaviours;
|
|
26
26
|
private style;
|
|
27
27
|
private shareDiv;
|
|
28
|
-
/** @zui */
|
|
29
28
|
readonly onSave: Event<[]>;
|
|
30
|
-
/** @zui */
|
|
31
29
|
readonly onShare: Event<[]>;
|
|
32
|
-
/**
|
|
33
|
-
* @
|
|
30
|
+
/**
|
|
31
|
+
* @default true
|
|
34
32
|
*/
|
|
35
|
-
|
|
33
|
+
visible: boolean;
|
|
36
34
|
/**
|
|
37
35
|
* The format of the image to capture.
|
|
38
|
-
* @
|
|
39
|
-
* @zdefault jpeg
|
|
36
|
+
* @default "jpeg"
|
|
40
37
|
*/
|
|
41
|
-
|
|
38
|
+
format: ValueOf<typeof ImageFormat>;
|
|
42
39
|
/**
|
|
43
40
|
* The quality of the image to capture.
|
|
44
|
-
* @
|
|
45
|
-
* @
|
|
41
|
+
* @default 0.92
|
|
42
|
+
* @zui
|
|
43
|
+
* @ztype proportion
|
|
46
44
|
*/
|
|
47
|
-
|
|
45
|
+
quality: number;
|
|
48
46
|
/**
|
|
49
47
|
* The name of the file to download.
|
|
50
|
-
* @
|
|
51
|
-
* @zdefault canvas
|
|
48
|
+
* @default "canvas"
|
|
52
49
|
*/
|
|
53
|
-
|
|
50
|
+
fileName: string;
|
|
54
51
|
/**
|
|
55
52
|
* The text to share.
|
|
56
|
-
* @
|
|
57
|
-
* @zdefault ''
|
|
53
|
+
* @default ""
|
|
58
54
|
*/
|
|
59
|
-
|
|
55
|
+
text: string;
|
|
60
56
|
/**
|
|
61
57
|
* The title to share.
|
|
62
|
-
* @
|
|
63
|
-
* @zdefault ''
|
|
58
|
+
* @default ""
|
|
64
59
|
*/
|
|
65
|
-
|
|
60
|
+
title: string;
|
|
66
61
|
/**
|
|
67
62
|
* Creates a new SnapshotUI component.
|
|
68
63
|
* @param contextManager - The current ContextManager
|
|
@@ -1,7 +1,41 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
2
|
+
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
3
|
+
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
4
|
+
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
5
|
+
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
6
|
+
var _, done = false;
|
|
7
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
8
|
+
var context = {};
|
|
9
|
+
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
10
|
+
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
11
|
+
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
12
|
+
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
13
|
+
if (kind === "accessor") {
|
|
14
|
+
if (result === void 0) continue;
|
|
15
|
+
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
16
|
+
if (_ = accept(result.get)) descriptor.get = _;
|
|
17
|
+
if (_ = accept(result.set)) descriptor.set = _;
|
|
18
|
+
if (_ = accept(result.init)) initializers.unshift(_);
|
|
19
|
+
}
|
|
20
|
+
else if (_ = accept(result)) {
|
|
21
|
+
if (kind === "field") initializers.unshift(_);
|
|
22
|
+
else descriptor[key] = _;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
26
|
+
done = true;
|
|
27
|
+
};
|
|
28
|
+
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
29
|
+
var useValue = arguments.length > 2;
|
|
30
|
+
for (var i = 0; i < initializers.length; i++) {
|
|
31
|
+
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
32
|
+
}
|
|
33
|
+
return useValue ? value : void 0;
|
|
34
|
+
};
|
|
35
|
+
import { CanvasContext, registerLoadable, useOverlay, zComponent, zObserve, zUI } from '..';
|
|
3
36
|
import { DownloadSnapshot } from '../behaviors/DownloadSnapshot';
|
|
4
37
|
import { ShareSnapshot } from '../behaviors/ShareSnapshot';
|
|
38
|
+
import { ImageFormat, TakeSnapshot } from '../behaviors/TakeSnapshot';
|
|
5
39
|
import { Component } from '../component';
|
|
6
40
|
import { SnapshotContext } from '../contexts/snapshotContext';
|
|
7
41
|
import { Event } from '../event';
|
|
@@ -16,123 +50,184 @@ const share_src = new URL('../../assets/share.png', import.meta.url).href;
|
|
|
16
50
|
* It includes observable properties to customize snapshot format, quality, file name, and sharing text or title.
|
|
17
51
|
* Events are emitted for save and share actions.
|
|
18
52
|
* @zcomponent
|
|
19
|
-
* @zgroup Social Sharing
|
|
20
53
|
* @zicon photo_camera
|
|
54
|
+
* @zgroup Social Sharing
|
|
21
55
|
*/
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
56
|
+
let SnapshotUI = (() => {
|
|
57
|
+
let _classDecorators = [zComponent({ icon: 'photo_camera', group: 'Social Sharing' })];
|
|
58
|
+
let _classDescriptor;
|
|
59
|
+
let _classExtraInitializers = [];
|
|
60
|
+
let _classThis;
|
|
61
|
+
let _classSuper = Component;
|
|
62
|
+
let _onSave_decorators;
|
|
63
|
+
let _onSave_initializers = [];
|
|
64
|
+
let _onSave_extraInitializers = [];
|
|
65
|
+
let _onShare_decorators;
|
|
66
|
+
let _onShare_initializers = [];
|
|
67
|
+
let _onShare_extraInitializers = [];
|
|
68
|
+
let _visible_decorators;
|
|
69
|
+
let _visible_initializers = [];
|
|
70
|
+
let _visible_extraInitializers = [];
|
|
71
|
+
let _format_decorators;
|
|
72
|
+
let _format_initializers = [];
|
|
73
|
+
let _format_extraInitializers = [];
|
|
74
|
+
let _quality_decorators;
|
|
75
|
+
let _quality_initializers = [];
|
|
76
|
+
let _quality_extraInitializers = [];
|
|
77
|
+
let _fileName_decorators;
|
|
78
|
+
let _fileName_initializers = [];
|
|
79
|
+
let _fileName_extraInitializers = [];
|
|
80
|
+
let _text_decorators;
|
|
81
|
+
let _text_initializers = [];
|
|
82
|
+
let _text_extraInitializers = [];
|
|
83
|
+
let _title_decorators;
|
|
84
|
+
let _title_initializers = [];
|
|
85
|
+
let _title_extraInitializers = [];
|
|
86
|
+
var SnapshotUI = class extends _classSuper {
|
|
87
|
+
static { _classThis = this; }
|
|
88
|
+
static {
|
|
89
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
90
|
+
_onSave_decorators = [zUI()];
|
|
91
|
+
_onShare_decorators = [zUI()];
|
|
92
|
+
_visible_decorators = [zUI(), zObserve((v, instance) => {
|
|
93
|
+
if (v) {
|
|
94
|
+
instance.captureButton.show();
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
instance.captureButton.hide();
|
|
98
|
+
}
|
|
99
|
+
})];
|
|
100
|
+
_format_decorators = [zObserve((v, instance) => {
|
|
101
|
+
const ssctx = instance.contextManager.get(SnapshotContext);
|
|
102
|
+
ssctx.fileType.value = v === ImageFormat.PNG ? 'image/png' : 'image/jpeg';
|
|
103
|
+
}), zUI()];
|
|
104
|
+
_quality_decorators = [zObserve((v, instance) => {
|
|
105
|
+
const ssctx = instance.contextManager.get(SnapshotContext);
|
|
106
|
+
ssctx.quality.value = v;
|
|
107
|
+
}), zUI({ type: 'proportion' })];
|
|
108
|
+
_fileName_decorators = [zObserve((v, instance) => {
|
|
109
|
+
const ssctx = instance.contextManager.get(SnapshotContext);
|
|
110
|
+
ssctx.fileName.value = v;
|
|
111
|
+
}), zUI()];
|
|
112
|
+
_text_decorators = [zUI(), zObserve((v, instance) => {
|
|
113
|
+
const ssctx = instance.contextManager.get(SnapshotContext);
|
|
114
|
+
ssctx.text.value;
|
|
115
|
+
})];
|
|
116
|
+
_title_decorators = [zObserve((v, instance) => {
|
|
117
|
+
const ssctx = instance.contextManager.get(SnapshotContext);
|
|
118
|
+
ssctx.title.value;
|
|
119
|
+
}), zUI()];
|
|
120
|
+
__esDecorate(null, null, _onSave_decorators, { kind: "field", name: "onSave", static: false, private: false, access: { has: obj => "onSave" in obj, get: obj => obj.onSave, set: (obj, value) => { obj.onSave = value; } }, metadata: _metadata }, _onSave_initializers, _onSave_extraInitializers);
|
|
121
|
+
__esDecorate(null, null, _onShare_decorators, { kind: "field", name: "onShare", static: false, private: false, access: { has: obj => "onShare" in obj, get: obj => obj.onShare, set: (obj, value) => { obj.onShare = value; } }, metadata: _metadata }, _onShare_initializers, _onShare_extraInitializers);
|
|
122
|
+
__esDecorate(null, null, _visible_decorators, { kind: "field", name: "visible", static: false, private: false, access: { has: obj => "visible" in obj, get: obj => obj.visible, set: (obj, value) => { obj.visible = value; } }, metadata: _metadata }, _visible_initializers, _visible_extraInitializers);
|
|
123
|
+
__esDecorate(null, null, _format_decorators, { kind: "field", name: "format", static: false, private: false, access: { has: obj => "format" in obj, get: obj => obj.format, set: (obj, value) => { obj.format = value; } }, metadata: _metadata }, _format_initializers, _format_extraInitializers);
|
|
124
|
+
__esDecorate(null, null, _quality_decorators, { kind: "field", name: "quality", static: false, private: false, access: { has: obj => "quality" in obj, get: obj => obj.quality, set: (obj, value) => { obj.quality = value; } }, metadata: _metadata }, _quality_initializers, _quality_extraInitializers);
|
|
125
|
+
__esDecorate(null, null, _fileName_decorators, { kind: "field", name: "fileName", static: false, private: false, access: { has: obj => "fileName" in obj, get: obj => obj.fileName, set: (obj, value) => { obj.fileName = value; } }, metadata: _metadata }, _fileName_initializers, _fileName_extraInitializers);
|
|
126
|
+
__esDecorate(null, null, _text_decorators, { kind: "field", name: "text", static: false, private: false, access: { has: obj => "text" in obj, get: obj => obj.text, set: (obj, value) => { obj.text = value; } }, metadata: _metadata }, _text_initializers, _text_extraInitializers);
|
|
127
|
+
__esDecorate(null, null, _title_decorators, { kind: "field", name: "title", static: false, private: false, access: { has: obj => "title" in obj, get: obj => obj.title, set: (obj, value) => { obj.title = value; } }, metadata: _metadata }, _title_initializers, _title_extraInitializers);
|
|
128
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
129
|
+
SnapshotUI = _classThis = _classDescriptor.value;
|
|
130
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
131
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
132
|
+
}
|
|
133
|
+
captureButton;
|
|
134
|
+
socialShareBehaviours;
|
|
135
|
+
style = document.createElement('link');
|
|
136
|
+
shareDiv;
|
|
137
|
+
onSave = __runInitializers(this, _onSave_initializers, new Event());
|
|
138
|
+
onShare = (__runInitializers(this, _onSave_extraInitializers), __runInitializers(this, _onShare_initializers, new Event()));
|
|
139
|
+
/**
|
|
140
|
+
* @default true
|
|
37
141
|
*/
|
|
38
|
-
|
|
39
|
-
if (visible) {
|
|
40
|
-
this.captureButton.show();
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
this.captureButton.hide();
|
|
44
|
-
}
|
|
45
|
-
});
|
|
142
|
+
visible = (__runInitializers(this, _onShare_extraInitializers), __runInitializers(this, _visible_initializers, true));
|
|
46
143
|
/**
|
|
47
144
|
* The format of the image to capture.
|
|
48
|
-
* @
|
|
49
|
-
* @zdefault jpeg
|
|
145
|
+
* @default "jpeg"
|
|
50
146
|
*/
|
|
51
|
-
|
|
52
|
-
const ssctx = this.contextManager.get(SnapshotContext);
|
|
53
|
-
ssctx.fileType.value = format === ImageFormat.PNG ? 'image/png' : 'image/jpeg';
|
|
54
|
-
});
|
|
147
|
+
format = (__runInitializers(this, _visible_extraInitializers), __runInitializers(this, _format_initializers, ImageFormat.JPEG));
|
|
55
148
|
/**
|
|
56
149
|
* The quality of the image to capture.
|
|
57
|
-
* @
|
|
58
|
-
* @
|
|
150
|
+
* @default 0.92
|
|
151
|
+
* @zui
|
|
152
|
+
* @ztype proportion
|
|
59
153
|
*/
|
|
60
|
-
|
|
61
|
-
const ssctx = this.contextManager.get(SnapshotContext);
|
|
62
|
-
ssctx.quality.value = quality;
|
|
63
|
-
});
|
|
154
|
+
quality = (__runInitializers(this, _format_extraInitializers), __runInitializers(this, _quality_initializers, 0.92));
|
|
64
155
|
/**
|
|
65
156
|
* The name of the file to download.
|
|
66
|
-
* @
|
|
67
|
-
* @zdefault canvas
|
|
157
|
+
* @default "canvas"
|
|
68
158
|
*/
|
|
69
|
-
|
|
70
|
-
const ssctx = this.contextManager.get(SnapshotContext);
|
|
71
|
-
ssctx.fileName.value = fileName;
|
|
72
|
-
});
|
|
159
|
+
fileName = (__runInitializers(this, _quality_extraInitializers), __runInitializers(this, _fileName_initializers, 'canvas'));
|
|
73
160
|
/**
|
|
74
161
|
* The text to share.
|
|
75
|
-
* @
|
|
76
|
-
* @zdefault ''
|
|
162
|
+
* @default ""
|
|
77
163
|
*/
|
|
78
|
-
|
|
79
|
-
const ssctx = this.contextManager.get(SnapshotContext);
|
|
80
|
-
ssctx.text.value = text;
|
|
81
|
-
});
|
|
164
|
+
text = (__runInitializers(this, _fileName_extraInitializers), __runInitializers(this, _text_initializers, ''));
|
|
82
165
|
/**
|
|
83
166
|
* The title to share.
|
|
84
|
-
* @
|
|
85
|
-
* @zdefault ''
|
|
167
|
+
* @default ""
|
|
86
168
|
*/
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
this.
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
this.
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
}
|
|
169
|
+
title = (__runInitializers(this, _text_extraInitializers), __runInitializers(this, _title_initializers, ''));
|
|
170
|
+
/**
|
|
171
|
+
* Creates a new SnapshotUI component.
|
|
172
|
+
* @param contextManager - The current ContextManager
|
|
173
|
+
* @param props - The constructor properties.
|
|
174
|
+
*/
|
|
175
|
+
constructor(contextManager, props) {
|
|
176
|
+
super(contextManager, props);
|
|
177
|
+
__runInitializers(this, _title_extraInitializers);
|
|
178
|
+
const showSupported = this.contextManager.get(SnapshotContext).shareAPISupported.value;
|
|
179
|
+
const showShare = (props.allowShare ?? true) && showSupported;
|
|
180
|
+
this.socialShareBehaviours = new SocialShareBehaviors(contextManager, this, {
|
|
181
|
+
allowShare: showShare,
|
|
182
|
+
});
|
|
183
|
+
this.socialShareBehaviours.onSave.addListener(() => {
|
|
184
|
+
this.onSave.emit();
|
|
185
|
+
});
|
|
186
|
+
this.socialShareBehaviours.onShare?.addListener(() => {
|
|
187
|
+
this.onShare.emit();
|
|
188
|
+
});
|
|
189
|
+
const overlay = useOverlay(this.contextManager).value;
|
|
190
|
+
this.shareDiv = new ShareDivElement(showShare, async () => {
|
|
191
|
+
try {
|
|
192
|
+
this.socialShareBehaviours.share();
|
|
193
|
+
}
|
|
194
|
+
catch (err) {
|
|
195
|
+
console.error('Error sharing:', err);
|
|
196
|
+
}
|
|
197
|
+
}, overlay);
|
|
198
|
+
this.captureButton = new CaptureButtonElement(this.contextManager);
|
|
199
|
+
registerLoadable(this, new Promise(resolve => {
|
|
200
|
+
this.style.onload = resolve;
|
|
201
|
+
}));
|
|
202
|
+
this.style.rel = 'stylesheet';
|
|
203
|
+
this.style.type = 'text/css';
|
|
204
|
+
this.style.href = style_src;
|
|
205
|
+
document.head.appendChild(this.style);
|
|
206
|
+
this.captureButton.onClick.addListener(() => {
|
|
207
|
+
this.socialShareBehaviours.capture();
|
|
208
|
+
this.shareDiv.show();
|
|
209
|
+
});
|
|
210
|
+
this.shareDiv.onDownload.addListener(() => {
|
|
211
|
+
this.socialShareBehaviours.download();
|
|
212
|
+
});
|
|
213
|
+
this.shareDiv.onClose.addListener(() => {
|
|
214
|
+
this.captureButton.show();
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
dispose() {
|
|
218
|
+
if (this.style.parentNode)
|
|
219
|
+
this.style.parentNode.removeChild(this.style);
|
|
220
|
+
this.socialShareBehaviours.dispose();
|
|
221
|
+
return super.dispose();
|
|
222
|
+
}
|
|
223
|
+
};
|
|
224
|
+
return SnapshotUI = _classThis;
|
|
225
|
+
})();
|
|
226
|
+
export { SnapshotUI };
|
|
135
227
|
class SocialShareBehaviors {
|
|
228
|
+
capture_b;
|
|
229
|
+
download_b;
|
|
230
|
+
share_b;
|
|
136
231
|
/**
|
|
137
232
|
* Creates a new SocialShareBehaviors component.
|
|
138
233
|
* @param contextManager - The current ContextManager
|
|
@@ -170,13 +265,15 @@ class SocialShareBehaviors {
|
|
|
170
265
|
}
|
|
171
266
|
}
|
|
172
267
|
class CaptureButtonElement {
|
|
268
|
+
contextManager;
|
|
269
|
+
button;
|
|
270
|
+
clickEvent = new Event();
|
|
173
271
|
/**
|
|
174
272
|
* Creates a new CaptureButtonElement component.
|
|
175
273
|
* @param contextManager - The current ContextManager
|
|
176
274
|
*/
|
|
177
275
|
constructor(contextManager) {
|
|
178
276
|
this.contextManager = contextManager;
|
|
179
|
-
this.clickEvent = new Event();
|
|
180
277
|
const template = `
|
|
181
278
|
<div id="zee-photo-button" class="zee-photo-button">
|
|
182
279
|
<div id="zee-social-share-circle" class="zee-social-share-circle"></div>
|
|
@@ -247,6 +344,10 @@ class CaptureButtonElement {
|
|
|
247
344
|
}
|
|
248
345
|
}
|
|
249
346
|
class ShareDivElement {
|
|
347
|
+
shareFunction;
|
|
348
|
+
onDownload = new Event();
|
|
349
|
+
// public onShare = new Event();
|
|
350
|
+
onClose = new Event();
|
|
250
351
|
/**
|
|
251
352
|
* Creates a new ShareDivElement component.
|
|
252
353
|
* @param withShareButton - Whether to include a share button.
|
|
@@ -254,10 +355,6 @@ class ShareDivElement {
|
|
|
254
355
|
*/
|
|
255
356
|
constructor(withShareButton, shareFunction, rootDom = document.body) {
|
|
256
357
|
this.shareFunction = shareFunction;
|
|
257
|
-
this.rootDom = rootDom;
|
|
258
|
-
this.onDownload = new Event();
|
|
259
|
-
// public onShare = new Event();
|
|
260
|
-
this.onClose = new Event();
|
|
261
358
|
const template = `
|
|
262
359
|
<div id="social-share-div" class="social-share-div">
|
|
263
360
|
<img id="zee-social-share-img" class="zee-social-share-img">
|
package/lib/context.d.ts
CHANGED
|
@@ -40,7 +40,10 @@ type ConstructorWithOnlyOptional<T> = RequiredKeys<ConstructorProps<T>> extends
|
|
|
40
40
|
* This type creates a tuple consisting of a constructor type and its corresponding properties.
|
|
41
41
|
* @typeParam T - The type of the context constructor.
|
|
42
42
|
*/
|
|
43
|
-
type ConstructorWithProps<T extends ContextConstructor = ContextConstructor> = [
|
|
43
|
+
type ConstructorWithProps<T extends ContextConstructor = ContextConstructor> = [
|
|
44
|
+
T,
|
|
45
|
+
ConstructorParameters<T>[1]
|
|
46
|
+
];
|
|
44
47
|
/**
|
|
45
48
|
* Type representing instances of a list of constructors with properties.
|
|
46
49
|
*
|
|
@@ -61,6 +64,9 @@ export declare class Context<ConstructorPropsType extends {
|
|
|
61
64
|
} = {}> {
|
|
62
65
|
contextManager: ContextManager;
|
|
63
66
|
constructorProps: ConstructorPropsType;
|
|
67
|
+
/**
|
|
68
|
+
* @default false
|
|
69
|
+
*/
|
|
64
70
|
disposed: boolean;
|
|
65
71
|
/**
|
|
66
72
|
* Creates an instance of Context.
|
|
@@ -68,7 +74,7 @@ export declare class Context<ConstructorPropsType extends {
|
|
|
68
74
|
* @param constructorProps - The constructor properties.
|
|
69
75
|
*/
|
|
70
76
|
constructor(contextManager: ContextManager, constructorProps: ConstructorPropsType);
|
|
71
|
-
dispose(): never;
|
|
77
|
+
dispose(): typeof Context.callSuperDispose & never;
|
|
72
78
|
private static callSuperDispose;
|
|
73
79
|
}
|
|
74
80
|
/**
|
|
@@ -79,6 +85,9 @@ export declare class Context<ConstructorPropsType extends {
|
|
|
79
85
|
* The `ContextManager` is also used to create components, behaviors, and other objects that require a context.
|
|
80
86
|
*/
|
|
81
87
|
export declare class ContextManager {
|
|
88
|
+
/**
|
|
89
|
+
* @default {}
|
|
90
|
+
*/
|
|
82
91
|
private _byKey;
|
|
83
92
|
private _root;
|
|
84
93
|
/**
|
|
@@ -136,15 +145,24 @@ export declare class ContextManager {
|
|
|
136
145
|
* @param props - Optional properties to initialize the context.
|
|
137
146
|
* @returns A tuple containing the forked `ContextManager` and the newly added context instance.
|
|
138
147
|
*/
|
|
139
|
-
fork<T extends new (contextManager: ContextManager, props: {}) => any>(ctx: ConstructorWithOnlyOptional<T>): [
|
|
140
|
-
|
|
148
|
+
fork<T extends new (contextManager: ContextManager, props: {}) => any>(ctx: ConstructorWithOnlyOptional<T>): [
|
|
149
|
+
ContextManager,
|
|
150
|
+
InstanceType<T>
|
|
151
|
+
];
|
|
152
|
+
fork<T extends new (contextManager: ContextManager, props: {}) => any>(ctx: T, props: ConstructorParameters<T>[1]): [
|
|
153
|
+
ContextManager,
|
|
154
|
+
InstanceType<T>
|
|
155
|
+
];
|
|
141
156
|
/**
|
|
142
157
|
* Factory function for creating new instances of a given context type, along with associated properties.
|
|
143
158
|
*
|
|
144
159
|
* @typeParam T - An array type representing a combination of a constructor and its corresponding properties.
|
|
145
160
|
* @returns An array where each element is a tuple, with the first element being the context manager and the second being the instance created by the constructor.
|
|
146
161
|
*/
|
|
147
|
-
forkMultiple<T extends ConstructorWithProps[]>(...ctx: T): [
|
|
162
|
+
forkMultiple<T extends ConstructorWithProps[]>(...ctx: T): [
|
|
163
|
+
ContextManager,
|
|
164
|
+
InstancesOfConstructorsWithProps<T>
|
|
165
|
+
];
|
|
148
166
|
/**
|
|
149
167
|
* Creates a new forked `ContextManager` instance with a shallow copy of the current context.
|
|
150
168
|
*
|
package/lib/context.js
CHANGED
|
@@ -6,6 +6,12 @@ let _nextContextKey = 1;
|
|
|
6
6
|
* @typeParam ConstructorPropsType - The type of the constructor properties, defaulting to an empty object.
|
|
7
7
|
*/
|
|
8
8
|
export class Context {
|
|
9
|
+
contextManager;
|
|
10
|
+
constructorProps;
|
|
11
|
+
/**
|
|
12
|
+
* @default false
|
|
13
|
+
*/
|
|
14
|
+
disposed = false;
|
|
9
15
|
/**
|
|
10
16
|
* Creates an instance of Context.
|
|
11
17
|
* @param contextManager The current ContextManager
|
|
@@ -14,14 +20,13 @@ export class Context {
|
|
|
14
20
|
constructor(contextManager, constructorProps) {
|
|
15
21
|
this.contextManager = contextManager;
|
|
16
22
|
this.constructorProps = constructorProps;
|
|
17
|
-
this.disposed = false;
|
|
18
23
|
}
|
|
19
24
|
dispose() {
|
|
20
25
|
this.disposed = true;
|
|
21
26
|
return undefined;
|
|
22
27
|
}
|
|
28
|
+
static callSuperDispose = Symbol('Calling super.dispose() is mandatory');
|
|
23
29
|
}
|
|
24
|
-
Context.callSuperDispose = Symbol('Calling super.dispose() is mandatory');
|
|
25
30
|
const keysByType = new Map();
|
|
26
31
|
/**
|
|
27
32
|
* Class for managing contexts.
|
|
@@ -31,10 +36,11 @@ const keysByType = new Map();
|
|
|
31
36
|
* The `ContextManager` is also used to create components, behaviors, and other objects that require a context.
|
|
32
37
|
*/
|
|
33
38
|
export class ContextManager {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
39
|
+
/**
|
|
40
|
+
* @default {}
|
|
41
|
+
*/
|
|
42
|
+
_byKey = {};
|
|
43
|
+
_root = this;
|
|
38
44
|
static create(ctx, props) {
|
|
39
45
|
const ret = new ContextManager();
|
|
40
46
|
ret.add(ctx, props ?? {});
|
|
@@ -1,15 +1,25 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Context, ContextManager } from '../context';
|
|
2
|
+
import type { Entity } from '../entity';
|
|
2
3
|
import { Event } from '../event';
|
|
3
4
|
/** @zcontext */
|
|
4
5
|
export declare class AnalyticsContext extends Context {
|
|
5
6
|
readonly onEvent: Event<[string, any]>;
|
|
6
|
-
/**
|
|
7
|
+
/**
|
|
8
|
+
* @zui
|
|
9
|
+
*/
|
|
7
10
|
logEvent(name: string, params?: any): void;
|
|
8
11
|
}
|
|
9
12
|
/**
|
|
10
13
|
* Logs an analytics event.
|
|
11
14
|
*/
|
|
12
15
|
export declare function logEvent(mgr: ContextManager, name: string, params?: any): void;
|
|
16
|
+
/**
|
|
17
|
+
* A decorator that logs an analytics event when the decorated function is called.
|
|
18
|
+
*
|
|
19
|
+
* @param name the name of the event to log
|
|
20
|
+
* @param params any additional parameters to pass ot the analytics provider
|
|
21
|
+
*/
|
|
22
|
+
export declare function zLogEvent<EntityType extends Entity>(name: string, params?: any): (originalMethod: (...args: any) => any, context: ClassMethodDecoratorContext<EntityType, (this: EntityType, ...args: any[]) => any>) => void;
|
|
13
23
|
/**
|
|
14
24
|
* Returns the analytics onEvent event.
|
|
15
25
|
*/
|