@tachybase/globals 1.3.11 → 1.3.13

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/LICENSE CHANGED
@@ -186,7 +186,7 @@
186
186
  same "printed page" as the copyright notice for easier
187
187
  identification within third-party archives.
188
188
 
189
- Copyright [2023-2024] [Tachybase team]
189
+ Copyright [2023-2025] [Tego team]
190
190
 
191
191
  Licensed under the Apache License, Version 2.0 (the "License");
192
192
  you may not use this file except in compliance with the License.
package/lib/index.d.ts CHANGED
@@ -1,12 +1,14 @@
1
1
  declare class TachybaseGlobal {
2
+ #private;
2
3
  private static instance;
3
4
  private dataMap;
4
5
  private constructor();
5
- static getInstance(): TachybaseGlobal;
6
+ static getInstance(initData?: Record<string, any>): TachybaseGlobal;
6
7
  set(key: string, value: any): void;
7
8
  get<T = any>(key: string): T | undefined;
8
9
  has(key: string): boolean;
9
10
  delete(key: string): boolean;
10
11
  clear(): void;
12
+ toJSON(): Record<string, any>;
11
13
  }
12
14
  export default TachybaseGlobal;
package/lib/index.js CHANGED
@@ -2,6 +2,9 @@ var __defProp = Object.defineProperty;
2
2
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
4
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __typeError = (msg) => {
6
+ throw TypeError(msg);
7
+ };
5
8
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
6
9
  var __export = (target, all) => {
7
10
  for (var name in all)
@@ -16,20 +19,30 @@ var __copyProps = (to, from, except, desc) => {
16
19
  return to;
17
20
  };
18
21
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
22
+ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
23
+ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
24
+ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
19
25
  var src_exports = {};
20
26
  __export(src_exports, {
21
27
  default: () => src_default
22
28
  });
23
29
  module.exports = __toCommonJS(src_exports);
30
+ var _id;
24
31
  const _TachybaseGlobal = class _TachybaseGlobal {
25
32
  // 私有构造函数,防止外部 new
26
- constructor() {
33
+ constructor(initData) {
34
+ __privateAdd(this, _id, Date.now());
27
35
  this.dataMap = /* @__PURE__ */ new Map();
36
+ if (initData) {
37
+ for (const [key, value] of Object.entries(initData)) {
38
+ this.dataMap.set(key, value);
39
+ }
40
+ }
28
41
  }
29
42
  // 获取单例实例
30
- static getInstance() {
43
+ static getInstance(initData) {
31
44
  if (!_TachybaseGlobal.instance) {
32
- _TachybaseGlobal.instance = new _TachybaseGlobal();
45
+ _TachybaseGlobal.instance = new _TachybaseGlobal(initData);
33
46
  }
34
47
  return _TachybaseGlobal.instance;
35
48
  }
@@ -53,7 +66,11 @@ const _TachybaseGlobal = class _TachybaseGlobal {
53
66
  clear() {
54
67
  this.dataMap.clear();
55
68
  }
69
+ toJSON() {
70
+ return { ...Object.fromEntries([...this.dataMap.entries()].filter(([key]) => key !== "PRESETS")), id: __privateGet(this, _id) };
71
+ }
56
72
  };
73
+ _id = new WeakMap();
57
74
  __name(_TachybaseGlobal, "TachybaseGlobal");
58
75
  let TachybaseGlobal = _TachybaseGlobal;
59
76
  var src_default = TachybaseGlobal;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tachybase/globals",
3
- "version": "1.3.11",
3
+ "version": "1.3.13",
4
4
  "description": "",
5
5
  "license": "Apache-2.0",
6
6
  "main": "./lib/index.js",