@stencil/core 5.0.0-next.0 → 5.0.0-rc.1

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.
Files changed (58) hide show
  1. package/README.md +94 -0
  2. package/bin/stencil.mjs +1 -1
  3. package/dist/app-data/index.d.ts +2 -0
  4. package/dist/{runtime/app-data → app-data}/index.js +23 -15
  5. package/dist/{runtime/app-globals → app-globals}/index.js +1 -2
  6. package/dist/client-BMtGBEQV.mjs +2498 -0
  7. package/dist/compiler/browser.d.ts +1573 -0
  8. package/dist/compiler/browser.js +16998 -0
  9. package/dist/compiler/index.d.mts +284 -7
  10. package/dist/compiler/index.mjs +3 -9
  11. package/dist/compiler/utils/index.d.mts +272 -3
  12. package/dist/compiler/utils/index.mjs +4 -5
  13. package/dist/{transpile-CJQcQEVa.mjs → compiler-C_Y38j4m.mjs} +20984 -15554
  14. package/dist/declarations/stencil-ext-modules.d.ts +8 -8
  15. package/dist/declarations/stencil-public-compiler.d.ts +1016 -840
  16. package/dist/declarations/stencil-public-compiler.js +3 -5
  17. package/dist/declarations/stencil-public-docs.d.ts +441 -376
  18. package/dist/declarations/stencil-public-docs.js +0 -0
  19. package/dist/declarations/stencil-public-runtime.d.ts +361 -113
  20. package/dist/fragment-Di1hWOC8.mjs +4 -0
  21. package/dist/helpers-pTCZhNi0.mjs +529 -0
  22. package/dist/{index-szczUd2l.d.mts → index-CFiy6MZ3.d.mts} +1471 -2044
  23. package/dist/index-CViiWNQ9.d.mts +104 -0
  24. package/dist/{stencil-private-Cgcr414u.d.ts → index-XQHZl0MW.d.ts} +308 -114
  25. package/dist/index.d.mts +14 -2
  26. package/dist/index.mjs +171 -4
  27. package/dist/jsx-runtime.d.mts +24 -0
  28. package/dist/jsx-runtime.mjs +3 -0
  29. package/dist/mock-doc.mjs +2 -3
  30. package/dist/{node-sys-BGURUNOZ.mjs → node-Bkq8vRnu.mjs} +176 -197
  31. package/dist/rolldown-runtime-BhDjJH2R.mjs +15 -0
  32. package/dist/{client-DR9zhmKG.mjs → runtime/client/lazy.js} +3794 -2659
  33. package/dist/runtime/client/{index.d.ts → runtime.d.ts} +516 -227
  34. package/dist/runtime/client/{index.js → runtime.js} +3596 -2857
  35. package/dist/runtime/index.d.ts +90 -72
  36. package/dist/runtime/index.js +3528 -2897
  37. package/dist/runtime/server/index.d.mts +243 -219
  38. package/dist/runtime/server/index.mjs +3770 -3352
  39. package/dist/runtime/server/runner.d.mts +114 -47
  40. package/dist/runtime/server/runner.mjs +12710 -763
  41. package/dist/signals/index.d.ts +58 -0
  42. package/dist/signals/index.js +182 -0
  43. package/dist/sys/node/index.d.mts +1 -3
  44. package/dist/sys/node/index.mjs +2 -7
  45. package/dist/sys/node/worker.d.mts +1 -1
  46. package/dist/sys/node/worker.mjs +3 -12
  47. package/dist/testing/index.d.mts +4763 -12
  48. package/dist/testing/index.mjs +7945 -618
  49. package/dist/util-CP6-333M.mjs +731 -0
  50. package/dist/validation-C1mr0klL.mjs +825 -0
  51. package/package.json +91 -59
  52. package/dist/chunk-ClPoSABd.mjs +0 -21
  53. package/dist/index-Bxo2jCf6.d.mts +0 -77
  54. package/dist/runtime/app-data/index.d.ts +0 -30
  55. package/dist/serialize-BJvhE9aQ.mjs +0 -775
  56. package/dist/validation-BdcPruW_.mjs +0 -1451
  57. /package/{LICENSE.md → LICENSE} +0 -0
  58. /package/dist/{runtime/app-globals → app-globals}/index.d.ts +0 -0
