@stencil/core 5.0.0-alpha.5 → 5.0.0-alpha.7

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 (43) hide show
  1. package/dist/{client-Dnio47yQ.mjs → client-Dd-NB5Ei.mjs} +2324 -2125
  2. package/dist/compiler/index.d.mts +5 -5
  3. package/dist/compiler/index.mjs +2 -2
  4. package/dist/compiler/utils/index.d.mts +2 -2
  5. package/dist/compiler/utils/index.mjs +3 -3
  6. package/dist/{compiler-Dxri2g8Z.mjs → compiler-BmT_yLHU.mjs} +13458 -12695
  7. package/dist/declarations/stencil-public-compiler.d.ts +273 -144
  8. package/dist/declarations/stencil-public-docs.d.ts +10 -0
  9. package/dist/declarations/stencil-public-runtime.d.ts +49 -12
  10. package/dist/{index-D61XZw0f.d.ts → index-BuveMLxy.d.ts} +82 -31
  11. package/dist/{index-D5zaocDq.d.mts → index-CVhWFUM0.d.mts} +249 -204
  12. package/dist/{index-Dat4djoo.d.mts → index-ch-cf-bZ.d.mts} +13 -2
  13. package/dist/index.d.mts +0 -1
  14. package/dist/index.mjs +1 -1
  15. package/dist/jsx-runtime.d.mts +18 -0
  16. package/dist/jsx-runtime.mjs +2 -0
  17. package/dist/{node-pj6rF4Wt.mjs → node-10UamZmn.mjs} +59 -55
  18. package/dist/{regular-expression-D0_N0PGa.mjs → regular-expression-CFVJOTUh.mjs} +83 -8
  19. package/dist/runtime/app-data/index.d.ts +1 -1
  20. package/dist/runtime/app-data/index.js +15 -9
  21. package/dist/{runtime-CKyUrF4i.js → runtime/client/lazy.js} +2539 -2199
  22. package/dist/runtime/client/{index.d.ts → runtime.d.ts} +49 -40
  23. package/dist/runtime/client/{index.js → runtime.js} +2401 -2185
  24. package/dist/runtime/index.d.ts +20 -3
  25. package/dist/runtime/index.js +4956 -2
  26. package/dist/runtime/server/index.d.mts +30 -39
  27. package/dist/runtime/server/index.mjs +2369 -2185
  28. package/dist/runtime/server/runner.d.mts +4 -6
  29. package/dist/runtime/server/runner.mjs +307 -361
  30. package/dist/signals/index.d.ts +47 -0
  31. package/dist/signals/index.js +199 -0
  32. package/dist/sys/node/index.d.mts +1 -1
  33. package/dist/sys/node/index.mjs +1 -1
  34. package/dist/sys/node/worker.mjs +2 -2
  35. package/dist/testing/index.d.mts +97 -3
  36. package/dist/testing/index.mjs +199 -50
  37. package/dist/{validation-BA8nzXu_.mjs → validation-ByxKj8bC.mjs} +21 -32
  38. package/package.json +41 -27
  39. package/dist/index-D-XN9HW_.d.ts +0 -30
  40. package/dist/jsx-runtime-B3vQbWIW.d.ts +0 -28
  41. package/dist/jsx-runtime.d.ts +0 -2
  42. package/dist/jsx-runtime.js +0 -2
  43. /package/dist/{chunk-CjcI7cDX.mjs → chunk-z9aeyW2b.mjs} +0 -0
