@ddd-qc/lit-happ 0.29.13 → 0.29.14

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.
@@ -16,7 +16,7 @@ export declare abstract class ViewModel {
16
16
  initializePerspectiveOnline(): Promise<void>;
17
17
  protected probeAllInner(): void;
18
18
  probeAll(): void;
19
- protected abstract hasChanged(): boolean;
19
+ protected hasChanged(): boolean;
20
20
  provideContext(providerHost: ReactiveElement): void;
21
21
  subscribe(providedHost: ReactiveControllerHost, propName: PropertyKey): void;
22
22
  unsubscribe(candidate: ReactiveControllerHost): void;
@@ -1 +1 @@
1
- {"version":3,"file":"ViewModel.d.ts","sourceRoot":"","sources":["../src/ViewModel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAkB,MAAM,cAAc,CAAC;AACtD,OAAO,EAAC,sBAAsB,EAAE,eAAe,EAAC,MAAM,KAAK,CAAC;AAC5D,OAAO,EAAC,WAAW,EAAC,MAAM,mBAAmB,CAAC;AAE9C,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAsBnC,8BAAsB,SAAS;IAG9B,SAAS,CAAC,oBAAoB,CAAC,EAAE,OAAO,CAAC;IACzC,SAAS,CAAC,cAAc,EAAE,CAAC,sBAAsB,EAAE,WAAW,CAAC,EAAE,CAAM;IACvE,SAAS,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC;IAE9B,SAAS,CAAC,UAAU,UAAQ;IAK5B,SAAS,CAAC,WAAW,QAAe;IAIpC,QAAQ,CAAC,aAAa,CAAC,EAAE,WAAW,CAAC;IAKrC,QAAQ,CAAC,UAAU,IAAI,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC;IAEhD,QAAQ,KAAK,WAAW,IAAI,MAAM,CAAC;IAInC,UAAU,IAAI,MAAM;IAId,4BAA4B,IAAI,OAAO,CAAC,IAAI,CAAC;IAE7C,2BAA2B,IAAI,OAAO,CAAC,IAAI,CAAC;IAElD,SAAS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S,CAAC,UAAU,IAAI,OAAO;IAY/B,cAAc,CAAC,YAAY,EAAE,eAAe,GAAG,IAAI;IAQnD,SAAS,CAAC,YAAY,EAAE,sBAAsB,EAAE,QAAQ,EAAE,WAAW,GAAG,IAAI;IAM5E,WAAW,CAAC,SAAS,EAAE,sBAAsB,GAAG,IAAI;IAYpD,SAAS,CAAC,iBAAiB,IAAI,OAAO;CAgBvC"}
package/dist/ViewModel.js CHANGED
@@ -6,7 +6,7 @@ export class ViewModel {
6
6
  this._canNotify = true;
7
7
  this._probeMutex = new Mutex();
8
8
  }
9
- comparable() { return this.perspective; }
9
+ comparable() { return {}; }
10
10
  async initializePerspectiveOffline() { }
11
11
  async initializePerspectiveOnline() { }
12
12
  probeAllInner() { }
@@ -23,6 +23,12 @@ export class ViewModel {
23
23
  release();
24
24
  });
25
25
  }
26
+ hasChanged() {
27
+ if (!this._previousPerspective || Object.keys(this._previousPerspective).length == 0) {
28
+ return true;
29
+ }
30
+ return Object.entries(this._previousPerspective).toString() != Object.entries(this.comparable()).toString();
31
+ }
26
32
  provideContext(providerHost) {
27
33
  console.log(`\t\tProviding context "${this.getContext()}" | in host `, providerHost);
28
34
  this._provider = new ContextProvider(providerHost, this.getContext(), this);
@@ -52,7 +58,7 @@ export class ViewModel {
52
58
  host.requestUpdate();
53
59
  }
54
60
  else {
55
- host[propName] = this._previousPerspective;
61
+ host[propName] = this.perspective;
56
62
  }
57
63
  }
58
64
  return true;
