@zcomponent/core 1.21.1-beta → 1.22.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/index.js CHANGED
@@ -1,2 +1,4 @@
1
- /* eslint-disable node/no-unsupported-features/es-syntax */
1
+ /* eslint-disable n/no-unsupported-features/es-syntax */
2
+ /* eslint-disable n/no-missing-import */
3
+
2
4
  export * from './lib';
@@ -19,6 +19,10 @@ export declare enum AnimationEvents {
19
19
  */
20
20
  export declare class Animation {
21
21
  private _initialize;
22
+ /**
23
+ * @internal
24
+ */
25
+ _FIX_SERIALIZE: boolean;
22
26
  /**
23
27
  * Collection of layers indexed by ID.
24
28
  */
@@ -19,6 +19,10 @@ export class Animation {
19
19
  */
20
20
  constructor(_initialize = true) {
21
21
  this._initialize = _initialize;
22
+ /**
23
+ * @internal
24
+ */
25
+ this._FIX_SERIALIZE = true;
22
26
  /**
23
27
  * Collection of layers indexed by ID.
24
28
  */
@@ -100,6 +100,7 @@ export declare class Layer {
100
100
  _activateLayerClip(layerClip: LayerClip | null | undefined, playOptions?: LayerClipPlayOptions): void;
101
101
  /** @internal */
102
102
  _evaulate(): void;
103
+ private _getTime;
103
104
  /** @internal */
104
105
  _serialize(state: AnimationState): void;
105
106
  /** @internal */
@@ -69,6 +69,8 @@ export class Layer {
69
69
  if (next && next.startTime && next.startTime && entry !== this._active && t - next.startTime > next.fadeTime) {
70
70
  entry.layerClip?.pause();
71
71
  this._queue.splice(i, 1);
72
+ if (entry.layerClip)
73
+ this.animation._pendingEvents.push({ evt: AnimationEvents.onLayerClipState, args: [entry.layerClip] });
72
74
  }
73
75
  if (entry.layerClip && entry === this._active) {
74
76
  if (next && (entry.layerClip.state.value === StreamState.Ended || next.fadeTime >= entry.layerClip.getRemainingTimeEstimate())) {
@@ -181,6 +183,9 @@ export class Layer {
181
183
  _evaulate() {
182
184
  this.animation.evaluateTouchedPaths([...this.influencedPaths.values()]);
183
185
  }
186
+ _getTime() {
187
+ return Math.floor(this.animation.timeSource?.() ?? performance.now());
188
+ }
184
189
  /** @internal */
185
190
  _serialize(state) {
186
191
  for (const layerClip of this._layerClips) {
@@ -191,13 +196,17 @@ export class Layer {
191
196
  const entry = {
192
197
  queue: [],
193
198
  };
199
+ const timeOfSerialization = this._getTime();
194
200
  for (const queueEntry of this._queue) {
195
201
  if (queueEntry.layerClip && queueEntry.layerClip.id === undefined)
196
202
  continue;
197
- entry.queue.push({
203
+ const mqe = {
198
204
  ...queueEntry,
199
205
  layerClip: queueEntry.layerClip === null ? null : queueEntry.layerClip?.id,
200
- });
206
+ };
207
+ if (mqe.startTime !== undefined)
208
+ mqe.startTime -= timeOfSerialization;
209
+ entry.queue.push(mqe);
201
210
  }
202
211
  entry.active = this._active === null ? null : this._active === undefined ? undefined : this._queue.indexOf(this._active);
203
212
  state.byLayer[this.id] = entry;
@@ -213,6 +222,7 @@ export class Layer {
213
222
  if (!entry)
214
223
  return;
215
224
  this._queue = [];
225
+ const timeOfSerialization = this._getTime();
216
226
  for (const qe of entry.queue) {
217
227
  let layerClip;
218
228
  if (typeof qe.layerClip === 'string') {
@@ -221,10 +231,13 @@ export class Layer {
221
231
  else if (qe.layerClip === null)
222
232
  layerClip = null;
223
233
  if (layerClip !== undefined) {
224
- this._queue.push({
234
+ const mqe = {
225
235
  ...qe,
226
236
  layerClip,
227
- });
237
+ };
238
+ if (mqe.startTime !== undefined)
239
+ mqe.startTime += timeOfSerialization;
240
+ this._queue.push(mqe);
228
241
  }
229
242
  }
230
243
  if (typeof entry.active === 'number') {
@@ -262,9 +262,9 @@ export class LayerClip {
262
262
  if (this.id === undefined)
263
263
  return;
264
264
  const timeOfSerialization = this._getTime();
265
- const t0 = timeOfSerialization - this._t0;
266
- const pauseTime = this._pauseTime === undefined ? undefined : timeOfSerialization - this._pauseTime;
267
- const t1 = isFinite(this._t1) ? timeOfSerialization - this._t1 : null;
265
+ const t0 = this._t0 - timeOfSerialization;
266
+ const pauseTime = this._pauseTime === undefined ? undefined : this._pauseTime - timeOfSerialization;
267
+ const t1 = isFinite(this._t1) ? this._t1 - timeOfSerialization : null;
268
268
  const ret = {
269
269
  t0,
270
270
  t1,
@@ -284,9 +284,9 @@ export class LayerClip {
284
284
  if (!entry)
285
285
  return;
286
286
  const timeOfDeserialization = this._getTime();
287
- this._t0 = timeOfDeserialization - entry.t0;
288
- this._t1 = entry.t1 === null ? Infinity : timeOfDeserialization - entry.t1;
289
- this._pauseTime = entry.pauseTime === undefined ? undefined : timeOfDeserialization - entry.pauseTime;
287
+ this._t0 = timeOfDeserialization + entry.t0;
288
+ this._t1 = entry.t1 === null ? Infinity : timeOfDeserialization + entry.t1;
289
+ this._pauseTime = entry.pauseTime === undefined ? undefined : timeOfDeserialization + entry.pauseTime;
290
290
  this._rate = entry.rate;
291
291
  this._loop = entry.loop;
292
292
  this._stopped = entry.stopped;
@@ -301,10 +301,7 @@ export class DefaultCookieConsent extends Component {
301
301
  if (isDesignTime(this.contextManager) && !designTimeOverride)
302
302
  return;
303
303
  const context = this.contextManager.get(CookieConsentContext);
304
- if (context.functionalCookies.value !== ConsentStatus.unknown &&
305
- context.marketingCookies.value !== ConsentStatus.unknown &&
306
- context.performanceCookies.value !== ConsentStatus.unknown &&
307
- !designTimeOverride)
304
+ if (context.functionalCookies.value !== ConsentStatus.unknown && context.marketingCookies.value !== ConsentStatus.unknown && context.performanceCookies.value !== ConsentStatus.unknown && !designTimeOverride)
308
305
  return;
309
306
  this._loadDOM(isSettings);
310
307
  const acceptedEssential = window.localStorage.getItem('zcomponent-cookieconsent-essential');
@@ -180,7 +180,7 @@ export function deleteEntityPropOverride(zcomp, id) {
180
180
  * @returns The unique ID for the EntityPropOverride.
181
181
  */
182
182
  function idForEntityPropOverride(override) {
183
- return (override.type + ':' + (override.entityPropIsConstructor ? 'constructorprop' : 'prop') + ':' + override.entityID + ':' + override.entityPropPath.join('.'));
183
+ return override.type + ':' + (override.entityPropIsConstructor ? 'constructorprop' : 'prop') + ':' + override.entityID + ':' + override.entityPropPath.join('.');
184
184
  }
185
185
  /**
186
186
  * Deep clones the given object.
@@ -1,3 +1,4 @@
1
+ /* eslint-disable eqeqeq */
1
2
  // License: CC0 (no rights reserved).
2
3
  // From https://github.com/rocicorp/fractional-indexing
3
4
  // This is based on https://observablehq.com/@dgreensp/implementing-fractional-indexing
package/lib/observable.js CHANGED
@@ -1,3 +1,5 @@
1
+ /* eslint-disable @typescript-eslint/no-this-alias */
2
+ /* eslint-disable @typescript-eslint/adjacent-overload-signatures */
1
3
  import { Emitter } from './emitter';
2
4
  /**
3
5
  * A class that holds a value and watches it for changes (deeply by default).
@@ -114,6 +116,7 @@ export class Observable extends Emitter {
114
116
  this._emit(this._value.proxy);
115
117
  }
116
118
  setValueAtPath(path, val) {
119
+ // eslint-disable-next-line @typescript-eslint/no-this-alias
117
120
  let target = this;
118
121
  let key = 'value';
119
122
  for (let i = 0; i < path.length; i++) {
package/lib/selectors.js CHANGED
@@ -342,9 +342,7 @@ ${Object.entries(scriptNames ?? {})
342
342
  .map(entry => {
343
343
  const values = Object.keys(entry[1]);
344
344
  if (values.length > 1) {
345
- return `\t\t${entry[0]}: {${values
346
- .map(e => `${JSON.stringify(e)}: ${importMapping.get(nodes[e].type)}${getBehaviorBlockForNode(behaviors, behaviorsByNodeID[nodes[e].id] ?? [], importMapping)}`)
347
- .join(', ')}},`;
345
+ return `\t\t${entry[0]}: {${values.map(e => `${JSON.stringify(e)}: ${importMapping.get(nodes[e].type)}${getBehaviorBlockForNode(behaviors, behaviorsByNodeID[nodes[e].id] ?? [], importMapping)}`).join(', ')}},`;
348
346
  }
349
347
  else {
350
348
  return `\t\t${entry[0]}: ${importMapping.get(nodes[values[0]].type)}${getBehaviorBlockForNode(behaviors, behaviorsByNodeID[nodes[values[0]].id] ?? [], importMapping)},`;
package/lib/types.js CHANGED
@@ -1,4 +1,5 @@
1
- import { EntityPropOverrideType, FunctionCallType, } from './data/core';
1
+ /* eslint-disable no-case-declarations */
2
+ import { EntityPropOverrideType, FunctionCallType } from './data/core';
2
3
  import { getSafeKeyName } from './selectors';
3
4
  /**
4
5
  * Enumeration of type names used in type definitions.
@@ -52,6 +53,7 @@ export var TypeHint;
52
53
  *
53
54
  * This enum lists different kinds of values types that can be used in a values definition, representing various data sources or formats.
54
55
  */
56
+ // If you add a new value here, please also add it to typeinfo.ts > ZAnnotationValue
55
57
  export var ValuesType;
56
58
  (function (ValuesType) {
57
59
  ValuesType["files"] = "files";
package/package.json CHANGED
@@ -1,14 +1,21 @@
1
1
  {
2
2
  "name": "@zcomponent/core",
3
- "version": "1.21.1-beta",
3
+ "version": "1.22.0",
4
4
  "description": "The core component model and built-in functionality for Mattercraft.",
5
+ "author": "Zappar Limited",
6
+ "license": "Proprietary",
5
7
  "main": "index.js",
6
8
  "types": "index.d.ts",
9
+ "type": "module",
7
10
  "engines": {
8
11
  "node": ">=12.0.0",
9
12
  "browsers": "defaults"
10
13
  },
11
- "type": "module",
14
+ "zexports": [
15
+ "./lib/components/**/*",
16
+ "./lib/behaviors/**/*",
17
+ "./lib/contexts/**/*"
18
+ ],
12
19
  "directories": {
13
20
  "lib": "lib"
14
21
  },
@@ -20,27 +27,68 @@
20
27
  "assets/**/*"
21
28
  ],
22
29
  "scripts": {
23
- "build": "rm -rf lib && tsc",
24
- "build-animation-tests": "tsc -p ./tsconfig.test.animation.json",
25
- "test": "env TS_NODE_PROJECT=\"tsconfig.testing.json\" mocha --es-module-specifier-resolution=node",
30
+ "build": "rm -rf lib && tsc && tsc-alias",
26
31
  "watch": "tsc -w",
27
- "predocs": "tsc",
28
- "docs": "typedoc"
32
+ "docs": "typedoc --out docs",
33
+ "test": "env TS_NODE_PROJECT=\"tsconfig.testing.json\" mocha --es-module-specifier-resolution=node",
34
+ "build-animation-tests": "tsc -p ./tsconfig.test.animation.json",
35
+ "predocs": "npm run ctix",
36
+ "ctix": "ctix build"
29
37
  },
30
- "author": "Zappar Limited",
31
- "license": "Proprietary",
32
38
  "devDependencies": {
33
39
  "@types/mocha": "^10.0.1",
34
- "@zappar/typedoc-plugin-mattercraft": "^0.0.4",
35
- "mocha": "^10.2.0",
36
- "ts-node": "^10.9.1",
37
- "typedoc": "^0.24.8",
38
- "typedoc-plugin-mdn-links": "^3.1.7",
39
- "typescript": "^4.9.4"
40
+ "mocha": "^10.2.0"
40
41
  },
41
- "zexports": [
42
- "./lib/components/**/*",
43
- "./lib/behaviors/**/*",
44
- "./lib/contexts/**/*"
45
- ]
42
+ "keywords": [],
43
+ "release": {
44
+ "extends": "semantic-release-commit-filter",
45
+ "ci": true,
46
+ "branches": [
47
+ "main",
48
+ {
49
+ "name": "beta",
50
+ "channel": "beta",
51
+ "prerelease": "beta"
52
+ },
53
+ {
54
+ "name": "alpha",
55
+ "channel": "alpha",
56
+ "prerelease": "alpha"
57
+ }
58
+ ],
59
+ "plugins": [
60
+ "@semantic-release/commit-analyzer",
61
+ "@semantic-release/release-notes-generator",
62
+ "@semantic-release/changelog",
63
+ "@semantic-release/npm",
64
+ "@semantic-release/gitlab",
65
+ [
66
+ "@semantic-release/git",
67
+ {
68
+ "assets": [
69
+ "package.json",
70
+ "packages/*/package.json",
71
+ "packages/*/CHANGELOG.md"
72
+ ],
73
+ "message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
74
+ }
75
+ ],
76
+ [
77
+ "@rimac-technology/semantic-release-s3",
78
+ {
79
+ "s3Bucket": {
80
+ "main": "mattercraft-api-docs/prod",
81
+ "beta": "mattercraft-api-docs-beta/beta",
82
+ "alpha": "mattercraft-api-docs-alpha/alpha"
83
+ },
84
+ "directoryPath": "../../docs/**/*",
85
+ "objectACL": "",
86
+ "removeDirectoryRoot": true,
87
+ "awsAccessKeyName": "DOCS_AWS_ACCESS_KEY_ID",
88
+ "awsSecretAccessKeyName": "DOCS_AWS_SECRET_ACCESS_KEY"
89
+ }
90
+ ]
91
+ ],
92
+ "tagFormat": "@zcomponent/core@${version}"
93
+ }
46
94
  }