@@ -0,0 +1,47 @@
1
+ import { ReadonlySignal, ReadonlySignal as ReadonlySignal$1, Signal, batch, computed, effect, signal, untracked } from "@preact/signals-core";
2
+ //#region src/runtime/signals.d.ts
3
+ declare const STENCIL_SIGNALS_SYMBOL: unique symbol;
4
+ //#endregion
5
+ //#region src/signals/index.d.ts
6
+ /**
7
+ * Returns the `ReadonlySignal` backing a `@Prop` member on a Stencil element.
8
+ * Requires `signalBacking: true` in `stencil.config.ts`.
9
+ * Only `@Prop` members are exposed - `@State` is internal component state.
10
+ *
11
+ * Useful for cross-component or cross-framework reactivity without polling or events:
12
+ * ```ts
13
+ * import { getSignal, computed } from '@stencil/core/signals';
14
+ *
15
+ * const count = getSignal<number>(myEl, 'count');
16
+ * const doubled = computed(() => count.value * 2);
17
+ * ```
18
+ *
19
+ * @param elm - the Stencil host element
20
+ * @param prop - the `@Prop` member name
21
+ * @returns the `ReadonlySignal` for the prop, or `null` if not found / not signal-backed
22
+ */
23
+ declare const getSignal: <T = unknown>(elm: Element, prop: string) => ReadonlySignal$1<T> | null;
24
+ /**
25
+ * Marks a class method as a reactive effect. Wraps the method in `effect()` after
26
+ * signal initialization and registers cleanup on disconnect. Dependencies are
27
+ * auto-tracked - any signal read inside re-runs the method on change.
28
+ *
29
+ * @example
30
+ * ```ts
31
+ * import { Effect } from '@stencil/core/signals';
32
+ *
33
+ * @Component({ tag: 'my-cmp' })
34
+ * export class MyCmp {
35
+ * @State() count = 0;
36
+ *
37
+ * @Effect()
38
+ * log() {
39
+ * console.log(this.count); // re-runs whenever count changes
40
+ * }
41
+ * }
42
+ * ```
43
+ * @returns a MethodDecorator that registers the method as a reactive effect
44
+ */
45
+ declare function Effect(): MethodDecorator;
46
+ //#endregion
47
+ export { Effect, type ReadonlySignal, STENCIL_SIGNALS_SYMBOL, type Signal, batch, computed, effect, getSignal, signal, untracked };
@@ -0,0 +1,199 @@
1
+ import { batch, computed, effect, signal, untracked } 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 the `@stencil/core/runtime/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
+ vdomRender: true,
61
+ vdomStyle: true,
62
+ vdomText: true,
63
+ propChangeCallback: true,
64
+ taskQueue: true,
65
+ lifecycle: true,
66
+ serializer: true,
67
+ deserializer: true,
68
+ patchAll: true,
69
+ patchChildren: true,
70
+ patchClone: true,
71
+ patchInsert: true,
72
+ hotModuleReplacement: false,
73
+ isDebug: false,
74
+ isDev: false,
75
+ isTesting: false,
76
+ hydrateServerSide: false,
77
+ hydrateClientSide: false,
78
+ lifecycleDOMEvents: false,
79
+ lazyLoad: false,
80
+ profile: false,
81
+ slotRelocation: true,
82
+ lightDomPatches: true,
83
+ slotChildNodes: true,
84
+ slotCloneNode: true,
85
+ slotDomMutations: true,
86
+ slotTextContent: true,
87
+ hydratedAttribute: false,
88
+ hydratedClass: true,
89
+ invisiblePrehydration: true,
90
+ staticHydrationStyles: false,
91
+ propBoolean: true,
92
+ propNumber: true,
93
+ propString: true,
94
+ constructableCSS: true,
95
+ devTools: false,
96
+ shadowDelegatesFocus: true,
97
+ shadowSlotAssignmentManual: false,
98
+ initializeNextTick: false,
99
+ asyncLoading: true,
100
+ asyncQueue: false
101
+ };
102
+ BUILD.isDev, BUILD.isTesting;
103
+ const MEMBER_FLAGS = {
104
+ String: 1,
105
+ Number: 2,
106
+ Boolean: 4,
107
+ Any: 8,
108
+ Unknown: 16,
109
+ State: 32,
110
+ Method: 64,
111
+ Event: 128,
112
+ Element: 256,
113
+ ReflectAttr: 512,
114
+ Mutable: 1024,
115
+ Getter: 2048,
116
+ Setter: 4096,
117
+ Prop: 31,
118
+ HasAttribute: 31,
119
+ PropLike: 63
120
+ };
121
+ //#endregion
122
+ //#region src/client/client-host-ref.ts
123
+ /**
124
+ * Given a {@link d.RuntimeRef} retrieve the corresponding {@link d.HostRef}
125
+ *
126
+ * @param ref the runtime ref of interest
127
+ * @returns the Host reference (if found) or undefined
128
+ */
129
+ const getHostRef = (ref) => {
130
+ if (ref.__s_ghr) return ref.__s_ghr();
131
+ };
132
+ //#endregion
133
+ //#region src/client/client-log.ts
134
+ const STENCIL_DEV_MODE = BUILD.isTesting ? ["STENCIL:"] : ["%cstencil", "color: white;background:#4c47ff;font-weight: bold; font-size:10px; padding:2px 6px; border-radius: 5px"];
135
+ const consoleDevWarn = (...m) => console.warn(...STENCIL_DEV_MODE, ...m);
136
+ /*!__STENCIL_STATIC_IMPORT_SWITCH__*/
137
+ (typeof window !== "undefined" ? window : {}).HTMLElement;
138
+ BUILD.constructableCSS;
139
+ //#endregion
140
+ //#region src/runtime/signals.ts
141
+ const STENCIL_SIGNALS_SYMBOL = Symbol.for("stencil.signals");
142
+ BUILD.lazyLoad || globalThis.HTMLElement;
143
+ //#endregion
144
+ //#region src/signals/index.ts
145
+ /**
146
+ * Returns the `ReadonlySignal` backing a `@Prop` member on a Stencil element.
147
+ * Requires `signalBacking: true` in `stencil.config.ts`.
148
+ * Only `@Prop` members are exposed - `@State` is internal component state.
149
+ *
150
+ * Useful for cross-component or cross-framework reactivity without polling or events:
151
+ * ```ts
152
+ * import { getSignal, computed } from '@stencil/core/signals';
153
+ *
154
+ * const count = getSignal<number>(myEl, 'count');
155
+ * const doubled = computed(() => count.value * 2);
156
+ * ```
157
+ *
158
+ * @param elm - the Stencil host element
159
+ * @param prop - the `@Prop` member name
160
+ * @returns the `ReadonlySignal` for the prop, or `null` if not found / not signal-backed
161
+ */
162
+ const getSignal = (elm, prop) => {
163
+ const hostRef = getHostRef(elm);
164
+ if (!hostRef?.$signalValues$) {
165
+ if (BUILD.isDev) consoleDevWarn(`getSignal('${prop}'): element <${elm.tagName.toLowerCase()}> is not signal-backed. Ensure signalBacking is true in stencil.config.ts.`);
166
+ return null;
167
+ }
168
+ if (!((hostRef.$cmpMeta$?.$members$?.[prop]?.[0] ?? 0) & MEMBER_FLAGS.Prop)) return null;
169
+ return hostRef.$signalValues$.get(prop) ?? null;
170
+ };
171
+ /**
172
+ * Marks a class method as a reactive effect. Wraps the method in `effect()` after
173
+ * signal initialization and registers cleanup on disconnect. Dependencies are
174
+ * auto-tracked - any signal read inside re-runs the method on change.
175
+ *
176
+ * @example
177
+ * ```ts
178
+ * import { Effect } from '@stencil/core/signals';
179
+ *
180
+ * @Component({ tag: 'my-cmp' })
181
+ * export class MyCmp {
182
+ * @State() count = 0;
183
+ *
184
+ * @Effect()
185
+ * log() {
186
+ * console.log(this.count); // re-runs whenever count changes
187
+ * }
188
+ * }
189
+ * ```
190
+ * @returns a MethodDecorator that registers the method as a reactive effect
191
+ */
192
+ function Effect() {
193
+ return (target, propertyKey) => {
194
+ const proto = target;
195
+ (proto.__stencilEffects ??= []).push(propertyKey);
196
+ };
197
+ }
198
+ //#endregion
199
+ export { Effect, STENCIL_SIGNALS_SYMBOL, batch, computed, effect, getSignal, signal, untracked };
@@ -1,4 +1,4 @@
1
- import { Qr as Logger, _r as CompilerSystem } from "../../index-D5zaocDq.mjs";
1
+ import { ei as Logger, vr as CompilerSystem } from "../../index-CVhWFUM0.mjs";
2
2
 
3
3
  //#region src/sys/node/logger/index.d.ts
4
4
  /**
@@ -1,2 +1,2 @@
1
- import { n as setupNodeProcess, r as createNodeLogger, t as createNodeSys } from "../../node-pj6rF4Wt.mjs";
1
+ import { n as setupNodeProcess, r as createNodeLogger, t as createNodeSys } from "../../node-10UamZmn.mjs";
2
2
  export { createNodeLogger, createNodeSys, setupNodeProcess };
@@ -1,5 +1,5 @@
1
- import { l as createWorkerMessageHandler } from "../../compiler-Dxri2g8Z.mjs";
2
- import { t as createNodeSys } from "../../node-pj6rF4Wt.mjs";
1
+ import { l as createWorkerMessageHandler } from "../../compiler-BmT_yLHU.mjs";
2
+ import { t as createNodeSys } from "../../node-10UamZmn.mjs";
3
3
  //#region src/sys/node/node-worker-thread.ts
4
4
  /**
5
5
  * Initialize a worker thread, setting up various machinery for managing
@@ -1,5 +1,5 @@
1
- import { B as ComponentCompilerMeta, E as CompilerCtx, Et as HostRef, Lt as NewSpecPageOptions, Mt as Module, Qr as Logger, Tt as HostElement, Yr as LoadConfigInit, Zr as LogLevel, _r as CompilerSystem, a as BuildCtx, aa as ValidatedConfig, da as RafCallback, ei as LoggerTimeSpan, fn as SpecPage, ia as UnvalidatedConfig, la as ErrorHandler, ma as UserBuildConditionals, pt as ComponentRuntimeMeta, sn as RuntimeRef, zr as Diagnostic } from "../index-D5zaocDq.mjs";
2
- import { _ as Env, c as getMode, d as Fragment, f as createEvent, g as setAssetPath, h as getAssetPath, i as getRenderingRef, n as h, p as getElement, r as forceUpdate, t as Host, u as Mixin } from "../index-Dat4djoo.mjs";
1
+ import { $r as LogLevel, B as ComponentCompilerMeta, Br as Diagnostic, Dt as HostRef, E as CompilerCtx, Et as HostElement, Nt as Module, Rt as NewSpecPageOptions, Zn as Compiler, Zr as LoadConfigInit, a as BuildCtx, aa as ValidatedConfig, cn as RuntimeRef, ei as Logger, fa as RafCallback, ha as UserBuildConditionals, ia as UnvalidatedConfig, kr as Config, mt as ComponentRuntimeMeta, ni as LoggerTimeSpan, pn as SpecPage, ua as ErrorHandler, vr as CompilerSystem } from "../index-CVhWFUM0.mjs";
2
+ import { a as h, b as Env, d as getMode, g as getElement, h as createEvent, i as Host, m as Fragment, o as forceUpdate, p as Mixin, s as getRenderingRef, v as getAssetPath, y as setAssetPath } from "../index-ch-cf-bZ.mjs";
3
3
  import { Mock } from "vitest";
4
4
 
5
5
  //#region src/testing/testing-logger.d.ts
@@ -98,6 +98,100 @@ declare function mockWindow(html?: string): Window;
98
98
  */
99
99
  declare const mockModule: (mod?: Partial<Module>) => Module;
100
100
  //#endregion
101
+ //#region src/testing/create-test-compiler.d.ts
102
+ /**
103
+ * Options for creating a test compiler
104
+ */
105
+ interface CreateTestCompilerOptions {
106
+ /**
107
+ * Additional configuration overrides for the test compiler
108
+ */
109
+ config?: Partial<Config>;
110
+ /**
111
+ * Path to a tsconfig.json file. Defaults to {@link TESTING_TSCONFIG}.
112
+ * To add custom options, create a file that `extends` the base fixture:
113
+ * `{ "extends": "./path/to/tsconfig.testing.json", "compilerOptions": { ... } }`
114
+ */
115
+ tsconfig?: string;
116
+ /**
117
+ * Pre-validated compiler setup from {@link prepareTestCompiler}. When
118
+ * provided, the expensive `loadConfig` step is skipped and a fresh compiler
119
+ * is created directly from the cached validated config.
120
+ */
121
+ setup?: PreparedTestCompiler;
122
+ }
123
+ /**
124
+ * Result of creating a test compiler
125
+ */
126
+ interface TestCompilerResult {
127
+ /**
128
+ * The compiler instance ready for testing
129
+ */
130
+ compiler: Compiler;
131
+ /**
132
+ * The validated configuration used to create the compiler
133
+ */
134
+ config: ValidatedConfig;
135
+ /**
136
+ * The compiler system instance
137
+ */
138
+ sys: CompilerSystem;
139
+ }
140
+ /**
141
+ * A pre-validated compiler configuration that can be reused across multiple
142
+ * `createTestCompiler` calls within the same test suite to avoid repeating
143
+ * the expensive `loadConfig` step.
144
+ *
145
+ * Obtain via {@link prepareTestCompiler} in a `beforeAll` block, then pass as
146
+ * `options.setup` to {@link createTestCompiler} in each `beforeEach`.
147
+ */
148
+ interface PreparedTestCompiler {
149
+ /** @internal */
150
+ _validatedConfig: ValidatedConfig;
151
+ /** @internal */
152
+ _tsconfigPath: string;
153
+ }
154
+ /**
155
+ * Runs the expensive one-time setup for a test compiler suite: patching the
156
+ * sys, reading and validating the tsconfig. Use this in a `beforeAll` block
157
+ * when a describe block contains multiple tests that each need a fresh
158
+ * compiler, to avoid repeating `loadConfig` on every test.
159
+ *
160
+ * @param options - Configuration options for preparing the test compiler
161
+ * @returns A {@link PreparedTestCompiler} that can be passed to {@link createTestCompiler}
162
+ *
163
+ * @example
164
+ * ```ts
165
+ * let setup: PreparedTestCompiler;
166
+ * beforeAll(async () => { setup = await prepareTestCompiler(); });
167
+ * beforeEach(async () => {
168
+ * const { compiler } = await createTestCompiler({ setup });
169
+ * });
170
+ * ```
171
+ */
172
+ declare const prepareTestCompiler: (options?: Omit<CreateTestCompilerOptions, "setup">) => Promise<PreparedTestCompiler>;
173
+ /**
174
+ * Creates a test compiler instance with a hybrid filesystem (reads from disk, writes to memory).
175
+ * This utility handles the common setup pattern for compiler tests.
176
+ *
177
+ * When multiple tests in the same suite need independent compiler instances,
178
+ * pass a {@link PreparedTestCompiler} from {@link prepareTestCompiler} as
179
+ * `options.setup` to skip the expensive `loadConfig` step on each test.
180
+ *
181
+ * @param options - Configuration options for the test compiler
182
+ * @returns An object with the compiler, validated config, and system instance
183
+ *
184
+ * @example
185
+ * ```ts
186
+ * const { compiler, config } = await createTestCompiler({
187
+ * config: { minifyCss: true }
188
+ * });
189
+ * await compiler.fs.writeFile('/src/index.html', '<cmp-a></cmp-a>');
190
+ * const result = await compiler.build();
191
+ * ```
192
+ */
193
+ declare const createTestCompiler: (options?: CreateTestCompilerOptions) => Promise<TestCompilerResult>;
194
+ //#endregion
101
195
  //#region src/testing/spec-page.d.ts
102
196
  /**
103
197
  * Creates a new spec page for unit testing
@@ -206,4 +300,4 @@ declare function readTask(cb: RafCallback): void;
206
300
  //#region src/testing/platform/index.d.ts
207
301
  declare const setMode: (handler: (elm: any) => string | undefined | null) => void;
208
302
  //#endregion
209
- export { Build, Env, Fragment, Host, Mixin, type SpecPage, createEvent, createTestingSystem, forceUpdate, getAssetPath, getElement, getHostRef, getMode, getRenderingRef, h, mockBuildCtx, mockCompilerCtx, mockCompilerSystem, mockComponentMeta, mockConfig, mockDocument, mockLoadConfigInit, mockLogger, mockModule, mockValidatedConfig, mockWindow, newSpecPage, readTask, registerHost, registerInstance, setAssetPath, setErrorHandler, setMode, setupConsoleMocker, shuffleArray, writeTask };
303
+ export { Build, type CreateTestCompilerOptions, Env, Fragment, Host, Mixin, type PreparedTestCompiler, type SpecPage, type TestCompilerResult, createEvent, createTestCompiler, createTestingSystem, forceUpdate, getAssetPath, getElement, getHostRef, getMode, getRenderingRef, h, mockBuildCtx, mockCompilerCtx, mockCompilerSystem, mockComponentMeta, mockConfig, mockDocument, mockLoadConfigInit, mockLogger, mockModule, mockValidatedConfig, mockWindow, newSpecPage, prepareTestCompiler, readTask, registerHost, registerInstance, setAssetPath, setErrorHandler, setMode, setupConsoleMocker, shuffleArray, writeTask };