sinho 0.3.1 → 0.3.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/.github/workflows/ci.yml +7 -5
- package/.github/workflows/deploy-docs.yml +2 -2
- package/README.md +2 -2
- package/dist/bundle.d.ts +16 -15
- package/dist/bundle.js +30 -23
- package/dist/bundle.min.js +1 -1
- package/dist/component.d.ts +5 -5
- package/dist/component.js +14 -5
- package/dist/component.js.map +1 -1
- package/dist/intrinsic/For.d.ts +3 -3
- package/dist/intrinsic/TagComponent.js +1 -1
- package/dist/intrinsic/TagComponent.js.map +1 -1
- package/dist/jsx-runtime/mod.d.ts +2 -2
- package/dist/scope.d.ts +4 -4
- package/dist/scope.js +15 -17
- package/dist/scope.js.map +1 -1
- package/package.json +18 -6
- package/src/component.ts +29 -9
- package/src/intrinsic/TagComponent.ts +1 -1
- package/src/scope.ts +17 -20
- package/web/docusaurus.config.ts +0 -18
- package/web/package-lock.json +8165 -4481
- package/web/package.json +5 -7
- package/web/src/components/monacoEditor.tsx +1 -1
- package/web/src/components/playground.tsx +1 -1
- package/web/src/pages/index.tsx +6 -2
- package/web/src/pages/playground.tsx +3 -3
- package/web/static/dist/bundle.d.ts +36 -15
- package/web/static/dist/bundle.min.js +1 -1
- package/dist/intrinsic/Dynamic.d.ts +0 -33
- package/dist/intrinsic/Dynamic.js +0 -53
- package/dist/intrinsic/Dynamic.js.map +0 -1
- package/dist/intrinsic/ErrorBoundary.d.ts +0 -14
- package/dist/intrinsic/ErrorBoundary.js +0 -36
- package/dist/intrinsic/ErrorBoundary.js.map +0 -1
- package/web/dist/shingo.min.d.ts +0 -1131
- package/web/dist/shingo.min.js +0 -1
package/.github/workflows/ci.yml
CHANGED
|
@@ -5,20 +5,22 @@ name: CI
|
|
|
5
5
|
|
|
6
6
|
on:
|
|
7
7
|
push:
|
|
8
|
-
branches:
|
|
8
|
+
branches: main
|
|
9
9
|
pull_request:
|
|
10
|
-
branches:
|
|
10
|
+
branches: main
|
|
11
11
|
|
|
12
12
|
jobs:
|
|
13
13
|
build:
|
|
14
14
|
runs-on: ubuntu-latest
|
|
15
15
|
|
|
16
16
|
steps:
|
|
17
|
-
-
|
|
17
|
+
- name: Checkout
|
|
18
|
+
uses: actions/checkout@v6
|
|
18
19
|
- name: Use Node.js
|
|
19
|
-
uses: actions/setup-node@
|
|
20
|
+
uses: actions/setup-node@v6
|
|
20
21
|
with:
|
|
21
|
-
|
|
22
|
+
node-version: 24
|
|
22
23
|
- run: npm ci
|
|
23
24
|
- run: npm run build
|
|
25
|
+
- run: npm run build-samples
|
|
24
26
|
- run: npm test
|
|
@@ -31,7 +31,7 @@ jobs:
|
|
|
31
31
|
runs-on: ubuntu-latest
|
|
32
32
|
steps:
|
|
33
33
|
- name: Checkout
|
|
34
|
-
uses: actions/checkout@
|
|
34
|
+
uses: actions/checkout@v6
|
|
35
35
|
- name: Install Dependencies
|
|
36
36
|
run: npm install && cd ./web && npm install
|
|
37
37
|
- name: Build
|
|
@@ -39,7 +39,7 @@ jobs:
|
|
|
39
39
|
- name: Setup Pages
|
|
40
40
|
uses: actions/configure-pages@v5
|
|
41
41
|
- name: Upload Artifact
|
|
42
|
-
uses: actions/upload-pages-artifact@
|
|
42
|
+
uses: actions/upload-pages-artifact@v4
|
|
43
43
|
with:
|
|
44
44
|
path: ./web/build
|
|
45
45
|
- name: Deploy to GitHub Pages
|
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@ API.
|
|
|
13
13
|
```tsx
|
|
14
14
|
import { Component, useSignal, defineComponents } from "sinho";
|
|
15
15
|
|
|
16
|
-
class
|
|
16
|
+
class MyCounter extends Component() {
|
|
17
17
|
render() {
|
|
18
18
|
const [value, setValue] = useSignal(0);
|
|
19
19
|
|
|
@@ -29,5 +29,5 @@ class Counter extends Component("x-counter") {
|
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
defineComponents(
|
|
32
|
+
defineComponents(MyCounter);
|
|
33
33
|
```
|
package/dist/bundle.d.ts
CHANGED
|
@@ -58,8 +58,8 @@ interface Effect {
|
|
|
58
58
|
type Cleanup = (() => void) | void | undefined | null;
|
|
59
59
|
interface Scope<out T = {}> {
|
|
60
60
|
readonly _parent?: Scope;
|
|
61
|
-
_effects: Effect
|
|
62
|
-
_subscopes: Scope
|
|
61
|
+
_effects: Set<Effect>;
|
|
62
|
+
_subscopes: Set<Scope>;
|
|
63
63
|
_details: T;
|
|
64
64
|
_run<T>(fn: () => T): T;
|
|
65
65
|
_cleanup(): void;
|
|
@@ -131,11 +131,11 @@ declare const MaybeSignal: {
|
|
|
131
131
|
/**
|
|
132
132
|
* Gets the value of the given {@link MaybeSignal}.
|
|
133
133
|
*/
|
|
134
|
-
get: <
|
|
134
|
+
get: <T>(signal: MaybeSignal<T>) => T;
|
|
135
135
|
/**
|
|
136
136
|
* Accesses the value of the given {@link MaybeSignal} without tracking.
|
|
137
137
|
*/
|
|
138
|
-
peek<
|
|
138
|
+
peek<T>(signal: MaybeSignal<T>): T;
|
|
139
139
|
};
|
|
140
140
|
|
|
141
141
|
interface DomIntrinsicElements {
|
|
@@ -945,7 +945,7 @@ declare abstract class ComponentInner<M extends Metadata> {
|
|
|
945
945
|
interface ComponentConstructor<M extends Metadata = {}> {
|
|
946
946
|
/** @ignore */
|
|
947
947
|
readonly [componentSym]: {
|
|
948
|
-
readonly _tagName: string;
|
|
948
|
+
readonly _tagName: string | null;
|
|
949
949
|
};
|
|
950
950
|
readonly observedAttributes: readonly string[];
|
|
951
951
|
new (): Component<M>;
|
|
@@ -978,7 +978,7 @@ type Component<M extends Metadata = {}> = {
|
|
|
978
978
|
*
|
|
979
979
|
* @example
|
|
980
980
|
* ```tsx
|
|
981
|
-
* class MyComponent extends Component(
|
|
981
|
+
* class MyComponent extends Component({
|
|
982
982
|
* myProp: prop<string>("Hello, world!"),
|
|
983
983
|
* onMyEvent: event(),
|
|
984
984
|
* }) {
|
|
@@ -992,15 +992,15 @@ type Component<M extends Metadata = {}> = {
|
|
|
992
992
|
* },
|
|
993
993
|
* }
|
|
994
994
|
*
|
|
995
|
-
*
|
|
995
|
+
* defineComponents(MyComponent);
|
|
996
996
|
* ```
|
|
997
997
|
*/
|
|
998
|
-
declare const Component: ((tagName
|
|
998
|
+
declare const Component: ((tagName?: string) => ComponentConstructor<{}>) & (<const M extends Metadata>(tagName: string, metadata: M, opts?: ComponentOptions) => ComponentConstructor<M>) & (<const M extends Metadata>(metadata: M, opts?: ComponentOptions) => ComponentConstructor<M>);
|
|
999
999
|
/**
|
|
1000
1000
|
* Determines whether the given value is a component created by
|
|
1001
1001
|
* extending {@link ComponentConstructor}.
|
|
1002
1002
|
*/
|
|
1003
|
-
declare const isComponent: (value: any) => value is ComponentConstructor
|
|
1003
|
+
declare const isComponent: (value: any) => value is ComponentConstructor | Component;
|
|
1004
1004
|
/**
|
|
1005
1005
|
* Represents a functional component.
|
|
1006
1006
|
*
|
|
@@ -1086,9 +1086,9 @@ declare const h: typeof createElement & {
|
|
|
1086
1086
|
* `For` is a component that can be used to render a list of items.
|
|
1087
1087
|
*/
|
|
1088
1088
|
declare const For: <T>(props: {
|
|
1089
|
-
each?: MaybeSignal<readonly T[]
|
|
1090
|
-
key?: (
|
|
1091
|
-
children?: (
|
|
1089
|
+
each?: MaybeSignal<readonly T[]>;
|
|
1090
|
+
key?: (item: T, index: number) => string | number;
|
|
1091
|
+
children?: (item: Signal<T>, index: Signal<number>, arr: SignalLike<readonly T[]>) => Template;
|
|
1092
1092
|
}) => Template;
|
|
1093
1093
|
|
|
1094
1094
|
/**
|
|
@@ -1125,9 +1125,9 @@ declare const Style: FunctionalComponent<{
|
|
|
1125
1125
|
declare const css: (strings: TemplateStringsArray, ...values: MaybeSignal<string | number>[]) => MaybeSignal<string>;
|
|
1126
1126
|
|
|
1127
1127
|
/** @ignore */
|
|
1128
|
-
declare const jsx: (type: any, props?:
|
|
1128
|
+
declare const jsx: (type: any, props?: object & {
|
|
1129
1129
|
key?: unknown;
|
|
1130
|
-
}
|
|
1130
|
+
}, key?: unknown) => Template;
|
|
1131
1131
|
/** @ignore */
|
|
1132
1132
|
declare namespace JSX {
|
|
1133
1133
|
type Element = Template;
|
|
@@ -1143,4 +1143,5 @@ declare namespace JSX {
|
|
|
1143
1143
|
}
|
|
1144
1144
|
}
|
|
1145
1145
|
|
|
1146
|
-
export {
|
|
1146
|
+
export { Component, Else, ElseIf, For, Fragment, If, JSX, MaybeSignal, Portal, Style, TemplateNodes, createContext, createElement, css, defineComponents, event, flushBatch, h, isComponent, jsx, jsx as jsxDEV, jsx as jsxs, prop, useBatch, useContext, useMountEffect as useEffect, useMemo, useRef, useSignal, useSubscope };
|
|
1147
|
+
export type { AttributeOptions, Children, Cleanup, ComponentConstructor, ComponentOptions, Context, DangerousHtml, EventConstructor, FunctionalComponent, Metadata, PropOptions, RefSignal, RefSignalSetter, SetSignalOptions, Signal, SignalLike, SignalSetter, Styles, SubscopeOptions, Template };
|
package/dist/bundle.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
const createScope = (parent) => {
|
|
2
2
|
return {
|
|
3
3
|
_parent: parent,
|
|
4
|
-
_effects:
|
|
5
|
-
_subscopes:
|
|
4
|
+
_effects: new Set(),
|
|
5
|
+
_subscopes: new Set(),
|
|
6
6
|
_details: { ...parent?._details },
|
|
7
7
|
_run(fn) {
|
|
8
8
|
const prevScope = currScope;
|
|
@@ -15,18 +15,19 @@ const createScope = (parent) => {
|
|
|
15
15
|
}
|
|
16
16
|
},
|
|
17
17
|
_cleanup() {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
[...this._subscopes].forEach((_, i, arr) => {
|
|
19
|
+
const subscope = arr[arr.length - 1 - i];
|
|
20
|
+
subscope._cleanup();
|
|
21
|
+
});
|
|
22
|
+
this._subscopes = new Set();
|
|
23
|
+
[...this._effects].forEach((_, i, arr) => {
|
|
24
|
+
const effect = arr[arr.length - 1 - i];
|
|
24
25
|
effect._clean?.();
|
|
25
26
|
effect._run = () => { };
|
|
26
27
|
effect._deps.forEach((signal) => signal._effects.delete(effect));
|
|
27
28
|
effect._deps.clear();
|
|
28
|
-
}
|
|
29
|
-
this._effects =
|
|
29
|
+
});
|
|
30
|
+
this._effects = new Set();
|
|
30
31
|
},
|
|
31
32
|
};
|
|
32
33
|
};
|
|
@@ -170,12 +171,12 @@ const useEffect = (fn, deps) => {
|
|
|
170
171
|
}
|
|
171
172
|
},
|
|
172
173
|
};
|
|
173
|
-
currScope._effects.
|
|
174
|
+
currScope._effects.add(effect);
|
|
174
175
|
effect._run();
|
|
175
176
|
if (!effect._deps.size && !effect._clean) {
|
|
176
177
|
// Optimization: Destroy effect since there's no cleanup and this effect
|
|
177
178
|
// won't be called again
|
|
178
|
-
currScope._effects.
|
|
179
|
+
currScope._effects.delete(effect);
|
|
179
180
|
}
|
|
180
181
|
};
|
|
181
182
|
/**
|
|
@@ -211,15 +212,12 @@ const useSubscope = (fn, opts) => {
|
|
|
211
212
|
const scope = createScope(parent);
|
|
212
213
|
Object.assign(scope._details, opts?.details);
|
|
213
214
|
try {
|
|
214
|
-
parent._subscopes.
|
|
215
|
+
parent._subscopes.add(scope);
|
|
215
216
|
const result = scope._run(fn);
|
|
216
217
|
return [
|
|
217
218
|
result,
|
|
218
219
|
() => {
|
|
219
|
-
|
|
220
|
-
if (index >= 0) {
|
|
221
|
-
parent._subscopes.splice(index, 1);
|
|
222
|
-
}
|
|
220
|
+
parent._subscopes.delete(scope);
|
|
223
221
|
scope._cleanup();
|
|
224
222
|
},
|
|
225
223
|
];
|
|
@@ -472,7 +470,7 @@ const useMountEffect = (fn, deps) => {
|
|
|
472
470
|
*
|
|
473
471
|
* @example
|
|
474
472
|
* ```tsx
|
|
475
|
-
* class MyComponent extends Component(
|
|
473
|
+
* class MyComponent extends Component({
|
|
476
474
|
* myProp: prop<string>("Hello, world!"),
|
|
477
475
|
* onMyEvent: event(),
|
|
478
476
|
* }) {
|
|
@@ -486,10 +484,17 @@ const useMountEffect = (fn, deps) => {
|
|
|
486
484
|
* },
|
|
487
485
|
* }
|
|
488
486
|
*
|
|
489
|
-
*
|
|
487
|
+
* defineComponents(MyComponent);
|
|
490
488
|
* ```
|
|
491
489
|
*/
|
|
492
|
-
const Component = ((
|
|
490
|
+
const Component = ((tagNameOrMetadata, metadataOrOpts, optsParam) => {
|
|
491
|
+
const tagName = typeof tagNameOrMetadata === "string" ? tagNameOrMetadata : null;
|
|
492
|
+
const metadata = typeof tagNameOrMetadata === "string"
|
|
493
|
+
? metadataOrOpts
|
|
494
|
+
: tagNameOrMetadata;
|
|
495
|
+
const opts = (typeof tagNameOrMetadata === "string"
|
|
496
|
+
? optsParam
|
|
497
|
+
: metadataOrOpts) ?? {};
|
|
493
498
|
// Extract attribute information
|
|
494
499
|
const observedAttributes = [];
|
|
495
500
|
const attributePropMap = new Map();
|
|
@@ -517,7 +522,7 @@ const Component = ((tagName, metadata = {}, opts = {}) => {
|
|
|
517
522
|
// Create base class
|
|
518
523
|
opts.shadow ??= { mode: "open" };
|
|
519
524
|
const getRenderParent = (component) => opts.shadow
|
|
520
|
-
? component.shadowRoot ?? component.attachShadow(opts.shadow)
|
|
525
|
+
? (component.shadowRoot ?? component.attachShadow(opts.shadow))
|
|
521
526
|
: component;
|
|
522
527
|
class _Component extends HTMLElement {
|
|
523
528
|
static [componentSym] = {
|
|
@@ -604,7 +609,9 @@ const defineComponents = (...args) => {
|
|
|
604
609
|
? [args[0], args.slice(1)]
|
|
605
610
|
: ["", args];
|
|
606
611
|
for (const component of components) {
|
|
607
|
-
customElements.define(prefix +
|
|
612
|
+
customElements.define(prefix +
|
|
613
|
+
(component[componentSym]._tagName ??
|
|
614
|
+
camelCaseToKebabCase(component.name)), component);
|
|
608
615
|
}
|
|
609
616
|
};
|
|
610
617
|
|
|
@@ -802,7 +809,7 @@ const TagComponent = (tagName, props = {}) => createTemplate(() => {
|
|
|
802
809
|
const svg = tagName == "svg" ? true : !!renderer._svg;
|
|
803
810
|
const node = hydrateElement(renderer._node(() => !svg
|
|
804
811
|
? document.createElement(tagName)
|
|
805
|
-
: document.createElementNS("http://www.w3.org/2000/svg", tagName)), svg, props, true);
|
|
812
|
+
: document.createElementNS("http://www.w3.org/2000/svg", tagName)), svg && tagName === "foreignObject" ? false : svg, props, true);
|
|
806
813
|
return [node];
|
|
807
814
|
});
|
|
808
815
|
|
package/dist/bundle.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const t=t=>({t:t,o:
|
|
1
|
+
const t=t=>({t:t,o:new Set,i:new Set,l:{...t?.l},u(t){const n=o;o=this;try{return t()}finally{o=n}},h(){[...this.i].forEach((t,n,e)=>{e[e.length-1-n].h()}),this.i=new Set,[...this.o].forEach((t,n,e)=>{const o=e[e.length-1-n];o.p?.(),o.u=()=>{},o._.forEach(t=>t.o.delete(o)),o._.clear()}),this.o=new Set}});let n,e,o=t(),s=!1;const r=()=>o,c=(t,o)=>{const r=()=>(!s&&n&&(n._.add(r),r.o.add(n)),r.peek());r.o=new Set,r.peek=()=>t;const c=(n,s)=>{const l={...o,...s};if(l.equals??=(t,n)=>t===n,e){const o="function"==typeof n?n(r.peek()):n;!l?.force&&l.equals(o,r.peek())||(l?.force?t=o:e.m.push(()=>t=o),l?.silent||r.o.forEach(t=>{t.v?e.S.add(t):e.o.add(t)}))}else i(()=>c(n,l))};return[r,c]},i=t=>{if(e)return t();e={m:[],o:new Set,S:new Set};try{const n=t();return l(),n}finally{e=void 0}},l=()=>{for(;e&&e.m.length+e.o.size+e.S.size>0;){e.o.forEach(t=>t.p?.()),e.m.forEach(t=>t()),e.m=[];const t=e.S.values().next().value??e.o.values().next().value;t&&(t.u(),e.S.delete(t),e.o.delete(t))}};let u=!1;const f=(t,e)=>{const r=!!e,c={M:o,v:u,_:new Set,u(){const o=n,c=s;n=this;try{this._.forEach(t=>t.o.delete(this)),this._.clear(),e&&(s=!1,e.forEach(t=>t())),s=r,this.p?.();const n=this.M.u(()=>i(t));this.p=n?()=>{this.M.u(()=>i(n)),this.p=null}:null}finally{n=o,s=c}}};o.o.add(c),c.u(),c._.size||c.p||o.o.delete(c)},a=(t,n)=>{const[e,o]=c(void 0,n);let s=!0;u=!0;try{f(()=>{o(t,s?{force:!0}:{}),s=!1})}finally{u=!1}return e},d=(n,s)=>{const r=e;e=void 0;const c=o,i=t(c);Object.assign(i.l,s?.details);try{c.i.add(i);return[i.u(n),()=>{c.i.delete(i),i.h()}]}finally{e=r}},h=(t,n)=>{const[e,o]=c(t,n);return e.set=o,e},p={upgrade:t=>()=>p.get(t),get:t=>"function"==typeof t?t():t,peek(t){const n=s;s=!0;try{return this.get(t)}finally{s=n}}},_=(t={})=>({k:[],C(t){return this.N?.next().value??t()},...t}),y=()=>{const t=r();return t.l.j??=_()},m=(t,n)=>{const e=y(),o=_({...e,...t}),[s,r]=d(n,{details:{j:o}});return f(()=>r),s},w=t=>(t[0]??"").toLowerCase()+t.slice(1).replace(/[A-Z]/g,t=>"-"+t.toLowerCase()),b=t=>t.startsWith("on:")?t.slice(3):w(t.slice(2)),g=Symbol(),v=(t,n)=>({[g]:Math.random().toString(36).slice(2),A:t,H:n}),S=t=>!!t?.[g],x=(t,n,e)=>{n.addEventListener(t[g],t=>{const n=p.get(e);void 0!==n&&(t.stopPropagation(),t.detail(n))})},M=t=>{const n=y();return a(()=>{let e=t.A;return n.L?.dispatchEvent(new CustomEvent(t[g],{detail:t=>e=t,bubbles:!0,composed:!0})),e})};var k;!function(t){t.forEach=(n,e)=>n.forEach(n=>Array.isArray(n)?t.forEach(n,e):e(n)),t.last=(n,e=n.length-1)=>{if(n.length)for(let o=e;o>=0;o--){const e=n[o];if(!Array.isArray(e))return e;const s=t.last(e);if(s)return s}}}(k||(k={}));const C=t=>({build(){const n=t();return n.build?.()??n}}),E=(t,n)=>({O:"p",T:t,...n}),N=(t=CustomEvent)=>({O:"e",D:t}),j=Symbol();let A;const H=(t,n)=>{A?A.push([t,n]):f(t,n)},L=(t,n,e)=>{const o="string"==typeof t?t:null,s="string"==typeof t?n:t,i=("string"==typeof t?e:n)??{},l=[],u=new Map;for(const t in s){const n=s[t];if("p"==n.O&&n.attribute){"function"==typeof n.attribute&&(n.attribute={transform:n.attribute});const e=n.attribute={name:w(t),static:!1,transform:t=>t,...n.attribute};u.set(e.name,{name:t,meta:n}),e.static||l.push(e.name)}}i.shadow??={mode:"open"};class a extends HTMLElement{static[j]={I:o};static observedAttributes=l;props={};events={};[j]={};constructor(){super();for(const t in s){const n=s[t];if("p"==n.O){const e=S(n.T)?n.T:null,[o,s]=c(e?void 0:n.T);this.props[t]=o,e&&x(e,this,o),Object.defineProperty(this,t,{get:o.peek,set:t=>s(()=>t,{force:!0})})}else if("e"==n.O&&t.startsWith("on")){const e=b(t);this.events[t]=t=>this.dispatchEvent(new n.D(e,t))}}}connectedCallback(){const t=(n=this,i.shadow?n.shadowRoot??n.attachShadow(i.shadow):n);var n;this[j].$=d(()=>m({P:!1,L:this,N:t.childNodes.values()},()=>{this[j].M=r();const n=A;A=[];try{k.forEach(this.render().build(),n=>{t.append(n)}),A.forEach(([t,n])=>f(t,n))}finally{A=n}}))[1]}disconnectedCallback(){this[j].$?.()}attributeChangedCallback(t,n,e){const o=u.get(t);o&&(this[o.name]=null!=e?o.meta.attribute.transform.call(this,e):S(o.meta.T)?void 0:o.meta.T)}}return a},O=t=>!!t?.[j],T=(...t)=>{const[n,e]="string"==typeof t[0]?[t[0],t.slice(1)]:["",t];for(const t of e)customElements.define(n+(t[j].I??w(t.name)),t)},D=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,I=(t,n,e)=>{"-"==n[0]?t.style.setProperty(n,""+e):t.style[n]=null==e?"":"number"!=typeof e||D.test(n)?""+e:e+"px"},$=(t,n,e,o)=>{const s=null==e||!1===e&&!n.includes("-");if(n.startsWith("prop:"))t[n.slice(5)]=e;else if(n.startsWith("attr:"))n=n.slice(5),s?t.removeAttribute(n):t.setAttribute(n,e);else if(!["innerHTML","outerHTML"].includes(n)){if(!["tabIndex","role",...o?["width","height","href","list","form","download","rowSpan","colSpan"]:[]].includes(n)&&n in t)try{return void(t[n]=e)}catch(t){}"function"==typeof e||(s?t.removeAttribute(n):t.setAttribute(n,e))}},z=({text:t,marker:n})=>C(()=>{const e=y(),o=n&&e.C(()=>document.createComment("")),s=e.C(()=>document.createTextNode(""));return f(()=>{const n=""+(p.get(t)??"");s.textContent!=n&&(s.textContent=n)}),o?[o,s]:[s]}),P=({children:t})=>C(()=>Array.isArray(t)?t.flatMap(t=>P({children:t}).build()):null==t?[]:["object"==typeof t?t.build():z({text:t}).build()]),V=(t,n,e,o)=>{const{ref:s,style:c,children:l,dangerouslySetInnerHTML:u,...a}=e;for(const n in c??{}){const e=c[n];f(()=>{I(t,n,p.get(e))})}for(const n in a){const e=a[n];if(n.startsWith("on")){const o=r(),s=t=>{o.u(()=>i(()=>e(t)))},c=b(n);f(()=>(t.addEventListener(c,s),()=>t.removeEventListener(c,s)))}else f(()=>{$(t,n,p.get(e),o)})}return u&&f(()=>{const n=p.get(u).__html;t.innerHTML!=n&&(t.innerHTML=n)}),s&&f(()=>(s.set(t),()=>s.set(void 0))),null!=e.children&&k.forEach(m({P:n,N:t.childNodes.values()},()=>P({children:e.children}).build()),n=>t.append(n)),t},Z=(t,n={},e)=>(null!=e&&(n.children=e),O(t)?((t,n)=>C(()=>{const e=y().C(()=>new t);return customElements.upgrade(e),V(e,!1,n),[e]}))(t,n):"function"==typeof t?C(()=>t(n)):((t,n={})=>C(()=>{const e=y(),o="svg"==t||!!e.P;return[V(e.C(()=>o?document.createElementNS("http://www.w3.org/2000/svg",t):document.createElement(t)),(!o||"foreignObject"!==t)&&o,n,!0)]}))(t,n)),q=new Proxy(Z,{get:(t,n)=>(e,o)=>t(n,e,o)}),B=(t,n)=>{const[e,o]=c({V:[],Z:new Map},{force:!0});let s=new Map;return f(()=>{const e=[],r=s,c=((t,n)=>{const e=new Map;for(let o=0;o<t.length;o++){const s=n(t[o],o);if(e.has(s))throw Error(`Duplicate key '${s}'`);e.set(s,o)}return e})(t(),n),i=(t=NaN)=>e.map(t=>"r"==t.q?n=>n<t.B?n:n==t.B?NaN:n-1:"a"==t.q?n=>n<t.B?n:n+1:"m"==t.q?n=>t.F<=n&&n<t.G?n+1:n==t.G?t.F:n:t=>t).reduce((t,n)=>n(t),t);for(const t of r.keys()){const n=i(r.get(t));c.has(t)||e.push({q:"r",J:t,B:n})}for(let o=0;o<t().length;o++){const s=n(t()[o],o),c=i(r.get(s));isNaN(c)?e.push({q:"a",J:s,B:o}):c!=o&&e.push({q:"m",J:s,G:c,F:o})}e.length>0&&o({V:e,Z:c}),s=c}),e},F=t=>C(()=>{const n=y(),e=p.upgrade(t.each??[]),o=n.C(()=>document.createComment("")),s=t.key??((t,n)=>n),r=[o,[]],i=new Map,l=B(e,s),u=t=>k.last(r[1],t-1)??o;return f(()=>{for(const n of l().V)if("r"==n.q){const{K:t,$:e}=i.get(n.J)??{};e?.(),r[1].splice(n.B,1),k.forEach(t??[],t=>t.parentNode?.removeChild(t)),i.delete(n.J)}else if("a"==n.q){let o;const[,s]=d(()=>{const[s,i]=c(n.B),[a,d]=c(e()[n.B]);f(()=>{0<=s()&&s()<e().length&&d(()=>e()[s()])}),f(()=>{const t=l().Z.get(n.J);null!=t&&i(t)}),o=t.children?.(a,s,e).build()??[],r[1].splice(n.B,0,o);let h=u(n.B);k.forEach(o,t=>{h.parentNode?.insertBefore(t,h.nextSibling),h=t})});i.set(n.J,{K:o,$:s})}else if("m"==n.q){const{K:t}=i.get(n.J)??{};r[1].splice(n.G,1),r[1].splice(n.F,0,t??[]);let e=u(n.F);k.forEach(t??[],t=>{e.parentNode?.insertBefore(t,e.nextSibling),e=t})}},[l]),r}),G=t=>(y().k=[],J({condition:t.condition,children:t.children})),J=t=>{const n=y(),e=n.k,o=p.upgrade(t.condition),s=a(()=>e.every(t=>!t())&&o());return n.k=[...e,o],C(()=>m({k:[]},()=>{const e=n.C(()=>document.createComment("")),o=[e,[]],r=a(()=>s()?P({children:t.children}):null);let c=[];return f(()=>{k.forEach(c,t=>t.parentNode?.removeChild(t)),o[1]=[];const[,t]=d(()=>{c=r()?.build()??[],o[1]=c;let t=e;k.forEach(c,n=>{t.parentNode?.insertBefore(n,t.nextSibling),t=n})});return t},[r]),o}))},K=({children:t})=>J({condition:!0,children:t}),Q=({mount:t,children:n})=>C(()=>m({N:void 0},()=>{const e=P({children:n}).build();return f(()=>(k.forEach(e,n=>t.appendChild(n)),()=>{k.forEach(e,t=>t.parentNode?.removeChild(t))}),[]),[]})),R=Symbol(),U=new Map,W=t=>{const n=t.children;if("function"==typeof n){const e=Z("style",{},z({text:n,marker:!1}));return t.light?Q({mount:document.head,children:e}):e}if(n){const o=y(),s=t.light?document:o.L?.shadowRoot??document,r=((t,n,e)=>{if(!U.has(n)){const t=new CSSStyleSheet;t.replaceSync(n),U.set(n,{R:t,U:0})}const o=U.get(n);o.U++,t.has(n)||t.set(n,{R:o.R,U:0});const s=t.get(n);return s.U++,f(()=>()=>{--s.U||(t.delete(n),e()),--o.U||U.delete(n)}),s.R})((e=s,e[R]??=new Map),n,()=>{s.adoptedStyleSheets=s.adoptedStyleSheets.filter(t=>t!=r)});s.adoptedStyleSheets.push(r)}var e;return P({})},X=(t,...n)=>{const e=()=>t.reduce((t,e,o)=>t+e+(p.get(n[o])??""),"");return n.some(t=>"function"==typeof t)?e:e()},Y=(t,n,e)=>(n&&null!=e&&(n.key=e),Z(t,n));export{L as Component,K as Else,J as ElseIf,F as For,P as Fragment,G as If,p as MaybeSignal,Q as Portal,W as Style,k as TemplateNodes,v as createContext,Z as createElement,X as css,T as defineComponents,N as event,l as flushBatch,q as h,O as isComponent,Y as jsx,Y as jsxDEV,Y as jsxs,E as prop,i as useBatch,M as useContext,H as useEffect,a as useMemo,h as useRef,c as useSignal,d as useSubscope};
|
package/dist/component.d.ts
CHANGED
|
@@ -178,7 +178,7 @@ export type Component<M extends Metadata = {}> = {
|
|
|
178
178
|
export interface ComponentConstructor<M extends Metadata = {}> {
|
|
179
179
|
/** @ignore */
|
|
180
180
|
readonly [componentSym]: {
|
|
181
|
-
readonly _tagName: string;
|
|
181
|
+
readonly _tagName: string | null;
|
|
182
182
|
};
|
|
183
183
|
readonly observedAttributes: readonly string[];
|
|
184
184
|
new (): Component<M>;
|
|
@@ -208,7 +208,7 @@ export declare const useMountEffect: (fn: () => Cleanup, deps?: SignalLike<unkno
|
|
|
208
208
|
*
|
|
209
209
|
* @example
|
|
210
210
|
* ```tsx
|
|
211
|
-
* class MyComponent extends Component(
|
|
211
|
+
* class MyComponent extends Component({
|
|
212
212
|
* myProp: prop<string>("Hello, world!"),
|
|
213
213
|
* onMyEvent: event(),
|
|
214
214
|
* }) {
|
|
@@ -222,15 +222,15 @@ export declare const useMountEffect: (fn: () => Cleanup, deps?: SignalLike<unkno
|
|
|
222
222
|
* },
|
|
223
223
|
* }
|
|
224
224
|
*
|
|
225
|
-
*
|
|
225
|
+
* defineComponents(MyComponent);
|
|
226
226
|
* ```
|
|
227
227
|
*/
|
|
228
|
-
export declare const Component: ((tagName
|
|
228
|
+
export declare const Component: ((tagName?: string) => ComponentConstructor<{}>) & (<const M extends Metadata>(tagName: string, metadata: M, opts?: ComponentOptions) => ComponentConstructor<M>) & (<const M extends Metadata>(metadata: M, opts?: ComponentOptions) => ComponentConstructor<M>);
|
|
229
229
|
/**
|
|
230
230
|
* Determines whether the given value is a component created by
|
|
231
231
|
* extending {@link ComponentConstructor}.
|
|
232
232
|
*/
|
|
233
|
-
export declare const isComponent: (value: any) => value is ComponentConstructor
|
|
233
|
+
export declare const isComponent: (value: any) => value is ComponentConstructor | Component;
|
|
234
234
|
/**
|
|
235
235
|
* Represents a functional component.
|
|
236
236
|
*
|
package/dist/component.js
CHANGED
|
@@ -121,7 +121,7 @@ export const useMountEffect = (fn, deps) => {
|
|
|
121
121
|
*
|
|
122
122
|
* @example
|
|
123
123
|
* ```tsx
|
|
124
|
-
* class MyComponent extends Component(
|
|
124
|
+
* class MyComponent extends Component({
|
|
125
125
|
* myProp: prop<string>("Hello, world!"),
|
|
126
126
|
* onMyEvent: event(),
|
|
127
127
|
* }) {
|
|
@@ -135,10 +135,17 @@ export const useMountEffect = (fn, deps) => {
|
|
|
135
135
|
* },
|
|
136
136
|
* }
|
|
137
137
|
*
|
|
138
|
-
*
|
|
138
|
+
* defineComponents(MyComponent);
|
|
139
139
|
* ```
|
|
140
140
|
*/
|
|
141
|
-
export const Component = ((
|
|
141
|
+
export const Component = ((tagNameOrMetadata, metadataOrOpts, optsParam) => {
|
|
142
|
+
const tagName = typeof tagNameOrMetadata === "string" ? tagNameOrMetadata : null;
|
|
143
|
+
const metadata = typeof tagNameOrMetadata === "string"
|
|
144
|
+
? metadataOrOpts
|
|
145
|
+
: tagNameOrMetadata;
|
|
146
|
+
const opts = (typeof tagNameOrMetadata === "string"
|
|
147
|
+
? optsParam
|
|
148
|
+
: metadataOrOpts) ?? {};
|
|
142
149
|
// Extract attribute information
|
|
143
150
|
const observedAttributes = [];
|
|
144
151
|
const attributePropMap = new Map();
|
|
@@ -166,7 +173,7 @@ export const Component = ((tagName, metadata = {}, opts = {}) => {
|
|
|
166
173
|
// Create base class
|
|
167
174
|
opts.shadow ??= { mode: "open" };
|
|
168
175
|
const getRenderParent = (component) => opts.shadow
|
|
169
|
-
? component.shadowRoot ?? component.attachShadow(opts.shadow)
|
|
176
|
+
? (component.shadowRoot ?? component.attachShadow(opts.shadow))
|
|
170
177
|
: component;
|
|
171
178
|
class _Component extends HTMLElement {
|
|
172
179
|
static [componentSym] = {
|
|
@@ -253,7 +260,9 @@ export const defineComponents = (...args) => {
|
|
|
253
260
|
? [args[0], args.slice(1)]
|
|
254
261
|
: ["", args];
|
|
255
262
|
for (const component of components) {
|
|
256
|
-
customElements.define(prefix +
|
|
263
|
+
customElements.define(prefix +
|
|
264
|
+
(component[componentSym]._tagName ??
|
|
265
|
+
camelCaseToKebabCase(component.name)), component);
|
|
257
266
|
}
|
|
258
267
|
};
|
|
259
268
|
//# sourceMappingURL=component.js.map
|
package/dist/component.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component.js","sourceRoot":"","sources":["../src/component.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,SAAS,EACT,WAAW,EACX,SAAS,GAEV,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EACL,oBAAoB,EAEpB,sBAAsB,GACvB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAW,SAAS,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAClE,OAAO,EAAY,aAAa,EAAE,MAAM,eAAe,CAAC;AAmKxD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,MAAM,CAAC,MAAM,IAAI,GAQiB,CAChC,gBAAiC,EACjC,IAAqB,EACN,EAAE,CAAC,CAAC;IACnB,IAAI,EAAE,GAAG;IACT,iBAAiB,EAAE,gBAAgB;IACnC,GAAG,IAAI;CACR,CAAC,CAAC;AAaH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,MAAM,CAAC,MAAM,KAAK,GAEsD,CAAC,CACvE,mBAAqC,WAAW,EACnB,EAAE,CAAC,CAAC;IACjC,IAAI,EAAE,GAAG;IACT,MAAM,EAAE,gBAAgB;CACzB,CAAC,CAAQ,CAAC;AAeX,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC;AA6DhD,IAAI,YAES,CAAC;AAEd;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAC5B,EAAiB,EACjB,IAA4B,EACtB,EAAE;IACR,IAAI,YAAY,EAAE,CAAC;QACjB,YAAY,CA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AC,iBAAiB,CAAC;YACtC,CAAC;QACH,CAAC;;IAKH,OAAO,UAAiB,CAAC;AAC3B,CAAC,CAAQ,CAAC;AAEV;;;GAGG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CACzB,KAAU,EACiC,EAAE,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,YAAY,CAAC,CAAC;AAkBxE;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAGyC,CACpE,GAAG,IAAgE,EACnE,EAAE;IACF,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,GACxB,OAAO,IAAI,CAAC,CAAC,CAAC,IAAI,QAAQ;QACxB,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAA2B,CAAC;QACpD,CAAC,CAAC,CAAC,EAAE,EAAE,IAA8B,CAAC,CAAC;IAE3C,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;QACnC,cAAc,CAAC,MAAM,CACnB,MAAM;YACJ,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC,QAAQ;gBAC/B,oBAAoB,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,EACzC,SAAS,CACV,CAAC;IACJ,CAAC;AACH,CAAC,CAAC"}
|
package/dist/intrinsic/For.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { Template } from "../template.js";
|
|
|
4
4
|
* `For` is a component that can be used to render a list of items.
|
|
5
5
|
*/
|
|
6
6
|
export declare const For: <T>(props: {
|
|
7
|
-
each?: MaybeSignal<readonly T[]
|
|
8
|
-
key?: (
|
|
9
|
-
children?: (
|
|
7
|
+
each?: MaybeSignal<readonly T[]>;
|
|
8
|
+
key?: (item: T, index: number) => string | number;
|
|
9
|
+
children?: (item: Signal<T>, index: Signal<number>, arr: SignalLike<readonly T[]>) => Template;
|
|
10
10
|
}) => Template;
|
|
@@ -61,7 +61,7 @@ export const TagComponent = (tagName, props = {}) => createTemplate(() => {
|
|
|
61
61
|
const svg = tagName == "svg" ? true : !!renderer._svg;
|
|
62
62
|
const node = hydrateElement(renderer._node(() => !svg
|
|
63
63
|
? document.createElement(tagName)
|
|
64
|
-
: document.createElementNS("http://www.w3.org/2000/svg", tagName)), svg, props, true);
|
|
64
|
+
: document.createElementNS("http://www.w3.org/2000/svg", tagName)), svg && tagName === "foreignObject" ? false : svg, props, true);
|
|
65
65
|
return [node];
|
|
66
66
|
});
|
|
67
67
|
//# sourceMappingURL=TagComponent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TagComponent.js","sourceRoot":"","sources":["../../src/intrinsic/TagComponent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACxD,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACzE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAY,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAEzE,MAAM,CAAC,MAAM,cAAc,GAAG,CAC5B,IAAO,EACP,GAAY,EACZ,KAAoB,EACpB,SAAmB,EAChB,EAAE;IACL,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,QAAQ,EAAE,uBAAuB,EAAE,GAAG,KAAK,EAAE,GAAG,KAAK,CAAC;IAE1E,KAAK,MAAM,IAAI,IAAI,KAAK,IAAI,EAAE,EAAE,CAAC;QAC/B,MAAM,KAAK,GAAG,KAAM,CAAC,IAAI,CAAC,CAAC;QAC3B,MAAM,MAAM,GAAG,KAAwD,CAAC;QAExE,SAAS,CAAC,GAAG,EAAE;YACb,QAAQ,CAAC,IAAI,EAAE,IAAI,EAAE,WAAW,CA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AU,CAAC,MAAM,EAAE;SACjC,EACD,GAAG,EAAE,CAAC,QAAQ,CAAC,EAAE,QAAQ,EAAE,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC,KAAK,EAAE,CACrD,EACD,CAAC,OAAO,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAClC,CAAC;IACJ,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,YAAY,GAAG,CAC1B,OAAe,EACf,QAAuB,EAAE,EACf,EAAE,CACZ,cAAc,CAAC,GAAG,EAAE;IAClB,MAAM,QAAQ,GAAG,WAAW,EAAE,CAAC;IAC/B,MAAM,GAAG,GAAG,OAAO,IAAI,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC;IACtD,MAAM,IAAI,GAAG,cAAc,CACzB,QAAQ,CAAC,KAAK,CAAC,GAAG,EAAE,CAClB,CAAC,GAAG;QACF,CAAC,CAAC,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC;QACjC,CAAC,CAAC,QAAQ,CAAC,eAAe,CAAC,4BAA4B,EAAE,OAAO,CAAC,CACpE,EACD,GAAG,IAAI,OAAO,KAAK,eAAe,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,EAChD,KAAK,EACL,IAAI,CACL,CAAC;IAEF,OAAO,CAAC,IAAI,CAAC,CAAC;AAChB,CAAC,CAAC,CAAC"}
|
|
@@ -2,9 +2,9 @@ import type { Template } from "../template.js";
|
|
|
2
2
|
import type { DomEventProps, DomIntrinsicElements, DomProps } from "../dom.js";
|
|
3
3
|
import type { jsxPropsSym } from "../component.js";
|
|
4
4
|
/** @ignore */
|
|
5
|
-
export declare const jsx: (type: any, props?:
|
|
5
|
+
export declare const jsx: (type: any, props?: object & {
|
|
6
6
|
key?: unknown;
|
|
7
|
-
}
|
|
7
|
+
}, key?: unknown) => Template;
|
|
8
8
|
/** @ignore */
|
|
9
9
|
export declare namespace JSX {
|
|
10
10
|
type Element = Template;
|
package/dist/scope.d.ts
CHANGED
|
@@ -58,8 +58,8 @@ interface Effect {
|
|
|
58
58
|
export type Cleanup = (() => void) | void | undefined | null;
|
|
59
59
|
export interface Scope<out T = {}> {
|
|
60
60
|
readonly _parent?: Scope;
|
|
61
|
-
_effects: Effect
|
|
62
|
-
_subscopes: Scope
|
|
61
|
+
_effects: Set<Effect>;
|
|
62
|
+
_subscopes: Set<Scope>;
|
|
63
63
|
_details: T;
|
|
64
64
|
_run<T>(fn: () => T): T;
|
|
65
65
|
_cleanup(): void;
|
|
@@ -137,10 +137,10 @@ export declare const MaybeSignal: {
|
|
|
137
137
|
/**
|
|
138
138
|
* Gets the value of the given {@link MaybeSignal}.
|
|
139
139
|
*/
|
|
140
|
-
get: <
|
|
140
|
+
get: <T>(signal: MaybeSignal<T>) => T;
|
|
141
141
|
/**
|
|
142
142
|
* Accesses the value of the given {@link MaybeSignal} without tracking.
|
|
143
143
|
*/
|
|
144
|
-
peek<
|
|
144
|
+
peek<T>(signal: MaybeSignal<T>): T;
|
|
145
145
|
};
|
|
146
146
|
export {};
|
package/dist/scope.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
const createScope = (parent) => {
|
|
2
2
|
return {
|
|
3
3
|
_parent: parent,
|
|
4
|
-
_effects:
|
|
5
|
-
_subscopes:
|
|
4
|
+
_effects: new Set(),
|
|
5
|
+
_subscopes: new Set(),
|
|
6
6
|
_details: { ...parent?._details },
|
|
7
7
|
_run(fn) {
|
|
8
8
|
const prevScope = currScope;
|
|
@@ -15,18 +15,19 @@ const createScope = (parent) => {
|
|
|
15
15
|
}
|
|
16
16
|
},
|
|
17
17
|
_cleanup() {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
[...this._subscopes].forEach((_, i, arr) => {
|
|
19
|
+
const subscope = arr[arr.length - 1 - i];
|
|
20
|
+
subscope._cleanup();
|
|
21
|
+
});
|
|
22
|
+
this._subscopes = new Set();
|
|
23
|
+
[...this._effects].forEach((_, i, arr) => {
|
|
24
|
+
const effect = arr[arr.length - 1 - i];
|
|
24
25
|
effect._clean?.();
|
|
25
26
|
effect._run = () => { };
|
|
26
27
|
effect._deps.forEach((signal) => signal._effects.delete(effect));
|
|
27
28
|
effect._deps.clear();
|
|
28
|
-
}
|
|
29
|
-
this._effects =
|
|
29
|
+
});
|
|
30
|
+
this._effects = new Set();
|
|
30
31
|
},
|
|
31
32
|
};
|
|
32
33
|
};
|
|
@@ -170,12 +171,12 @@ export const useEffect = (fn, deps) => {
|
|
|
170
171
|
}
|
|
171
172
|
},
|
|
172
173
|
};
|
|
173
|
-
currScope._effects.
|
|
174
|
+
currScope._effects.add(effect);
|
|
174
175
|
effect._run();
|
|
175
176
|
if (!effect._deps.size && !effect._clean) {
|
|
176
177
|
// Optimization: Destroy effect since there's no cleanup and this effect
|
|
177
178
|
// won't be called again
|
|
178
|
-
currScope._effects.
|
|
179
|
+
currScope._effects.delete(effect);
|
|
179
180
|
}
|
|
180
181
|
};
|
|
181
182
|
/**
|
|
@@ -211,15 +212,12 @@ export const useSubscope = (fn, opts) => {
|
|
|
211
212
|
const scope = createScope(parent);
|
|
212
213
|
Object.assign(scope._details, opts?.details);
|
|
213
214
|
try {
|
|
214
|
-
parent._subscopes.
|
|
215
|
+
parent._subscopes.add(scope);
|
|
215
216
|
const result = scope._run(fn);
|
|
216
217
|
return [
|
|
217
218
|
result,
|
|
218
219
|
() => {
|
|
219
|
-
|
|
220
|
-
if (index >= 0) {
|
|
221
|
-
parent._subscopes.splice(index, 1);
|
|
222
|
-
}
|
|
220
|
+
parent._subscopes.delete(scope);
|
|
223
221
|
scope._cleanup();
|
|
224
222
|
},
|
|
225
223
|
];
|