@dooboostore/simple-web-component 1.0.54 → 1.0.56
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 +342 -56
- package/dist/cjs/decorators/addEventListener.js +37 -14
- package/dist/cjs/decorators/addEventListener.js.map +2 -2
- package/dist/cjs/decorators/applyAttribute.js +6 -3
- package/dist/cjs/decorators/applyAttribute.js.map +2 -2
- package/dist/cjs/decorators/applyClass.js +18 -2
- package/dist/cjs/decorators/applyClass.js.map +2 -2
- package/dist/cjs/decorators/applyNode.js +10 -3
- package/dist/cjs/decorators/applyNode.js.map +2 -2
- package/dist/cjs/decorators/changedAttribute.js +2 -5
- package/dist/cjs/decorators/changedAttribute.js.map +2 -2
- package/dist/cjs/decorators/elementDefine.js +13 -2
- package/dist/cjs/decorators/elementDefine.js.map +2 -2
- package/dist/cjs/decorators/eventMedia.js +2 -5
- package/dist/cjs/decorators/eventMedia.js.map +2 -2
- package/dist/cjs/decorators/fetch.js +216 -82
- package/dist/cjs/decorators/fetch.js.map +3 -3
- package/dist/cjs/decorators/index.js +1 -0
- package/dist/cjs/decorators/index.js.map +2 -2
- package/dist/cjs/decorators/intersectionObserver.js +3 -6
- package/dist/cjs/decorators/intersectionObserver.js.map +2 -2
- package/dist/cjs/decorators/mutationObserver.js +3 -6
- package/dist/cjs/decorators/mutationObserver.js.map +2 -2
- package/dist/cjs/decorators/parameter.js +197 -33
- package/dist/cjs/decorators/parameter.js.map +3 -3
- package/dist/cjs/decorators/persistState.js +474 -0
- package/dist/cjs/decorators/persistState.js.map +7 -0
- package/dist/cjs/decorators/resizeObserver.js +3 -6
- package/dist/cjs/decorators/resizeObserver.js.map +2 -2
- package/dist/cjs/decorators/setInterval.js +2 -5
- package/dist/cjs/decorators/setInterval.js.map +2 -2
- package/dist/cjs/decorators/setTimeout.js +2 -5
- package/dist/cjs/decorators/setTimeout.js.map +2 -2
- package/dist/cjs/decorators/subscribeSwcAppMessage.js.map +1 -1
- package/dist/cjs/elements/SwcAppMixin.js +50 -2
- package/dist/cjs/elements/SwcAppMixin.js.map +2 -2
- package/dist/esm/decorators/addEventListener.js +38 -15
- package/dist/esm/decorators/addEventListener.js.map +2 -2
- package/dist/esm/decorators/applyAttribute.js +6 -3
- package/dist/esm/decorators/applyAttribute.js.map +2 -2
- package/dist/esm/decorators/applyClass.js +18 -2
- package/dist/esm/decorators/applyClass.js.map +2 -2
- package/dist/esm/decorators/applyNode.js +10 -3
- package/dist/esm/decorators/applyNode.js.map +2 -2
- package/dist/esm/decorators/changedAttribute.js +3 -6
- package/dist/esm/decorators/changedAttribute.js.map +2 -2
- package/dist/esm/decorators/elementDefine.js +15 -4
- package/dist/esm/decorators/elementDefine.js.map +2 -2
- package/dist/esm/decorators/eventMedia.js +3 -6
- package/dist/esm/decorators/eventMedia.js.map +2 -2
- package/dist/esm/decorators/fetch.js +216 -82
- package/dist/esm/decorators/fetch.js.map +3 -3
- package/dist/esm/decorators/index.js +1 -0
- package/dist/esm/decorators/index.js.map +2 -2
- package/dist/esm/decorators/intersectionObserver.js +4 -7
- package/dist/esm/decorators/intersectionObserver.js.map +2 -2
- package/dist/esm/decorators/mutationObserver.js +4 -7
- package/dist/esm/decorators/mutationObserver.js.map +2 -2
- package/dist/esm/decorators/parameter.js +197 -33
- package/dist/esm/decorators/parameter.js.map +3 -3
- package/dist/esm/decorators/persistState.js +455 -0
- package/dist/esm/decorators/persistState.js.map +7 -0
- package/dist/esm/decorators/resizeObserver.js +4 -7
- package/dist/esm/decorators/resizeObserver.js.map +2 -2
- package/dist/esm/decorators/setInterval.js +3 -6
- package/dist/esm/decorators/setInterval.js.map +2 -2
- package/dist/esm/decorators/setTimeout.js +3 -6
- package/dist/esm/decorators/setTimeout.js.map +2 -2
- package/dist/esm/decorators/subscribeSwcAppMessage.js.map +1 -1
- package/dist/esm/elements/SwcAppMixin.js +51 -3
- package/dist/esm/elements/SwcAppMixin.js.map +2 -2
- package/dist/esm-bundle/dooboostore-simple-web-component.esm.js +4491 -3637
- package/dist/esm-bundle/dooboostore-simple-web-component.esm.js.map +4 -4
- package/dist/types/decorators/addEventListener.d.ts +15 -0
- package/dist/types/decorators/addEventListener.d.ts.map +1 -1
- package/dist/types/decorators/applyAttribute.d.ts +1 -0
- package/dist/types/decorators/applyAttribute.d.ts.map +1 -1
- package/dist/types/decorators/applyClass.d.ts.map +1 -1
- package/dist/types/decorators/applyNode.d.ts +4 -2
- package/dist/types/decorators/applyNode.d.ts.map +1 -1
- package/dist/types/decorators/changedAttribute.d.ts.map +1 -1
- package/dist/types/decorators/elementDefine.d.ts.map +1 -1
- package/dist/types/decorators/eventMedia.d.ts.map +1 -1
- package/dist/types/decorators/fetch.d.ts +52 -31
- package/dist/types/decorators/fetch.d.ts.map +1 -1
- package/dist/types/decorators/index.d.ts +1 -0
- package/dist/types/decorators/index.d.ts.map +1 -1
- package/dist/types/decorators/intersectionObserver.d.ts.map +1 -1
- package/dist/types/decorators/mutationObserver.d.ts.map +1 -1
- package/dist/types/decorators/parameter.d.ts +169 -31
- package/dist/types/decorators/parameter.d.ts.map +1 -1
- package/dist/types/decorators/persistState.d.ts +66 -0
- package/dist/types/decorators/persistState.d.ts.map +1 -0
- package/dist/types/decorators/resizeObserver.d.ts.map +1 -1
- package/dist/types/decorators/setInterval.d.ts.map +1 -1
- package/dist/types/decorators/setTimeout.d.ts.map +1 -1
- package/dist/types/decorators/subscribeSwcAppMessage.d.ts +1 -1
- package/dist/types/decorators/subscribeSwcAppMessage.d.ts.map +1 -1
- package/dist/types/elements/SwcAppMixin.d.ts +12 -0
- package/dist/types/elements/SwcAppMixin.d.ts.map +1 -1
- package/dist/umd-bundle/dooboostore-simple-web-component.umd.js +4491 -3637
- package/dist/umd-bundle/dooboostore-simple-web-component.umd.js.map +4 -4
- package/lsp/bin/swc-lsp.js +3 -0
- package/lsp/out/server/server.js +9960 -0
- package/lsp/package.json +56 -0
- package/package.json +24 -9
- package/src/decorators/addEventListener.ts +23 -15
- package/src/decorators/applyAttribute.ts +8 -3
- package/src/decorators/applyClass.ts +22 -2
- package/src/decorators/applyNode.ts +18 -6
- package/src/decorators/changedAttribute.ts +3 -4
- package/src/decorators/elementDefine.ts +19 -7
- package/src/decorators/eventMedia.ts +3 -6
- package/src/decorators/fetch.ts +270 -140
- package/src/decorators/index.ts +1 -0
- package/src/decorators/intersectionObserver.ts +4 -5
- package/src/decorators/mutationObserver.ts +4 -5
- package/src/decorators/parameter.ts +326 -42
- package/src/decorators/persistState.ts +408 -0
- package/src/decorators/resizeObserver.ts +4 -5
- package/src/decorators/setInterval.ts +3 -4
- package/src/decorators/setTimeout.ts +3 -4
- package/src/decorators/subscribeSwcAppMessage.ts +1 -1
- package/src/elements/SwcAppMixin.ts +64 -5
|
@@ -0,0 +1,455 @@
|
|
|
1
|
+
const ASYNC_STORAGES = /* @__PURE__ */ new Set(["indexeddb"]);
|
|
2
|
+
const isAsyncStorage = (storage) => ASYNC_STORAGES.has(storage ?? "local");
|
|
3
|
+
const PERSIST_WRAPPED = Symbol.for("simple-web-component:persist-wrapped");
|
|
4
|
+
const winOf = (inst) => {
|
|
5
|
+
try {
|
|
6
|
+
return inst?.ownerDocument?.defaultView ?? globalThis;
|
|
7
|
+
} catch {
|
|
8
|
+
return globalThis;
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
const storeOf = (w, storage) => {
|
|
12
|
+
try {
|
|
13
|
+
if (storage === "local")
|
|
14
|
+
return w?.localStorage ?? null;
|
|
15
|
+
if (storage === "session")
|
|
16
|
+
return w?.sessionStorage ?? null;
|
|
17
|
+
return null;
|
|
18
|
+
} catch {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
const readCookie = (w, key) => {
|
|
23
|
+
try {
|
|
24
|
+
const doc = w?.document ?? globalThis?.document;
|
|
25
|
+
if (!doc?.cookie && doc?.cookie !== "")
|
|
26
|
+
return null;
|
|
27
|
+
const parts = String(doc.cookie).split(";");
|
|
28
|
+
for (const p of parts) {
|
|
29
|
+
const i = p.indexOf("=");
|
|
30
|
+
const k = p.slice(0, i).trim();
|
|
31
|
+
if (k === key)
|
|
32
|
+
return decodeURIComponent(p.slice(i + 1).trim());
|
|
33
|
+
}
|
|
34
|
+
return null;
|
|
35
|
+
} catch {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
const writeCookie = (w, key, raw, opts = {}) => {
|
|
40
|
+
const doc = w?.document ?? globalThis?.document;
|
|
41
|
+
if (!doc)
|
|
42
|
+
return;
|
|
43
|
+
let c = `${key}=${encodeURIComponent(raw)}; path=${opts.path ?? "/"}`;
|
|
44
|
+
if (opts.domain)
|
|
45
|
+
c += `; domain=${opts.domain}`;
|
|
46
|
+
if (opts.maxAge !== void 0)
|
|
47
|
+
c += `; max-age=${opts.maxAge}`;
|
|
48
|
+
if (opts.expires)
|
|
49
|
+
c += `; expires=${opts.expires.toUTCString()}`;
|
|
50
|
+
if (opts.secure)
|
|
51
|
+
c += "; secure";
|
|
52
|
+
if (opts.sameSite)
|
|
53
|
+
c += `; samesite=${opts.sameSite}`;
|
|
54
|
+
try {
|
|
55
|
+
doc.cookie = c;
|
|
56
|
+
} catch {
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
const eraseCookie = (w, key, opts = {}) => {
|
|
60
|
+
writeCookie(w, key, "", { path: opts.path ?? "/", domain: opts.domain, expires: /* @__PURE__ */ new Date(0) });
|
|
61
|
+
};
|
|
62
|
+
const IDB_DB = "swc-persist";
|
|
63
|
+
const IDB_STORE = "kv";
|
|
64
|
+
const idbConns = /* @__PURE__ */ new WeakMap();
|
|
65
|
+
const idbOpen = (w) => {
|
|
66
|
+
const idb = w?.indexedDB ?? globalThis?.indexedDB;
|
|
67
|
+
if (!idb)
|
|
68
|
+
return Promise.reject(new Error("[SWC] indexedDB unavailable"));
|
|
69
|
+
const wKey = w ?? globalThis;
|
|
70
|
+
let p = idbConns.get(wKey);
|
|
71
|
+
if (!p) {
|
|
72
|
+
p = new Promise((resolve, reject) => {
|
|
73
|
+
const req = idb.open(IDB_DB, 1);
|
|
74
|
+
req.onupgradeneeded = () => req.result.createObjectStore(IDB_STORE);
|
|
75
|
+
req.onsuccess = () => resolve(req.result);
|
|
76
|
+
req.onerror = () => reject(req.error);
|
|
77
|
+
});
|
|
78
|
+
p.catch(() => idbConns.delete(wKey));
|
|
79
|
+
idbConns.set(wKey, p);
|
|
80
|
+
}
|
|
81
|
+
return p;
|
|
82
|
+
};
|
|
83
|
+
const idbTx = async (w, mode, fn) => {
|
|
84
|
+
const db = await idbOpen(w);
|
|
85
|
+
return new Promise((resolve, reject) => {
|
|
86
|
+
const tx = db.transaction(IDB_STORE, mode);
|
|
87
|
+
const req = fn(tx.objectStore(IDB_STORE));
|
|
88
|
+
req.onsuccess = () => resolve(req.result);
|
|
89
|
+
req.onerror = () => reject(req.error);
|
|
90
|
+
});
|
|
91
|
+
};
|
|
92
|
+
const idbGet = (w, key) => idbTx(w, "readonly", (s) => s.get(key)).then((v) => v === void 0 ? null : v);
|
|
93
|
+
const idbSet = (w, key, raw) => idbTx(w, "readwrite", (s) => s.put(raw, key)).then(() => void 0);
|
|
94
|
+
const idbDel = (w, key) => idbTx(w, "readwrite", (s) => s.delete(key)).then(() => void 0);
|
|
95
|
+
const defSer = (v) => JSON.stringify(v);
|
|
96
|
+
const defDe = (s) => {
|
|
97
|
+
try {
|
|
98
|
+
return JSON.parse(s);
|
|
99
|
+
} catch {
|
|
100
|
+
return s;
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
async function persistReadAsync(inst, key, opts) {
|
|
104
|
+
const storage = opts?.storage ?? "local";
|
|
105
|
+
if (!isAsyncStorage(storage))
|
|
106
|
+
return persistRead(inst, key, opts);
|
|
107
|
+
const de = opts?.deserialize ?? defDe;
|
|
108
|
+
const raw = await idbGet(winOf(inst), key);
|
|
109
|
+
if (raw === null || raw === void 0)
|
|
110
|
+
return void 0;
|
|
111
|
+
try {
|
|
112
|
+
return de(raw);
|
|
113
|
+
} catch {
|
|
114
|
+
return raw;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
async function persistWriteAsync(inst, key, value, opts) {
|
|
118
|
+
const storage = opts?.storage ?? "local";
|
|
119
|
+
if (!isAsyncStorage(storage)) {
|
|
120
|
+
persistWrite(inst, key, value, opts);
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
if (value === void 0) {
|
|
124
|
+
await persistRemoveAsync(inst, key, opts);
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
const se = opts?.serialize ?? defSer;
|
|
128
|
+
await idbSet(winOf(inst), key, se(value));
|
|
129
|
+
}
|
|
130
|
+
async function persistRemoveAsync(inst, key, opts = {}) {
|
|
131
|
+
const storage = opts?.storage ?? "local";
|
|
132
|
+
if (!isAsyncStorage(storage)) {
|
|
133
|
+
persistRemove(inst, key, opts);
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
await idbDel(winOf(inst), key);
|
|
137
|
+
}
|
|
138
|
+
const warnedAsyncField = /* @__PURE__ */ new WeakSet();
|
|
139
|
+
const isPromiseLike = (v) => v instanceof Promise || v && typeof v.then === "function";
|
|
140
|
+
function persistRead(inst, key, opts) {
|
|
141
|
+
const storage = opts?.storage ?? "local";
|
|
142
|
+
const de = opts?.deserialize ?? defDe;
|
|
143
|
+
const w = winOf(inst);
|
|
144
|
+
let raw = null;
|
|
145
|
+
if (storage === "cookie")
|
|
146
|
+
raw = readCookie(w, key);
|
|
147
|
+
else
|
|
148
|
+
raw = storeOf(w, storage)?.getItem(key) ?? null;
|
|
149
|
+
if (raw === null || raw === void 0)
|
|
150
|
+
return void 0;
|
|
151
|
+
try {
|
|
152
|
+
return de(raw);
|
|
153
|
+
} catch {
|
|
154
|
+
return raw;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
function persistWrite(inst, key, value, opts) {
|
|
158
|
+
const storage = opts?.storage ?? "local";
|
|
159
|
+
if (value === void 0) {
|
|
160
|
+
persistRemove(inst, key, opts);
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
const se = opts?.serialize ?? defSer;
|
|
164
|
+
const raw = se(value);
|
|
165
|
+
const w = winOf(inst);
|
|
166
|
+
if (storage === "cookie")
|
|
167
|
+
writeCookie(w, key, raw, opts);
|
|
168
|
+
else {
|
|
169
|
+
try {
|
|
170
|
+
storeOf(w, storage)?.setItem(key, raw);
|
|
171
|
+
} catch (e) {
|
|
172
|
+
console.warn("[SWC] persistState write failed:", e);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
function persistRemove(inst, key, opts = {}) {
|
|
177
|
+
const storage = opts?.storage ?? "local";
|
|
178
|
+
const w = winOf(inst);
|
|
179
|
+
if (storage === "cookie")
|
|
180
|
+
eraseCookie(w, key, opts);
|
|
181
|
+
else {
|
|
182
|
+
try {
|
|
183
|
+
storeOf(w, storage)?.removeItem(key);
|
|
184
|
+
} catch {
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
const pickValue = (ret, valueKey) => valueKey !== void 0 ? ret && typeof ret === "object" ? ret[valueKey] : void 0 : ret;
|
|
189
|
+
function defineField(targetObj, propertyKey, key, opts) {
|
|
190
|
+
const slot = Symbol(`persist:${String(propertyKey)}`);
|
|
191
|
+
const initialized = Symbol(`persist:init:${String(propertyKey)}`);
|
|
192
|
+
const storage = opts?.storage ?? "local";
|
|
193
|
+
const async = isAsyncStorage(storage);
|
|
194
|
+
if (async && !warnedAsyncField.has(targetObj)) {
|
|
195
|
+
warnedAsyncField.add(targetObj);
|
|
196
|
+
console.warn(`[SWC] @persistState(${storage}) on field "${String(propertyKey)}" resolves asynchronously: first read returns the initializer, the stored value lands right after. Prefer calling persistReadAsync directly or Promise-typed fields for async backends.`);
|
|
197
|
+
}
|
|
198
|
+
Object.defineProperty(targetObj, propertyKey, {
|
|
199
|
+
get() {
|
|
200
|
+
const own = Object.getOwnPropertyDescriptor(this, propertyKey);
|
|
201
|
+
if (own && "value" in own) {
|
|
202
|
+
delete this[propertyKey];
|
|
203
|
+
const initVal = own.value;
|
|
204
|
+
if (async && isPromiseLike(initVal)) {
|
|
205
|
+
this[slot] = initVal;
|
|
206
|
+
this[initialized] = true;
|
|
207
|
+
void persistReadAsync(this, key, opts).then((stored) => {
|
|
208
|
+
if (stored !== void 0) {
|
|
209
|
+
this[slot] = Promise.resolve(stored);
|
|
210
|
+
} else {
|
|
211
|
+
void initVal.then((v) => {
|
|
212
|
+
this[slot] = v;
|
|
213
|
+
void persistWriteAsync(this, key, v, opts).catch((e) => console.warn("[SWC] persistState write failed:", e));
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
}).catch(() => void 0);
|
|
217
|
+
return this[slot];
|
|
218
|
+
}
|
|
219
|
+
this[slot] = initVal;
|
|
220
|
+
this[initialized] = true;
|
|
221
|
+
if (async) {
|
|
222
|
+
void persistReadAsync(this, key, opts).then((stored) => {
|
|
223
|
+
if (stored !== void 0)
|
|
224
|
+
this[slot] = stored;
|
|
225
|
+
else
|
|
226
|
+
void persistWriteAsync(this, key, this[slot], opts).catch((e) => console.warn("[SWC] persistState write failed:", e));
|
|
227
|
+
}).catch(() => void 0);
|
|
228
|
+
} else {
|
|
229
|
+
const stored = persistRead(this, key, opts);
|
|
230
|
+
if (stored !== void 0)
|
|
231
|
+
this[slot] = stored;
|
|
232
|
+
else
|
|
233
|
+
persistWrite(this, key, this[slot], opts);
|
|
234
|
+
}
|
|
235
|
+
return this[slot];
|
|
236
|
+
}
|
|
237
|
+
if (!this[initialized]) {
|
|
238
|
+
this[initialized] = true;
|
|
239
|
+
if (async) {
|
|
240
|
+
void persistReadAsync(this, key, opts).then((stored) => {
|
|
241
|
+
if (stored !== void 0)
|
|
242
|
+
this[slot] = stored;
|
|
243
|
+
else if (this[slot] !== void 0)
|
|
244
|
+
void persistWriteAsync(this, key, this[slot], opts).catch((e) => console.warn("[SWC] persistState write failed:", e));
|
|
245
|
+
}).catch(() => void 0);
|
|
246
|
+
} else {
|
|
247
|
+
const stored = persistRead(this, key, opts);
|
|
248
|
+
this[slot] = stored !== void 0 ? stored : this[slot];
|
|
249
|
+
if (stored === void 0 && this[slot] !== void 0)
|
|
250
|
+
persistWrite(this, key, this[slot], opts);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
return this[slot];
|
|
254
|
+
},
|
|
255
|
+
set(nv) {
|
|
256
|
+
if (async) {
|
|
257
|
+
const firstCall = !this[initialized];
|
|
258
|
+
this[slot] = nv;
|
|
259
|
+
this[initialized] = true;
|
|
260
|
+
if (firstCall) {
|
|
261
|
+
void persistReadAsync(this, key, opts).then((stored) => {
|
|
262
|
+
if (stored !== void 0) {
|
|
263
|
+
this[slot] = isPromiseLike(nv) ? Promise.resolve(stored) : stored;
|
|
264
|
+
return;
|
|
265
|
+
}
|
|
266
|
+
if (isPromiseLike(nv)) {
|
|
267
|
+
void nv.then((v) => {
|
|
268
|
+
this[slot] = v;
|
|
269
|
+
void persistWriteAsync(this, key, v, opts).catch((e) => console.warn("[SWC] persistState write failed:", e));
|
|
270
|
+
});
|
|
271
|
+
} else if (nv !== void 0) {
|
|
272
|
+
void persistWriteAsync(this, key, nv, opts).catch((e) => console.warn("[SWC] persistState write failed:", e));
|
|
273
|
+
}
|
|
274
|
+
}).catch(() => void 0);
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
277
|
+
if (isPromiseLike(nv)) {
|
|
278
|
+
void nv.then((v) => {
|
|
279
|
+
this[slot] = v;
|
|
280
|
+
void persistWriteAsync(this, key, v, opts).catch((e) => console.warn("[SWC] persistState write failed:", e));
|
|
281
|
+
});
|
|
282
|
+
} else if (nv === void 0) {
|
|
283
|
+
void persistRemoveAsync(this, key, opts).catch(() => void 0);
|
|
284
|
+
} else {
|
|
285
|
+
void persistWriteAsync(this, key, nv, opts).catch((e) => console.warn("[SWC] persistState write failed:", e));
|
|
286
|
+
}
|
|
287
|
+
return;
|
|
288
|
+
}
|
|
289
|
+
if (!this[initialized]) {
|
|
290
|
+
const stored = persistRead(this, key, opts);
|
|
291
|
+
this[initialized] = true;
|
|
292
|
+
if (stored !== void 0) {
|
|
293
|
+
this[slot] = stored;
|
|
294
|
+
return;
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
this[slot] = nv;
|
|
298
|
+
this[initialized] = true;
|
|
299
|
+
persistWrite(this, key, nv, opts);
|
|
300
|
+
},
|
|
301
|
+
enumerable: true,
|
|
302
|
+
configurable: true
|
|
303
|
+
});
|
|
304
|
+
}
|
|
305
|
+
function wrapMethod(targetObj, propertyKey, descriptor, key, opts) {
|
|
306
|
+
const original = descriptor.value;
|
|
307
|
+
if (original[PERSIST_WRAPPED])
|
|
308
|
+
return descriptor;
|
|
309
|
+
const storage = opts?.storage ?? "local";
|
|
310
|
+
const async = isAsyncStorage(storage);
|
|
311
|
+
const wrapped = function(...args) {
|
|
312
|
+
const res = original.apply(this, args);
|
|
313
|
+
const doPersist = (v) => {
|
|
314
|
+
const val = pickValue(v, opts?.valueKey);
|
|
315
|
+
if (val === void 0)
|
|
316
|
+
return;
|
|
317
|
+
if (async)
|
|
318
|
+
void persistWriteAsync(this, key, val, opts).catch((e) => console.warn("[SWC] persistState write failed:", e));
|
|
319
|
+
else
|
|
320
|
+
persistWrite(this, key, val, opts);
|
|
321
|
+
};
|
|
322
|
+
if (res instanceof Promise)
|
|
323
|
+
return res.then((v) => {
|
|
324
|
+
doPersist(v);
|
|
325
|
+
return v;
|
|
326
|
+
});
|
|
327
|
+
doPersist(res);
|
|
328
|
+
return res;
|
|
329
|
+
};
|
|
330
|
+
wrapped[PERSIST_WRAPPED] = true;
|
|
331
|
+
descriptor.value = wrapped;
|
|
332
|
+
return descriptor;
|
|
333
|
+
}
|
|
334
|
+
function persistState(keyOrTarget, optionsOrKey, descriptor) {
|
|
335
|
+
if (typeof keyOrTarget === "object" && (typeof optionsOrKey === "string" || typeof optionsOrKey === "symbol")) {
|
|
336
|
+
const targetObj = keyOrTarget;
|
|
337
|
+
const propertyKey = optionsOrKey;
|
|
338
|
+
if (descriptor)
|
|
339
|
+
return wrapMethod(targetObj, propertyKey, descriptor, String(propertyKey), { storage: "local" });
|
|
340
|
+
defineField(targetObj, propertyKey, String(propertyKey), { storage: "local" });
|
|
341
|
+
return;
|
|
342
|
+
}
|
|
343
|
+
const key = typeof keyOrTarget === "string" ? keyOrTarget : void 0;
|
|
344
|
+
const opts = typeof keyOrTarget === "object" && keyOrTarget !== null ? {} : optionsOrKey ?? {};
|
|
345
|
+
return (targetObj, propertyKey, desc) => {
|
|
346
|
+
const k = key ?? String(propertyKey);
|
|
347
|
+
if (desc)
|
|
348
|
+
return wrapMethod(targetObj, propertyKey, desc, k, opts);
|
|
349
|
+
defineField(targetObj, propertyKey, k, opts);
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
const alias = (storage, extra = {}) => {
|
|
353
|
+
const fn = (a, b, c) => {
|
|
354
|
+
if (typeof b === "string" || typeof b === "symbol") {
|
|
355
|
+
if (c)
|
|
356
|
+
return wrapMethod(a, b, c, String(b), { storage, ...extra });
|
|
357
|
+
defineField(a, b, String(b), { storage, ...extra });
|
|
358
|
+
return;
|
|
359
|
+
}
|
|
360
|
+
if (typeof a === "string")
|
|
361
|
+
return persistState(a, { ...b ?? {}, storage, ...extra });
|
|
362
|
+
if (a && typeof a === "object" && b === void 0 && c === void 0) {
|
|
363
|
+
return persistState(void 0, { ...a ?? {}, storage, ...extra });
|
|
364
|
+
}
|
|
365
|
+
return persistState(void 0, { storage, ...extra })(a, b, c);
|
|
366
|
+
};
|
|
367
|
+
return fn;
|
|
368
|
+
};
|
|
369
|
+
const localStorage = alias("local");
|
|
370
|
+
const sessionStorage = alias("session");
|
|
371
|
+
const cookie = alias("cookie", { path: "/" });
|
|
372
|
+
const indexedDb = alias("indexeddb");
|
|
373
|
+
function removePersistState(a, b, c) {
|
|
374
|
+
if (c) {
|
|
375
|
+
const propertyKey = b;
|
|
376
|
+
const orig = c.value;
|
|
377
|
+
c.value = function(...args) {
|
|
378
|
+
const res = orig.apply(this, args);
|
|
379
|
+
const doRemove = (v) => {
|
|
380
|
+
const go = a?.valueKey !== void 0 ? v && typeof v === "object" ? v[a.valueKey] : void 0 : true;
|
|
381
|
+
if (!go)
|
|
382
|
+
return;
|
|
383
|
+
persistRemove(this, String(propertyKey), a ?? {});
|
|
384
|
+
};
|
|
385
|
+
if (res instanceof Promise)
|
|
386
|
+
return res.then((v) => {
|
|
387
|
+
doRemove(v);
|
|
388
|
+
return v;
|
|
389
|
+
});
|
|
390
|
+
doRemove(res);
|
|
391
|
+
return res;
|
|
392
|
+
};
|
|
393
|
+
return c;
|
|
394
|
+
}
|
|
395
|
+
const key = typeof a === "string" ? a : void 0;
|
|
396
|
+
const opts = typeof a === "object" && a !== null ? a : b ?? {};
|
|
397
|
+
return (target, propertyKey, descriptor) => {
|
|
398
|
+
const k = key ?? String(propertyKey);
|
|
399
|
+
const orig = descriptor.value;
|
|
400
|
+
descriptor.value = function(...args) {
|
|
401
|
+
const res = orig.apply(this, args);
|
|
402
|
+
const doRemove = (v) => {
|
|
403
|
+
const vk = opts?.valueKey;
|
|
404
|
+
const go = vk !== void 0 ? v && typeof v === "object" ? v[vk] : void 0 : true;
|
|
405
|
+
if (!go)
|
|
406
|
+
return;
|
|
407
|
+
persistRemove(this, k, opts);
|
|
408
|
+
};
|
|
409
|
+
if (res instanceof Promise)
|
|
410
|
+
return res.then((v) => {
|
|
411
|
+
doRemove(v);
|
|
412
|
+
return v;
|
|
413
|
+
});
|
|
414
|
+
doRemove(res);
|
|
415
|
+
return res;
|
|
416
|
+
};
|
|
417
|
+
return descriptor;
|
|
418
|
+
};
|
|
419
|
+
}
|
|
420
|
+
const removeAlias = (storage) => (a, b, c) => {
|
|
421
|
+
if (c) {
|
|
422
|
+
const key = String(b);
|
|
423
|
+
return removePersistState(key, { storage })(a, b, c);
|
|
424
|
+
}
|
|
425
|
+
if (typeof a === "string")
|
|
426
|
+
return removePersistState(a, { ...b ?? {}, storage });
|
|
427
|
+
if (a && typeof a === "object")
|
|
428
|
+
return removePersistState(void 0, { ...a ?? {}, storage });
|
|
429
|
+
return (t, pk, d) => removePersistState(String(pk), { storage })(t, pk, d);
|
|
430
|
+
};
|
|
431
|
+
const removeLocalStorage = removeAlias("local");
|
|
432
|
+
const removeSessionStorage = removeAlias("session");
|
|
433
|
+
const removeCookie = removeAlias("cookie");
|
|
434
|
+
const removeIndexedDb = removeAlias("indexeddb");
|
|
435
|
+
export {
|
|
436
|
+
ASYNC_STORAGES,
|
|
437
|
+
cookie,
|
|
438
|
+
indexedDb,
|
|
439
|
+
isAsyncStorage,
|
|
440
|
+
localStorage,
|
|
441
|
+
persistRead,
|
|
442
|
+
persistReadAsync,
|
|
443
|
+
persistRemove,
|
|
444
|
+
persistRemoveAsync,
|
|
445
|
+
persistState,
|
|
446
|
+
persistWrite,
|
|
447
|
+
persistWriteAsync,
|
|
448
|
+
removeCookie,
|
|
449
|
+
removeIndexedDb,
|
|
450
|
+
removeLocalStorage,
|
|
451
|
+
removePersistState,
|
|
452
|
+
removeSessionStorage,
|
|
453
|
+
sessionStorage
|
|
454
|
+
};
|
|
455
|
+
//# sourceMappingURL=persistState.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/decorators/persistState.ts"],
|
|
4
|
+
"sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\n\nexport type PersistStorage = 'local' | 'session' | 'cookie' | 'indexeddb';\n/** Sync backends complete synchronously; async ones resolve in a microtask/macrotask. */\nexport const ASYNC_STORAGES: ReadonlySet<string> = new Set(['indexeddb']);\nexport const isAsyncStorage = (storage?: string) => ASYNC_STORAGES.has(storage ?? 'local');\nexport interface CookieOpts {\n path?: string;\n domain?: string;\n maxAge?: number;\n expires?: Date;\n secure?: boolean;\n sameSite?: 'Strict' | 'Lax' | 'None';\n}\nexport interface CookieRemoveOpts {\n path?: string;\n domain?: string;\n}\nexport type PersistOptions =\n | { storage?: 'local' | 'session' | 'indexeddb'; valueKey?: string | symbol; serialize?: (v: any) => string; deserialize?: (s: string) => any }\n | ({ storage: 'cookie'; valueKey?: string | symbol; serialize?: (v: any) => string; deserialize?: (s: string) => any } & CookieOpts);\nexport type RemovePersistOptions =\n | { storage?: 'local' | 'session' | 'indexeddb'; valueKey?: string | symbol }\n | ({ storage: 'cookie'; valueKey?: string | symbol } & CookieRemoveOpts);\n\n/** Marks a method already wrapped for persist injection — prevents double-wrap. */\nconst PERSIST_WRAPPED = Symbol.for('simple-web-component:persist-wrapped');\n\nconst winOf = (inst: any): any => {\n try {\n return inst?.ownerDocument?.defaultView ?? (globalThis as any);\n } catch { return globalThis as any; }\n};\nconst storeOf = (w: any, storage: PersistStorage): Storage | null => {\n try {\n if (storage === 'local') return w?.localStorage ?? null;\n if (storage === 'session') return w?.sessionStorage ?? null;\n return null;\n } catch { return null; }\n};\n\nconst readCookie = (w: any, key: string): string | null => {\n try {\n const doc = w?.document ?? (globalThis as any)?.document;\n if (!doc?.cookie && doc?.cookie !== '') return null;\n const parts = String(doc.cookie).split(';');\n for (const p of parts) {\n const i = p.indexOf('=');\n const k = p.slice(0, i).trim();\n if (k === key) return decodeURIComponent(p.slice(i + 1).trim());\n }\n return null;\n } catch { return null; }\n};\nconst writeCookie = (w: any, key: string, raw: string, opts: CookieOpts = {}) => {\n const doc = w?.document ?? (globalThis as any)?.document;\n if (!doc) return;\n let c = `${key}=${encodeURIComponent(raw)}; path=${opts.path ?? '/'}`;\n if (opts.domain) c += `; domain=${opts.domain}`;\n if (opts.maxAge !== undefined) c += `; max-age=${opts.maxAge}`;\n if (opts.expires) c += `; expires=${opts.expires.toUTCString()}`;\n if (opts.secure) c += '; secure';\n if (opts.sameSite) c += `; samesite=${opts.sameSite}`;\n try { doc.cookie = c; } catch { /* ignore */ }\n};\nconst eraseCookie = (w: any, key: string, opts: CookieRemoveOpts = {}) => {\n writeCookie(w, key, '', { path: opts.path ?? '/', domain: opts.domain, expires: new Date(0) });\n};\n\n// ─── IndexedDB backend (async; single db/store, raw strings) ───\nconst IDB_DB = 'swc-persist';\nconst IDB_STORE = 'kv';\nconst idbConns = new WeakMap<object, Promise<any>>();\nconst idbOpen = (w: any): Promise<any> => {\n const idb = w?.indexedDB ?? (globalThis as any)?.indexedDB;\n if (!idb) return Promise.reject(new Error('[SWC] indexedDB unavailable'));\n const wKey = w ?? globalThis;\n let p = idbConns.get(wKey);\n if (!p) {\n p = new Promise((resolve, reject) => {\n const req = idb.open(IDB_DB, 1);\n req.onupgradeneeded = () => req.result.createObjectStore(IDB_STORE);\n req.onsuccess = () => resolve(req.result);\n req.onerror = () => reject(req.error);\n });\n // 열기에 실패하면 캐시에서 지워서 다음 호출이 재시도할 수 있게 한다 — 그대로 캐싱해두면 한 번 실패로 영구히 막힌다.\n p.catch(() => idbConns.delete(wKey));\n idbConns.set(wKey, p);\n }\n return p;\n};\nconst idbTx = async (w: any, mode: IDBTransactionMode, fn: (store: any) => IDBRequest): Promise<any> => {\n const db = await idbOpen(w);\n return new Promise((resolve, reject) => {\n const tx = db.transaction(IDB_STORE, mode);\n const req = fn(tx.objectStore(IDB_STORE));\n req.onsuccess = () => resolve(req.result);\n req.onerror = () => reject(req.error);\n });\n};\nconst idbGet = (w: any, key: string): Promise<string | null> =>\n idbTx(w, 'readonly', (s) => s.get(key)).then((v) => (v === undefined ? null : v));\nconst idbSet = (w: any, key: string, raw: string): Promise<void> =>\n idbTx(w, 'readwrite', (s) => s.put(raw, key)).then(() => undefined);\nconst idbDel = (w: any, key: string): Promise<void> =>\n idbTx(w, 'readwrite', (s) => s.delete(key)).then(() => undefined);\n\nconst defSer = (v: any) => JSON.stringify(v);\nconst defDe = (s: string) => {\n try { return JSON.parse(s); } catch { return s; }\n};\n\nexport async function persistReadAsync(inst: any, key: string, opts: PersistOptions & { storage?: PersistStorage }): Promise<any> {\n const storage = opts?.storage ?? 'local';\n if (!isAsyncStorage(storage)) return persistRead(inst, key, opts);\n const de = (opts as any)?.deserialize ?? defDe;\n const raw = await idbGet(winOf(inst), key);\n if (raw === null || raw === undefined) return undefined;\n try { return de(raw); } catch { return raw; }\n}\nexport async function persistWriteAsync(inst: any, key: string, value: any, opts: PersistOptions & { storage?: PersistStorage }): Promise<void> {\n const storage = opts?.storage ?? 'local';\n if (!isAsyncStorage(storage)) { persistWrite(inst, key, value, opts); return; }\n if (value === undefined) { await persistRemoveAsync(inst, key, opts as any); return; }\n const se = (opts as any)?.serialize ?? defSer;\n await idbSet(winOf(inst), key, se(value));\n}\nexport async function persistRemoveAsync(inst: any, key: string, opts: RemovePersistOptions & { storage?: PersistStorage } = {}): Promise<void> {\n const storage = (opts as any)?.storage ?? 'local';\n if (!isAsyncStorage(storage)) { persistRemove(inst, key, opts); return; }\n await idbDel(winOf(inst), key);\n}\n\nconst warnedAsyncField = new WeakSet<object>();\nconst isPromiseLike = (v: any) => v instanceof Promise || (v && typeof v.then === 'function');\n\nexport function persistRead(inst: any, key: string, opts: PersistOptions & { storage?: PersistStorage }): any {\n const storage = opts?.storage ?? 'local';\n const de = (opts as any)?.deserialize ?? defDe;\n const w = winOf(inst);\n let raw: string | null = null;\n if (storage === 'cookie') raw = readCookie(w, key);\n else raw = storeOf(w, storage)?.getItem(key) ?? null;\n if (raw === null || raw === undefined) return undefined;\n try { return de(raw); } catch { return raw; }\n}\nexport function persistWrite(inst: any, key: string, value: any, opts: PersistOptions & { storage?: PersistStorage }) {\n const storage = opts?.storage ?? 'local';\n if (value === undefined) { persistRemove(inst, key, opts as any); return; }\n const se = (opts as any)?.serialize ?? defSer;\n const raw = se(value);\n const w = winOf(inst);\n if (storage === 'cookie') writeCookie(w, key, raw, opts as CookieOpts);\n else {\n try { storeOf(w, storage)?.setItem(key, raw); }\n catch (e) { console.warn('[SWC] persistState write failed:', e); }\n }\n}\nexport function persistRemove(inst: any, key: string, opts: RemovePersistOptions & { storage?: PersistStorage } = {}) {\n const storage = (opts as any)?.storage ?? 'local';\n const w = winOf(inst);\n if (storage === 'cookie') eraseCookie(w, key, opts as CookieRemoveOpts);\n else {\n try { storeOf(w, storage)?.removeItem(key); } catch { /* ignore */ }\n }\n}\n\nconst pickValue = (ret: any, valueKey?: string | symbol) =>\n valueKey !== undefined ? (ret && typeof ret === 'object' ? ret[valueKey] : undefined) : ret;\n\nfunction defineField(targetObj: any, propertyKey: string | symbol, key: string, opts: PersistOptions & { storage?: PersistStorage }) {\n const slot = Symbol(`persist:${String(propertyKey)}`);\n const initialized = Symbol(`persist:init:${String(propertyKey)}`);\n const storage = (opts as any)?.storage ?? 'local';\n const async = isAsyncStorage(storage);\n // Runtime guard: a getter cannot await — the first read resolves behind.\n // Warn once per class so the flicker (initial → restored) is a conscious choice.\n if (async && !warnedAsyncField.has(targetObj)) {\n warnedAsyncField.add(targetObj);\n console.warn(`[SWC] @persistState(${storage}) on field \"${String(propertyKey)}\" resolves asynchronously: first read returns the initializer, the stored value lands right after. Prefer calling persistReadAsync directly or Promise-typed fields for async backends.`);\n }\n Object.defineProperty(targetObj, propertyKey, {\n get(this: any) {\n const own = Object.getOwnPropertyDescriptor(this, propertyKey);\n if (own && 'value' in own) {\n delete this[propertyKey];\n const initVal = own.value;\n // Promise initializer: persist its resolution, expose the promise meanwhile.\n // Stored value still wins if present — mirrors the non-Promise branch below.\n if (async && isPromiseLike(initVal)) {\n this[slot] = initVal;\n this[initialized] = true;\n void persistReadAsync(this, key, opts).then((stored) => {\n if (stored !== undefined) {\n this[slot] = Promise.resolve(stored);\n } else {\n void (initVal as Promise<any>).then((v) => {\n this[slot] = v;\n void persistWriteAsync(this, key, v, opts).catch((e) => console.warn('[SWC] persistState write failed:', e));\n });\n }\n }).catch(() => undefined);\n return this[slot];\n }\n this[slot] = initVal;\n this[initialized] = true;\n // initializer wins on first boot? No — stored value wins if present.\n if (async) {\n // cannot await in a getter — read behind, update the slot when it lands.\n void persistReadAsync(this, key, opts).then((stored) => {\n if (stored !== undefined) this[slot] = stored;\n else void persistWriteAsync(this, key, this[slot], opts).catch((e) => console.warn('[SWC] persistState write failed:', e));\n }).catch(() => undefined);\n } else {\n const stored = persistRead(this, key, opts);\n if (stored !== undefined) this[slot] = stored;\n else persistWrite(this, key, this[slot], opts);\n }\n return this[slot];\n }\n if (!this[initialized]) {\n this[initialized] = true;\n if (async) {\n void persistReadAsync(this, key, opts).then((stored) => {\n if (stored !== undefined) this[slot] = stored;\n else if (this[slot] !== undefined) void persistWriteAsync(this, key, this[slot], opts).catch((e) => console.warn('[SWC] persistState write failed:', e));\n }).catch(() => undefined);\n } else {\n const stored = persistRead(this, key, opts);\n this[slot] = stored !== undefined ? stored : this[slot];\n if (stored === undefined && this[slot] !== undefined) persistWrite(this, key, this[slot], opts);\n }\n }\n return this[slot];\n },\n set(this: any, nv: any) {\n if (async) {\n const firstCall = !this[initialized];\n this[slot] = nv;\n this[initialized] = true;\n if (firstCall) {\n // 필드 초기화의 첫 set — 생성자 할당(또는 초기값 없는 필드의 첫 접근)이라 저장된 값이 있으면 그게 이긴다.\n void persistReadAsync(this, key, opts).then((stored) => {\n if (stored !== undefined) { this[slot] = isPromiseLike(nv) ? Promise.resolve(stored) : stored; return; }\n if (isPromiseLike(nv)) {\n void (nv as Promise<any>).then((v) => {\n this[slot] = v;\n void persistWriteAsync(this, key, v, opts).catch((e) => console.warn('[SWC] persistState write failed:', e));\n });\n } else if (nv !== undefined) {\n void persistWriteAsync(this, key, nv, opts).catch((e) => console.warn('[SWC] persistState write failed:', e));\n }\n }).catch(() => undefined);\n return;\n }\n // 생성자 이후의 명시적 재할당 — 의도된 덮어쓰기이므로 그대로 저장.\n if (isPromiseLike(nv)) {\n void (nv as Promise<any>).then((v) => {\n this[slot] = v;\n void persistWriteAsync(this, key, v, opts).catch((e) => console.warn('[SWC] persistState write failed:', e));\n });\n } else if (nv === undefined) {\n void persistRemoveAsync(this, key, opts as any).catch(() => undefined);\n } else {\n void persistWriteAsync(this, key, nv, opts).catch((e) => console.warn('[SWC] persistState write failed:', e));\n }\n return;\n }\n // field initializer runs through the setter at construction and would\n // clobber the stored value — stored wins on first write.\n if (!this[initialized]) {\n const stored = persistRead(this, key, opts);\n this[initialized] = true;\n if (stored !== undefined) { this[slot] = stored; return; }\n }\n this[slot] = nv;\n this[initialized] = true;\n persistWrite(this, key, nv, opts);\n },\n enumerable: true,\n configurable: true,\n });\n}\n\nfunction wrapMethod(targetObj: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor, key: string, opts: PersistOptions & { storage?: PersistStorage }) {\n const original = descriptor.value;\n if ((original as any)[PERSIST_WRAPPED]) return descriptor;\n const storage = (opts as any)?.storage ?? 'local';\n const async = isAsyncStorage(storage);\n const wrapped = function (this: any, ...args: any[]) {\n const res = (original as any).apply(this, args);\n const doPersist = (v: any) => {\n const val = pickValue(v, (opts as any)?.valueKey);\n if (val === undefined) return;\n if (async) void persistWriteAsync(this, key, val, opts).catch((e) => console.warn('[SWC] persistState write failed:', e));\n else persistWrite(this, key, val, opts);\n };\n if (res instanceof Promise) return res.then((v: any) => { doPersist(v); return v; });\n doPersist(res);\n return res;\n };\n (wrapped as any)[PERSIST_WRAPPED] = true;\n descriptor.value = wrapped;\n return descriptor;\n}\n\n// ─── persistState (field + method, bareable) ───\nexport function persistState(target: Object, propertyKey: string | symbol): void;\nexport function persistState(key?: string, options?: PersistOptions): PropertyDecorator & MethodDecorator;\nexport function persistState(keyOrTarget?: string | Object, optionsOrKey?: PersistOptions | string | symbol, descriptor?: PropertyDescriptor): any {\n // bare: @persistState\n if (typeof keyOrTarget === 'object' && (typeof optionsOrKey === 'string' || typeof optionsOrKey === 'symbol')) {\n const targetObj = keyOrTarget as Object;\n const propertyKey = optionsOrKey as string | symbol;\n if (descriptor) return wrapMethod(targetObj, propertyKey, descriptor, String(propertyKey), { storage: 'local' });\n defineField(targetObj, propertyKey, String(propertyKey), { storage: 'local' });\n return;\n }\n const key = typeof keyOrTarget === 'string' ? keyOrTarget : undefined;\n const opts = (typeof keyOrTarget === 'object' && keyOrTarget !== null ? {} : (optionsOrKey as PersistOptions ?? {})) as PersistOptions & { storage?: PersistStorage };\n return (targetObj: Object, propertyKey: string | symbol, desc?: PropertyDescriptor): any => {\n const k = key ?? String(propertyKey);\n if (desc) return wrapMethod(targetObj, propertyKey, desc, k, opts);\n defineField(targetObj, propertyKey, k, opts);\n };\n}\n\n// thin aliases — storage preset\nconst alias = (storage: PersistStorage, extra: any = {}) => {\n const fn = (a?: any, b?: any, c?: PropertyDescriptor): any => {\n // bare: @localStorage\n if (typeof b === 'string' || typeof b === 'symbol') {\n if (c) return wrapMethod(a, b, c, String(b), { storage, ...extra });\n defineField(a, b, String(b), { storage, ...extra });\n return;\n }\n if (typeof a === 'string') return persistState(a, { ...(b ?? {}), storage, ...extra });\n if (a && typeof a === 'object' && b === undefined && c === undefined) {\n // @localStorage({...}) options form\n return persistState(undefined, { ...(a ?? {}), storage, ...extra });\n }\n return (persistState(undefined, { storage, ...extra }) as any)(a, b, c!);\n };\n return fn;\n};\nexport const localStorage = alias('local');\nexport const sessionStorage = alias('session');\nexport const cookie = alias('cookie', { path: '/' });\n/** Async backend — see runtime guards in wrapMethod/defineField. */\nexport const indexedDb = alias('indexeddb');\n\n// ─── remove* (method only, Declaration = action) ───\nexport function removePersistState(key?: string, options?: RemovePersistOptions): MethodDecorator;\nexport function removePersistState(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): any;\nexport function removePersistState(a?: any, b?: any, c?: PropertyDescriptor): any {\n if (c) {\n const propertyKey = b as string | symbol;\n const orig = c.value;\n c.value = function (...args: any[]) {\n const res = orig.apply(this, args);\n const doRemove = (v: any) => {\n const go = (a as RemovePersistOptions)?.valueKey !== undefined\n ? (v && typeof v === 'object' ? v[(a as any).valueKey] : undefined)\n : true;\n if (!go) return;\n persistRemove(this, String(propertyKey), (a as any) ?? {});\n };\n if (res instanceof Promise) return res.then((v: any) => { doRemove(v); return v; });\n doRemove(res);\n return res;\n };\n return c;\n }\n const key = typeof a === 'string' ? a : undefined;\n const opts = (typeof a === 'object' && a !== null ? a : (b as any ?? {})) as RemovePersistOptions;\n return (target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): any => {\n const k = key ?? String(propertyKey);\n const orig = descriptor.value;\n descriptor.value = function (...args: any[]) {\n const res = orig.apply(this, args);\n const doRemove = (v: any) => {\n const vk = (opts as any)?.valueKey;\n const go = vk !== undefined ? (v && typeof v === 'object' ? v[vk] : undefined) : true;\n if (!go) return;\n persistRemove(this, k, opts);\n };\n if (res instanceof Promise) return res.then((v: any) => { doRemove(v); return v; });\n doRemove(res);\n return res;\n };\n return descriptor;\n };\n}\nconst removeAlias = (storage: PersistStorage) => (a?: any, b?: any, c?: PropertyDescriptor): any => {\n if (c) {\n const key = String(b);\n return removePersistState(key, { storage } as any)(a!, b!, c);\n }\n if (typeof a === 'string') return removePersistState(a, { ...(b ?? {}), storage } as any);\n if (a && typeof a === 'object') return removePersistState(undefined, { ...(a ?? {}), storage } as any);\n // bare @removeLocalStorage\n return (t: Object, pk: string | symbol, d: PropertyDescriptor): any =>\n removePersistState(String(pk), { storage } as any)(t, pk, d);\n};\nexport const removeLocalStorage = removeAlias('local');\nexport const removeSessionStorage = removeAlias('session');\nexport const removeCookie = removeAlias('cookie');\nexport const removeIndexedDb = removeAlias('indexeddb');\n"],
|
|
5
|
+
"mappings": "AAIO,MAAM,iBAAsC,oBAAI,IAAI,CAAC,WAAW,CAAC;AACjE,MAAM,iBAAiB,CAAC,YAAqB,eAAe,IAAI,WAAW,OAAO;AAqBzF,MAAM,kBAAkB,OAAO,IAAI,sCAAsC;AAEzE,MAAM,QAAQ,CAAC,SAAkB;AAC/B,MAAI;AACF,WAAO,MAAM,eAAe,eAAgB;EAC9C,QAAQ;AAAE,WAAO;EAAmB;AACtC;AACA,MAAM,UAAU,CAAC,GAAQ,YAA2C;AAClE,MAAI;AACF,QAAI,YAAY;AAAS,aAAO,GAAG,gBAAgB;AACnD,QA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AkB,YAAY,WAAW;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -2,7 +2,7 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
3
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
4
|
import { ReflectUtils } from "@dooboostore/core";
|
|
5
|
-
import { buildSwcParameterArgs } from "./parameter.js";
|
|
5
|
+
import { buildSwcParameterArgs, buildCommonKindValues } from "./parameter.js";
|
|
6
6
|
const RESIZE_OBSERVER_METADATA_KEY = Symbol.for("simple-web-component:resize-observer");
|
|
7
7
|
const applyResizeObserver = (selector, options, targetObj, propertyKey) => {
|
|
8
8
|
const constructor = targetObj.constructor;
|
|
@@ -98,13 +98,10 @@ class ResizeObserverLifeCycler {
|
|
|
98
98
|
void (async () => {
|
|
99
99
|
const helper = SwcUtils.getHelperAndHostSet(inst);
|
|
100
100
|
if (opts.filter && !await opts.filter(matchedEls, { currentThis: inst, helper })) return;
|
|
101
|
-
const
|
|
102
|
-
const
|
|
103
|
-
const legacyArgs = [matchedEls, entries.filter((e) => matchedEls.includes(e.target)), obs, { ...hostSet, $root: root }];
|
|
101
|
+
const common = buildCommonKindValues(inst, helperHostSet.$w);
|
|
102
|
+
const legacyArgs = [matchedEls, entries.filter((e) => matchedEls.includes(e.target)), obs, { ...common.hostSet, $root: root }];
|
|
104
103
|
const buildArgs = (beforeReturn) => buildSwcParameterArgs(inst, m.propertyKey, {
|
|
105
|
-
|
|
106
|
-
helperHostSet: helper,
|
|
107
|
-
helperSet,
|
|
104
|
+
...common,
|
|
108
105
|
resizeObserverBeforeReturn: beforeReturn
|
|
109
106
|
}, [...legacyArgs, beforeReturn]);
|
|
110
107
|
let args = buildArgs(void 0);
|