@tschk/moonshine-dom 0.4.49 → 0.4.80
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/package.json +3 -3
- package/src/component.ts +2 -0
- package/src/dom.ts +3 -3
- package/src/ssr.ts +8 -4
- package/src/store.ts +22 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tschk/moonshine-dom",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.80",
|
|
4
4
|
"description": "Independent Moonshine DOM, SSR and reactive rendering",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"type": "module",
|
|
@@ -47,10 +47,10 @@
|
|
|
47
47
|
"test": "bun test"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@tschk/moonshine": "^0.4.
|
|
50
|
+
"@tschk/moonshine": "^0.4.80"
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|
|
53
|
-
"@tschk/moonshine-framework": "^0.4.
|
|
53
|
+
"@tschk/moonshine-framework": "^0.4.80"
|
|
54
54
|
},
|
|
55
55
|
"peerDependenciesMeta": {
|
|
56
56
|
"@tschk/moonshine-framework": {
|
package/src/component.ts
CHANGED
|
@@ -19,6 +19,8 @@ type ComponentContextSource = ComponentContext & {
|
|
|
19
19
|
export const componentEvents = /* @__PURE__ */ Symbol(
|
|
20
20
|
"moonshine.component.events",
|
|
21
21
|
);
|
|
22
|
+
/** Internal unforgeable registry for native ref wrappers across Vue/Nuxt adapters. */
|
|
23
|
+
export const nativeRefSet = /* @__PURE__ */ new WeakSet<object>();
|
|
22
24
|
export interface ComponentContext<P = unknown> {
|
|
23
25
|
readonly props: P;
|
|
24
26
|
readonly owner: Owner;
|
package/src/dom.ts
CHANGED
|
@@ -43,14 +43,14 @@ export type DOMChild =
|
|
|
43
43
|
|
|
44
44
|
const SVG = "http://www.w3.org/2000/svg";
|
|
45
45
|
const HTML = "http://www.w3.org/1999/xhtml";
|
|
46
|
-
const SVG_TAGS = new Set(
|
|
46
|
+
const SVG_TAGS = /* @__PURE__ */ new Set(
|
|
47
47
|
"animate animateMotion animateTransform circle clipPath defs desc ellipse feBlend feColorMatrix feComponentTransfer feComposite feConvolveMatrix feDiffuseLighting feDisplacementMap feDistantLight feDropShadow feFlood feFuncA feFuncB feFuncG feFuncR feGaussianBlur feImage feMerge feMergeNode feMorphology feOffset fePointLight feSpecularLighting feSpotLight feTile feTurbulence filter foreignObject g image line linearGradient marker mask metadata mpath path pattern polygon polyline radialGradient rect set stop switch symbol text textPath tspan use view".split(
|
|
48
48
|
" ",
|
|
49
49
|
),
|
|
50
50
|
);
|
|
51
51
|
let namespace = HTML;
|
|
52
|
-
const selectUpdates = new WeakMap<Node, () => void>();
|
|
53
|
-
const styleNames = new WeakMap<Element, Set<string>>();
|
|
52
|
+
const selectUpdates = /* @__PURE__ */ new WeakMap<Node, () => void>();
|
|
53
|
+
const styleNames = /* @__PURE__ */ new WeakMap<Element, Set<string>>();
|
|
54
54
|
|
|
55
55
|
function childrenNamespace(parent: Node): string {
|
|
56
56
|
return parent instanceof Element &&
|
package/src/ssr.ts
CHANGED
|
@@ -30,8 +30,12 @@ import {
|
|
|
30
30
|
export { scopeSSRChild } from "./ssr-owner";
|
|
31
31
|
|
|
32
32
|
/** Compiler-only typed selection; payloads preserve literal function/object identity. */
|
|
33
|
-
export const selectBinding =
|
|
34
|
-
|
|
33
|
+
export const selectBinding = /* @__PURE__ */ Symbol(
|
|
34
|
+
"moonshine server select binding",
|
|
35
|
+
);
|
|
36
|
+
export const optionBinding = /* @__PURE__ */ Symbol(
|
|
37
|
+
"moonshine server option binding",
|
|
38
|
+
);
|
|
35
39
|
type BindingValue = { value: unknown; preserveSelected?: boolean };
|
|
36
40
|
const ELEMENT_NAME = /^[a-zA-Z][a-zA-Z0-9:_-]*$/;
|
|
37
41
|
const ATTRIBUTE_NAME = /^[a-zA-Z_:][a-zA-Z0-9:_.-]*$/;
|
|
@@ -69,7 +73,7 @@ function bindingValue(
|
|
|
69
73
|
if (!props || !Object.hasOwn(props, key)) return undefined;
|
|
70
74
|
return validateBindingBox(Reflect.get(props, key));
|
|
71
75
|
}
|
|
72
|
-
const html = Symbol("moonshine server HTML");
|
|
76
|
+
const html = /* @__PURE__ */ Symbol("moonshine server HTML");
|
|
73
77
|
type Selection = {
|
|
74
78
|
values?: Set<string>;
|
|
75
79
|
binding?: BindingValue;
|
|
@@ -92,7 +96,7 @@ export type SSRChild =
|
|
|
92
96
|
| readonly SSRChild[]
|
|
93
97
|
| (() => SSRChild);
|
|
94
98
|
|
|
95
|
-
const VOID = new Set([
|
|
99
|
+
const VOID = /* @__PURE__ */ new Set([
|
|
96
100
|
"area",
|
|
97
101
|
"base",
|
|
98
102
|
"br",
|
package/src/store.ts
CHANGED
|
@@ -2,9 +2,23 @@
|
|
|
2
2
|
import { batch, createSignal, untrack } from "./reactive";
|
|
3
3
|
|
|
4
4
|
type Key = string | number | symbol;
|
|
5
|
-
type
|
|
5
|
+
export type StorePathRange = { from?: number; to?: number; by?: number };
|
|
6
|
+
type Range = StorePathRange;
|
|
6
7
|
type Selector =
|
|
7
8
|
Key | readonly Key[] | Range | ((value: any, index: number) => boolean);
|
|
9
|
+
export type Store<T> = T;
|
|
10
|
+
export type NotWrappable =
|
|
11
|
+
string | number | bigint | symbol | boolean | Function | null | undefined;
|
|
12
|
+
export type StoreSetter<T, U extends PropertyKey[] = []> =
|
|
13
|
+
T | Partial<T> | ((prevState: T, traversed: U) => T | Partial<T> | void);
|
|
14
|
+
export interface ReconcileOptions {
|
|
15
|
+
key?: string | null;
|
|
16
|
+
merge?: boolean;
|
|
17
|
+
}
|
|
18
|
+
export const $RAW: unique symbol = Symbol("store-raw");
|
|
19
|
+
export const DEV: { readonly $RAW: typeof $RAW } | undefined = Object.freeze({
|
|
20
|
+
$RAW,
|
|
21
|
+
});
|
|
8
22
|
type Update<T> =
|
|
9
23
|
T | Partial<T> | ((previous: T, path: Key[]) => T | Partial<T> | void);
|
|
10
24
|
export interface SetStoreFunction<T> {
|
|
@@ -182,6 +196,7 @@ function wrap<T>(
|
|
|
182
196
|
const methods = new Map<PropertyKey, Function>();
|
|
183
197
|
const proxy: object = new Proxy(value, {
|
|
184
198
|
get(target, key, receiver) {
|
|
199
|
+
if (key === $RAW) return target;
|
|
185
200
|
// Undefined constructor selects ordinary arrays without exposing prototypes.
|
|
186
201
|
if (writable && key === "constructor" && Array.isArray(target))
|
|
187
202
|
return undefined;
|
|
@@ -216,6 +231,7 @@ function wrap<T>(
|
|
|
216
231
|
return wrap(result, mode, equals);
|
|
217
232
|
},
|
|
218
233
|
has(target, key) {
|
|
234
|
+
if (key === $RAW) return true;
|
|
219
235
|
if (tracked) track(state(target).has, key);
|
|
220
236
|
return key in target;
|
|
221
237
|
},
|
|
@@ -375,6 +391,11 @@ export function createMutable<T extends object>(
|
|
|
375
391
|
return wrap(target, "mutable", options.equals ?? strictEqual);
|
|
376
392
|
}
|
|
377
393
|
|
|
394
|
+
/** Apply a store modifier (such as produce or reconcile) to a mutable store inside a batched untracked scope. */
|
|
395
|
+
export function modifyMutable<T>(state: T, modifier: (state: T) => T): void {
|
|
396
|
+
batch(() => untrack(() => modifier(raw(state))));
|
|
397
|
+
}
|
|
398
|
+
|
|
378
399
|
export function produce<T>(fn: (state: T) => void): (state: T) => T {
|
|
379
400
|
return (value) => {
|
|
380
401
|
if (wrappable(raw(value)))
|