@pyreon/ui-core 0.16.0 → 0.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.d.ts CHANGED
@@ -309,8 +309,22 @@ declare const useStableValue: <T>(value: T) => T;
309
309
  * Accepts either an array of keys (builds a Set internally) or a
310
310
  * pre-built `Set<string>` for hot paths where the same key list is
311
311
  * reused across many calls (avoids per-call Set allocation).
312
+ *
313
+ * Copies own property DESCRIPTORS (not values) so that getter-shaped
314
+ * properties — produced by `makeReactiveProps` in `@pyreon/core` for
315
+ * compiler-emitted `<Comp prop={signal()}>` — survive the copy with
316
+ * their reactive subscription intact. For data properties the
317
+ * behaviour is identical to value-copying.
312
318
  */
313
319
  declare const omit: <T extends Record<string, any>>(obj: T | null | undefined, keys?: readonly (string | keyof T)[] | Set<string>) => Partial<T>;
320
+ /**
321
+ * Returns a copy of `obj` containing only the specified keys.
322
+ *
323
+ * See `omit` above — same descriptor-preserving semantics: getter-
324
+ * shaped properties survive the copy with reactive subscription
325
+ * intact. For data properties the behaviour is identical to
326
+ * value-copying.
327
+ */
314
328
  declare const pick: <T extends Record<string, any>>(obj: T | null | undefined, keys?: readonly (string | keyof T)[]) => Partial<T>;
315
329
  declare const get: (obj: any, path: string | string[], defaultValue?: any) => any;
316
330
  declare const set: (obj: Record<string, any>, path: string | string[], value: any) => Record<string, any>;
package/lib/index.js CHANGED
@@ -412,22 +412,38 @@ const useStableValue = (value) => {
412
412
  * Accepts either an array of keys (builds a Set internally) or a
413
413
  * pre-built `Set<string>` for hot paths where the same key list is
414
414
  * reused across many calls (avoids per-call Set allocation).
415
+ *
416
+ * Copies own property DESCRIPTORS (not values) so that getter-shaped
417
+ * properties — produced by `makeReactiveProps` in `@pyreon/core` for
418
+ * compiler-emitted `<Comp prop={signal()}>` — survive the copy with
419
+ * their reactive subscription intact. For data properties the
420
+ * behaviour is identical to value-copying.
415
421
  */
416
422
  const omit = (obj, keys) => {
417
423
  if (obj == null) return {};
418
- if (!keys || (keys instanceof Set ? keys.size === 0 : keys.length === 0)) return { ...obj };
424
+ const descriptors = Object.getOwnPropertyDescriptors(obj);
425
+ if (!keys || (keys instanceof Set ? keys.size === 0 : keys.length === 0)) return Object.defineProperties({}, descriptors);
419
426
  const keysSet = keys instanceof Set ? keys : new Set(keys);
420
427
  const result = {};
421
- for (const key in obj) if (Object.hasOwn(obj, key) && !keysSet.has(key)) result[key] = obj[key];
428
+ for (const key of Object.keys(descriptors)) if (!keysSet.has(key)) Object.defineProperty(result, key, descriptors[key]);
422
429
  return result;
423
430
  };
431
+ /**
432
+ * Returns a copy of `obj` containing only the specified keys.
433
+ *
434
+ * See `omit` above — same descriptor-preserving semantics: getter-
435
+ * shaped properties survive the copy with reactive subscription
436
+ * intact. For data properties the behaviour is identical to
437
+ * value-copying.
438
+ */
424
439
  const pick = (obj, keys) => {
425
440
  if (obj == null) return {};
426
- if (!keys || keys.length === 0) return { ...obj };
441
+ if (!keys || keys.length === 0) return Object.defineProperties({}, Object.getOwnPropertyDescriptors(obj));
427
442
  const result = {};
428
443
  for (const key of keys) {
429
444
  const k = key;
430
- if (Object.hasOwn(obj, k)) result[k] = obj[k];
445
+ const descriptor = Object.getOwnPropertyDescriptor(obj, k);
446
+ if (descriptor) Object.defineProperty(result, k, descriptor);
431
447
  }
432
448
  return result;
433
449
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pyreon/ui-core",
3
- "version": "0.16.0",
3
+ "version": "0.18.0",
4
4
  "description": "Core utilities, config, and context for Pyreon UI System",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -38,16 +38,16 @@
38
38
  },
39
39
  "devDependencies": {
40
40
  "@pyreon/manifest": "0.13.1",
41
- "@pyreon/typescript": "^0.16.0",
41
+ "@pyreon/typescript": "^0.18.0",
42
42
  "@vitus-labs/tools-rolldown": "^2.3.0"
43
43
  },
44
44
  "engines": {
45
45
  "node": ">= 22"
46
46
  },
47
47
  "dependencies": {
48
- "@pyreon/core": "^0.16.0",
49
- "@pyreon/reactivity": "^0.16.0",
50
- "@pyreon/styler": "^0.16.0",
51
- "@pyreon/unistyle": "^0.16.0"
48
+ "@pyreon/core": "^0.18.0",
49
+ "@pyreon/reactivity": "^0.18.0",
50
+ "@pyreon/styler": "^0.18.0",
51
+ "@pyreon/unistyle": "^0.18.0"
52
52
  }
53
53
  }
