@stencil/core 5.0.0-alpha.15 → 5.0.0-alpha.17
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/README.md +94 -0
- package/dist/app-data/index.js +1 -1
- package/dist/{client-aTQ7xHxx.mjs → client-CgXNkftm.mjs} +18 -6
- package/dist/compiler/index.d.mts +167 -2
- package/dist/compiler/index.mjs +4 -3
- package/dist/compiler/utils/index.d.mts +1 -1
- package/dist/compiler/utils/index.mjs +1 -1
- package/dist/{compiler-DFO3q3RZ.mjs → compiler-CXWiPNlE.mjs} +410 -110
- package/dist/declarations/stencil-public-compiler.d.ts +45 -15
- package/dist/{index-BvkyxSY6.d.mts → index-3fu7WQs4.d.mts} +1 -1
- package/dist/{index-vY35H18z.d.mts → index-F3IidHM1.d.mts} +45 -15
- package/dist/index.mjs +1 -1
- package/dist/jsx-runtime.mjs +1 -1
- package/dist/{node-BSwezCWj.mjs → node-jFf98r0u.mjs} +53 -53
- package/dist/runtime/client/lazy.js +20 -6
- package/dist/runtime/client/runtime.js +20 -6
- package/dist/runtime/index.js +20 -6
- package/dist/runtime/server/index.mjs +20 -6
- package/dist/signals/index.js +1 -1
- 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.d.mts +2 -2
- package/dist/testing/index.mjs +14 -14
- package/dist/{validation-CtaOJgnM.mjs → validation-ByxKj8bC.mjs} +5 -5
- package/package.json +4 -4
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { n as __require } from "./chunk-z9aeyW2b.mjs";
|
|
2
|
-
import { O as HYDRATED_CSS, f as scopeCss } from "./client-
|
|
2
|
+
import { O as HYDRATED_CSS, f as scopeCss } from "./client-CgXNkftm.mjs";
|
|
3
3
|
import { $ as VALID_CONFIG_OUTPUT_TARGETS, C as ASSETS, D as COLLECTION_MANIFEST_FILE_NAME, E as COLLECTION_APP_DATA_FILE_NAME, F as DOCS_README, J as STANDALONE, L as EVENT_FLAGS, O as COPY, P as DOCS_JSON, Q as TYPES, R as GENERATED_DTS, T as COLLECTION, U as LOADER_BUNDLE, X as STYLE_EXT, Y as STATS, _ as sortBy, a as fromEntries, b as toTitleCase, d as isNumber$1, et as WATCH_FLAGS, f as isObject, h as noop, i as flatOne, j as DIST_LAZY, l as isFunction, m as mergeIntoWith, n as dashToPascalCase, o as isBoolean$1, p as isString$1, u as isIterable, x as unique, y as toDashCase, z as GLOBAL_STYLE } from "./regular-expression-CFVJOTUh.mjs";
|
|
4
|
-
import { $ as loadTypeScriptDiagnostics, A as isOutputTargetCollection, B as isOutputTargetGlobalStyle, Ct as formatComponentRuntimeMeta, E as getComponentsDtsSrcFilePath, Et as byteSize, F as isOutputTargetDocsCustom, G as isOutputTargetStats, H as isOutputTargetSsr, I as isOutputTargetDocsCustomElementsManifest, J as isValidConfigOutputTarget, K as isOutputTargetTypes, L as isOutputTargetDocsJson, M as isOutputTargetCustom, N as isOutputTargetDistLazy, O as getComponentsFromModules, P as isOutputTargetDocs, Q as loadTypeScriptDiagnostic, R as isOutputTargetDocsReadme, S as ok, St as isGlob, T as filterExcludedComponents, Tt as stringifyRuntimeData, U as isOutputTargetSsrWasm, V as isOutputTargetLoaderBundle, W as isOutputTargetStandalone, Y as relativeImport, Z as augmentDiagnosticWithNode, _ as getSourceMappingUrlForEndOfFile, _t as catchError, a as getTextDocs, at as relative$1, b as err, ct as isRolldownError, d as isTsxFile, dt as normalizeDiagnostics, et as join$2, f as parsePackageJson, ft as splitLineBreaks, g as getInlineSourceMappingUrlLinker, gt as buildWarn, h as isRemoteUrl, ht as buildJsonFileError, i as generatePreamble, it as normalizePath, j as isOutputTargetCopy, k as isOutputTargetAssets, lt as loadRolldownDiagnostics, m as readPackageJson, mt as buildError, n as addDocBlock, nt as normalizeFsPath, o as hasDependency, ot as resolve$2, p as readOnlyArrayHasStringMember, q as isOutputTargetWww, r as createJsVarName, rt as normalizeFsPathQuery, s as isDtsFile, st as createOnWarnFn, t as validateComponentTag, u as isTsFile, vt as hasError, w as filterActiveTargets, x as map, xt as isRootPath, y as rolldownToStencilSourceMap, yt as hasWarning, z as isOutputTargetDocsVscode } from "./validation-
|
|
5
|
-
import { i as CustomElementsExportBehaviorOptions, o as buildEvents, r as createNodeLogger, t as createNodeSys } from "./node-
|
|
4
|
+
import { $ as loadTypeScriptDiagnostics, A as isOutputTargetCollection, B as isOutputTargetGlobalStyle, Ct as formatComponentRuntimeMeta, E as getComponentsDtsSrcFilePath, Et as byteSize, F as isOutputTargetDocsCustom, G as isOutputTargetStats, H as isOutputTargetSsr, I as isOutputTargetDocsCustomElementsManifest, J as isValidConfigOutputTarget, K as isOutputTargetTypes, L as isOutputTargetDocsJson, M as isOutputTargetCustom, N as isOutputTargetDistLazy, O as getComponentsFromModules, P as isOutputTargetDocs, Q as loadTypeScriptDiagnostic, R as isOutputTargetDocsReadme, S as ok, St as isGlob, T as filterExcludedComponents, Tt as stringifyRuntimeData, U as isOutputTargetSsrWasm, V as isOutputTargetLoaderBundle, W as isOutputTargetStandalone, Y as relativeImport, Z as augmentDiagnosticWithNode, _ as getSourceMappingUrlForEndOfFile, _t as catchError, a as getTextDocs, at as relative$1, b as err, ct as isRolldownError, d as isTsxFile, dt as normalizeDiagnostics, et as join$2, f as parsePackageJson, ft as splitLineBreaks, g as getInlineSourceMappingUrlLinker, gt as buildWarn, h as isRemoteUrl, ht as buildJsonFileError, i as generatePreamble, it as normalizePath, j as isOutputTargetCopy, k as isOutputTargetAssets, lt as loadRolldownDiagnostics, m as readPackageJson, mt as buildError, n as addDocBlock, nt as normalizeFsPath, o as hasDependency, ot as resolve$2, p as readOnlyArrayHasStringMember, q as isOutputTargetWww, r as createJsVarName, rt as normalizeFsPathQuery, s as isDtsFile, st as createOnWarnFn, t as validateComponentTag, u as isTsFile, vt as hasError, w as filterActiveTargets, x as map, xt as isRootPath, y as rolldownToStencilSourceMap, yt as hasWarning, z as isOutputTargetDocsVscode } from "./validation-ByxKj8bC.mjs";
|
|
5
|
+
import { i as CustomElementsExportBehaviorOptions, o as buildEvents, r as createNodeLogger, t as createNodeSys } from "./node-jFf98r0u.mjs";
|
|
6
6
|
import ts, { default as ts$1 } from "typescript";
|
|
7
7
|
import { readFileSync } from "node:fs";
|
|
8
8
|
import { basename, dirname, isAbsolute, join, resolve } from "node:path";
|
|
9
9
|
import { fileURLToPath } from "node:url";
|
|
10
10
|
import picomatch from "picomatch";
|
|
11
|
-
import path, { basename as basename$1, dirname as dirname$1, extname, isAbsolute as isAbsolute$1, join as join$1 } from "path";
|
|
11
|
+
import path$1, { basename as basename$1, dirname as dirname$1, extname, isAbsolute as isAbsolute$1, join as join$1 } from "path";
|
|
12
12
|
import { cloneDocument, createDocument, serializeNodeToHtml } from "@stencil/mock-doc";
|
|
13
13
|
import postcss from "postcss";
|
|
14
14
|
import postcssSafeParser from "postcss-safe-parser";
|
|
@@ -28,9 +28,9 @@ import { createJiti } from "jiti";
|
|
|
28
28
|
import * as process$1 from "process";
|
|
29
29
|
import { dataToEsm } from "@rollup/pluginutils";
|
|
30
30
|
//#region src/version.ts
|
|
31
|
-
const version = "5.0.0-alpha.
|
|
32
|
-
const buildId = "
|
|
33
|
-
const vermoji = "
|
|
31
|
+
const version = "5.0.0-alpha.17";
|
|
32
|
+
const buildId = "1783170414";
|
|
33
|
+
const vermoji = "🎨";
|
|
34
34
|
/**
|
|
35
35
|
* Get the installed version of a tool/dependency.
|
|
36
36
|
* Handles packages with exports maps that point to subdirectories.
|
|
@@ -1738,16 +1738,6 @@ const isInternal = (jsDocs) => {
|
|
|
1738
1738
|
return !!(jsDocs && jsDocs.tags.some((s) => s.name === "internal"));
|
|
1739
1739
|
};
|
|
1740
1740
|
/**
|
|
1741
|
-
* Check if a class element is a method with a specific name.
|
|
1742
|
-
*
|
|
1743
|
-
* @param member - the class element to check
|
|
1744
|
-
* @param methodName - the method name to match
|
|
1745
|
-
* @returns true if the member is a method with the specified name
|
|
1746
|
-
*/
|
|
1747
|
-
const isMethod = (member, methodName) => {
|
|
1748
|
-
return ts.isMethodDeclaration(member) && member.name && member.name.escapedText === methodName;
|
|
1749
|
-
};
|
|
1750
|
-
/**
|
|
1751
1741
|
* Create an ESM import statement.
|
|
1752
1742
|
*
|
|
1753
1743
|
* @param importFnNames - the names to import
|
|
@@ -2111,6 +2101,7 @@ const generateAppDataModule = (build, config) => {
|
|
|
2111
2101
|
};
|
|
2112
2102
|
const serializeCollectionManifest = (config, compilerCtx, buildCtx) => {
|
|
2113
2103
|
const buildFlags = getBuildFeatures(buildCtx.moduleFiles.filter((mod) => !mod.isCollectionDependency).flatMap((mod) => mod.cmps));
|
|
2104
|
+
buildFlags.hydrateClientSide = config.outputTargets.some(isOutputTargetSsr);
|
|
2114
2105
|
const ldp = config.compat?.lightDomPatches ?? true;
|
|
2115
2106
|
if (buildFlags.slotRelocation && ldp !== false) {
|
|
2116
2107
|
buildFlags.lightDomPatches = ldp === true;
|
|
@@ -3093,6 +3084,7 @@ const removeCollectionImports = (compilerCtx) => {
|
|
|
3093
3084
|
//#region src/compiler/bundle/entry-alias-ids.ts
|
|
3094
3085
|
const STENCIL_CORE_ID = "@stencil/core";
|
|
3095
3086
|
const STENCIL_INTERNAL_ID = "@stencil/core/runtime";
|
|
3087
|
+
const STENCIL_APP_DATA_ID = "@stencil/core/app-data";
|
|
3096
3088
|
const STENCIL_APP_GLOBALS_ID = "@stencil/core/app-globals";
|
|
3097
3089
|
const STENCIL_SSR_FACTORY_ID = "@stencil/core/runtime/server/ssr-factory";
|
|
3098
3090
|
const STENCIL_INTERNAL_STANDALONE_CLIENT_PLATFORM_ID = "@stencil/core/runtime/client/standalone";
|
|
@@ -7193,6 +7185,51 @@ const getDocsCustomStates = (cmpMeta) => {
|
|
|
7193
7185
|
docs: state.docs || ""
|
|
7194
7186
|
})), (state) => state.name);
|
|
7195
7187
|
};
|
|
7188
|
+
/**
|
|
7189
|
+
* Convert a single {@link d.ComponentCompilerMeta} to a {@link d.JsonDocsComponent}
|
|
7190
|
+
* without reading any files from disk (readme/usage are left empty).
|
|
7191
|
+
*
|
|
7192
|
+
* Useful for single-file transpilation contexts (e.g. `transpileSync`) when a
|
|
7193
|
+
* full build context is not available.
|
|
7194
|
+
* @param cmp the component metadata to convert
|
|
7195
|
+
* @param filePath absolute path to the component source file
|
|
7196
|
+
* @param rootDir project root used to make `filePath` relative (defaults to `process.cwd()`)
|
|
7197
|
+
* @returns a {@link d.JsonDocsComponent} with empty readme/usage
|
|
7198
|
+
*/
|
|
7199
|
+
const cmpMetaToDocsComponent = (cmp, filePath, rootDir = process.cwd()) => {
|
|
7200
|
+
const normalizedFilePath = normalizePath(filePath);
|
|
7201
|
+
const dirPath = normalizePath(dirname$1(normalizedFilePath));
|
|
7202
|
+
const docs = cmp.docs ?? {
|
|
7203
|
+
text: "",
|
|
7204
|
+
tags: []
|
|
7205
|
+
};
|
|
7206
|
+
return {
|
|
7207
|
+
dirPath,
|
|
7208
|
+
filePath: normalizePath(relative$1(rootDir, normalizedFilePath), false),
|
|
7209
|
+
fileName: basename$1(normalizedFilePath),
|
|
7210
|
+
readmePath: normalizePath(join$2(dirPath, "readme.md")),
|
|
7211
|
+
usagesDir: normalizePath(join$2(dirPath, "usage")),
|
|
7212
|
+
tag: cmp.tagName,
|
|
7213
|
+
readme: "",
|
|
7214
|
+
overview: docs.text,
|
|
7215
|
+
usage: {},
|
|
7216
|
+
docs: docs.text,
|
|
7217
|
+
docsTags: docs.tags,
|
|
7218
|
+
encapsulation: getDocsEncapsulation(cmp),
|
|
7219
|
+
dependents: cmp.directDependents ?? [],
|
|
7220
|
+
dependencies: cmp.directDependencies ?? [],
|
|
7221
|
+
dependencyGraph: {},
|
|
7222
|
+
deprecation: getDocsDeprecationText(docs.tags),
|
|
7223
|
+
props: getDocsProperties(cmp),
|
|
7224
|
+
methods: getDocsMethods(cmp.methods ?? []),
|
|
7225
|
+
events: getDocsEvents(cmp.events ?? []),
|
|
7226
|
+
styles: getDocsStyles(cmp),
|
|
7227
|
+
slots: getDocsSlots(docs.tags),
|
|
7228
|
+
parts: getDocsParts(cmp.htmlParts ?? [], docs.tags),
|
|
7229
|
+
customStates: getDocsCustomStates(cmp),
|
|
7230
|
+
listeners: getDocsListeners(cmp.listeners ?? [])
|
|
7231
|
+
};
|
|
7232
|
+
};
|
|
7196
7233
|
const getNameText = (name, tags) => {
|
|
7197
7234
|
return tags.filter((tag) => tag.name === name && tag.text).map(({ text }) => {
|
|
7198
7235
|
const [namePart, ...rest] = (" " + text).split(" - ");
|
|
@@ -7366,6 +7403,19 @@ const convertTypeReferences = (references) => {
|
|
|
7366
7403
|
}));
|
|
7367
7404
|
};
|
|
7368
7405
|
/**
|
|
7406
|
+
* Converts Stencil docsTags to CEM Tag objects, skipping `@deprecated` which
|
|
7407
|
+
* is already conveyed by the dedicated `deprecated` CEM field.
|
|
7408
|
+
* @param docsTags the Stencil docsTags array
|
|
7409
|
+
* @returns CEM Tag array or undefined if no tags remain
|
|
7410
|
+
*/
|
|
7411
|
+
const toTags = (docsTags) => {
|
|
7412
|
+
const tags = docsTags.filter((t) => t.name !== "deprecated").map((t) => ({
|
|
7413
|
+
name: t.name,
|
|
7414
|
+
...t.text && { text: t.text }
|
|
7415
|
+
}));
|
|
7416
|
+
return tags.length > 0 ? tags : void 0;
|
|
7417
|
+
};
|
|
7418
|
+
/**
|
|
7369
7419
|
* Create a CEM Type object from a type string and optional references
|
|
7370
7420
|
* @param text the type string
|
|
7371
7421
|
* @param references Stencil's type references map
|
|
@@ -7391,7 +7441,8 @@ const componentToDeclaration = (component) => {
|
|
|
7391
7441
|
...prop.type && { type: createType(prop.type, prop.complexType?.references) },
|
|
7392
7442
|
...prop.default !== void 0 && { default: prop.default },
|
|
7393
7443
|
fieldName: prop.name,
|
|
7394
|
-
...prop.deprecation !== void 0 && { deprecated: prop.deprecation || true }
|
|
7444
|
+
...prop.deprecation !== void 0 && { deprecated: prop.deprecation || true },
|
|
7445
|
+
...toTags(prop.docsTags) && { tags: toTags(prop.docsTags) }
|
|
7395
7446
|
}));
|
|
7396
7447
|
const members = [...component.props.map((prop) => ({
|
|
7397
7448
|
kind: "field",
|
|
@@ -7402,7 +7453,8 @@ const componentToDeclaration = (component) => {
|
|
|
7402
7453
|
...prop.deprecation !== void 0 && { deprecated: prop.deprecation || true },
|
|
7403
7454
|
...!prop.mutable && { readonly: true },
|
|
7404
7455
|
...prop.attr && { attribute: prop.attr },
|
|
7405
|
-
...prop.reflectToAttr && { reflects: true }
|
|
7456
|
+
...prop.reflectToAttr && { reflects: true },
|
|
7457
|
+
...toTags(prop.docsTags) && { tags: toTags(prop.docsTags) }
|
|
7406
7458
|
})), ...component.methods.map((method) => ({
|
|
7407
7459
|
kind: "method",
|
|
7408
7460
|
name: method.name,
|
|
@@ -7416,13 +7468,15 @@ const componentToDeclaration = (component) => {
|
|
|
7416
7468
|
...method.returns && { return: {
|
|
7417
7469
|
...method.returns.type && { type: createType(method.returns.type, method.complexType?.references) },
|
|
7418
7470
|
...method.returns.docs && { description: method.returns.docs }
|
|
7419
|
-
} }
|
|
7471
|
+
} },
|
|
7472
|
+
...toTags(method.docsTags) && { tags: toTags(method.docsTags) }
|
|
7420
7473
|
}))];
|
|
7421
7474
|
const events = component.events.map((event) => ({
|
|
7422
7475
|
name: event.event,
|
|
7423
7476
|
...event.docs && { description: event.docs },
|
|
7424
7477
|
type: createType(event.detail ? `CustomEvent<${event.detail}>` : "CustomEvent", event.complexType?.references),
|
|
7425
|
-
...event.deprecation !== void 0 && { deprecated: event.deprecation || true }
|
|
7478
|
+
...event.deprecation !== void 0 && { deprecated: event.deprecation || true },
|
|
7479
|
+
...toTags(event.docsTags) && { tags: toTags(event.docsTags) }
|
|
7426
7480
|
}));
|
|
7427
7481
|
const slots = component.slots.map((slot) => ({
|
|
7428
7482
|
name: slot.name,
|
|
@@ -7447,13 +7501,14 @@ const componentToDeclaration = (component) => {
|
|
|
7447
7501
|
name: className,
|
|
7448
7502
|
...component.docs && { description: component.docs },
|
|
7449
7503
|
...component.deprecation !== void 0 && { deprecated: component.deprecation || true },
|
|
7504
|
+
...toTags(component.docsTags) && { tags: toTags(component.docsTags) },
|
|
7450
7505
|
...attributes.length > 0 && { attributes },
|
|
7451
7506
|
...members.length > 0 && { members },
|
|
7452
7507
|
...events.length > 0 && { events },
|
|
7453
7508
|
...slots.length > 0 && { slots },
|
|
7454
7509
|
...cssParts.length > 0 && { cssParts },
|
|
7455
7510
|
...cssProperties.length > 0 && { cssProperties },
|
|
7456
|
-
...component.customStates.length > 0 && {
|
|
7511
|
+
...component.customStates.length > 0 && { cssStates: component.customStates.map((state) => ({
|
|
7457
7512
|
name: state.name,
|
|
7458
7513
|
initialValue: state.initialValue,
|
|
7459
7514
|
...state.docs && { description: state.docs }
|
|
@@ -11197,17 +11252,24 @@ const updateNativeComponentClass = (transformOpts, classNode, moduleFile, cmp, b
|
|
|
11197
11252
|
return updateComponentClass(transformOpts, withHeritageClauses, withHeritageClauses.heritageClauses, members);
|
|
11198
11253
|
};
|
|
11199
11254
|
/**
|
|
11200
|
-
*
|
|
11201
|
-
*
|
|
11202
|
-
*
|
|
11203
|
-
*
|
|
11255
|
+
* Transforms a Stencil superclass (a base class that Stencil components extend)
|
|
11256
|
+
* in the **full build** path, where `compilerCtx.moduleMap` is populated and the
|
|
11257
|
+
* module is flagged with `isExtended = true`.
|
|
11258
|
+
*
|
|
11259
|
+
* For the stateless transpile / unplugin path, use {@link updateNativeBaseClass}
|
|
11260
|
+
* instead — it preserves the `ClassDeclaration` form so derived components can
|
|
11261
|
+
* still import the base class by name.
|
|
11262
|
+
*
|
|
11263
|
+
* - Adds `extends HTMLElement` if necessary
|
|
11264
|
+
* - Ensures the constructor has a `super()` call
|
|
11265
|
+
* - Removes static metadata properties
|
|
11204
11266
|
*
|
|
11205
11267
|
* @param node the class node to update
|
|
11206
11268
|
* @param moduleFile the module file containing the class
|
|
11207
11269
|
* @param transformOpts transformation options
|
|
11208
11270
|
* @returns the updated class node
|
|
11209
11271
|
*/
|
|
11210
|
-
const
|
|
11272
|
+
const updateNativeSuperClass = (node, moduleFile, transformOpts) => {
|
|
11211
11273
|
let withHeritageClauses = updateNativeHostComponentHeritageClauses(node, moduleFile);
|
|
11212
11274
|
const ctor = withHeritageClauses.members.find(ts.isConstructorDeclaration);
|
|
11213
11275
|
if (!foundSuper(ctor?.body?.statements)) {
|
|
@@ -11231,6 +11293,26 @@ const updateNativeHostComponentHeritageClauses = (classNode, moduleFile) => {
|
|
|
11231
11293
|
return ts.factory.updateClassDeclaration(classNode, classNode.modifiers, classNode.name, classNode.typeParameters, [heritageClause], classNode.members);
|
|
11232
11294
|
};
|
|
11233
11295
|
/**
|
|
11296
|
+
* Transforms a Stencil superclass (a base class that Stencil components extend)
|
|
11297
|
+
* in the **stateless transpile / unplugin** path, where `compilerCtx.moduleMap`
|
|
11298
|
+
* is not populated.
|
|
11299
|
+
*
|
|
11300
|
+
* For the full build path, use {@link updateNativeSuperClass} instead.
|
|
11301
|
+
*
|
|
11302
|
+
* Unlike `updateNativeSuperClass` this function keeps the class as a
|
|
11303
|
+
* `ClassDeclaration` so the `export` modifier is preserved — derived
|
|
11304
|
+
* components still need to import the base class by name.
|
|
11305
|
+
*
|
|
11306
|
+
* @param node the base class declaration
|
|
11307
|
+
* @param moduleFile the module file (used to register the HTMLElement import)
|
|
11308
|
+
* @returns the updated class declaration
|
|
11309
|
+
*/
|
|
11310
|
+
const updateNativeBaseClass = (node, moduleFile) => {
|
|
11311
|
+
const withHeritageClauses = updateNativeHostComponentHeritageClauses(node, moduleFile);
|
|
11312
|
+
const membersWithCtor = updateConstructor(withHeritageClauses, removeStaticMetaProperties(withHeritageClauses), [], void 0, false);
|
|
11313
|
+
return ts.factory.updateClassDeclaration(withHeritageClauses, withHeritageClauses.modifiers, withHeritageClauses.name, withHeritageClauses.typeParameters, withHeritageClauses.heritageClauses, membersWithCtor);
|
|
11314
|
+
};
|
|
11315
|
+
/**
|
|
11234
11316
|
* Perform various modifications to the class members of a Stencil component
|
|
11235
11317
|
* which are necessary for it to be a 'native' web component.
|
|
11236
11318
|
*
|
|
@@ -11260,6 +11342,15 @@ const updateNativeHostComponentMembers = (transformOpts, classNode, moduleFile,
|
|
|
11260
11342
|
};
|
|
11261
11343
|
//#endregion
|
|
11262
11344
|
//#region src/compiler/transformers/component-native/tranform-to-native-component.ts
|
|
11345
|
+
const STENCIL_META_GETTER_NAMES = [
|
|
11346
|
+
"properties",
|
|
11347
|
+
"states",
|
|
11348
|
+
"events",
|
|
11349
|
+
"listeners",
|
|
11350
|
+
"watchers",
|
|
11351
|
+
"methods"
|
|
11352
|
+
];
|
|
11353
|
+
const isStencilBaseClass = (node) => node.members.some((m) => isStaticGetter(m) && ts.isGetAccessorDeclaration(m) && ts.isIdentifier(m.name) && STENCIL_META_GETTER_NAMES.includes(m.name.text));
|
|
11263
11354
|
/**
|
|
11264
11355
|
* A function that returns a transformation factory. The returned factory
|
|
11265
11356
|
* performs a series of transformations on Stencil components, in order to
|
|
@@ -11291,7 +11382,8 @@ const nativeComponentTransform = (compilerCtx, transformOpts, buildCtx) => {
|
|
|
11291
11382
|
if (ts.isClassDeclaration(node)) {
|
|
11292
11383
|
const cmp = getComponentMeta(compilerCtx, tsSourceFile, node);
|
|
11293
11384
|
if (cmp != null) return updateNativeComponentClass(transformOpts, node, moduleFile, cmp, buildCtx);
|
|
11294
|
-
else if (compilerCtx.moduleMap.get(tsSourceFile.fileName)?.isExtended) return
|
|
11385
|
+
else if (compilerCtx.moduleMap.get(tsSourceFile.fileName)?.isExtended) return updateNativeSuperClass(node, moduleFile, transformOpts);
|
|
11386
|
+
else if (moduleFile && (isStencilBaseClass(node) || transformOpts.transformAsBaseClass)) return updateNativeBaseClass(node, moduleFile);
|
|
11295
11387
|
}
|
|
11296
11388
|
return ts.visitEachChild(node, visitNode, transformCtx);
|
|
11297
11389
|
};
|
|
@@ -14593,8 +14685,7 @@ function buildExtendsTree(compilerCtx, classDeclaration, dependentClasses, typeC
|
|
|
14593
14685
|
if (keepLooking) buildExtendsTree(compilerCtx, foundClassDeclaration, dependentClasses, typeChecker, buildCtx, ogModule);
|
|
14594
14686
|
return;
|
|
14595
14687
|
}
|
|
14596
|
-
|
|
14597
|
-
importStatements.forEach((statement) => {
|
|
14688
|
+
currentSource.statements.filter(ts.isImportDeclaration).forEach((statement) => {
|
|
14598
14689
|
if (statement.importClause?.namedBindings && ts.isNamedImports(statement.importClause?.namedBindings)) statement.importClause?.namedBindings.elements.forEach((element) => {
|
|
14599
14690
|
if (element.name.getText() === extendee.getText()) {
|
|
14600
14691
|
const className = element.propertyName?.getText() || element.name.getText();
|
|
@@ -14602,11 +14693,6 @@ function buildExtendsTree(compilerCtx, classDeclaration, dependentClasses, typeC
|
|
|
14602
14693
|
}
|
|
14603
14694
|
});
|
|
14604
14695
|
});
|
|
14605
|
-
if (!importStatements.length) currentSource.statements.filter(ts.isVariableStatement).forEach((statement) => {
|
|
14606
|
-
statement.declarationList.declarations.forEach((declaration) => {
|
|
14607
|
-
if (declaration.initializer && ts.isCallExpression(declaration.initializer) && ts.isIdentifier(declaration.initializer.expression) && declaration.initializer.expression.escapedText === "require" && declaration.initializer.arguments.length === 1 && ts.isStringLiteral(declaration.initializer.arguments[0])) resolveAndProcessExtendedClass(compilerCtx, buildCtx, classDeclaration, currentSource, declaration.initializer.arguments[0].text.replaceAll(/['"]/g, ""), extendee.getText(), dependentClasses, typeChecker, ogModule, targetScriptTarget);
|
|
14608
|
-
});
|
|
14609
|
-
});
|
|
14610
14696
|
}
|
|
14611
14697
|
});
|
|
14612
14698
|
return dependentClasses;
|
|
@@ -14634,7 +14720,7 @@ function mergeExtendedClassMeta(compilerCtx, typeChecker, buildCtx, cmpNode, sta
|
|
|
14634
14720
|
let listeners = parseStaticListeners(staticMembers);
|
|
14635
14721
|
let events = parseStaticEvents(staticMembers);
|
|
14636
14722
|
let watchers = parseStaticWatchers(staticMembers);
|
|
14637
|
-
let classMethods = cmpNode.members.filter(ts.isMethodDeclaration);
|
|
14723
|
+
let classMethods = cmpNode.members.filter(ts.isMethodDeclaration).map((m) => ts.isIdentifier(m.name) ? m.name.text : "").filter(Boolean);
|
|
14638
14724
|
let serializers = parseStaticSerializers(staticMembers, "serializers");
|
|
14639
14725
|
let deserializers = parseStaticSerializers(staticMembers, "deserializers");
|
|
14640
14726
|
tree.forEach((extendedClass) => {
|
|
@@ -14667,7 +14753,7 @@ function mergeExtendedClassMeta(compilerCtx, typeChecker, buildCtx, cmpNode, sta
|
|
|
14667
14753
|
watchers = [...deDupeMembers(parseStaticWatchers(extendedStaticMembers) ?? [], watchers), ...watchers];
|
|
14668
14754
|
serializers = [...deDupeMembers(parseStaticSerializers(extendedStaticMembers, "serializers") ?? [], serializers), ...serializers];
|
|
14669
14755
|
deserializers = [...deDupeMembers(parseStaticSerializers(extendedStaticMembers, "deserializers") ?? [], deserializers), ...deserializers];
|
|
14670
|
-
classMethods = [...classMethods, ...extendedClass.classNode.members.filter(ts.isMethodDeclaration)
|
|
14756
|
+
classMethods = [...classMethods, ...extendedClass.classNode.members.filter(ts.isMethodDeclaration).map((m) => ts.isIdentifier(m.name) ? m.name.text : "").filter(Boolean)];
|
|
14671
14757
|
if (isMixin) hasMixin = true;
|
|
14672
14758
|
});
|
|
14673
14759
|
return {
|
|
@@ -14684,23 +14770,274 @@ function mergeExtendedClassMeta(compilerCtx, typeChecker, buildCtx, cmpNode, sta
|
|
|
14684
14770
|
deserializers
|
|
14685
14771
|
};
|
|
14686
14772
|
}
|
|
14773
|
+
const EMPTY_DOCS = {
|
|
14774
|
+
text: "",
|
|
14775
|
+
tags: []
|
|
14776
|
+
};
|
|
14777
|
+
const EMPTY_PROP_COMPLEX_TYPE = {
|
|
14778
|
+
original: "any",
|
|
14779
|
+
resolved: "any",
|
|
14780
|
+
references: {}
|
|
14781
|
+
};
|
|
14782
|
+
const EMPTY_EVENT_COMPLEX_TYPE = {
|
|
14783
|
+
original: "any",
|
|
14784
|
+
resolved: "any",
|
|
14785
|
+
references: {}
|
|
14786
|
+
};
|
|
14787
|
+
const EMPTY_METHOD_COMPLEX_TYPE = {
|
|
14788
|
+
signature: "() => void",
|
|
14789
|
+
parameters: [],
|
|
14790
|
+
references: {},
|
|
14791
|
+
return: "void"
|
|
14792
|
+
};
|
|
14793
|
+
function extractDecoratorOptions(node) {
|
|
14794
|
+
if (!node || !ts.isObjectLiteralExpression(node)) return {};
|
|
14795
|
+
const result = {};
|
|
14796
|
+
for (const prop of node.properties) {
|
|
14797
|
+
if (!ts.isPropertyAssignment(prop) || !ts.isIdentifier(prop.name)) continue;
|
|
14798
|
+
const key = prop.name.text;
|
|
14799
|
+
const val = prop.initializer;
|
|
14800
|
+
if (ts.isStringLiteral(val)) result[key] = val.text;
|
|
14801
|
+
else if (val.kind === ts.SyntaxKind.TrueKeyword) result[key] = true;
|
|
14802
|
+
else if (val.kind === ts.SyntaxKind.FalseKeyword) result[key] = false;
|
|
14803
|
+
else if (ts.isNumericLiteral(val)) result[key] = Number(val.text);
|
|
14804
|
+
}
|
|
14805
|
+
return result;
|
|
14806
|
+
}
|
|
14807
|
+
/**
|
|
14808
|
+
* Extract Stencil member metadata from source text using parse-only TypeScript
|
|
14809
|
+
* (no Program, no TypeChecker). Handles both decorator syntax (.tsx source files)
|
|
14810
|
+
* and compiled static getter syntax (.js collection files).
|
|
14811
|
+
*
|
|
14812
|
+
* @param code source text to parse
|
|
14813
|
+
* @param className name of the class to extract metadata from
|
|
14814
|
+
* @param fileName virtual filename used to determine script kind
|
|
14815
|
+
* @returns extracted metadata, or null if the named class is not found
|
|
14816
|
+
*/
|
|
14817
|
+
function extractInheritedMeta(code, className, fileName = "__stencil_parent__.tsx") {
|
|
14818
|
+
const scriptKind = fileName.endsWith(".tsx") || fileName.endsWith(".ts") ? ts.ScriptKind.TSX : ts.ScriptKind.JS;
|
|
14819
|
+
const classDecl = ts.createSourceFile(fileName, code, ts.ScriptTarget.ESNext, true, scriptKind).statements.filter(ts.isClassDeclaration).find((c) => c.name?.text === className);
|
|
14820
|
+
if (!classDecl) return null;
|
|
14821
|
+
const methodNames = classDecl.members.filter(ts.isMethodDeclaration).map((m) => ts.isIdentifier(m.name) ? m.name.text : "").filter(Boolean);
|
|
14822
|
+
const staticMembers = classDecl.members.filter(isStaticGetter);
|
|
14823
|
+
if (staticMembers.some((m) => ts.isGetAccessorDeclaration(m) && ts.isIdentifier(m.name) && [
|
|
14824
|
+
"properties",
|
|
14825
|
+
"states",
|
|
14826
|
+
"events",
|
|
14827
|
+
"listeners",
|
|
14828
|
+
"watchers",
|
|
14829
|
+
"methods"
|
|
14830
|
+
].includes(m.name.text))) return {
|
|
14831
|
+
properties: parseStaticProps(staticMembers),
|
|
14832
|
+
states: parseStaticStates(staticMembers),
|
|
14833
|
+
methods: parseStaticMethods(staticMembers),
|
|
14834
|
+
events: parseStaticEvents(staticMembers),
|
|
14835
|
+
listeners: parseStaticListeners(staticMembers),
|
|
14836
|
+
watchers: parseStaticWatchers(staticMembers),
|
|
14837
|
+
methodNames
|
|
14838
|
+
};
|
|
14839
|
+
const properties = [];
|
|
14840
|
+
const states = [];
|
|
14841
|
+
const methods = [];
|
|
14842
|
+
const events = [];
|
|
14843
|
+
const listeners = [];
|
|
14844
|
+
const watchers = [];
|
|
14845
|
+
for (const member of classDecl.members) {
|
|
14846
|
+
if (!ts.isPropertyDeclaration(member) && !ts.isMethodDeclaration(member)) continue;
|
|
14847
|
+
if (!ts.isIdentifier(member.name)) continue;
|
|
14848
|
+
const memberName = member.name.text;
|
|
14849
|
+
const decorators = ts.getDecorators?.(member) ?? [];
|
|
14850
|
+
for (const dec of decorators) {
|
|
14851
|
+
if (!ts.isCallExpression(dec.expression) || !ts.isIdentifier(dec.expression.expression)) continue;
|
|
14852
|
+
const decName = dec.expression.expression.text;
|
|
14853
|
+
const args = dec.expression.arguments;
|
|
14854
|
+
if (decName === "Prop" && ts.isPropertyDeclaration(member)) {
|
|
14855
|
+
const opts = extractDecoratorOptions(args[0]);
|
|
14856
|
+
properties.push({
|
|
14857
|
+
name: memberName,
|
|
14858
|
+
attribute: typeof opts.attribute === "string" ? opts.attribute.toLowerCase() : toDashCase(memberName),
|
|
14859
|
+
reflect: !!opts.reflect,
|
|
14860
|
+
mutable: !!opts.mutable,
|
|
14861
|
+
required: false,
|
|
14862
|
+
optional: !!member.questionToken,
|
|
14863
|
+
type: "any",
|
|
14864
|
+
complexType: EMPTY_PROP_COMPLEX_TYPE,
|
|
14865
|
+
docs: EMPTY_DOCS,
|
|
14866
|
+
internal: false,
|
|
14867
|
+
getter: false,
|
|
14868
|
+
setter: false
|
|
14869
|
+
});
|
|
14870
|
+
} else if (decName === "State" && ts.isPropertyDeclaration(member)) states.push({ name: memberName });
|
|
14871
|
+
else if (decName === "Event" && ts.isPropertyDeclaration(member)) {
|
|
14872
|
+
const opts = extractDecoratorOptions(args[0]);
|
|
14873
|
+
events.push({
|
|
14874
|
+
name: typeof opts.eventName === "string" ? opts.eventName : memberName,
|
|
14875
|
+
method: memberName,
|
|
14876
|
+
bubbles: opts.bubbles !== false,
|
|
14877
|
+
cancelable: opts.cancelable !== false,
|
|
14878
|
+
composed: !!opts.composed,
|
|
14879
|
+
docs: EMPTY_DOCS,
|
|
14880
|
+
complexType: EMPTY_EVENT_COMPLEX_TYPE,
|
|
14881
|
+
internal: false
|
|
14882
|
+
});
|
|
14883
|
+
} else if (decName === "Method" && ts.isMethodDeclaration(member)) methods.push({
|
|
14884
|
+
name: memberName,
|
|
14885
|
+
docs: EMPTY_DOCS,
|
|
14886
|
+
complexType: EMPTY_METHOD_COMPLEX_TYPE,
|
|
14887
|
+
internal: false
|
|
14888
|
+
});
|
|
14889
|
+
else if (decName === "Watch" && ts.isMethodDeclaration(member)) {
|
|
14890
|
+
const propName = ts.isStringLiteral(args[0]) ? args[0].text : null;
|
|
14891
|
+
if (propName) watchers.push({
|
|
14892
|
+
propName,
|
|
14893
|
+
methodName: memberName
|
|
14894
|
+
});
|
|
14895
|
+
} else if (decName === "Listen" && ts.isMethodDeclaration(member)) {
|
|
14896
|
+
const eventName = ts.isStringLiteral(args[0]) ? args[0].text : null;
|
|
14897
|
+
if (eventName) {
|
|
14898
|
+
const listenOpts = extractDecoratorOptions(args[1]);
|
|
14899
|
+
listeners.push({
|
|
14900
|
+
name: eventName,
|
|
14901
|
+
method: memberName,
|
|
14902
|
+
capture: !!listenOpts.capture,
|
|
14903
|
+
passive: !!listenOpts.passive,
|
|
14904
|
+
target: typeof listenOpts.target === "string" ? listenOpts.target : void 0
|
|
14905
|
+
});
|
|
14906
|
+
}
|
|
14907
|
+
}
|
|
14908
|
+
}
|
|
14909
|
+
}
|
|
14910
|
+
return {
|
|
14911
|
+
properties,
|
|
14912
|
+
states,
|
|
14913
|
+
methods,
|
|
14914
|
+
events,
|
|
14915
|
+
listeners,
|
|
14916
|
+
watchers,
|
|
14917
|
+
methodNames
|
|
14918
|
+
};
|
|
14919
|
+
}
|
|
14920
|
+
function getExtendsClassName(node) {
|
|
14921
|
+
const heritage = node.heritageClauses?.find((h) => h.token === ts.SyntaxKind.ExtendsKeyword);
|
|
14922
|
+
if (!heritage?.types.length) return null;
|
|
14923
|
+
const expr = heritage.types[0].expression;
|
|
14924
|
+
return ts.isIdentifier(expr) ? expr.text : null;
|
|
14925
|
+
}
|
|
14926
|
+
function findImportSpecifier(sf, localName) {
|
|
14927
|
+
for (const stmt of sf.statements) {
|
|
14928
|
+
if (!ts.isImportDeclaration(stmt) || !ts.isStringLiteral(stmt.moduleSpecifier)) continue;
|
|
14929
|
+
const clause = stmt.importClause;
|
|
14930
|
+
if (!clause) continue;
|
|
14931
|
+
if (clause.name?.text === localName) return stmt.moduleSpecifier.text;
|
|
14932
|
+
const bindings = clause.namedBindings;
|
|
14933
|
+
if (bindings && ts.isNamedImports(bindings)) {
|
|
14934
|
+
for (const el of bindings.elements) if (el.name.text === localName) return stmt.moduleSpecifier.text;
|
|
14935
|
+
}
|
|
14936
|
+
}
|
|
14937
|
+
return null;
|
|
14938
|
+
}
|
|
14939
|
+
/**
|
|
14940
|
+
* Resolves the inheritance chain for a component using a caller-supplied
|
|
14941
|
+
* `resolveImport` callback instead of the full compiler infrastructure.
|
|
14942
|
+
* Safe to call from `transpileSync`/`transpileAsync` (no TypeChecker needed).
|
|
14943
|
+
*
|
|
14944
|
+
* @param cmpNode the component's class declaration
|
|
14945
|
+
* @param staticMembers static getter members already parsed from the component
|
|
14946
|
+
* @param sourceFile the source file containing the component (for import resolution)
|
|
14947
|
+
* @param resolveImport callback that resolves an import specifier to source code
|
|
14948
|
+
* @returns merged metadata including all inherited members
|
|
14949
|
+
*/
|
|
14950
|
+
function mergeExtendedClassMetaWithResolveImport(cmpNode, staticMembers, sourceFile, resolveImport) {
|
|
14951
|
+
let doesExtend = false;
|
|
14952
|
+
let properties = parseStaticProps(staticMembers);
|
|
14953
|
+
let states = parseStaticStates(staticMembers);
|
|
14954
|
+
let methods = parseStaticMethods(staticMembers);
|
|
14955
|
+
let listeners = parseStaticListeners(staticMembers);
|
|
14956
|
+
let events = parseStaticEvents(staticMembers);
|
|
14957
|
+
let watchers = parseStaticWatchers(staticMembers);
|
|
14958
|
+
let classMethods = cmpNode.members.filter(ts.isMethodDeclaration).map((m) => ts.isIdentifier(m.name) ? m.name.text : "").filter(Boolean);
|
|
14959
|
+
const serializers = [];
|
|
14960
|
+
const deserializers = [];
|
|
14961
|
+
let currentNode = cmpNode;
|
|
14962
|
+
let currentSf = sourceFile;
|
|
14963
|
+
let currentPath = sourceFile.fileName;
|
|
14964
|
+
const visited = /* @__PURE__ */ new Set();
|
|
14965
|
+
while (true) {
|
|
14966
|
+
const parentClassName = getExtendsClassName(currentNode);
|
|
14967
|
+
if (!parentClassName) break;
|
|
14968
|
+
const specifier = findImportSpecifier(currentSf, parentClassName);
|
|
14969
|
+
if (!specifier) break;
|
|
14970
|
+
const resolved = resolveImport(specifier, currentPath);
|
|
14971
|
+
if (!resolved) break;
|
|
14972
|
+
const { code, path: resolvedPath } = resolved;
|
|
14973
|
+
if (visited.has(resolvedPath)) break;
|
|
14974
|
+
visited.add(resolvedPath);
|
|
14975
|
+
const isTs = resolvedPath.endsWith(".tsx") || resolvedPath.endsWith(".ts");
|
|
14976
|
+
const parentSf = ts.createSourceFile(resolvedPath, code, ts.ScriptTarget.ESNext, true, isTs ? ts.ScriptKind.TSX : ts.ScriptKind.JS);
|
|
14977
|
+
const parentClass = parentSf.statements.filter(ts.isClassDeclaration).find((c) => c.name?.text === parentClassName);
|
|
14978
|
+
if (!parentClass) break;
|
|
14979
|
+
const parentStaticMembers = parentClass.members.filter(isStaticGetter);
|
|
14980
|
+
const parentMeta = parentStaticMembers.some((m) => ts.isGetAccessorDeclaration(m) && ts.isIdentifier(m.name) && [
|
|
14981
|
+
"properties",
|
|
14982
|
+
"states",
|
|
14983
|
+
"events",
|
|
14984
|
+
"listeners",
|
|
14985
|
+
"watchers",
|
|
14986
|
+
"methods"
|
|
14987
|
+
].includes(m.name.text)) ? {
|
|
14988
|
+
properties: parseStaticProps(parentStaticMembers),
|
|
14989
|
+
states: parseStaticStates(parentStaticMembers),
|
|
14990
|
+
methods: parseStaticMethods(parentStaticMembers),
|
|
14991
|
+
events: parseStaticEvents(parentStaticMembers),
|
|
14992
|
+
listeners: parseStaticListeners(parentStaticMembers),
|
|
14993
|
+
watchers: parseStaticWatchers(parentStaticMembers),
|
|
14994
|
+
methodNames: parentClass.members.filter(ts.isMethodDeclaration).map((m) => ts.isIdentifier(m.name) ? m.name.text : "").filter(Boolean)
|
|
14995
|
+
} : extractInheritedMeta(code, parentClassName, resolvedPath);
|
|
14996
|
+
if (!parentMeta) break;
|
|
14997
|
+
doesExtend = true;
|
|
14998
|
+
const mixinPropsExcludingStates = parentMeta.properties.filter((mp) => !states.some((s) => s.name === mp.name));
|
|
14999
|
+
const mixinStatesExcludingProps = parentMeta.states.filter((ms) => !properties.some((p) => p.name === ms.name));
|
|
15000
|
+
properties = [...deDupeMembers(mixinPropsExcludingStates, properties), ...properties];
|
|
15001
|
+
states = [...deDupeMembers(mixinStatesExcludingProps, states), ...states];
|
|
15002
|
+
methods = [...deDupeMembers(parentMeta.methods, methods), ...methods];
|
|
15003
|
+
events = [...deDupeMembers(parentMeta.events, events), ...events];
|
|
15004
|
+
listeners = [...deDupeMembers(parentMeta.listeners, listeners), ...listeners];
|
|
15005
|
+
watchers = [...deDupeMembers(parentMeta.watchers, watchers), ...watchers];
|
|
15006
|
+
classMethods = [...classMethods, ...parentMeta.methodNames];
|
|
15007
|
+
currentNode = parentClass;
|
|
15008
|
+
currentSf = parentSf;
|
|
15009
|
+
currentPath = resolvedPath;
|
|
15010
|
+
}
|
|
15011
|
+
return {
|
|
15012
|
+
doesExtend,
|
|
15013
|
+
properties,
|
|
15014
|
+
states,
|
|
15015
|
+
methods,
|
|
15016
|
+
listeners,
|
|
15017
|
+
events,
|
|
15018
|
+
watchers,
|
|
15019
|
+
classMethods,
|
|
15020
|
+
serializers,
|
|
15021
|
+
deserializers
|
|
15022
|
+
};
|
|
15023
|
+
}
|
|
14687
15024
|
//#endregion
|
|
14688
15025
|
//#region src/compiler/transformers/static-to-meta/class-methods.ts
|
|
14689
15026
|
const parseClassMethods = (classMethods, cmpMeta) => {
|
|
14690
15027
|
if (!classMethods?.length) return;
|
|
14691
|
-
const hasHostData = classMethods.
|
|
14692
|
-
cmpMeta.hasAttributeChangedCallbackFn = classMethods.
|
|
14693
|
-
cmpMeta.hasConnectedCallbackFn = classMethods.
|
|
14694
|
-
cmpMeta.hasDisconnectedCallbackFn = classMethods.
|
|
14695
|
-
cmpMeta.hasComponentWillLoadFn = classMethods.
|
|
14696
|
-
cmpMeta.hasComponentWillUpdateFn = classMethods.
|
|
14697
|
-
cmpMeta.hasComponentWillRenderFn = classMethods.
|
|
14698
|
-
cmpMeta.hasComponentDidRenderFn = classMethods.
|
|
14699
|
-
cmpMeta.hasComponentDidLoadFn = classMethods.
|
|
14700
|
-
cmpMeta.hasComponentShouldUpdateFn = classMethods.
|
|
14701
|
-
cmpMeta.hasComponentDidUpdateFn = classMethods.
|
|
15028
|
+
const hasHostData = classMethods.includes("hostData");
|
|
15029
|
+
cmpMeta.hasAttributeChangedCallbackFn = classMethods.includes("attributeChangedCallback");
|
|
15030
|
+
cmpMeta.hasConnectedCallbackFn = classMethods.includes("connectedCallback");
|
|
15031
|
+
cmpMeta.hasDisconnectedCallbackFn = classMethods.includes("disconnectedCallback");
|
|
15032
|
+
cmpMeta.hasComponentWillLoadFn = classMethods.includes("componentWillLoad");
|
|
15033
|
+
cmpMeta.hasComponentWillUpdateFn = classMethods.includes("componentWillUpdate");
|
|
15034
|
+
cmpMeta.hasComponentWillRenderFn = classMethods.includes("componentWillRender");
|
|
15035
|
+
cmpMeta.hasComponentDidRenderFn = classMethods.includes("componentDidRender");
|
|
15036
|
+
cmpMeta.hasComponentDidLoadFn = classMethods.includes("componentDidLoad");
|
|
15037
|
+
cmpMeta.hasComponentShouldUpdateFn = classMethods.includes("componentShouldUpdate");
|
|
15038
|
+
cmpMeta.hasComponentDidUpdateFn = classMethods.includes("componentDidUpdate");
|
|
14702
15039
|
cmpMeta.hasLifecycle = cmpMeta.hasComponentWillLoadFn || cmpMeta.hasComponentDidLoadFn || cmpMeta.hasComponentWillUpdateFn || cmpMeta.hasComponentDidUpdateFn;
|
|
14703
|
-
cmpMeta.hasRenderFn = classMethods.
|
|
15040
|
+
cmpMeta.hasRenderFn = classMethods.includes("render") || hasHostData;
|
|
14704
15041
|
cmpMeta.hasVdomRender = cmpMeta.hasVdomRender || hasHostData;
|
|
14705
15042
|
};
|
|
14706
15043
|
//#endregion
|
|
@@ -14954,7 +15291,7 @@ const parseStaticComponentMeta = (compilerCtx, typeChecker, cmpNode, moduleFile,
|
|
|
14954
15291
|
const staticMembers = cmpNode.members.filter(isStaticGetter);
|
|
14955
15292
|
const tagName = getComponentTagName(staticMembers);
|
|
14956
15293
|
if (tagName == null) return cmpNode;
|
|
14957
|
-
const { doesExtend, properties, states, methods, listeners, events, watchers, classMethods, serializers, deserializers } = mergeExtendedClassMeta(compilerCtx, typeChecker, buildCtx, cmpNode, staticMembers, moduleFile);
|
|
15294
|
+
const { doesExtend, properties, states, methods, listeners, events, watchers, classMethods, serializers, deserializers } = transformOpts?.resolveImport ? mergeExtendedClassMetaWithResolveImport(cmpNode, staticMembers, moduleFile.staticSourceFile, transformOpts.resolveImport) : mergeExtendedClassMeta(compilerCtx, typeChecker, buildCtx, cmpNode, staticMembers, moduleFile);
|
|
14958
15295
|
const docs = serializeSymbol(typeChecker, typeChecker ? typeChecker.getSymbolAtLocation(cmpNode.name) : void 0);
|
|
14959
15296
|
const isCollectionDependency = moduleFile.isCollectionDependency;
|
|
14960
15297
|
const encapsulation = parseStaticEncapsulation(staticMembers);
|
|
@@ -21416,7 +21753,7 @@ const getCssToEsmImports = (varNames, cssText, filePath, modeName) => {
|
|
|
21416
21753
|
const cssImports = [];
|
|
21417
21754
|
if (!cssText.includes("@import")) return cssImports;
|
|
21418
21755
|
cssText = stripCssComments(cssText);
|
|
21419
|
-
const dir = path.dirname(filePath);
|
|
21756
|
+
const dir = path$1.dirname(filePath);
|
|
21420
21757
|
let r;
|
|
21421
21758
|
while (r = CSS_IMPORT_RE.exec(cssText)) {
|
|
21422
21759
|
const cssImportData = {
|
|
@@ -21430,7 +21767,7 @@ const getCssToEsmImports = (varNames, cssText, filePath, modeName) => {
|
|
|
21430
21767
|
else if (isCssNodeModule(cssImportData.url)) {
|
|
21431
21768
|
cssImportData.filePath = cssImportData.url.substring(1);
|
|
21432
21769
|
cssImportData.isNodeModule = true;
|
|
21433
|
-
} else if (path.isAbsolute(cssImportData.url)) cssImportData.filePath = normalizePath(cssImportData.url);
|
|
21770
|
+
} else if (path$1.isAbsolute(cssImportData.url)) cssImportData.filePath = normalizePath(cssImportData.url);
|
|
21434
21771
|
else cssImportData.filePath = normalizePath(resolve$2(dir, cssImportData.url));
|
|
21435
21772
|
cssImportData.varName = createCssVarName(cssImportData.filePath, modeName);
|
|
21436
21773
|
if (varNames.has(cssImportData.varName)) cssImportData.varName += varNames.size;
|
|
@@ -21473,7 +21810,7 @@ const isLocalCssImport = (srcImport) => {
|
|
|
21473
21810
|
* @returns an appropriate Css var name
|
|
21474
21811
|
*/
|
|
21475
21812
|
const createCssVarName = (filePath, modeName) => {
|
|
21476
|
-
let varName = path.basename(filePath);
|
|
21813
|
+
let varName = path$1.basename(filePath);
|
|
21477
21814
|
if (modeName && modeName !== "$" && !varName.includes(modeName)) varName = modeName + "-" + varName;
|
|
21478
21815
|
return createJsVarName(varName);
|
|
21479
21816
|
};
|
|
@@ -21849,7 +22186,7 @@ const getWriteFilePathFromUrlPath = (manager, inputHref) => {
|
|
|
21849
22186
|
const inputPathParts = inputPathname.split("/");
|
|
21850
22187
|
const isPrerrenderRoot = basePathname === inputPathname;
|
|
21851
22188
|
let fileName;
|
|
21852
|
-
if (isPrerrenderRoot) fileName = path.basename(manager.outputTarget.indexHtml);
|
|
22189
|
+
if (isPrerrenderRoot) fileName = path$1.basename(manager.outputTarget.indexHtml);
|
|
21853
22190
|
else fileName = "index.html";
|
|
21854
22191
|
const pathParts = [];
|
|
21855
22192
|
for (let i = 0; i < inputPathParts.length; i++) {
|
|
@@ -22677,7 +23014,7 @@ const createSystem = (c) => {
|
|
|
22677
23014
|
isSymbolicLink,
|
|
22678
23015
|
nextTick,
|
|
22679
23016
|
normalizePath: normalize,
|
|
22680
|
-
platformPath: path,
|
|
23017
|
+
platformPath: path$1,
|
|
22681
23018
|
readDir,
|
|
22682
23019
|
readDirSync,
|
|
22683
23020
|
readFile,
|
|
@@ -22791,7 +23128,9 @@ const getTranspileConfig = (input) => {
|
|
|
22791
23128
|
style: compileOpts.style,
|
|
22792
23129
|
styleImportData: compileOpts.styleImportData,
|
|
22793
23130
|
target: compileOpts.target,
|
|
22794
|
-
|
|
23131
|
+
resolveImport: input.resolveImport,
|
|
23132
|
+
transformAsBaseClass: input.transformAsBaseClass,
|
|
23133
|
+
buildOverrides: input.buildOverrides
|
|
22795
23134
|
};
|
|
22796
23135
|
return {
|
|
22797
23136
|
compileOpts,
|
|
@@ -22919,21 +23258,8 @@ const transpileModule = (config, input, transformOpts) => {
|
|
|
22919
23258
|
if (tsCompilerOptions.jsx != null && !isAutomaticRuntime && !isString$1(tsCompilerOptions.jsxFragmentFactory)) tsCompilerOptions.jsxFragmentFactory = "Fragment";
|
|
22920
23259
|
if (tsCompilerOptions.paths && !isString$1(tsCompilerOptions.baseUrl)) tsCompilerOptions.baseUrl = ".";
|
|
22921
23260
|
const sourceFile = ts.createSourceFile(sourceFilePath, input, tsCompilerOptions.target);
|
|
22922
|
-
const
|
|
22923
|
-
|
|
22924
|
-
const currentDir = normalizePath(transformOpts.currentDirectory || process.cwd());
|
|
22925
|
-
for (const [filePath, text] of Object.entries(transformOpts.extraFiles)) {
|
|
22926
|
-
const resolvedPath = normalizePath(filePath.startsWith("/") ? filePath : join$2(currentDir, filePath));
|
|
22927
|
-
extraSourceFiles.set(resolvedPath, ts.createSourceFile(resolvedPath, text, tsCompilerOptions.target));
|
|
22928
|
-
}
|
|
22929
|
-
tsCompilerOptions.noResolve = false;
|
|
22930
|
-
}
|
|
22931
|
-
const compilerHost = {
|
|
22932
|
-
getSourceFile: (fileName) => {
|
|
22933
|
-
const normalized = normalizePath(fileName);
|
|
22934
|
-
if (normalized === normalizePath(sourceFilePath)) return sourceFile;
|
|
22935
|
-
return extraSourceFiles.get(normalized);
|
|
22936
|
-
},
|
|
23261
|
+
const program = ts.createProgram([sourceFilePath], tsCompilerOptions, {
|
|
23262
|
+
getSourceFile: (fileName) => normalizePath(fileName) === normalizePath(sourceFilePath) ? sourceFile : void 0,
|
|
22937
23263
|
writeFile: (name, text) => {
|
|
22938
23264
|
if (name.endsWith(".js.map") || name.endsWith(".mjs.map")) results.map = text;
|
|
22939
23265
|
else if (name.endsWith(".js") || name.endsWith(".mjs")) results.code = text;
|
|
@@ -22943,45 +23269,12 @@ const transpileModule = (config, input, transformOpts) => {
|
|
|
22943
23269
|
getCanonicalFileName: (fileName) => fileName,
|
|
22944
23270
|
getCurrentDirectory: () => transformOpts.currentDirectory || process.cwd(),
|
|
22945
23271
|
getNewLine: () => ts.sys.newLine || "\n",
|
|
22946
|
-
fileExists: (fileName) =>
|
|
22947
|
-
const normalized = normalizePath(fileName);
|
|
22948
|
-
return normalized === normalizePath(sourceFilePath) || extraSourceFiles.has(normalized);
|
|
22949
|
-
},
|
|
23272
|
+
fileExists: (fileName) => normalizePath(fileName) === normalizePath(sourceFilePath),
|
|
22950
23273
|
readFile: () => "",
|
|
22951
23274
|
directoryExists: () => true,
|
|
22952
23275
|
getDirectories: () => []
|
|
22953
|
-
};
|
|
22954
|
-
const program = ts.createProgram([sourceFilePath, ...extraSourceFiles.keys()], tsCompilerOptions, compilerHost);
|
|
23276
|
+
});
|
|
22955
23277
|
const typeChecker = program.getTypeChecker();
|
|
22956
|
-
if (extraSourceFiles.size > 0) {
|
|
22957
|
-
const miniCompilerHost = {
|
|
22958
|
-
getSourceFile: (fileName) => extraSourceFiles.get(normalizePath(fileName)),
|
|
22959
|
-
writeFile: () => {},
|
|
22960
|
-
getDefaultLibFileName: () => "lib.d.ts",
|
|
22961
|
-
useCaseSensitiveFileNames: () => false,
|
|
22962
|
-
getCanonicalFileName: (f) => f,
|
|
22963
|
-
getCurrentDirectory: () => transformOpts.currentDirectory || process.cwd(),
|
|
22964
|
-
getNewLine: () => ts.sys.newLine || "\n",
|
|
22965
|
-
fileExists: (f) => extraSourceFiles.has(normalizePath(f)),
|
|
22966
|
-
readFile: () => "",
|
|
22967
|
-
directoryExists: () => true,
|
|
22968
|
-
getDirectories: () => []
|
|
22969
|
-
};
|
|
22970
|
-
const miniProgram = ts.createProgram([...extraSourceFiles.keys()], {
|
|
22971
|
-
...tsCompilerOptions,
|
|
22972
|
-
noResolve: true
|
|
22973
|
-
}, miniCompilerHost);
|
|
22974
|
-
const miniTypeChecker = miniProgram.getTypeChecker();
|
|
22975
|
-
const decoratorConverter = convertDecoratorsToStatic(config, buildCtx.diagnostics, miniTypeChecker, miniProgram);
|
|
22976
|
-
for (const [resolvedPath, rawSource] of extraSourceFiles) {
|
|
22977
|
-
const transformResult = ts.transform(rawSource, [decoratorConverter], tsCompilerOptions);
|
|
22978
|
-
const processedSource = transformResult.transformed[0];
|
|
22979
|
-
transformResult.dispose();
|
|
22980
|
-
const moduleFile = getModuleLegacy(compilerCtx, resolvedPath);
|
|
22981
|
-
moduleFile.staticSourceFile = processedSource;
|
|
22982
|
-
moduleFile.staticSourceFileText = processedSource.getFullText?.() ?? rawSource.text;
|
|
22983
|
-
}
|
|
22984
|
-
}
|
|
22985
23278
|
const transformers = {
|
|
22986
23279
|
before: [
|
|
22987
23280
|
convertDecoratorsToStatic(config, buildCtx.diagnostics, typeChecker, program),
|
|
@@ -22997,8 +23290,11 @@ const transpileModule = (config, input, transformOpts) => {
|
|
|
22997
23290
|
}
|
|
22998
23291
|
if (transformOpts.componentExport === "customelement" || transformOpts.componentExport === "module") transformers.after.push(nativeComponentTransform(compilerCtx, transformOpts, buildCtx));
|
|
22999
23292
|
else transformers.after.push(lazyComponentTransform(compilerCtx, transformOpts, buildCtx));
|
|
23000
|
-
|
|
23001
|
-
|
|
23293
|
+
program.emit(void 0, void 0, void 0, false, transformers);
|
|
23294
|
+
if (transformOpts.buildOverrides && results.code) {
|
|
23295
|
+
const mutations = Object.entries(transformOpts.buildOverrides).filter(([, v]) => v !== void 0).map(([k, v]) => `__stencilBUILD.${k}=${v};`).join("");
|
|
23296
|
+
if (mutations) results.code = `import{BUILD as __stencilBUILD}from"${STENCIL_APP_DATA_ID}";\n${mutations}\n` + results.code;
|
|
23297
|
+
}
|
|
23002
23298
|
const tsDiagnostics = [...program.getSyntacticDiagnostics()];
|
|
23003
23299
|
if (config.validateTypes) tsDiagnostics.push(...program.getOptionsDiagnostics());
|
|
23004
23300
|
buildCtx.diagnostics.push(...loadTypeScriptDiagnostics(tsDiagnostics));
|
|
@@ -23096,7 +23392,11 @@ const transpileCode = (config, transpileOpts, transformOpts, results) => {
|
|
|
23096
23392
|
if (moduleFile) {
|
|
23097
23393
|
results.outputFilePath = moduleFile.jsFilePath;
|
|
23098
23394
|
moduleFile.cmps.forEach((cmp) => {
|
|
23099
|
-
results.data.push(
|
|
23395
|
+
results.data.push({
|
|
23396
|
+
...getPublicCompilerMeta(cmp),
|
|
23397
|
+
docs: cmp.docs,
|
|
23398
|
+
styleDocs: cmp.styleDocs
|
|
23399
|
+
});
|
|
23100
23400
|
});
|
|
23101
23401
|
moduleFile.originalImports.forEach((originalImport) => {
|
|
23102
23402
|
results.imports.push({ path: originalImport });
|
|
@@ -23133,4 +23433,4 @@ const shouldTranspileModule = (ext) => [
|
|
|
23133
23433
|
"js"
|
|
23134
23434
|
].includes(ext);
|
|
23135
23435
|
//#endregion
|
|
23136
|
-
export {
|
|
23436
|
+
export { version as C, vermoji as S, cmpMetaToDocsComponent as _, createPrerenderer as a, getBuildFeatures as b, createWorkerContext as c, nodeRequire as d, optimizeCss as f, generateManifest as g, Cache as h, createSystem as i, createWorkerMessageHandler as l, validateConfig as m, transpile as n, loadConfig as o, createInMemoryFs as p, transpileSync as r, createCompiler as s, ts$1 as t, optimizeJs as u, BuildContext as v, versions as w, buildId as x, getScopeId as y };
|