@stencil/core 5.0.0-rc.7 → 5.0.0-rc.9
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/dist/{client-BA_FU9aB.mjs → client-DkvdNuPu.mjs} +5 -5
- package/dist/compiler/browser.d.ts +23 -5
- package/dist/compiler/browser.js +61 -11
- package/dist/compiler/index.d.mts +2 -2
- package/dist/compiler/index.mjs +2 -2
- package/dist/compiler/utils/index.d.mts +1 -1
- package/dist/{compiler-CH-Qh_aM.mjs → compiler-JKsb5iht.mjs} +226 -101
- package/dist/declarations/stencil-public-compiler.d.ts +25 -7
- package/dist/{index-CFiy6MZ3.d.mts → index-BxnfbT3a.d.mts} +25 -7
- package/dist/{index-CViiWNQ9.d.mts → index-xOwTL_5Z.d.mts} +1 -1
- package/dist/index.mjs +1 -1
- package/dist/jsx-runtime.mjs +1 -1
- package/dist/{node-Bsfi3pOs.mjs → node-C59vQZNg.mjs} +1 -1
- package/dist/runtime/client/lazy.js +174 -137
- package/dist/runtime/client/runtime.js +174 -137
- package/dist/runtime/index.js +174 -137
- package/dist/runtime/server/index.mjs +174 -137
- package/dist/runtime/server/runner.mjs +80 -5
- package/dist/sys/node/index.d.mts +1 -1
- package/dist/sys/node/index.mjs +1 -1
- package/dist/sys/node/worker.mjs +2 -2
- package/dist/testing/index.mjs +175 -138
- package/package.json +4 -4
|
@@ -4515,10 +4515,18 @@ interface TranspileOptions {
|
|
|
4515
4515
|
*/
|
|
4516
4516
|
additionalTagTransformers?: boolean;
|
|
4517
4517
|
/**
|
|
4518
|
-
* Callback used to resolve
|
|
4519
|
-
*
|
|
4520
|
-
*
|
|
4521
|
-
*
|
|
4518
|
+
* Callback used to resolve imported source during a single-file transpile.
|
|
4519
|
+
* Return the resolved absolute path and source text of that module, or `null`
|
|
4520
|
+
* to leave the specifier unresolved.
|
|
4521
|
+
*
|
|
4522
|
+
* It is called in two situations, told apart by `context.kind`:
|
|
4523
|
+
* - **inheritance** (`context` is `undefined`): a component's `extends` clause
|
|
4524
|
+
* references a class from another module, so the compiler can merge the
|
|
4525
|
+
* parent's metadata.
|
|
4526
|
+
* - **`'type-info'`**: the file uses `resolveVar()`, so the compiler follows its
|
|
4527
|
+
* imports (and theirs) to read constants declared elsewhere. The returned
|
|
4528
|
+
* module is only used for type information - it is never emitted or treated
|
|
4529
|
+
* as a base class.
|
|
4522
4530
|
*
|
|
4523
4531
|
* @example
|
|
4524
4532
|
* ```ts
|
|
@@ -4530,7 +4538,7 @@ interface TranspileOptions {
|
|
|
4530
4538
|
* });
|
|
4531
4539
|
* ```
|
|
4532
4540
|
*/
|
|
4533
|
-
resolveImport?: (specifier: string, importer: string) => {
|
|
4541
|
+
resolveImport?: (specifier: string, importer: string, context?: ResolveImportContext) => {
|
|
4534
4542
|
code: string;
|
|
4535
4543
|
path: string;
|
|
4536
4544
|
} | null;
|
|
@@ -4594,7 +4602,7 @@ interface TransformOptions {
|
|
|
4594
4602
|
/**
|
|
4595
4603
|
* @see {@link TranspileOptions.resolveImport}
|
|
4596
4604
|
*/
|
|
4597
|
-
resolveImport?: (specifier: string, importer: string) => {
|
|
4605
|
+
resolveImport?: (specifier: string, importer: string, context?: ResolveImportContext) => {
|
|
4598
4606
|
code: string;
|
|
4599
4607
|
path: string;
|
|
4600
4608
|
} | null;
|
|
@@ -4603,6 +4611,16 @@ interface TransformOptions {
|
|
|
4603
4611
|
/** @see {@link TranspileOptions.buildOverrides} */
|
|
4604
4612
|
buildOverrides?: BuildOverrides;
|
|
4605
4613
|
}
|
|
4614
|
+
/**
|
|
4615
|
+
* Extra information passed as the third argument of {@link TranspileOptions.resolveImport}.
|
|
4616
|
+
*/
|
|
4617
|
+
interface ResolveImportContext {
|
|
4618
|
+
/**
|
|
4619
|
+
* `'type-info'` when the module is only needed for type information (e.g. `resolveVar()`
|
|
4620
|
+
* reading a constant declared in another file).
|
|
4621
|
+
*/
|
|
4622
|
+
kind: 'type-info';
|
|
4623
|
+
}
|
|
4606
4624
|
interface CompileScriptMinifyOptions {
|
|
4607
4625
|
target?: CompileTarget;
|
|
4608
4626
|
pretty?: boolean;
|
|
@@ -6275,4 +6293,4 @@ type MsgToWorker<T extends WorkerContextMethod> = IPCSerializable<{
|
|
|
6275
6293
|
*/
|
|
6276
6294
|
type WorkerMsgHandler = <T extends WorkerContextMethod>(msgToWorker: MsgToWorker<T>) => ReturnType<CompilerWorkerContext[T]>;
|
|
6277
6295
|
//#endregion
|
|
6278
|
-
export { CompilerFsStats as $,
|
|
6296
|
+
export { CompilerFsStats as $, COLLECTION as $i, WatcherCloseResults as $n, rolldownToStencilSourceMap as $r, OutputTargetBuild as $t, BuildOverrides as A, WWW as Aa, shouldExcludeComponent as Ai, ResolveModuleIdOptions as An, FsWriteResults as Ar, HotModuleReplacement as At, CompilerEventBuildLog as B, normalizeDiagnostics as Bi, SsrDocumentOptions as Bn, isDtsFile as Br, Logger as Bt, BuildEmitEvents as C, STANDALONE as Ca, isOutputTargetSsrWasm as Ci, PluginTransformResults as Cn, JsonDocsSlot as Cr, DevServerEditor as Ct, BuildOnEventRemove as D, TYPES as Da, isOutputTargetWww as Di, PrerenderResults as Dn, JsonDocsUsage as Dr, HistoryApiFallback as Dt, BuildNoChangeResults as E, SVG_NS as Ea, isOutputTargetTypes as Ei, PrerenderOptions as En, JsonDocsTypeLibrary as Er, FsWatchResults as Et, Compiler as F, catchError as Fi, RolldownConfig as Fn, addDocBlock as Fr, LazyRequire as Ft, CompilerEventFileAdd as G, createOnWarnFn as Gi, SystemDetails as Gn, parsePackageJson as Gr, OptimizeCssInput as Gt, CompilerEventBuildStart as H, augmentDiagnosticWithNode as Hi, StencilConfig as Hn, isJsxFile as Hr, LoggerTimeSpan as Ht, CompilerBuildResults as I, hasError as Ii, SerializeDocumentOptions as In, createJsVarName as Ir, LightDomPatches as It, CompilerEventFsChange as J, formatComponentRuntimeMeta as Ji, TranspileOptions as Jn, getInlineSourceMappingUrlLinker as Jr, OptimizeJsOutput as Jt, CompilerEventFileDelete as K, isRolldownError as Ki, TransformOptions as Kn, readOnlyArrayHasStringMember as Kr, OptimizeCssOutput as Kt, CompilerBuildStart as L, hasWarning as Li, ServiceWorkerConfig as Ln, generatePreamble as Lr, LoadConfigInit as Lt, CliInitOptions as M, buildError as Mi, ResolveModuleOptions as Mn, validateComponentModes as Mr, HydrateFactoryOptions as Mt, CompileScriptMinifyOptions as N, buildJsonFileError as Ni, RobotsTxtOpts as Nn, validateComponentTag as Nr, HydratedFlag as Nt, BuildOnEvents as O, VALID_CONFIG_OUTPUT_TARGETS as Oa, isValidConfigOutputTarget as Oi, PrerenderStartOptions as On, JsonDocsValue as Or, HmrGlobalStyleUpdate as Ot, CompileTarget as P, buildWarn as Pi, RobotsTxtResults as Pn, ParsePackageJsonResult as Pr, LOG_LEVELS as Pt, CompilerFileWatcherEvent as Q, CMP_FLAGS as Qi, ValidatedOutputTargetWww as Qn, relativizeSourceMap as Qr, OutputTargetBaseNext as Qt, CompilerDependency as R, shouldIgnoreError as Ri, SitemapXmpOpts as Rn, getTextDocs as Rr, LoadConfigResults as Rt, AutoprefixerOptions as S, SSR_WASM as Sa, isOutputTargetSsr as Si, PluginCtx as Sn, JsonDocsProp as Sr, DevServerConfig as St, BuildLog as T, STYLE_EXT as Ta, isOutputTargetStats as Ti, PrerenderHydrateOptions as Tn, JsonDocsTag as Tr, DocsReadmeCustomColumn as Tt, CompilerEventDirAdd as U, loadTypeScriptDiagnostic as Ui, StencilDevServerConfig as Un, isTsFile as Ur, ModeConfig as Ut, CompilerEventBuildNoChange as V, splitLineBreaks as Vi, SsrFactoryOptions as Vn, isJsFile as Vr, LoggerLineUpdater as Vt, CompilerEventDirDelete as W, loadTypeScriptDiagnostics as Wi, StencilDocsConfig as Wn, isTsxFile as Wr, NodeResolveConfig as Wt, CompilerFileWatcher as X, stringifyRuntimeData as Xi, UnvalidatedConfig as Xn, getSourceMappingUrlForEndOfFile as Xr, OutputTargetAssets as Xt, CompilerEventName as Y, formatLazyBundleRuntimeMeta as Yi, TranspileResults as Yn, getRolldownSourceMapOptions as Yr, OutputTarget as Yt, CompilerFileWatcherCallback as Z, ASSETS as Zi, ValidatedConfig as Zn, getSourceMappingUrlLinker as Zr, OutputTargetBase as Zt, PrintLine as _, LISTENER_FLAGS as _a, isOutputTargetDocsReadme as _i, OutputTargetWww as _n, JsonDocsEvent as _r, CopyTask as _t, ComponentCompilerEvent as a, DIST_LAZY as aa, getComponentsDtsTypesFilePath as ai, OutputTargetDocsCustom as an, MixedInCtor as ar, CompilerSystemRealpathResults as at, SsrResults as b, NODE_TYPES as ba, isOutputTargetLoaderBundle as bi, PlatformPath as bn, JsonDocsMethodReturn as br, CustomElementsExportBehaviorOptions as bt, ComponentCompilerMethod as c, DOCS_CUSTOM_ELEMENTS_MANIFEST as ca, isOutputTargetCollection as ci, OutputTargetDocsReadme as cn, ResolutionHandler as cr, CompilerSystemRemoveFileResults as ct, ComponentCompilerTypeReferences as d, DOCS_VSCODE as da, isOutputTargetDistLazy as di, OutputTargetLoaderBundle as dn, VNode as dr, CompilerSystemWriteFileResults as dt, COLLECTION_APP_DATA_FILE_NAME as ea, result_d_exports as ei, OutputTargetCollection as en, WorkerMainController as er, CompilerRequest as et, ComponentGlobalStyle as f, EVENT_FLAGS as fa, isOutputTargetDocs as fi, OutputTargetSsr as fn, JsonDocMethodParameter as fr, CompilerWatcher as ft, PrerenderUrlResults as g, HTML_NS as ga, isOutputTargetDocsJson as gi, OutputTargetTypes as gn, JsonDocsDependencyGraph as gr, CopyResults as gt, PackageJsonData as h, HOST_FLAGS as ha, isOutputTargetDocsCustomElementsManifest as hi, OutputTargetStats as hn, JsonDocsCustomState as hr, ConfigCompat as ht, CompilerWorkerContext as i, DEFAULT_STYLE_MODE as ia, getComponentsDtsSrcFilePath as ii, OutputTargetDocsAgentSkill as in, FunctionalComponent as ir, CompilerSystemCreateDirectoryResults as it, BuildResultsComponentGraph as j, XLINK_NS as ja, TASK_CANCELED_MSG as ji, ResolveModuleIdResults as jn, ModeValidationError as jr, HydrateDocumentOptions as jt, BuildOutput as k, WATCH_FLAGS as ka, relativeImport as ki, ResolveImportContext as kn, StyleDoc as kr, HmrStyleUpdate as kt, ComponentCompilerProperty as l, DOCS_JSON as la, isOutputTargetCopy as li, OutputTargetDocsVscode as ln, TagTransformer as lr, CompilerSystemRenameResults as lt, LazyBundlesRuntimeData as m, GLOBAL_STYLE as ma, isOutputTargetDocsCustom as mi, OutputTargetStandalone as mn, JsonDocsComponent as mr, ConfigBundle as mt, ChildType as n, COPY as na, filterActiveTargets as ni, OutputTargetCustom as nn, ComponentInterface as nr, CompilerSystem as nt, ComponentCompilerListener as o, DOCS_AGENT_SKILL as oa, getComponentsFromModules as oi, OutputTargetDocsCustomElementsManifest as on, RafCallback as or, CompilerSystemRemoveDirectoryOptions as ot, HostElement as p, GENERATED_DTS as pa, isOutputTargetDocsAgentSkill as pi, OutputTargetSsrWasm as pn, JsonDocs as pr, Config as pt, CompilerEventFileUpdate as q, loadRolldownDiagnostics as qi, TranspileOnlyResults as qn, readPackageJson as qr, OptimizeJsInput as qt, CompilerCtx as r, CUSTOM as ra, filterExcludedComponents as ri, OutputTargetDistLazy as rn, ErrorHandler as rr, CompilerSystemCreateDirectoryOptions as rt, ComponentCompilerMeta as s, DOCS_CUSTOM as sa, isOutputTargetAssets as si, OutputTargetDocsJson as sn, ReactiveControllerHostInterface as sr, CompilerSystemRemoveDirectoryResults as st, BuildCtx as t, COLLECTION_MANIFEST_FILE_NAME as ta, FilterComponentsResult as ti, OutputTargetCopy as tn, WorkerOptions as tr, CompilerRequestResponse as tt, ComponentCompilerState as u, DOCS_README as ua, isOutputTargetCustom as ui, OutputTargetGlobalStyle as un, UserBuildConditionals as ur, CompilerSystemRenamedPath as ut, PropsType as v, LOADER_BUNDLE as va, isOutputTargetDocsVscode as vi, PageReloadStrategy as vn, JsonDocsListener as vr, Credentials as vt, BuildEvents as w, STATS as wa, isOutputTargetStandalone as wi, PrerenderConfig as wn, JsonDocsStyle as wr, Diagnostic$1 as wt, WorkerMsgHandler as x, SSR as xa, isOutputTargetServerRenderer as xi, Plugin$1 as xn, JsonDocsPart as xr, DevServer as xt, RuntimeRef as y, MEMBER_FLAGS as ya, isOutputTargetGlobalStyle as yi, ParsedPath as yn, JsonDocsMethod as yr, CustomElementsExportBehavior as yt, CompilerEventBuildFinish as z, escapeHtml as zi, SitemapXmpResults as zn, hasDependency as zr, LogLevel as zt };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { cr as ResolutionHandler, dr as VNode, ir as FunctionalComponent, lr as TagTransformer, n as ChildType, or as RafCallback, p as HostElement, rr as ErrorHandler, ur as UserBuildConditionals, v as PropsType, y as RuntimeRef } from "./index-BxnfbT3a.mjs";
|
|
2
2
|
//#region src/client/client-build.d.ts
|
|
3
3
|
/**
|
|
4
4
|
* `isDev` / `isTesting` are getters, not copies: the transpile path (e.g. `@stencil/unplugin`)
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as Build, S as setErrorHandler, _ as getAssetPath, a as transformTag, b as writeTask, c as Mixin, d as Host, f as h, g as getShadowRoot, h as getElement, i as setTagTransformer, l as getMode, m as getRenderingRef, o as render, p as forceUpdate, s as ReactiveControllerHost, u as setMode, v as setAssetPath, x as setPlatformHelpers, y as readTask } from "./client-
|
|
1
|
+
import { C as Build, S as setErrorHandler, _ as getAssetPath, a as transformTag, b as writeTask, c as Mixin, d as Host, f as h, g as getShadowRoot, h as getElement, i as setTagTransformer, l as getMode, m as getRenderingRef, o as render, p as forceUpdate, s as ReactiveControllerHost, u as setMode, v as setAssetPath, x as setPlatformHelpers, y as readTask } from "./client-DkvdNuPu.mjs";
|
|
2
2
|
import { t as Fragment } from "./fragment-Di1hWOC8.mjs";
|
|
3
3
|
//#region src/client/client-decorators.ts
|
|
4
4
|
/**
|
package/dist/jsx-runtime.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { n as __require } from "./rolldown-runtime-BhDjJH2R.mjs";
|
|
2
|
-
import "./client-
|
|
2
|
+
import "./client-DkvdNuPu.mjs";
|
|
3
3
|
import { c as isFunction, f as isString, m as noop, r as flatOne } from "./helpers-pTCZhNi0.mjs";
|
|
4
4
|
import { X as TASK_CANCELED_MSG, Z as buildError, et as catchError, it as isGlob, q as normalizePath, rt as shouldIgnoreError } from "./util-CP6-333M.mjs";
|
|
5
5
|
import fs from "node:fs";
|
|
@@ -1044,7 +1044,7 @@ const patchSlotPrepend = (HostElementPrototype) => {
|
|
|
1044
1044
|
return toReturn;
|
|
1045
1045
|
}
|
|
1046
1046
|
if (newChild.nodeType === 1 && !!newChild.getAttribute("slot")) newChild.hidden = true;
|
|
1047
|
-
return HostElementPrototype.__prepend(newChild);
|
|
1047
|
+
return HostElementPrototype.__prepend.call(this, newChild);
|
|
1048
1048
|
});
|
|
1049
1049
|
};
|
|
1050
1050
|
};
|
|
@@ -1800,12 +1800,51 @@ const isComplexType = (o) => {
|
|
|
1800
1800
|
return o === "object" || o === "function";
|
|
1801
1801
|
};
|
|
1802
1802
|
//#endregion
|
|
1803
|
-
//#region src/runtime/
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1803
|
+
//#region src/runtime/parse-property-value.ts
|
|
1804
|
+
/**
|
|
1805
|
+
* Parse a new property value for a given property type.
|
|
1806
|
+
*
|
|
1807
|
+
* While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
|
|
1808
|
+
* it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
|
|
1809
|
+
* 1. `any`, the type given to `propValue` in the function signature
|
|
1810
|
+
* 2. the type stored from `propType`.
|
|
1811
|
+
*
|
|
1812
|
+
* This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
|
|
1813
|
+
*
|
|
1814
|
+
* Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
|
|
1815
|
+
* a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
|
|
1816
|
+
* based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
|
|
1817
|
+
* ```tsx
|
|
1818
|
+
* <my-cmp prop-val={0}></my-cmp>
|
|
1819
|
+
* ```
|
|
1820
|
+
*
|
|
1821
|
+
* HTML prop values on the other hand, will always a string
|
|
1822
|
+
*
|
|
1823
|
+
* @param propValue the new value to coerce to some type
|
|
1824
|
+
* @param propType the type of the prop, expressed as a binary number
|
|
1825
|
+
* @returns the parsed/coerced value
|
|
1826
|
+
*/
|
|
1827
|
+
const parsePropertyValue = (propValue, propType) => {
|
|
1828
|
+
if (propValue != null && !isComplexType(propValue)) {
|
|
1829
|
+
/**
|
|
1830
|
+
* ensure this value is of the correct prop type
|
|
1831
|
+
*/
|
|
1832
|
+
if (BUILD.propBoolean && propType & MEMBER_FLAGS.Boolean) return propValue === "" || !!propValue;
|
|
1833
|
+
/**
|
|
1834
|
+
* force it to be a number
|
|
1835
|
+
*/
|
|
1836
|
+
if (BUILD.propNumber && propType & MEMBER_FLAGS.Number) return typeof propValue === "string" ? parseFloat(propValue) : typeof propValue === "number" ? propValue : NaN;
|
|
1837
|
+
/**
|
|
1838
|
+
* could have been passed as a number or boolean but we still want it as a string
|
|
1839
|
+
*/
|
|
1840
|
+
if (BUILD.propString && propType & MEMBER_FLAGS.String) return String(propValue);
|
|
1841
|
+
return propValue;
|
|
1842
|
+
}
|
|
1843
|
+
/**
|
|
1844
|
+
* not sure exactly what type we want so no need to change to a different type
|
|
1845
|
+
*/
|
|
1846
|
+
return propValue;
|
|
1847
|
+
};
|
|
1809
1848
|
//#endregion
|
|
1810
1849
|
//#region src/runtime/event-emitter.ts
|
|
1811
1850
|
const createEvent = (ref, name, flags) => {
|
|
@@ -3212,6 +3251,124 @@ const serverSideConnected = (elm) => {
|
|
|
3212
3251
|
}
|
|
3213
3252
|
};
|
|
3214
3253
|
//#endregion
|
|
3254
|
+
//#region src/runtime/set-value.ts
|
|
3255
|
+
/**
|
|
3256
|
+
* The value a reflected prop writes to its attribute: the serialized value if it has one.
|
|
3257
|
+
* @param hostRef the component's host ref
|
|
3258
|
+
* @param propName the prop
|
|
3259
|
+
* @param val the prop's value
|
|
3260
|
+
* @returns the value to reflect
|
|
3261
|
+
*/
|
|
3262
|
+
const getReflectedValue = (hostRef, propName, val) => BUILD.serializer && hostRef.$serializerValues$.has(propName) ? hostRef.$serializerValues$.get(propName) : val;
|
|
3263
|
+
/**
|
|
3264
|
+
* Write a reflected prop's attribute as soon as the prop changes, like native elements do,
|
|
3265
|
+
* so it agrees with the prop before watchers run. Until the first render, rendering reflects it.
|
|
3266
|
+
* @param hostRef the component's host ref
|
|
3267
|
+
* @param cmpMeta the component's runtime metadata
|
|
3268
|
+
* @param elm the host element
|
|
3269
|
+
* @param propName the prop that changed
|
|
3270
|
+
* @param oldAttrVal the previously reflected value
|
|
3271
|
+
* @param newAttrVal the value to reflect
|
|
3272
|
+
*/
|
|
3273
|
+
const reflectProp = (hostRef, cmpMeta, elm, propName, oldAttrVal, newAttrVal) => {
|
|
3274
|
+
if (!(hostRef.$flags$ & HOST_FLAGS.hasRendered) || !(cmpMeta.$members$[propName][0] & MEMBER_FLAGS.ReflectAttr)) return;
|
|
3275
|
+
const attrName = cmpMeta.$attrsToReflect$?.find(([p]) => p === propName)?.[1];
|
|
3276
|
+
if (!attrName) return;
|
|
3277
|
+
if (BUILD.serializer) hostRef.$flags$ |= HOST_FLAGS.isReflecting;
|
|
3278
|
+
setAccessor(elm, attrName, oldAttrVal, newAttrVal, false, VNODE_FLAGS.isHost);
|
|
3279
|
+
if (BUILD.serializer) hostRef.$flags$ &= ~HOST_FLAGS.isReflecting;
|
|
3280
|
+
};
|
|
3281
|
+
const applySerializers = (hostRef, cmpMeta, propName, val, instance) => {
|
|
3282
|
+
const run = (inst) => {
|
|
3283
|
+
let attrVal = val;
|
|
3284
|
+
for (const serializer of cmpMeta.$serializers$[propName]) {
|
|
3285
|
+
const [[methodName]] = Object.entries(serializer);
|
|
3286
|
+
attrVal = inst[methodName](attrVal, propName);
|
|
3287
|
+
}
|
|
3288
|
+
hostRef.$serializerValues$.set(propName, attrVal);
|
|
3289
|
+
};
|
|
3290
|
+
if (instance) run(instance);
|
|
3291
|
+
else hostRef.$fetchedCbList$.push(() => run(hostRef.$lazyInstance$));
|
|
3292
|
+
};
|
|
3293
|
+
const getValue = (ref, propName) => {
|
|
3294
|
+
if (BUILD.signalBacking) {
|
|
3295
|
+
const sig = getHostRef(ref)?.$signalValues$?.get(propName);
|
|
3296
|
+
if (sig !== void 0) return sig.value;
|
|
3297
|
+
}
|
|
3298
|
+
return getHostRef(ref).$instanceValues$.get(propName);
|
|
3299
|
+
};
|
|
3300
|
+
const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
3301
|
+
const hostRef = getHostRef(ref);
|
|
3302
|
+
if (BUILD.serializer && hostRef?.$flags$ & HOST_FLAGS.isReflecting && hostRef.$serializerValues$.has(propName) && hostRef.$serializerValues$.get(propName) === newVal) return;
|
|
3303
|
+
if (BUILD.signalBacking) {
|
|
3304
|
+
const sig = hostRef?.$signalValues$?.get(propName);
|
|
3305
|
+
if (sig !== void 0) {
|
|
3306
|
+
const parsed = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
|
|
3307
|
+
if (BUILD.serializer && BUILD.reflect && cmpMeta.$attrsToReflect$ && cmpMeta.$serializers$?.[propName]) {
|
|
3308
|
+
const elm = BUILD.lazyLoad ? hostRef.$hostElement$ : ref;
|
|
3309
|
+
applySerializers(hostRef, cmpMeta, propName, parsed, BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm);
|
|
3310
|
+
}
|
|
3311
|
+
if (!(Number.isNaN(sig.peek()) && Number.isNaN(parsed))) sig.value = parsed;
|
|
3312
|
+
return;
|
|
3313
|
+
}
|
|
3314
|
+
}
|
|
3315
|
+
if (!hostRef) {
|
|
3316
|
+
if (BUILD.lazyLoad) throw new Error(BUILD.isDev ? `Couldn't find host element for "${cmpMeta.$tagName$}". This usually happens when integrating a 3rd party Stencil component with another Stencil runtime. See https://github.com/stenciljs/core/issues/5457` : `Host element not found for "${cmpMeta.$tagName$}"`);
|
|
3317
|
+
return;
|
|
3318
|
+
}
|
|
3319
|
+
const elm = BUILD.lazyLoad ? hostRef.$hostElement$ : ref;
|
|
3320
|
+
const oldVal = hostRef.$instanceValues$.get(propName);
|
|
3321
|
+
const flags = hostRef.$flags$;
|
|
3322
|
+
const instance = BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm;
|
|
3323
|
+
newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
|
|
3324
|
+
const didValueChange = newVal !== oldVal && !(Number.isNaN(oldVal) && Number.isNaN(newVal));
|
|
3325
|
+
if ((!BUILD.lazyLoad || !(flags & HOST_FLAGS.isConstructingInstance) || oldVal === void 0) && didValueChange) {
|
|
3326
|
+
hostRef.$instanceValues$.set(propName, newVal);
|
|
3327
|
+
const oldAttrVal = BUILD.reflect && getReflectedValue(hostRef, propName, oldVal);
|
|
3328
|
+
if (BUILD.serializer && BUILD.reflect && cmpMeta.$attrsToReflect$ && cmpMeta.$serializers$?.[propName]) applySerializers(hostRef, cmpMeta, propName, newVal, instance);
|
|
3329
|
+
if (BUILD.reflect) reflectProp(hostRef, cmpMeta, elm, propName, oldAttrVal, getReflectedValue(hostRef, propName, newVal));
|
|
3330
|
+
if (BUILD.isDev) {
|
|
3331
|
+
if (hostRef.$flags$ & HOST_FLAGS.devOnRender) consoleDevWarn(`The state/prop "${propName}" changed during rendering. This can potentially lead to infinite-loops and other bugs.`, "\nElement", elm, "\nNew value", newVal, "\nOld value", oldVal);
|
|
3332
|
+
else if (hostRef.$flags$ & HOST_FLAGS.devOnDidLoad) consoleDevWarn(`The state/prop "${propName}" changed during "componentDidLoad()", this triggers extra re-renders, try to setup on "componentWillLoad()"`, "\nElement", elm, "\nNew value", newVal, "\nOld value", oldVal);
|
|
3333
|
+
}
|
|
3334
|
+
if (BUILD.propChangeCallback && cmpMeta.$watchers$) {
|
|
3335
|
+
const watchMethods = cmpMeta.$watchers$[propName];
|
|
3336
|
+
if (watchMethods) watchMethods.map((watcher) => {
|
|
3337
|
+
try {
|
|
3338
|
+
const [[watchMethodName, watcherFlags]] = Object.entries(watcher);
|
|
3339
|
+
if (flags & HOST_FLAGS.isWatchReady || watcherFlags & WATCH_FLAGS.Immediate) {
|
|
3340
|
+
if (BUILD.signalBacking && !hostRef.$signalValues$) return;
|
|
3341
|
+
if (!instance) hostRef.$fetchedCbList$.push(() => {
|
|
3342
|
+
hostRef.$lazyInstance$[watchMethodName](newVal, oldVal, propName);
|
|
3343
|
+
});
|
|
3344
|
+
else instance[watchMethodName](newVal, oldVal, propName);
|
|
3345
|
+
}
|
|
3346
|
+
} catch (e) {
|
|
3347
|
+
consoleError(e, elm);
|
|
3348
|
+
}
|
|
3349
|
+
});
|
|
3350
|
+
}
|
|
3351
|
+
if (BUILD.updatable && flags & HOST_FLAGS.hasRendered) {
|
|
3352
|
+
if (instance.componentShouldUpdate) {
|
|
3353
|
+
const changes = hostRef.$queuedPropChanges$ ||= {};
|
|
3354
|
+
changes[propName] = {
|
|
3355
|
+
newVal,
|
|
3356
|
+
oldVal: changes[propName]?.oldVal ?? oldVal
|
|
3357
|
+
};
|
|
3358
|
+
}
|
|
3359
|
+
if (!(flags & HOST_FLAGS.isQueuedForUpdate)) scheduleUpdate(hostRef, false);
|
|
3360
|
+
}
|
|
3361
|
+
}
|
|
3362
|
+
};
|
|
3363
|
+
//#endregion
|
|
3364
|
+
//#region src/runtime/signals-core.ts
|
|
3365
|
+
const getCore = () => globalThis[Symbol.for("stencil.preact-signals-core")] ??= SignalsCore;
|
|
3366
|
+
const effect = (fn, options) => getCore().effect(fn, options);
|
|
3367
|
+
const untracked = (fn) => getCore().untracked(fn);
|
|
3368
|
+
function signal(value, options) {
|
|
3369
|
+
return getCore().signal(value, options);
|
|
3370
|
+
}
|
|
3371
|
+
//#endregion
|
|
3215
3372
|
//#region src/runtime/signals.ts
|
|
3216
3373
|
const STENCIL_SIGNALS_SYMBOL = Symbol.for("stencil.signals");
|
|
3217
3374
|
/**
|
|
@@ -3256,6 +3413,14 @@ const initializeSignals = (elm, hostRef, cmpMeta) => {
|
|
|
3256
3413
|
}
|
|
3257
3414
|
prevScheduleVal = newVal;
|
|
3258
3415
|
}));
|
|
3416
|
+
if (BUILD.reflect && memberFlags & MEMBER_FLAGS.ReflectAttr) {
|
|
3417
|
+
let prevAttrVal = getReflectedValue(hostRef, memberName, sig.peek());
|
|
3418
|
+
disposers.push(effect(() => {
|
|
3419
|
+
const attrVal = getReflectedValue(hostRef, memberName, sig.value);
|
|
3420
|
+
untracked(() => reflectProp(hostRef, cmpMeta, elm, memberName, prevAttrVal, attrVal));
|
|
3421
|
+
prevAttrVal = attrVal;
|
|
3422
|
+
}));
|
|
3423
|
+
}
|
|
3259
3424
|
if (BUILD.propChangeCallback && cmpMeta.$watchers$?.[memberName]) {
|
|
3260
3425
|
const watchMethods = cmpMeta.$watchers$[memberName];
|
|
3261
3426
|
let prevWatchVal = sig.peek();
|
|
@@ -3324,7 +3489,7 @@ const initializeEffects = (elm, hostRef) => {
|
|
|
3324
3489
|
* Modified for Stencil's compiler and vdom
|
|
3325
3490
|
*/
|
|
3326
3491
|
const h = (nodeName, vnodeData, ...children) => {
|
|
3327
|
-
if (typeof nodeName === "string") nodeName = transformTag(nodeName);
|
|
3492
|
+
if (typeof nodeName === "string" && nodeName.includes("-")) nodeName = transformTag(nodeName);
|
|
3328
3493
|
let child = null;
|
|
3329
3494
|
let key = null;
|
|
3330
3495
|
let slotName = null;
|
|
@@ -3798,7 +3963,7 @@ const addSlottedNodes = (slottedNodes, slotNodeId, slotName, slotNode, hostId) =
|
|
|
3798
3963
|
if (!slottedNode || slottedNode.nodeValue?.startsWith("s.")) return;
|
|
3799
3964
|
do {
|
|
3800
3965
|
const sa = slottedNode["getAttribute"] && slottedNode.getAttribute("slot");
|
|
3801
|
-
if ((sa || slottedNode["s-sn"]) === slotName || slotName === "" && !slottedNode["s-sn"] && !sa && (slottedNode.nodeType === NODE_TYPE.CommentNode || slottedNode.nodeType === NODE_TYPE.TextNode)) {
|
|
3966
|
+
if ((slottedNode["getAttribute"] && slottedNode.getAttribute("s-sn")) === slotName || (sa || slottedNode["s-sn"]) === slotName || slotName === "" && !slottedNode["s-sn"] && !sa && (slottedNode.nodeType === NODE_TYPE.CommentNode || slottedNode.nodeType === NODE_TYPE.TextNode)) {
|
|
3802
3967
|
slottedNode["s-sn"] = slotName;
|
|
3803
3968
|
group.push({
|
|
3804
3969
|
slot: slotNode,
|
|
@@ -4320,134 +4485,6 @@ const normalizeWatchers = (raw) => {
|
|
|
4320
4485
|
return out;
|
|
4321
4486
|
};
|
|
4322
4487
|
//#endregion
|
|
4323
|
-
//#region src/runtime/parse-property-value.ts
|
|
4324
|
-
/**
|
|
4325
|
-
* Parse a new property value for a given property type.
|
|
4326
|
-
*
|
|
4327
|
-
* While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
|
|
4328
|
-
* it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
|
|
4329
|
-
* 1. `any`, the type given to `propValue` in the function signature
|
|
4330
|
-
* 2. the type stored from `propType`.
|
|
4331
|
-
*
|
|
4332
|
-
* This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
|
|
4333
|
-
*
|
|
4334
|
-
* Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
|
|
4335
|
-
* a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
|
|
4336
|
-
* based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
|
|
4337
|
-
* ```tsx
|
|
4338
|
-
* <my-cmp prop-val={0}></my-cmp>
|
|
4339
|
-
* ```
|
|
4340
|
-
*
|
|
4341
|
-
* HTML prop values on the other hand, will always a string
|
|
4342
|
-
*
|
|
4343
|
-
* @param propValue the new value to coerce to some type
|
|
4344
|
-
* @param propType the type of the prop, expressed as a binary number
|
|
4345
|
-
* @returns the parsed/coerced value
|
|
4346
|
-
*/
|
|
4347
|
-
const parsePropertyValue = (propValue, propType) => {
|
|
4348
|
-
if (propValue != null && !isComplexType(propValue)) {
|
|
4349
|
-
/**
|
|
4350
|
-
* ensure this value is of the correct prop type
|
|
4351
|
-
*/
|
|
4352
|
-
if (BUILD.propBoolean && propType & MEMBER_FLAGS.Boolean) return propValue === "" || !!propValue;
|
|
4353
|
-
/**
|
|
4354
|
-
* force it to be a number
|
|
4355
|
-
*/
|
|
4356
|
-
if (BUILD.propNumber && propType & MEMBER_FLAGS.Number) return typeof propValue === "string" ? parseFloat(propValue) : typeof propValue === "number" ? propValue : NaN;
|
|
4357
|
-
/**
|
|
4358
|
-
* could have been passed as a number or boolean but we still want it as a string
|
|
4359
|
-
*/
|
|
4360
|
-
if (BUILD.propString && propType & MEMBER_FLAGS.String) return String(propValue);
|
|
4361
|
-
return propValue;
|
|
4362
|
-
}
|
|
4363
|
-
/**
|
|
4364
|
-
* not sure exactly what type we want so no need to change to a different type
|
|
4365
|
-
*/
|
|
4366
|
-
return propValue;
|
|
4367
|
-
};
|
|
4368
|
-
//#endregion
|
|
4369
|
-
//#region src/runtime/set-value.ts
|
|
4370
|
-
const applySerializers = (hostRef, cmpMeta, propName, val, instance) => {
|
|
4371
|
-
const run = (inst) => {
|
|
4372
|
-
let attrVal = val;
|
|
4373
|
-
for (const serializer of cmpMeta.$serializers$[propName]) {
|
|
4374
|
-
const [[methodName]] = Object.entries(serializer);
|
|
4375
|
-
attrVal = inst[methodName](attrVal, propName);
|
|
4376
|
-
}
|
|
4377
|
-
hostRef.$serializerValues$.set(propName, attrVal);
|
|
4378
|
-
};
|
|
4379
|
-
if (instance) run(instance);
|
|
4380
|
-
else hostRef.$fetchedCbList$.push(() => run(hostRef.$lazyInstance$));
|
|
4381
|
-
};
|
|
4382
|
-
const getValue = (ref, propName) => {
|
|
4383
|
-
if (BUILD.signalBacking) {
|
|
4384
|
-
const sig = getHostRef(ref)?.$signalValues$?.get(propName);
|
|
4385
|
-
if (sig !== void 0) return sig.value;
|
|
4386
|
-
}
|
|
4387
|
-
return getHostRef(ref).$instanceValues$.get(propName);
|
|
4388
|
-
};
|
|
4389
|
-
const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
4390
|
-
const hostRef = getHostRef(ref);
|
|
4391
|
-
if (BUILD.serializer && hostRef?.$flags$ & HOST_FLAGS.isReflecting && hostRef.$serializerValues$.has(propName) && hostRef.$serializerValues$.get(propName) === newVal) return;
|
|
4392
|
-
if (BUILD.signalBacking) {
|
|
4393
|
-
const sig = hostRef?.$signalValues$?.get(propName);
|
|
4394
|
-
if (sig !== void 0) {
|
|
4395
|
-
const parsed = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
|
|
4396
|
-
if (BUILD.serializer && BUILD.reflect && cmpMeta.$attrsToReflect$ && cmpMeta.$serializers$?.[propName]) {
|
|
4397
|
-
const elm = BUILD.lazyLoad ? hostRef.$hostElement$ : ref;
|
|
4398
|
-
applySerializers(hostRef, cmpMeta, propName, parsed, BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm);
|
|
4399
|
-
}
|
|
4400
|
-
if (!(Number.isNaN(sig.peek()) && Number.isNaN(parsed))) sig.value = parsed;
|
|
4401
|
-
return;
|
|
4402
|
-
}
|
|
4403
|
-
}
|
|
4404
|
-
if (!hostRef) {
|
|
4405
|
-
if (BUILD.lazyLoad) throw new Error(BUILD.isDev ? `Couldn't find host element for "${cmpMeta.$tagName$}". This usually happens when integrating a 3rd party Stencil component with another Stencil runtime. See https://github.com/stenciljs/core/issues/5457` : `Host element not found for "${cmpMeta.$tagName$}"`);
|
|
4406
|
-
return;
|
|
4407
|
-
}
|
|
4408
|
-
const elm = BUILD.lazyLoad ? hostRef.$hostElement$ : ref;
|
|
4409
|
-
const oldVal = hostRef.$instanceValues$.get(propName);
|
|
4410
|
-
const flags = hostRef.$flags$;
|
|
4411
|
-
const instance = BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm;
|
|
4412
|
-
newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
|
|
4413
|
-
const didValueChange = newVal !== oldVal && !(Number.isNaN(oldVal) && Number.isNaN(newVal));
|
|
4414
|
-
if ((!BUILD.lazyLoad || !(flags & HOST_FLAGS.isConstructingInstance) || oldVal === void 0) && didValueChange) {
|
|
4415
|
-
hostRef.$instanceValues$.set(propName, newVal);
|
|
4416
|
-
if (BUILD.serializer && BUILD.reflect && cmpMeta.$attrsToReflect$ && cmpMeta.$serializers$?.[propName]) applySerializers(hostRef, cmpMeta, propName, newVal, instance);
|
|
4417
|
-
if (BUILD.isDev) {
|
|
4418
|
-
if (hostRef.$flags$ & HOST_FLAGS.devOnRender) consoleDevWarn(`The state/prop "${propName}" changed during rendering. This can potentially lead to infinite-loops and other bugs.`, "\nElement", elm, "\nNew value", newVal, "\nOld value", oldVal);
|
|
4419
|
-
else if (hostRef.$flags$ & HOST_FLAGS.devOnDidLoad) consoleDevWarn(`The state/prop "${propName}" changed during "componentDidLoad()", this triggers extra re-renders, try to setup on "componentWillLoad()"`, "\nElement", elm, "\nNew value", newVal, "\nOld value", oldVal);
|
|
4420
|
-
}
|
|
4421
|
-
if (BUILD.propChangeCallback && cmpMeta.$watchers$) {
|
|
4422
|
-
const watchMethods = cmpMeta.$watchers$[propName];
|
|
4423
|
-
if (watchMethods) watchMethods.map((watcher) => {
|
|
4424
|
-
try {
|
|
4425
|
-
const [[watchMethodName, watcherFlags]] = Object.entries(watcher);
|
|
4426
|
-
if (flags & HOST_FLAGS.isWatchReady || watcherFlags & WATCH_FLAGS.Immediate) {
|
|
4427
|
-
if (BUILD.signalBacking && !hostRef.$signalValues$) return;
|
|
4428
|
-
if (!instance) hostRef.$fetchedCbList$.push(() => {
|
|
4429
|
-
hostRef.$lazyInstance$[watchMethodName](newVal, oldVal, propName);
|
|
4430
|
-
});
|
|
4431
|
-
else instance[watchMethodName](newVal, oldVal, propName);
|
|
4432
|
-
}
|
|
4433
|
-
} catch (e) {
|
|
4434
|
-
consoleError(e, elm);
|
|
4435
|
-
}
|
|
4436
|
-
});
|
|
4437
|
-
}
|
|
4438
|
-
if (BUILD.updatable && flags & HOST_FLAGS.hasRendered) {
|
|
4439
|
-
if (instance.componentShouldUpdate) {
|
|
4440
|
-
const changes = hostRef.$queuedPropChanges$ ||= {};
|
|
4441
|
-
changes[propName] = {
|
|
4442
|
-
newVal,
|
|
4443
|
-
oldVal: changes[propName]?.oldVal ?? oldVal
|
|
4444
|
-
};
|
|
4445
|
-
}
|
|
4446
|
-
if (!(flags & HOST_FLAGS.isQueuedForUpdate)) scheduleUpdate(hostRef, false);
|
|
4447
|
-
}
|
|
4448
|
-
}
|
|
4449
|
-
};
|
|
4450
|
-
//#endregion
|
|
4451
4488
|
//#region src/runtime/proxy-component.ts
|
|
4452
4489
|
/**
|
|
4453
4490
|
* Serialize a prop value the way `setAccessor()` does when it reflects it, so the runtime can
|