@toyz/loom 0.12.1 → 0.12.3
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/dist/decorators/index.d.ts +1 -0
- package/dist/decorators/index.d.ts.map +1 -1
- package/dist/decorators/index.js +1 -0
- package/dist/decorators/index.js.map +1 -1
- package/dist/store/index.d.ts +1 -0
- package/dist/store/index.d.ts.map +1 -1
- package/dist/store/index.js +1 -0
- package/dist/store/index.js.map +1 -1
- package/dist/store/readonly.d.ts +14 -0
- package/dist/store/readonly.d.ts.map +1 -0
- package/dist/store/readonly.js +40 -0
- package/dist/store/readonly.js.map +1 -0
- package/package.json +1 -1
|
@@ -8,6 +8,7 @@ export { REACTIVES, PROPS, WATCHERS, EMITTERS, COMPUTED_DIRTY, CATCH_HANDLER, IN
|
|
|
8
8
|
export { createDecorator } from "./create";
|
|
9
9
|
export { on, emit } from "./events";
|
|
10
10
|
export { reactive, prop, computed, params, routeQuery, watch } from "../store";
|
|
11
|
+
export { readonly } from "../store";
|
|
11
12
|
export { service, inject, factory } from "../di";
|
|
12
13
|
/** @deprecated Use `@watch(Service)` or `@watch(Service, "prop")` instead. Will be removed in v1.0. */
|
|
13
14
|
export { watch as watchService } from "../di";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/decorators/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EACL,SAAS,EACT,KAAK,EACL,QAAQ,EACR,QAAQ,EACR,cAAc,EACd,aAAa,EACb,aAAa,EACb,WAAW,EACX,WAAW,EACX,UAAU,GACX,MAAM,WAAW,CAAC;AAGnB,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAG3C,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAKpC,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/decorators/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EACL,SAAS,EACT,KAAK,EACL,QAAQ,EACR,QAAQ,EACR,cAAc,EACd,aAAa,EACb,aAAa,EACb,WAAW,EACX,WAAW,EACX,UAAU,GACX,MAAM,WAAW,CAAC;AAGnB,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAG3C,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAKpC,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAC/E,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAGpC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AACjD,uGAAuG;AACvG,OAAO,EAAE,KAAK,IAAI,YAAY,EAAE,MAAM,OAAO,CAAC;AAG9C,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACxD,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAGnF,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACnF,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC"}
|
package/dist/decorators/index.js
CHANGED
|
@@ -13,6 +13,7 @@ export { on, emit } from "./events";
|
|
|
13
13
|
// ── Re-exports from domain folders ──
|
|
14
14
|
// Store: reactive state, persistence, @watch(field/store)
|
|
15
15
|
export { reactive, prop, computed, params, routeQuery, watch } from "../store";
|
|
16
|
+
export { readonly } from "../store";
|
|
16
17
|
// DI: service container decorators, @watch(Service)
|
|
17
18
|
export { service, inject, factory } from "../di";
|
|
18
19
|
/** @deprecated Use `@watch(Service)` or `@watch(Service, "prop")` instead. Will be removed in v1.0. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/decorators/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,4CAA4C;AAC5C,OAAO,EACL,SAAS,EACT,KAAK,EACL,QAAQ,EACR,QAAQ,EACR,cAAc,EACd,aAAa,EACb,aAAa,EACb,WAAW,EACX,WAAW,EACX,UAAU,GACX,MAAM,WAAW,CAAC;AAEnB,6DAA6D;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAE3C,sCAAsC;AACtC,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAEpC,uCAAuC;AAEvC,0DAA0D;AAC1D,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/decorators/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,4CAA4C;AAC5C,OAAO,EACL,SAAS,EACT,KAAK,EACL,QAAQ,EACR,QAAQ,EACR,cAAc,EACd,aAAa,EACb,aAAa,EACb,WAAW,EACX,WAAW,EACX,UAAU,GACX,MAAM,WAAW,CAAC;AAEnB,6DAA6D;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAE3C,sCAAsC;AACtC,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAEpC,uCAAuC;AAEvC,0DAA0D;AAC1D,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAC/E,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEpC,oDAAoD;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AACjD,uGAAuG;AACvG,OAAO,EAAE,KAAK,IAAI,YAAY,EAAE,MAAM,OAAO,CAAC;AAE9C,kEAAkE;AAClE,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACxD,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEnF,sDAAsD;AACtD,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACnF,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC"}
|
package/dist/store/index.d.ts
CHANGED
|
@@ -8,5 +8,6 @@ export type { Subscriber, Updater, Identifiable } from "./reactive";
|
|
|
8
8
|
export { MemoryStorage, LocalAdapter, SessionAdapter, LocalMedium, SessionMedium } from "./storage";
|
|
9
9
|
export type { StorageAdapter, StorageMedium, PersistOptions } from "./storage";
|
|
10
10
|
export { reactive, prop, computed, params, routeQuery, store } from "./decorators";
|
|
11
|
+
export { readonly } from "./readonly";
|
|
11
12
|
export { watch } from "./watch";
|
|
12
13
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/store/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AACvD,YAAY,EAAE,UAAU,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAGpE,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,cAAc,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AACpG,YAAY,EAAE,cAAc,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAG/E,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/store/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AACvD,YAAY,EAAE,UAAU,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAGpE,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,cAAc,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AACpG,YAAY,EAAE,cAAc,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAG/E,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AACnF,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAGtC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC"}
|
package/dist/store/index.js
CHANGED
|
@@ -9,6 +9,7 @@ export { Reactive, CollectionStore } from "./reactive";
|
|
|
9
9
|
export { MemoryStorage, LocalAdapter, SessionAdapter, LocalMedium, SessionMedium } from "./storage";
|
|
10
10
|
// Decorators
|
|
11
11
|
export { reactive, prop, computed, params, routeQuery, store } from "./decorators";
|
|
12
|
+
export { readonly } from "./readonly";
|
|
12
13
|
// Watch
|
|
13
14
|
export { watch } from "./watch";
|
|
14
15
|
//# sourceMappingURL=index.js.map
|
package/dist/store/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/store/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,sBAAsB;AACtB,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAGvD,mBAAmB;AACnB,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,cAAc,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAGpG,aAAa;AACb,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/store/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,sBAAsB;AACtB,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAGvD,mBAAmB;AACnB,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,cAAc,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAGpG,aAAa;AACb,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AACnF,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,QAAQ;AACR,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Loom — @readonly decorator
|
|
3
|
+
*
|
|
4
|
+
* Composable auto-accessor decorator that enforces immutability.
|
|
5
|
+
* Stacks with @prop, @reactive, or standalone.
|
|
6
|
+
*
|
|
7
|
+
* ```ts
|
|
8
|
+
* @prop @readonly accessor users!: User[]; // parent can update, child can't mutate
|
|
9
|
+
* @reactive @readonly accessor id = crypto.randomUUID(); // set once, locked
|
|
10
|
+
* @readonly accessor config = { theme: "dark" }; // standalone
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export declare function readonly<This extends object, V>(target: ClassAccessorDecoratorTarget<This, V>, context: ClassAccessorDecoratorContext<This, V>): ClassAccessorDecoratorResult<This, V>;
|
|
14
|
+
//# sourceMappingURL=readonly.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"readonly.d.ts","sourceRoot":"","sources":["../../src/store/readonly.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH,wBAAgB,QAAQ,CAAC,IAAI,SAAS,MAAM,EAAE,CAAC,EAC7C,MAAM,EAAE,4BAA4B,CAAC,IAAI,EAAE,CAAC,CAAC,EAC7C,OAAO,EAAE,6BAA6B,CAAC,IAAI,EAAE,CAAC,CAAC,GAC9C,4BAA4B,CAAC,IAAI,EAAE,CAAC,CAAC,CA0BvC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Loom — @readonly decorator
|
|
3
|
+
*
|
|
4
|
+
* Composable auto-accessor decorator that enforces immutability.
|
|
5
|
+
* Stacks with @prop, @reactive, or standalone.
|
|
6
|
+
*
|
|
7
|
+
* ```ts
|
|
8
|
+
* @prop @readonly accessor users!: User[]; // parent can update, child can't mutate
|
|
9
|
+
* @reactive @readonly accessor id = crypto.randomUUID(); // set once, locked
|
|
10
|
+
* @readonly accessor config = { theme: "dark" }; // standalone
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
const LOCKED = Symbol("loom:readonly:locked");
|
|
14
|
+
export function readonly(target, context) {
|
|
15
|
+
const name = String(context.name);
|
|
16
|
+
const lockKey = Symbol(`readonly:${name}`);
|
|
17
|
+
return {
|
|
18
|
+
get() {
|
|
19
|
+
const val = target.get.call(this);
|
|
20
|
+
// Freeze objects/arrays so .push(), .name = ... etc. throw
|
|
21
|
+
if (val !== null && typeof val === "object" && !Object.isFrozen(val)) {
|
|
22
|
+
return Object.freeze(val);
|
|
23
|
+
}
|
|
24
|
+
return val;
|
|
25
|
+
},
|
|
26
|
+
set(val) {
|
|
27
|
+
if (this[lockKey]) {
|
|
28
|
+
throw new Error(`Cannot mutate readonly property '${name}'`);
|
|
29
|
+
}
|
|
30
|
+
target.set.call(this, val);
|
|
31
|
+
this[lockKey] = true;
|
|
32
|
+
},
|
|
33
|
+
init(val) {
|
|
34
|
+
// init runs during field initialization — allow it
|
|
35
|
+
// Lock will be set on the first explicit set() call
|
|
36
|
+
return val;
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=readonly.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"readonly.js","sourceRoot":"","sources":["../../src/store/readonly.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,MAAM,MAAM,GAAG,MAAM,CAAC,sBAAsB,CAAC,CAAC;AAE9C,MAAM,UAAU,QAAQ,CACtB,MAA6C,EAC7C,OAA+C;IAE/C,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAClC,MAAM,OAAO,GAAG,MAAM,CAAC,YAAY,IAAI,EAAE,CAAC,CAAC;IAE3C,OAAO;QACL,GAAG;YACD,MAAM,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAM,CAAC;YACvC,2DAA2D;YAC3D,IAAI,GAAG,KAAK,IAAI,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;gBACrE,OAAO,MAAM,CAAC,MAAM,CAAC,GAAG,CAAM,CAAC;YACjC,CAAC;YACD,OAAO,GAAG,CAAC;QACb,CAAC;QACD,GAAG,CAAY,GAAM;YACnB,IAAI,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;gBAClB,MAAM,IAAI,KAAK,CAAC,oCAAoC,IAAI,GAAG,CAAC,CAAC;YAC/D,CAAC;YACD,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;YAC3B,IAAI,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC;QACvB,CAAC;QACD,IAAI,CAAY,GAAM;YACpB,mDAAmD;YACnD,oDAAoD;YACpD,OAAO,GAAG,CAAC;QACb,CAAC;KACF,CAAC;AACJ,CAAC"}
|