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/dist/scope.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scope.js","sourceRoot":"","sources":["../src/scope.ts"],"names":[],"mappings":"AA8EA,MAAM,WAAW,GAAG,CAAC,MAAc,EAAS,EAAE;IAC5C,OAAO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AAC,MAAM,CAAC,CAAC;QAC1B,CAAC;gBAAS,CAAC;YACT,aAAa,GAAG,aAAa,CAAC;QAChC,CAAC;IACH,CAAC;CACF,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sinho",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.3",
|
|
4
4
|
"description": "A lightweight signal-based library for building web components with a React-like API.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ui",
|
|
@@ -32,6 +32,12 @@
|
|
|
32
32
|
"default": "./dist/jsx-runtime/mod.js"
|
|
33
33
|
}
|
|
34
34
|
},
|
|
35
|
+
"./jsx-dev-runtime": {
|
|
36
|
+
"import": {
|
|
37
|
+
"types": "./dist/jsx-runtime/mod.d.ts",
|
|
38
|
+
"default": "./dist/jsx-runtime/mod.js"
|
|
39
|
+
}
|
|
40
|
+
},
|
|
35
41
|
"./min": {
|
|
36
42
|
"import": {
|
|
37
43
|
"types": "./dist/mod.d.ts",
|
|
@@ -43,6 +49,12 @@
|
|
|
43
49
|
"types": "./dist/mod.d.ts",
|
|
44
50
|
"default": "./dist/bundle.min.js"
|
|
45
51
|
}
|
|
52
|
+
},
|
|
53
|
+
"./min/jsx-dev-runtime": {
|
|
54
|
+
"import": {
|
|
55
|
+
"types": "./dist/mod.d.ts",
|
|
56
|
+
"default": "./dist/bundle.min.js"
|
|
57
|
+
}
|
|
46
58
|
}
|
|
47
59
|
},
|
|
48
60
|
"scripts": {
|
|
@@ -51,21 +63,21 @@
|
|
|
51
63
|
"build": "tsc && npm run bundle && npm run minify",
|
|
52
64
|
"bundle": "rollup ./dist/mod.js --file ./dist/bundle.js --format es --plugin @rollup/plugin-node-resolve && rollup ./dist/mod.d.ts --file ./dist/bundle.d.ts --format es --plugin rollup-plugin-dts",
|
|
53
65
|
"minify": "terser ./dist/bundle.js --output ./dist/bundle.min.js --config-file ./terser.config.json",
|
|
54
|
-
"test": "node --
|
|
66
|
+
"test": "node --experimental-test-coverage --test \"./dist/**/*.test.js\"",
|
|
55
67
|
"build-test": "npm run build && npm test",
|
|
56
68
|
"check-size": "node ./ci/check-size.js",
|
|
57
69
|
"build-samples": "tsc --project ./samples/tsconfig.json && rollup ./samples/dist/counter/mod.js --file ./samples/dist/counter/bundle.js --format es --plugin @rollup/plugin-node-resolve && rollup ./samples/dist/theme/mod.js --file ./samples/dist/theme/bundle.js --format es --plugin @rollup/plugin-node-resolve && rollup ./samples/dist/todo/mod.js --file ./samples/dist/todo/bundle.js --format es --plugin @rollup/plugin-node-resolve"
|
|
58
70
|
},
|
|
59
71
|
"devDependencies": {
|
|
60
|
-
"@happy-dom/global-registrator": "^
|
|
61
|
-
"@rollup/plugin-node-resolve": "^
|
|
62
|
-
"@types/node": "^
|
|
72
|
+
"@happy-dom/global-registrator": "^20.8.7",
|
|
73
|
+
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
74
|
+
"@types/node": "^24.12.0",
|
|
63
75
|
"copyfiles": "^2.4.1",
|
|
64
76
|
"prettier": "^3.2.5",
|
|
65
77
|
"rollup": "^4.13.0",
|
|
66
78
|
"rollup-plugin-dts": "^6.1.0",
|
|
67
79
|
"serve": "^14.2.1",
|
|
68
80
|
"terser": "^5.29.2",
|
|
69
|
-
"typescript": "^
|
|
81
|
+
"typescript": "^6.0.2"
|
|
70
82
|
}
|
|
71
83
|
}
|
package/src/component.ts
CHANGED
|
@@ -356,7 +356,7 @@ export type Component<M extends Metadata = {}> = {
|
|
|
356
356
|
export interface ComponentConstructor<M extends Metadata = {}> {
|
|
357
357
|
/** @ignore */
|
|
358
358
|
readonly [componentSym]: {
|
|
359
|
-
readonly _tagName: string;
|
|
359
|
+
readonly _tagName: string | null;
|
|
360
360
|
};
|
|
361
361
|
readonly observedAttributes: readonly string[];
|
|
362
362
|
|
|
@@ -403,7 +403,7 @@ export const useMountEffect = (
|
|
|
403
403
|
*
|
|
404
404
|
* @example
|
|
405
405
|
* ```tsx
|
|
406
|
-
* class MyComponent extends Component(
|
|
406
|
+
* class MyComponent extends Component({
|
|
407
407
|
* myProp: prop<string>("Hello, world!"),
|
|
408
408
|
* onMyEvent: event(),
|
|
409
409
|
* }) {
|
|
@@ -417,19 +417,34 @@ export const useMountEffect = (
|
|
|
417
417
|
* },
|
|
418
418
|
* }
|
|
419
419
|
*
|
|
420
|
-
*
|
|
420
|
+
* defineComponents(MyComponent);
|
|
421
421
|
* ```
|
|
422
422
|
*/
|
|
423
|
-
export const Component: ((tagName
|
|
423
|
+
export const Component: ((tagName?: string) => ComponentConstructor<{}>) &
|
|
424
424
|
(<const M extends Metadata>(
|
|
425
425
|
tagName: string,
|
|
426
426
|
metadata: M,
|
|
427
427
|
opts?: ComponentOptions,
|
|
428
|
+
) => ComponentConstructor<M>) &
|
|
429
|
+
(<const M extends Metadata>(
|
|
430
|
+
metadata: M,
|
|
431
|
+
opts?: ComponentOptions,
|
|
428
432
|
) => ComponentConstructor<M>) = ((
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
433
|
+
tagNameOrMetadata?: string | Metadata,
|
|
434
|
+
metadataOrOpts?: Metadata | ComponentOptions,
|
|
435
|
+
optsParam?: ComponentOptions,
|
|
432
436
|
): ComponentConstructor => {
|
|
437
|
+
const tagName =
|
|
438
|
+
typeof tagNameOrMetadata === "string" ? tagNameOrMetadata : null;
|
|
439
|
+
const metadata =
|
|
440
|
+
typeof tagNameOrMetadata === "string"
|
|
441
|
+
? (metadataOrOpts as Metadata)
|
|
442
|
+
: tagNameOrMetadata;
|
|
443
|
+
const opts =
|
|
444
|
+
(typeof tagNameOrMetadata === "string"
|
|
445
|
+
? optsParam
|
|
446
|
+
: (metadataOrOpts as ComponentOptions)) ?? {};
|
|
447
|
+
|
|
433
448
|
// Extract attribute information
|
|
434
449
|
|
|
435
450
|
const observedAttributes: string[] = [];
|
|
@@ -477,7 +492,7 @@ export const Component: ((tagName: string) => ComponentConstructor<{}>) &
|
|
|
477
492
|
|
|
478
493
|
const getRenderParent = (component: _Component) =>
|
|
479
494
|
opts.shadow
|
|
480
|
-
? component.shadowRoot ?? component.attachShadow(opts.shadow)
|
|
495
|
+
? (component.shadowRoot ?? component.attachShadow(opts.shadow))
|
|
481
496
|
: component;
|
|
482
497
|
abstract class _Component extends HTMLElement {
|
|
483
498
|
static readonly [componentSym]: ComponentConstructor[typeof componentSym] =
|
|
@@ -624,6 +639,11 @@ export const defineComponents: ((
|
|
|
624
639
|
: ["", args as ComponentConstructor[]];
|
|
625
640
|
|
|
626
641
|
for (const component of components) {
|
|
627
|
-
customElements.define(
|
|
642
|
+
customElements.define(
|
|
643
|
+
prefix +
|
|
644
|
+
(component[componentSym]._tagName ??
|
|
645
|
+
camelCaseToKebabCase(component.name)),
|
|
646
|
+
component,
|
|
647
|
+
);
|
|
628
648
|
}
|
|
629
649
|
};
|
package/src/scope.ts
CHANGED
|
@@ -68,8 +68,8 @@ export type Cleanup = (() => void) | void | undefined | null;
|
|
|
68
68
|
|
|
69
69
|
export interface Scope<out T = {}> {
|
|
70
70
|
readonly _parent?: Scope;
|
|
71
|
-
_effects: Effect
|
|
72
|
-
_subscopes: Scope
|
|
71
|
+
_effects: Set<Effect>;
|
|
72
|
+
_subscopes: Set<Scope>;
|
|
73
73
|
_details: T;
|
|
74
74
|
|
|
75
75
|
_run<T>(fn: () => T): T;
|
|
@@ -79,8 +79,8 @@ export interface Scope<out T = {}> {
|
|
|
79
79
|
const createScope = (parent?: Scope): Scope => {
|
|
80
80
|
return {
|
|
81
81
|
_parent: parent,
|
|
82
|
-
_effects:
|
|
83
|
-
_subscopes:
|
|
82
|
+
_effects: new Set(),
|
|
83
|
+
_subscopes: new Set(),
|
|
84
84
|
_details: { ...parent?._details },
|
|
85
85
|
|
|
86
86
|
_run<T>(fn: () => T): T {
|
|
@@ -95,22 +95,23 @@ const createScope = (parent?: Scope): Scope => {
|
|
|
95
95
|
},
|
|
96
96
|
|
|
97
97
|
_cleanup(): void {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
98
|
+
[...this._subscopes].forEach((_, i, arr) => {
|
|
99
|
+
const subscope = arr[arr.length - 1 - i];
|
|
100
|
+
subscope._cleanup();
|
|
101
|
+
});
|
|
101
102
|
|
|
102
|
-
this._subscopes =
|
|
103
|
+
this._subscopes = new Set();
|
|
103
104
|
|
|
104
|
-
|
|
105
|
-
const effect =
|
|
105
|
+
[...this._effects].forEach((_, i, arr) => {
|
|
106
|
+
const effect = arr[arr.length - 1 - i];
|
|
106
107
|
effect._clean?.();
|
|
107
108
|
effect._run = () => {};
|
|
108
109
|
|
|
109
110
|
effect._deps.forEach((signal) => signal._effects.delete(effect));
|
|
110
111
|
effect._deps.clear();
|
|
111
|
-
}
|
|
112
|
+
});
|
|
112
113
|
|
|
113
|
-
this._effects =
|
|
114
|
+
this._effects = new Set();
|
|
114
115
|
},
|
|
115
116
|
};
|
|
116
117
|
};
|
|
@@ -307,14 +308,14 @@ export const useEffect = (
|
|
|
307
308
|
},
|
|
308
309
|
};
|
|
309
310
|
|
|
310
|
-
currScope._effects.
|
|
311
|
+
currScope._effects.add(effect);
|
|
311
312
|
effect._run();
|
|
312
313
|
|
|
313
314
|
if (!effect._deps.size && !effect._clean) {
|
|
314
315
|
// Optimization: Destroy effect since there's no cleanup and this effect
|
|
315
316
|
// won't be called again
|
|
316
317
|
|
|
317
|
-
currScope._effects.
|
|
318
|
+
currScope._effects.delete(effect);
|
|
318
319
|
}
|
|
319
320
|
};
|
|
320
321
|
|
|
@@ -363,17 +364,13 @@ export const useSubscope = <T>(
|
|
|
363
364
|
Object.assign(scope._details, opts?.details);
|
|
364
365
|
|
|
365
366
|
try {
|
|
366
|
-
parent._subscopes.
|
|
367
|
+
parent._subscopes.add(scope);
|
|
367
368
|
const result = scope._run(fn);
|
|
368
369
|
|
|
369
370
|
return [
|
|
370
371
|
result,
|
|
371
372
|
() => {
|
|
372
|
-
|
|
373
|
-
if (index >= 0) {
|
|
374
|
-
parent._subscopes.splice(index, 1);
|
|
375
|
-
}
|
|
376
|
-
|
|
373
|
+
parent._subscopes.delete(scope);
|
|
377
374
|
scope._cleanup();
|
|
378
375
|
},
|
|
379
376
|
];
|
package/web/docusaurus.config.ts
CHANGED
|
@@ -88,11 +88,6 @@ const config: Config = {
|
|
|
88
88
|
position: "left",
|
|
89
89
|
label: "Documentation",
|
|
90
90
|
},
|
|
91
|
-
{
|
|
92
|
-
to: "api",
|
|
93
|
-
label: "API",
|
|
94
|
-
position: "left",
|
|
95
|
-
},
|
|
96
91
|
{
|
|
97
92
|
to: "playground",
|
|
98
93
|
label: "Playground",
|
|
@@ -122,19 +117,6 @@ const config: Config = {
|
|
|
122
117
|
} satisfies Preset.ThemeConfig,
|
|
123
118
|
|
|
124
119
|
plugins: [
|
|
125
|
-
[
|
|
126
|
-
"docusaurus-plugin-typedoc-api",
|
|
127
|
-
{
|
|
128
|
-
projectRoot: path.join(__dirname, ".."),
|
|
129
|
-
packages: [
|
|
130
|
-
{
|
|
131
|
-
path: "./",
|
|
132
|
-
entry: "./src/mod.ts",
|
|
133
|
-
},
|
|
134
|
-
],
|
|
135
|
-
minimal: true,
|
|
136
|
-
},
|
|
137
|
-
],
|
|
138
120
|
() => ({
|
|
139
121
|
name: "monaco",
|
|
140
122
|
configureWebpack: () => ({
|