package/src/utils.ts CHANGED
@@ -4,34 +4,57 @@
4
4
  * Accepts either an array of keys (builds a Set internally) or a
5
5
  * pre-built `Set<string>` for hot paths where the same key list is
6
6
  * reused across many calls (avoids per-call Set allocation).
7
+ *
8
+ * Copies own property DESCRIPTORS (not values) so that getter-shaped
9
+ * properties — produced by `makeReactiveProps` in `@pyreon/core` for
10
+ * compiler-emitted `<Comp prop={signal()}>` — survive the copy with
11
+ * their reactive subscription intact. For data properties the
12
+ * behaviour is identical to value-copying.
7
13
  */
8
14
  export const omit = <T extends Record<string, any>>(
9
15
  obj: T | null | undefined,
10
16
  keys?: readonly (string | keyof T)[] | Set<string>,
11
17
  ): Partial<T> => {
12
18
  if (obj == null) return {} as Partial<T>
13
- if (!keys || (keys instanceof Set ? keys.size === 0 : keys.length === 0)) return { ...obj }
19
+ const descriptors = Object.getOwnPropertyDescriptors(obj)
20
+ if (!keys || (keys instanceof Set ? keys.size === 0 : keys.length === 0)) {
21
+ return Object.defineProperties({} as Partial<T>, descriptors)
22
+ }
14
23
  const keysSet = keys instanceof Set ? keys : new Set(keys as readonly string[])
15
24
  const result: Record<string, any> = {}
16
- for (const key in obj) {
17
- if (Object.hasOwn(obj, key) && !keysSet.has(key)) {
18
- result[key] = obj[key]
25
+ for (const key of Object.keys(descriptors)) {
26
+ if (!keysSet.has(key)) {
27
+ Object.defineProperty(result, key, descriptors[key]!)
19
28
  }
20
29
  }
21
30
  return result as Partial<T>
22
31
  }
23
32
 
33
+ /**
34
+ * Returns a copy of `obj` containing only the specified keys.
35
+ *
36
+ * See `omit` above — same descriptor-preserving semantics: getter-
37
+ * shaped properties survive the copy with reactive subscription
38
+ * intact. For data properties the behaviour is identical to
39
+ * value-copying.
40
+ */
24
41
  export const pick = <T extends Record<string, any>>(
25
42
  obj: T | null | undefined,
26
43
  keys?: readonly (string | keyof T)[],
27
44
  ): Partial<T> => {
28
45
  if (obj == null) return {} as Partial<T>
29
- if (!keys || keys.length === 0) return { ...obj }
46
+ if (!keys || keys.length === 0) {
47
+ return Object.defineProperties(
48
+ {} as Partial<T>,
49
+ Object.getOwnPropertyDescriptors(obj),
50
+ )
51
+ }
30
52
  const result: Record<string, any> = {}
31
53
  for (const key of keys) {
32
54
  const k = key as string
33
- if (Object.hasOwn(obj, k)) {
34
- result[k] = obj[k]
55
+ const descriptor = Object.getOwnPropertyDescriptor(obj, k)
56
+ if (descriptor) {
57
+ Object.defineProperty(result, k, descriptor)
35
58
  }
36
59
  }
37
60
  return result as Partial<T>