@@ -0,0 +1,58 @@
1
+ import * as SignalsCore from "@preact/signals-core";
2
+ import { ReadonlySignal, Signal } from "@preact/signals-core";
3
+ import "rolldown";
4
+ import "typescript";
5
+ //#region src/runtime/signals-core.d.ts
6
+ declare const batch: typeof SignalsCore.batch;
7
+ declare const computed: typeof SignalsCore.computed;
8
+ declare const effect: typeof SignalsCore.effect;
9
+ declare const untracked: typeof SignalsCore.untracked;
10
+ declare function signal<T>(value: T, options?: SignalsCore.SignalOptions<T>): SignalsCore.Signal<T>;
11
+ declare function signal<T = undefined>(): SignalsCore.Signal<T | undefined>;
12
+ //#endregion
13
+ //#region src/runtime/signals.d.ts
14
+ declare const STENCIL_SIGNALS_SYMBOL: unique symbol;
15
+ //#endregion
16
+ //#region src/signals/index.d.ts
17
+ /**
18
+ * Returns the `ReadonlySignal` backing a `@Prop` member on a Stencil element.
19
+ * Requires `signalBacking: true` in `stencil.config.ts`.
20
+ * Only `@Prop` members are exposed - `@State` is internal component state.
21
+ *
22
+ * Useful for cross-component or cross-framework reactivity without polling or events:
23
+ * ```ts
24
+ * import { getSignal, computed } from '@stencil/core/signals';
25
+ *
26
+ * const count = getSignal<number>(myEl, 'count');
27
+ * const doubled = computed(() => count.value * 2);
28
+ * ```
29
+ *
30
+ * @param elm - the Stencil host element
31
+ * @param prop - the `@Prop` member name
32
+ * @returns the `ReadonlySignal` for the prop, or `null` if not found / not signal-backed
33
+ */
34
+ declare const getSignal: <T = unknown>(elm: Element, prop: string) => ReadonlySignal<T> | null;
35
+ /**
36
+ * Marks a class method as a reactive effect. Wraps the method in `effect()` after
37
+ * signal initialization and registers cleanup on disconnect. Dependencies are
38
+ * auto-tracked - any signal read inside re-runs the method on change.
39
+ *
40
+ * @example
41
+ * ```ts
42
+ * import { Effect } from '@stencil/core/signals';
43
+ *
44
+ * @Component({ tag: 'my-cmp' })
45
+ * export class MyCmp {
46
+ * @State() count = 0;
47
+ *
48
+ * @Effect()
49
+ * log() {
50
+ * console.log(this.count); // re-runs whenever count changes
51
+ * }
52
+ * }
53
+ * ```
54
+ * @returns a MethodDecorator that registers the method as a reactive effect
55
+ */
56
+ declare function Effect(): MethodDecorator;
57
+ //#endregion
58
+ export { Effect, type ReadonlySignal, STENCIL_SIGNALS_SYMBOL, type Signal, batch, computed, effect, getSignal, signal, untracked };
@@ -0,0 +1,182 @@
1
+ import * as SignalsCore from "@preact/signals-core";
2
+ //#region src/app-data/index.ts
3
+ /**
4
+ * A collection of default build flags for a Stencil project.
5
+ *
6
+ * This collection can be found throughout the Stencil codebase, often imported from the `virtual:app-data` module like so:
7
+ * ```ts
8
+ * import { BUILD } from 'virtual:app-data';
9
+ * ```
10
+ * and is used to determine if a portion of the output of a Stencil _project_'s compilation step can be eliminated.
11
+ *
12
+ * e.g. When `BUILD.allRenderFn` evaluates to `false`, the compiler will eliminate conditional statements like:
13
+ * ```ts
14
+ * if (BUILD.allRenderFn) {
15
+ * // some code that will be eliminated if BUILD.allRenderFn is false
16
+ * }
17
+ * ```
18
+ *
19
+ * `virtual:app-data`, the module that `BUILD` is imported from, is an alias for `@stencil/core/app-data`, and is
20
+ * partially referenced by {@link STENCIL_APP_DATA_ID}. The `src/compiler/bundle/app-data-plugin.ts` references
21
+ * `STENCIL_APP_DATA_ID` uses it to replace these defaults with {@link BuildConditionals} that are derived from a
22
+ * Stencil project's contents (i.e. metadata from the components). This replacement happens at a Stencil project's
23
+ * compile time. Such code can be found at `src/compiler/app-core/app-data.ts`.
24
+ */
25
+ const BUILD = {
26
+ allRenderFn: false,
27
+ element: true,
28
+ event: true,
29
+ hasRenderFn: true,
30
+ hostListener: true,
31
+ hostListenerTargetWindow: true,
32
+ hostListenerTargetDocument: true,
33
+ hostListenerTargetBody: true,
34
+ hostListenerTarget: true,
35
+ member: true,
36
+ method: true,
37
+ mode: true,
38
+ observeAttribute: true,
39
+ prop: true,
40
+ propMutable: true,
41
+ reflect: true,
42
+ scoped: true,
43
+ shadowDom: true,
44
+ shadowModeClosed: false,
45
+ slot: true,
46
+ cssAnnotations: true,
47
+ state: true,
48
+ style: true,
49
+ formAssociated: true,
50
+ svg: true,
51
+ updatable: true,
52
+ vdomAttribute: true,
53
+ vdomXlink: true,
54
+ vdomClass: true,
55
+ vdomFunctional: true,
56
+ vdomKey: true,
57
+ vdomListener: true,
58
+ vdomRef: true,
59
+ vdomPropOrAttr: true,
60
+ vdomPropOrAttrPrefix: true,
61
+ vdomRender: true,
62
+ vdomStyle: true,
63
+ vdomText: true,
64
+ propChangeCallback: true,
65
+ taskQueue: true,
66
+ lifecycle: true,
67
+ serializer: true,
68
+ deserializer: true,
69
+ patchAll: true,
70
+ patchChildren: true,
71
+ patchClone: true,
72
+ patchInsert: true,
73
+ hotModuleReplacement: false,
74
+ isDebug: false,
75
+ isDev: false,
76
+ isTesting: false,
77
+ hydrateServerSide: false,
78
+ hydrateClientSide: true,
79
+ lifecycleDOMEvents: false,
80
+ lazyLoad: false,
81
+ profile: false,
82
+ slotRelocation: true,
83
+ lightDomPatches: true,
84
+ slotChildNodes: true,
85
+ slotCloneNode: true,
86
+ slotDomMutations: true,
87
+ slotTextContent: true,
88
+ hydratedAttribute: false,
89
+ hydratedClass: true,
90
+ invisiblePrehydration: true,
91
+ staticHydrationStyles: false,
92
+ propBoolean: true,
93
+ propNumber: true,
94
+ propString: true,
95
+ constructableCSS: true,
96
+ devTools: false,
97
+ shadowDelegatesFocus: true,
98
+ shadowSlotAssignmentManual: false,
99
+ shadowClonable: true,
100
+ shadowSerializable: true,
101
+ shadowReferenceTarget: true,
102
+ initializeNextTick: false,
103
+ asyncLoading: true,
104
+ asyncQueue: false
105
+ };
106
+ //#endregion
107
+ //#region src/client/client-log.ts
108
+ const STENCIL_DEV_MODE = BUILD.isTesting ? ["STENCIL:"] : ["%cstencil", "color: white;background:#4c47ff;font-weight: bold; font-size:10px; padding:2px 6px; border-radius: 5px"];
109
+ const consoleDevWarn = (...m) => console.warn(...STENCIL_DEV_MODE, ...m);
110
+ /*!__STENCIL_STATIC_IMPORT_SWITCH__*/
111
+ (typeof window !== "undefined" ? window : {}).HTMLElement;
112
+ BUILD.constructableCSS;
113
+ //#endregion
114
+ //#region src/runtime/signals-core.ts
115
+ const getCore = () => globalThis[Symbol.for("stencil.preact-signals-core")] ??= SignalsCore;
116
+ const batch = (fn) => getCore().batch(fn);
117
+ const computed = (fn, options) => getCore().computed(fn, options);
118
+ const effect = (fn, options) => getCore().effect(fn, options);
119
+ const untracked = (fn) => getCore().untracked(fn);
120
+ function signal(value, options) {
121
+ return getCore().signal(value, options);
122
+ }
123
+ //#endregion
124
+ //#region src/runtime/signals.ts
125
+ const STENCIL_SIGNALS_SYMBOL = Symbol.for("stencil.signals");
126
+ BUILD.lazyLoad || globalThis.HTMLElement;
127
+ //#endregion
128
+ //#region src/signals/index.ts
129
+ /**
130
+ * Returns the `ReadonlySignal` backing a `@Prop` member on a Stencil element.
131
+ * Requires `signalBacking: true` in `stencil.config.ts`.
132
+ * Only `@Prop` members are exposed - `@State` is internal component state.
133
+ *
134
+ * Useful for cross-component or cross-framework reactivity without polling or events:
135
+ * ```ts
136
+ * import { getSignal, computed } from '@stencil/core/signals';
137
+ *
138
+ * const count = getSignal<number>(myEl, 'count');
139
+ * const doubled = computed(() => count.value * 2);
140
+ * ```
141
+ *
142
+ * @param elm - the Stencil host element
143
+ * @param prop - the `@Prop` member name
144
+ * @returns the `ReadonlySignal` for the prop, or `null` if not found / not signal-backed
145
+ */
146
+ const getSignal = (elm, prop) => {
147
+ const signals = elm[STENCIL_SIGNALS_SYMBOL];
148
+ if (!signals) {
149
+ if (BUILD.isDev) consoleDevWarn(`getSignal('${prop}'): element <${elm.tagName.toLowerCase()}> is not signal-backed. Ensure signalBacking is true in stencil.config.ts.`);
150
+ return null;
151
+ }
152
+ return signals.get(prop) ?? null;
153
+ };
154
+ /**
155
+ * Marks a class method as a reactive effect. Wraps the method in `effect()` after
156
+ * signal initialization and registers cleanup on disconnect. Dependencies are
157
+ * auto-tracked - any signal read inside re-runs the method on change.
158
+ *
159
+ * @example
160
+ * ```ts
161
+ * import { Effect } from '@stencil/core/signals';
162
+ *
163
+ * @Component({ tag: 'my-cmp' })
164
+ * export class MyCmp {
165
+ * @State() count = 0;
166
+ *
167
+ * @Effect()
168
+ * log() {
169
+ * console.log(this.count); // re-runs whenever count changes
170
+ * }
171
+ * }
172
+ * ```
173
+ * @returns a MethodDecorator that registers the method as a reactive effect
174
+ */
175
+ function Effect() {
176
+ return (target, propertyKey) => {
177
+ const proto = target;
178
+ (proto.__stencilEffects ??= []).push(propertyKey);
179
+ };
180
+ }
181
+ //#endregion
182
+ export { Effect, STENCIL_SIGNALS_SYMBOL, batch, computed, effect, getSignal, signal, untracked };
@@ -1,6 +1,4 @@
1
- import "../../chunk-ClPoSABd.mjs";
2
- import { gr as CompilerSystem, ri as Logger } from "../../index-szczUd2l.mjs";
3
-
1
+ import { Bt as Logger, nt as CompilerSystem } from "../../index-CFiy6MZ3.mjs";
4
2
  //#region src/sys/node/logger/index.d.ts