@@ -1 +1 @@
1
- {"version":3,"file":"ViewModel.js","sourceRoot":"","sources":["../src/ViewModel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,eAAe,EAAC,MAAM,cAAc,CAAC;AAItD,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAsBnC,MAAM,OAAgB,SAAS;IAA/B;QAIW,mBAAc,GAA4C,EAAE,CAAC;QAG7D,eAAU,GAAG,IAAI,CAAC;QAKlB,gBAAW,GAAG,IAAI,KAAK,EAAE,CAAC;IAoGtC,C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MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;SACxC;IACL,CAAC;IAGS,iBAAiB;QACzB,IAAI,CAAC,IAAI,CAAC,UAAU,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,EAAE;YAC1C,OAAO,KAAK,CAAC;SACd;QAGD,IAAI,CAAC,oBAAoB,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC;QAC9C,KAAK,MAAM,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,IAAI,CAAC,cAAc,EAAE;YAClD,IAAI,QAAQ,IAAI,EAAE,EAAE;gBACjB,IAAY,CAAC,aAAa,EAAE,CAAC;aAC/B;iBAAM;gBACJ,IAAY,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC,oBAAoB,CAAC;aACrD;SACF;QACD,OAAO,IAAI,CAAC;IACd,CAAC;CAEF","sourcesContent":["import {Context, ContextProvider} from \"@lit/context\";\nimport {ReactiveControllerHost, ReactiveElement} from \"lit\";\nimport {AppSignalCb} from \"@holochain/client\";\n\nimport { Mutex } from 'async-mutex';\n//import {deepCopy} from \"./deepcopy/deepCopy\";\n\n// enum InitializationState {\n// Uninitialized = \"Uninitialized\",\n// InitializingOffline = \"InitializingOffline\",\n// InitializingOnline = \"InitializingOnline\",\n// Initialized = \"Initialized\",\n// }\n\n\n/**\n * ABC of a ViewModel.\n * It mediates the interaction between a View (CustomElements) and a Model (Zome / DNA).\n * It is an Observable meant to be observed by (Lit) ReactiveElements.\n * It is meant to be a singleton passed around by a (Lit) Context.\n * The ViewModel contains a perspective: All the data that a view can observe.\n * To update subscribers, it makes use of Lit's reactive properties.\n * When subscribing, a host must provide a reactive property that has the ViewModel's perspestives's type.\n * Hosts can trigger probing in order to get an updated perspective.\n * The perspective can be automatically updated by internal events.\n */\n export abstract class ViewModel {\n\n /** -- Fields -- */\n protected _previousPerspective?: unknown;\n protected _providedHosts: [ReactiveControllerHost, PropertyKey][] = [];\n protected _provider?: unknown; // FIXME type: ContextProvider<this.getContext()>;\n\n protected _canNotify = true; // Master switch for notifying subscribers\n\n //protected _initializationState: InitializationState = InitializationState.Uninitialized;\n\n\n protected _probeMutex = new Mutex();\n\n /** -- Abstract fields -- */\n\n abstract signalHandler?: AppSignalCb;\n\n\n /** -- Abstract methods -- */\n\n abstract getContext(): Context<unknown, unknown>;\n /* Child class should implement with specific type */\n abstract get perspective(): Object;\n\n\n /* Children are expected to override and provide a lightweight easy-to-compare perspective */\n comparable(): Object { return this.perspective }\n\n\n /* (optional) Set perspective with data from the source-chain only */\n async initializePerspectiveOffline(): Promise<void> {}\n /* (optional) Set perspective with data from the DHT */\n async initializePerspectiveOnline(): Promise<void> {}\n /* (optional) Lets the observer trigger probing into the network in order to get an updated perspective */\n protected probeAllInner(): void {};\n\n /**\n * Mutex wrapping of probeAllInner: Don't call probeAll() during a probeAll()\n * Should not be async as we expect this to be long, so happs are expected to use signals instead if something changed.\n */\n probeAll(): void {\n // if (this._initializationState !== InitializationState.Initialized) {\n // console.warn(\"probeAll() called on unitialized ViewModel\");\n // return;\n // }\n if (this._probeMutex.isLocked()) {\n console.log(\"probeAll() call skipped. Reason: Already running.\");\n return;\n }\n this._probeMutex\n .acquire()\n .then(async (release) => {\n this.probeAllInner();\n release();\n });\n }\n\n /**\n * Return true if the perspective has changed. This will trigger an update on the observers\n * Child classes are expected to compare their latest constructed perspective (the one returned by this.perspective())\n * with this._previousPerspective.\n */\n protected abstract hasChanged(): boolean;\n\n\n /** -- Final methods -- */\n\n /** Set ContextProvider for host */\n provideContext(providerHost: ReactiveElement): void {\n console.log(`\\t\\tProviding context \"${this.getContext()}\" | in host `, providerHost);\n this._provider = new ContextProvider(providerHost, this.getContext(), this);\n }\n\n /** -- Observer pattern -- */\n\n /** */\n subscribe(providedHost: ReactiveControllerHost, propName: PropertyKey): void {\n (providedHost as any)[propName] = this.perspective;\n this._providedHosts.push([providedHost, propName])\n }\n\n /** */\n unsubscribe(candidate: ReactiveControllerHost): void {\n let index = 0;\n for (const [host, _propName] of this._providedHosts) {\n if (host === candidate) break;\n index += 1;\n }\n if (index > -1) {\n this._providedHosts.splice(index, 1);\n }\n }\n\n /** */\n protected notifySubscribers(): boolean {\n if (!this._canNotify || !this.hasChanged()) {\n return false;\n }\n //this._previousPerspective = deepCopy(this.perspective);\n //this._previousPerspective = structuredClone(this.perspective);\n this._previousPerspective = this.comparable();\n for (const [host, propName] of this._providedHosts) {\n if (propName == \"\") {\n (host as any).requestUpdate();\n } else {\n (host as any)[propName] = this._previousPerspective;\n }\n }\n return true;\n }\n\n}\n"]}
1
+ {"version":3,"file":"ViewModel.js","sourceRoot":"","sources":["../src/ViewModel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,eAAe,EAAC,MAAM,cAAc,CAAC;AAItD,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAsBnC,MAAM,OAAgB,SAAS;IAA/B;QAIW,mBAAc,GAA4C,EAAE,CAAC;QAG7D,eAAU,GAAG,IAAI,CAAC;QAKlB,gBAAW,GAAG,IAAI,KAAK,EAAE,CAAC;IAwGtC,CAAC;IAzFC,UAAU,KAAa,OAAO,EAAE,CAAA,CAAC,CAAC;IAIlC,KAAK,CAAC,4BAA4B,KAAmB,CAAC;IAEtD,KAAK,CAAC,2BAA2B,KAAmB,CAAC;IAE3C,aAAa,KAAU,CAAC;IAAA,CAAC;IAMnC,QAAQ;QAKN,IAAI,IAAI,CAAC,WAAW,CAAC,QAAQ,EAAE,EAAE;YAC/B,OAAO,CAAC,GAAG,CAAC,mDAAmD,CAAC,CAAC;YACjE,OAAO;SACR;QACD,IAAI,CAAC,WAAW;aACb,OAAO,EAAE;aACT,IAAI,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;YACtB,IAAI,CAAC,aAAa,EAAE,CAAC;YACrB,OAAO,EAAE,CAAC;QACZ,CAAC,CAAC,CAAC;IACP,CAAC;IAMS,UAAU;QAElB,IAAI,CAAC,IAAI,CAAC,oBAAoB,IAAI,MAAM,CAAC,IAAI,CA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,CAAC;QAC9C,KAAK,MAAM,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,IAAI,CAAC,cAAc,EAAE;YAClD,IAAI,QAAQ,IAAI,EAAE,EAAE;gBACjB,IAAY,CAAC,aAAa,EAAE,CAAC;aAC/B;iBAAM;gBACJ,IAAY,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC,WAAW,CAAC;aAC5C;SACF;QACD,OAAO,IAAI,CAAC;IACd,CAAC;CAEF","sourcesContent":["import {Context, ContextProvider} from \"@lit/context\";\nimport {ReactiveControllerHost, ReactiveElement} from \"lit\";\nimport {AppSignalCb} from \"@holochain/client\";\n\nimport { Mutex } from 'async-mutex';\n\n\n// enum InitializationState {\n// Uninitialized = \"Uninitialized\",\n// InitializingOffline = \"InitializingOffline\",\n// InitializingOnline = \"InitializingOnline\",\n// Initialized = \"Initialized\",\n// }\n\n\n/**\n * ABC of a ViewModel.\n * It mediates the interaction between a View (CustomElements) and a Model (Zome / DNA).\n * It is an Observable meant to be observed by (Lit) ReactiveElements.\n * It is meant to be a singleton passed around by a (Lit) Context.\n * The ViewModel contains a perspective: All the data that a view can observe.\n * To update subscribers, it makes use of Lit's reactive properties.\n * When subscribing, a host must provide a reactive property that has the ViewModel's perspestives's type.\n * Hosts can trigger probing in order to get an updated perspective.\n * The perspective can be automatically updated by internal events.\n */\n export abstract class ViewModel {\n\n /** -- Fields -- */\n protected _previousPerspective?: unknown;\n protected _providedHosts: [ReactiveControllerHost, PropertyKey][] = [];\n protected _provider?: unknown; // FIXME type: ContextProvider<this.getContext()>;\n\n protected _canNotify = true; // Master switch for notifying subscribers\n\n //protected _initializationState: InitializationState = InitializationState.Uninitialized;\n\n\n protected _probeMutex = new Mutex();\n\n /** -- Abstract fields -- */\n\n abstract signalHandler?: AppSignalCb;\n\n\n /** -- Abstract methods -- */\n\n abstract getContext(): Context<unknown, unknown>;\n /* Child class should implement with specific type */\n abstract get perspective(): Object;\n\n\n /* Children are expected to override and provide a lightweight and easy-to-compare version of the perspective */\n comparable(): Object { return {} }\n\n\n /* (optional) Set perspective with data from the source-chain only */\n async initializePerspectiveOffline(): Promise<void> {}\n /* (optional) Set perspective with data from the DHT */\n async initializePerspectiveOnline(): Promise<void> {}\n /* (optional) Lets the observer trigger probing into the network in order to get an updated perspective */\n protected probeAllInner(): void {};\n\n /**\n * Mutex wrapping of probeAllInner: Don't call probeAll() during a probeAll()\n * Should not be async as we expect this to be long, so happs are expected to use signals instead if something changed.\n */\n probeAll(): void {\n // if (this._initializationState !== InitializationState.Initialized) {\n // console.warn(\"probeAll() called on unitialized ViewModel\");\n // return;\n // }\n if (this._probeMutex.isLocked()) {\n console.log(\"probeAll() call skipped. Reason: Already running.\");\n return;\n }\n this._probeMutex\n .acquire()\n .then(async (release) => {\n this.probeAllInner();\n release();\n });\n }\n\n /**\n * Return true if the perspective has changed (compared to _previousPerspective).\n * This will trigger an update on the observers.\n */\n protected hasChanged(): boolean {\n /** return true if previous is empty, meaning comparable() has not been implemented */\n if (!this._previousPerspective || Object.keys(this._previousPerspective).length == 0) {\n return true;\n }\n return Object.entries(this._previousPerspective).toString() != Object.entries(this.comparable()).toString();\n }\n\n\n /** -- Final methods -- */\n\n /** Set ContextProvider for host */\n provideContext(providerHost: ReactiveElement): void {\n console.log(`\\t\\tProviding context \"${this.getContext()}\" | in host `, providerHost);\n this._provider = new ContextProvider(providerHost, this.getContext(), this);\n }\n\n /** -- Observer pattern -- */\n\n /** */\n subscribe(providedHost: ReactiveControllerHost, propName: PropertyKey): void {\n (providedHost as any)[propName] = this.perspective;\n this._providedHosts.push([providedHost, propName])\n }\n\n /** */\n unsubscribe(candidate: ReactiveControllerHost): void {\n let index = 0;\n for (const [host, _propName] of this._providedHosts) {\n if (host === candidate) break;\n index += 1;\n }\n if (index > -1) {\n this._providedHosts.splice(index, 1);\n }\n }\n\n /** */\n protected notifySubscribers(): boolean {\n if (!this._canNotify || !this.hasChanged()) {\n return false;\n }\n //this._previousPerspective = structuredClone(this.perspective);\n this._previousPerspective = this.comparable();\n for (const [host, propName] of this._providedHosts) {\n if (propName == \"\") {\n (host as any).requestUpdate();\n } else {\n (host as any)[propName] = this.perspective;\n }\n }\n return true;\n }\n\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ddd-qc/lit-happ",
3
- "version": "0.29.13",
3
+ "version": "0.29.14",
4
4
  "description": "MVVM Framework for holochain apps using Lit",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
@@ -1,2 +0,0 @@
1
- export declare function cloneArrayBuffer(arrayBuffer: ArrayBuffer): ArrayBuffer;
2
- //# sourceMappingURL=cloneArrayBuffer.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cloneArrayBuffer.d.ts","sourceRoot":"","sources":["../../src/deepcopy/cloneArrayBuffer.ts"],"names":[],"mappings":"AAOA,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,WAAW,GAAG,WAAW,CAItE"}
@@ -1,6 +0,0 @@
1
- export function cloneArrayBuffer(arrayBuffer) {
2
- const result = new ArrayBuffer(arrayBuffer.byteLength);
3
- new Uint8Array(result).set(new Uint8Array(arrayBuffer));
4
- return result;
5
- }
6
- //# sourceMappingURL=cloneArrayBuffer.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cloneArrayBuffer.js","sourceRoot":"","sources":["../../src/deepcopy/cloneArrayBuffer.ts"],"names":[],"mappings":"AAOA,MAAM,UAAU,gBAAgB,CAAC,WAAwB;IACvD,MAAM,MAAM,GAAG,IAAI,WAAW,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;IACvD,IAAI,UAAU,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,IAAI,UAAU,CAAC,WAAW,CAAC,CAAC,CAAC;IACxD,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["/**\r\n * Creates a clone of `arrayBuffer`.\r\n *\r\n * @private\r\n * @param {ArrayBuffer} arrayBuffer The array buffer to clone.\r\n * @returns {ArrayBuffer} Returns the cloned array buffer.\r\n */\r\nexport function cloneArrayBuffer(arrayBuffer: ArrayBuffer): ArrayBuffer {\r\n const result = new ArrayBuffer(arrayBuffer.byteLength);\r\n new Uint8Array(result).set(new Uint8Array(arrayBuffer));\r\n return result;\r\n}\r\n"]}
@@ -1,2 +0,0 @@
1
- export declare function cloneDataView(dataView: DataView): DataView;
2
- //# sourceMappingURL=cloneDataView.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cloneDataView.d.ts","sourceRoot":"","sources":["../../src/deepcopy/cloneDataView.ts"],"names":[],"mappings":"AASA,wBAAgB,aAAa,CAAC,QAAQ,EAAE,QAAQ,GAAG,QAAQ,CAG1D"}
@@ -1,6 +0,0 @@
1
- import { cloneArrayBuffer } from "./cloneArrayBuffer";
2
- export function cloneDataView(dataView) {
3
- const buffer = cloneArrayBuffer(dataView.buffer);
4
- return new DataView(buffer, dataView.byteOffset, dataView.byteLength);
5
- }
6
- //# sourceMappingURL=cloneDataView.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cloneDataView.js","sourceRoot":"","sources":["../../src/deepcopy/cloneDataView.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAStD,MAAM,UAAU,aAAa,CAAC,QAAkB;IAC9C,MAAM,MAAM,GAAG,gBAAgB,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IACjD,OAAO,IAAI,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,UAAU,EAAE,QAAQ,CAAC,UAAU,CAAC,CAAC;AACxE,CAAC","sourcesContent":["import { cloneArrayBuffer } from \"./cloneArrayBuffer\";\r\n\r\n/**\r\n * Creates a clone of `dataView`.\r\n *\r\n * @private\r\n * @param {Object} dataView The data view to clone.\r\n * @returns {Object} Returns the cloned data view.\r\n */\r\nexport function cloneDataView(dataView: DataView): DataView {\r\n const buffer = cloneArrayBuffer(dataView.buffer);\r\n return new DataView(buffer, dataView.byteOffset, dataView.byteLength);\r\n}\r\n"]}
@@ -1,2 +0,0 @@
1
- export declare function cloneDate(targetDate: Date): Date;
2
- //# sourceMappingURL=cloneDate.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cloneDate.d.ts","sourceRoot":"","sources":["../../src/deepcopy/cloneDate.ts"],"names":[],"mappings":"AAOA,wBAAgB,SAAS,CAAC,UAAU,EAAE,IAAI,GAAG,IAAI,CAEhD"}
@@ -1,4 +0,0 @@
1
- export function cloneDate(targetDate) {
2
- return new Date(targetDate.getTime());
3
- }
4
- //# sourceMappingURL=cloneDate.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cloneDate.js","sourceRoot":"","sources":["../../src/deepcopy/cloneDate.ts"],"names":[],"mappings":"AAOA,MAAM,UAAU,SAAS,CAAC,UAAgB;IACxC,OAAO,IAAI,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC,CAAC;AACxC,CAAC","sourcesContent":["/**\r\n * Creates a clone of `date`.\r\n *\r\n * @private\r\n * @param {Date} typedDate The date to clone.\r\n * @returns {Object} Returns the cloned date.\r\n */\r\nexport function cloneDate(targetDate: Date): Date {\r\n return new Date(targetDate.getTime());\r\n}\r\n"]}
@@ -1,2 +0,0 @@
1
- export declare function cloneMap<K, V>(targetMap: Map<K, V>): Map<K, V>;
2
- //# sourceMappingURL=cloneMap.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cloneMap.d.ts","sourceRoot":"","sources":["../../src/deepcopy/cloneMap.ts"],"names":[],"mappings":"AASA,wBAAgB,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,SAAS,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAI9D"}
@@ -1,7 +0,0 @@
1
- import { deepCopy } from "./deepCopy";
2
- export function cloneMap(targetMap) {
3
- const map = new Map();
4
- targetMap.forEach((value, key) => map.set(deepCopy(key), deepCopy(value)));
5
- return map;
6
- }
7
- //# sourceMappingURL=cloneMap.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cloneMap.js","sourceRoot":"","sources":["../../src/deepcopy/cloneMap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAStC,MAAM,UAAU,QAAQ,CAAO,SAAoB;IACjD,MAAM,GAAG,GAAG,IAAI,GAAG,EAAQ,CAAC;IAC5B,SAAS,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAC3E,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["import { deepCopy } from \"./deepCopy\";\r\n\r\n/**\r\n * Creates a clone of `map`.\r\n *\r\n * @private\r\n * @param {Date} typedDate The map to clone.\r\n * @returns {Object} Returns the cloned map.\r\n */\r\nexport function cloneMap<K, V>(targetMap: Map<K, V>): Map<K, V> {\r\n const map = new Map<K, V>();\r\n targetMap.forEach((value, key) => map.set(deepCopy(key), deepCopy(value)));\r\n return map;\r\n}\r\n"]}
@@ -1,2 +0,0 @@
1
- export declare function cloneRegExp(targetRegexp: RegExp): RegExp;
2
- //# sourceMappingURL=cloneRegexp.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cloneRegexp.d.ts","sourceRoot":"","sources":["../../src/deepcopy/cloneRegexp.ts"],"names":[],"mappings":"AAOA,wBAAgB,WAAW,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAIxD"}
@@ -1,6 +0,0 @@
1
- export function cloneRegExp(targetRegexp) {
2
- const result = new RegExp(targetRegexp.source, targetRegexp.flags);
3
- result.lastIndex = targetRegexp.lastIndex;
4
- return result;
5
- }
6
- //# sourceMappingURL=cloneRegexp.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cloneRegexp.js","sourceRoot":"","sources":["../../src/deepcopy/cloneRegexp.ts"],"names":[],"mappings":"AAOA,MAAM,UAAU,WAAW,CAAC,YAAoB;IAC9C,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,YAAY,CAAC,MAAM,EAAE,YAAY,CAAC,KAAK,CAAC,CAAC;IACnE,MAAM,CAAC,SAAS,GAAG,YAAY,CAAC,SAAS,CAAC;IAC1C,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["/**\r\n * Creates a clone of `regexp`.\r\n *\r\n * @private\r\n * @param {Object} targetRegexp The regexp to clone.\r\n * @returns {Object} Returns the cloned regexp.\r\n */\r\nexport function cloneRegExp(targetRegexp: RegExp): RegExp {\r\n const result = new RegExp(targetRegexp.source, targetRegexp.flags);\r\n result.lastIndex = targetRegexp.lastIndex;\r\n return result;\r\n}\r\n"]}
@@ -1,3 +0,0 @@
1
- export type TypedArrayType = Float32Array | Float64Array | Int8Array | Int16Array | Int32Array | Uint8Array | Uint16Array | Uint32Array | Uint8ClampedArray | BigInt64Array | BigUint64Array;
2
- export declare function cloneTypedArray(typedArray: TypedArrayType): TypedArrayType;
3
- //# sourceMappingURL=cloneTypedArray.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cloneTypedArray.d.ts","sourceRoot":"","sources":["../../src/deepcopy/cloneTypedArray.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,cAAc,GACtB,YAAY,GACZ,YAAY,GACZ,SAAS,GACT,UAAU,GACV,UAAU,GACV,UAAU,GACV,WAAW,GACX,WAAW,GACX,iBAAiB,GACjB,aAAa,GACb,cAAc,CAAC;AAkCnB,wBAAgB,eAAe,CAAC,UAAU,EAAE,cAAc,GAAG,cAAc,CAa1E"}
@@ -1,22 +0,0 @@
1
- import { cloneArrayBuffer } from "./cloneArrayBuffer";
2
- const TypedArrayMap = {
3
- "[object Float32Array]": Float32Array,
4
- "[object Float64Array]": Float64Array,
5
- "[object Int8Array]": Int8Array,
6
- "[object Int16Array]": Int16Array,
7
- "[object Int32Array]": Int32Array,
8
- "[object Uint8Array]": Uint8Array,
9
- "[object Uint16Array]": Uint16Array,
10
- "[object Uint32Array]": Uint32Array,
11
- "[object Uint8ClampedArray]": Uint8ClampedArray
12
- };
13
- export function cloneTypedArray(typedArray) {
14
- try {
15
- TypedArrayMap["[object BigInt64Array]"] = BigInt64Array;
16
- TypedArrayMap["[object BigUint64Array]"] = BigUint64Array;
17
- }
18
- catch (e) { }
19
- const buffer = cloneArrayBuffer(typedArray.buffer);
20
- return new TypedArrayMap[Object.prototype.toString.call(typedArray)](buffer, typedArray.byteOffset, typedArray.length);
21
- }
22
- //# sourceMappingURL=cloneTypedArray.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cloneTypedArray.js","sourceRoot":"","sources":["../../src/deepcopy/cloneTypedArray.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AA4BtD,MAAM,aAAa,GAA8C;IAC/D,uBAAuB,EAAE,YAAY;IACrC,uBAAuB,EAAE,YAAY;IACrC,oBAAoB,EAAE,SAAS;IAC/B,qBAAqB,EAAE,UAAU;IACjC,qBAAqB,EAAE,UAAU;IACjC,qBAAqB,EAAE,UAAU;IACjC,sBAAsB,EAAE,WAAW;IACnC,sBAAsB,EAAE,WAAW;IACnC,4BAA4B,EAAE,iBAAiB;CAChD,CAAC;AASF,MAAM,UAAU,eAAe,CAAC,UAA0B;IACxD,IAAG;QACD,aAAa,CAAC,wBAAwB,CAAC,GAAG,aAAa,CAAC;QACxD,aAAa,CAAC,yBAAyB,CAAC,GAAG,cAAc,CAAC;KAC3D;IAAA,OAAM,CAAC,EAAC,GAAE;IAEX,MAAM,MAAM,GAAG,gBAAgB,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;IAEnD,OAAO,IAAI,aAAa,CAAC,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAClE,MAAM,EACN,UAAU,CAAC,UAAU,EACrB,UAAU,CAAC,MAAM,CAClB,CAAC;AACJ,CAAC","sourcesContent":["import { cloneArrayBuffer } from \"./cloneArrayBuffer\";\r\n\r\nexport type TypedArrayType =\r\n | Float32Array\r\n | Float64Array\r\n | Int8Array\r\n | Int16Array\r\n | Int32Array\r\n | Uint8Array\r\n | Uint16Array\r\n | Uint32Array\r\n | Uint8ClampedArray\r\n | BigInt64Array\r\n | BigUint64Array;\r\n\r\ntype TypedArrayConstructorType =\r\n | Float32ArrayConstructor\r\n | Float64ArrayConstructor\r\n | Int8ArrayConstructor\r\n | Int16ArrayConstructor\r\n | Int32ArrayConstructor\r\n | Uint8ArrayConstructor\r\n | Uint16ArrayConstructor\r\n | Uint32ArrayConstructor\r\n | Uint8ClampedArrayConstructor\r\n | BigInt64ArrayConstructor\r\n | BigUint64ArrayConstructor;\r\n\r\nconst TypedArrayMap: Record<string, TypedArrayConstructorType> = {\r\n \"[object Float32Array]\": Float32Array,\r\n \"[object Float64Array]\": Float64Array,\r\n \"[object Int8Array]\": Int8Array,\r\n \"[object Int16Array]\": Int16Array,\r\n \"[object Int32Array]\": Int32Array,\r\n \"[object Uint8Array]\": Uint8Array,\r\n \"[object Uint16Array]\": Uint16Array,\r\n \"[object Uint32Array]\": Uint32Array,\r\n \"[object Uint8ClampedArray]\": Uint8ClampedArray\r\n};\r\n\r\n/**\r\n * Creates a clone of `typedArray`.\r\n *\r\n * @private\r\n * @param {Object} typedArray The typed array to clone.\r\n * @returns {Object} Returns the cloned typed array.\r\n */\r\nexport function cloneTypedArray(typedArray: TypedArrayType): TypedArrayType {\r\n try{\r\n TypedArrayMap[\"[object BigInt64Array]\"] = BigInt64Array;\r\n TypedArrayMap[\"[object BigUint64Array]\"] = BigUint64Array;\r\n }catch(e){}\r\n\r\n const buffer = cloneArrayBuffer(typedArray.buffer);\r\n // @ts-ignore\r\n return new TypedArrayMap[Object.prototype.toString.call(typedArray)](\r\n buffer,\r\n typedArray.byteOffset,\r\n typedArray.length\r\n );\r\n}\r\n"]}
@@ -1,2 +0,0 @@
1
- export declare function deepCopy<T>(target: T): T;
2
- //# sourceMappingURL=deepCopy.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"deepCopy.d.ts","sourceRoot":"","sources":["../../src/deepcopy/deepCopy.ts"],"names":[],"mappings":"AAiCA,wBAAgB,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,GAAG,CAAC,CA2BxC"}
@@ -1,49 +0,0 @@
1
- import { cloneArrayBuffer } from "./cloneArrayBuffer";
2
- import { cloneDataView } from "./cloneDataView";
3
- import { cloneDate } from "./cloneDate";
4
- import { cloneMap } from "./cloneMap";
5
- import { cloneRegExp } from "./cloneRegexp";
6
- import { cloneTypedArray } from "./cloneTypedArray";
7
- const TypedArrayMap = {
8
- "[object Date]": cloneDate,
9
- "[object ArrayBuffer]": cloneArrayBuffer,
10
- "[object DataView]": cloneDataView,
11
- "[object Float32Array]": cloneTypedArray,
12
- "[object Float64Array]": cloneTypedArray,
13
- "[object Int8Array]": cloneTypedArray,
14
- "[object Int16Array]": cloneTypedArray,
15
- "[object Int32Array]": cloneTypedArray,
16
- "[object Uint8Array]": cloneTypedArray,
17
- "[object Uint8ClampedArray]": cloneTypedArray,
18
- "[object Uint16Array]": cloneTypedArray,
19
- "[object Uint32Array]": cloneTypedArray,
20
- "[object BigInt64Array]": cloneTypedArray,
21
- "[object BigUint64Array]": cloneTypedArray,
22
- "[object RegExp]": cloneRegExp,
23
- "[object Map]": cloneMap,
24
- };
25
- export function deepCopy(target) {
26
- const tag = Object.prototype.toString.call(target);
27
- if (TypedArrayMap[tag]) {
28
- return TypedArrayMap[tag](target);
29
- }
30
- if (target === null) {
31
- return target;
32
- }
33
- if (target instanceof Array) {
34
- const cp = [];
35
- target.forEach((v) => {
36
- cp.push(v);
37
- });
38
- return cp.map((n) => deepCopy(n));
39
- }
40
- if (typeof target === "object") {
41
- const cp = { ...target };
42
- Object.keys(cp).forEach((k) => {
43
- cp[k] = deepCopy(cp[k]);
44
- });
45
- return cp;
46
- }
47
- return target;
48
- }
49
- //# sourceMappingURL=deepCopy.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"deepCopy.js","sourceRoot":"","sources":["../../src/deepcopy/deepCopy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,MAAM,aAAa,GAA6B;IAC9C,eAAe,EAAE,SAAS;IAC1B,sBAAsB,EAAE,gBAAgB;IACxC,mBAAmB,EAAE,aAAa;IAClC,uBAAuB,EAAE,eAAe;IACxC,uBAAuB,EAAE,eAAe;IACxC,oBAAoB,EAAE,eAAe;IACrC,qBAAqB,EAAE,eAAe;IACtC,qBAAqB,EAAE,eAAe;IACtC,qBAAqB,EAAE,eAAe;IACtC,4BAA4B,EAAE,eAAe;IAC7C,sBAAsB,EAAE,eAAe;IACvC,sBAAsB,EAAE,eAAe;IACvC,wBAAwB,EAAE,eAAe;IACzC,yBAAyB,EAAE,eAAe;IAC1C,iBAAiB,EAAE,WAAW;IAC9B,cAAc,EAAE,QAAQ;CACzB,CAAC;AASF,MAAM,UAAU,QAAQ,CAAI,MAAS;IACnC,MAAM,GAAG,GAAG,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAEnD,IAAI,aAAa,CAAC,GAAG,CAAC,EAAE;QAEtB,OAAO,aAAa,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC;KACnC;IACD,IAAI,MAAM,KAAK,IAAI,EAAE;QACnB,OAAO,MAAM,CAAC;KACf;IACD,IAAI,MAAM,YAAY,KAAK,EAAE;QAC3B,MAAM,EAAE,GAAG,EAAW,CAAC;QACtB,MAAgB,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;YAC9B,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACb,CAAC,CAAC,CAAC;QACH,OAAO,EAAE,CAAC,GAAG,CAAC,CAAC,CAAM,EAAE,EAAE,CAAC,QAAQ,CAAM,CAAC,CAAC,CAAQ,CAAC;KACpD;IACD,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE;QAC9B,MAAM,EAAE,GAAG,EAAE,GAAI,MAAiC,EAEjD,CAAC;QACF,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;YAC5B,EAAE,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAM,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;QAC/B,CAAC,CAAC,CAAC;QACH,OAAO,EAAO,CAAC;KAChB;IACD,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { cloneArrayBuffer } from \"./cloneArrayBuffer\";\r\nimport { cloneDataView } from \"./cloneDataView\";\r\nimport { cloneDate } from \"./cloneDate\";\r\nimport { cloneMap } from \"./cloneMap\";\r\nimport { cloneRegExp } from \"./cloneRegexp\";\r\nimport { cloneTypedArray } from \"./cloneTypedArray\";\r\n\r\nconst TypedArrayMap: Record<string, Function> = {\r\n \"[object Date]\": cloneDate,\r\n \"[object ArrayBuffer]\": cloneArrayBuffer,\r\n \"[object DataView]\": cloneDataView,\r\n \"[object Float32Array]\": cloneTypedArray,\r\n \"[object Float64Array]\": cloneTypedArray,\r\n \"[object Int8Array]\": cloneTypedArray,\r\n \"[object Int16Array]\": cloneTypedArray,\r\n \"[object Int32Array]\": cloneTypedArray,\r\n \"[object Uint8Array]\": cloneTypedArray,\r\n \"[object Uint8ClampedArray]\": cloneTypedArray,\r\n \"[object Uint16Array]\": cloneTypedArray,\r\n \"[object Uint32Array]\": cloneTypedArray,\r\n \"[object BigInt64Array]\": cloneTypedArray,\r\n \"[object BigUint64Array]\": cloneTypedArray,\r\n \"[object RegExp]\": cloneRegExp,\r\n \"[object Map]\": cloneMap,\r\n};\r\n\r\n/**\r\n * Deep copy function for TypeScript.\r\n * @param T Generic type of target/copied value.\r\n * @param target Target value to be copied.\r\n * @see Original source: ts-deepcopy https://github.com/ykdr2017/ts-deepcopy\r\n * @see Code pen https://codepen.io/erikvullings/pen/ejyBYg\r\n */\r\nexport function deepCopy<T>(target: T): T {\r\n const tag = Object.prototype.toString.call(target);\r\n\r\n if (TypedArrayMap[tag]) {\r\n // @ts-ignore\r\n return TypedArrayMap[tag](target);\r\n }\r\n if (target === null) {\r\n return target;\r\n }\r\n if (target instanceof Array) {\r\n const cp = [] as any[];\r\n (target as any[]).forEach((v) => {\r\n cp.push(v);\r\n });\r\n return cp.map((n: any) => deepCopy<any>(n)) as any;\r\n }\r\n if (typeof target === \"object\") {\r\n const cp = { ...(target as { [key: string]: any }) } as {\r\n [key: string]: any;\r\n };\r\n Object.keys(cp).forEach((k) => {\r\n cp[k] = deepCopy<any>(cp[k]);\r\n });\r\n return cp as T;\r\n }\r\n return target;\r\n}\r\n"]}