5
3
  /**
6
4
  * Create a logger to run in a Node environment
@@ -1,7 +1,2 @@
1
- import "../../chunk-ClPoSABd.mjs";
2
- import "../../client-DR9zhmKG.mjs";
3
- import "../../serialize-BJvhE9aQ.mjs";
4
- import "../../validation-BdcPruW_.mjs";
5
- import { n as setupNodeProcess, r as createNodeLogger, t as createNodeSys } from "../../node-sys-BGURUNOZ.mjs";
6
-
7
- export { createNodeLogger, createNodeSys, setupNodeProcess };
1
+ import { n as setupNodeProcess, r as createNodeLogger, t as createNodeSys } from "../../node-Bkq8vRnu.mjs";
2
+ export { createNodeLogger, createNodeSys, setupNodeProcess };
@@ -1 +1 @@
1
- export { };
1
+ export {}
@@ -1,12 +1,5 @@
1
- import "../../chunk-ClPoSABd.mjs";
2
- import "../../client-DR9zhmKG.mjs";
3
- import "../../serialize-BJvhE9aQ.mjs";
4
- import { c as createWorkerMessageHandler } from "../../transpile-CJQcQEVa.mjs";
5
- import "../../validation-BdcPruW_.mjs";
6
- import { t as createNodeSys } from "../../node-sys-BGURUNOZ.mjs";
7
- import "./index.mjs";
8
- import "../../compiler/index.mjs";
9
-
1
+ import { l as createWorkerMessageHandler } from "../../compiler-C_Y38j4m.mjs";
2
+ import { t as createNodeSys } from "../../node-Bkq8vRnu.mjs";
10
3
  //#region src/sys/node/node-worker-thread.ts
11
4
  /**
12
5
  * Initialize a worker thread, setting up various machinery for managing
@@ -49,12 +42,10 @@ const initNodeWorkerThread = (process, msgHandler) => {
49
42
  errorHandler(-1, e);
50
43
  });
51
44
  };
52
-
53
45
  //#endregion
54
46
  //#region src/sys/node/worker.ts
55
47
  const nodeSys = createNodeSys({ process });
56
48
  const msgHandler = createWorkerMessageHandler(nodeSys);
57
49
  initNodeWorkerThread(process, msgHandler);
58
-
59
50
  //#endregion
60
- export { };
51
+ export {};