@dcloudio/uni-cli-shared 3.0.0-alpha-5000820260420001 → 3.0.0-alpha-5000820260430001
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/lib/dom2/app/@vue/compiler-sfc/dist/compiler-sfc.cjs.js +26 -1
- package/lib/dom2/app/@vue/compiler-sfc/dist/compiler-sfc.esm-browser.js +30 -3
- package/lib/dom2/app/@vue/compiler-vapor/dist/compiler-vapor.cjs.js +4 -1
- package/lib/dom2/app/@vue/compiler-vapor/dist/compiler-vapor.esm-browser.js +4 -1
- package/lib/dom2/app/@vue/compiler-vapor-dom2/dist/compiler-vapor-dom2.cjs.js +1 -1
- package/package.json +5 -5
|
@@ -15052,6 +15052,18 @@ function processDefineSlots(ctx, node, declId) {
|
|
|
15052
15052
|
//#endregion
|
|
15053
15053
|
//#region packages/compiler-sfc/src/script/defineOptions.ts
|
|
15054
15054
|
const DEFINE_OPTIONS = "defineOptions";
|
|
15055
|
+
function isUniModuleImportSource(source) {
|
|
15056
|
+
return /^@\/uni_modules?\//.test(source);
|
|
15057
|
+
}
|
|
15058
|
+
function resolveRootElementClassBindingName(node) {
|
|
15059
|
+
const value = (0, _vue_compiler_dom.unwrapTSNode)(node);
|
|
15060
|
+
if (value.type === "Identifier") return value.name;
|
|
15061
|
+
if (value.type !== "ObjectExpression") return;
|
|
15062
|
+
for (const prop of value.properties) if (prop.type === "ObjectProperty" && prop.key.type === "Identifier" && prop.key.name === "class") {
|
|
15063
|
+
const classValue = (0, _vue_compiler_dom.unwrapTSNode)(prop.value);
|
|
15064
|
+
if (classValue.type === "Identifier") return classValue.name;
|
|
15065
|
+
}
|
|
15066
|
+
}
|
|
15055
15067
|
function processDefineOptions(ctx, node) {
|
|
15056
15068
|
if (!isCallOf(node, DEFINE_OPTIONS)) return false;
|
|
15057
15069
|
if (ctx.hasDefineOptionsCall) ctx.error(`duplicate ${DEFINE_OPTIONS}() call`, node);
|
|
@@ -15085,6 +15097,13 @@ function processDefineOptions(ctx, node) {
|
|
|
15085
15097
|
break;
|
|
15086
15098
|
case "rootElement":
|
|
15087
15099
|
hasRootElementOption = true;
|
|
15100
|
+
if (prop.type === "ObjectProperty") {
|
|
15101
|
+
const bindingName = resolveRootElementClassBindingName(prop.value);
|
|
15102
|
+
if (bindingName) {
|
|
15103
|
+
const binding = ctx.userImports[bindingName];
|
|
15104
|
+
if (binding && !binding.isType && isUniModuleImportSource(binding.source)) ctx.rootElementFromUniModule = true;
|
|
15105
|
+
}
|
|
15106
|
+
}
|
|
15088
15107
|
break;
|
|
15089
15108
|
}
|
|
15090
15109
|
}
|
|
@@ -15487,6 +15506,8 @@ function compileScript(sfc, options) {
|
|
|
15487
15506
|
}
|
|
15488
15507
|
if (ctx.rootElementTagName) compilerOptions.rootElementTagName = ctx.rootElementTagName;
|
|
15489
15508
|
else delete compilerOptions.rootElementTagName;
|
|
15509
|
+
if (ctx.rootElementFromUniModule) compilerOptions.rootElementFromUniModule = true;
|
|
15510
|
+
else delete compilerOptions.rootElementFromUniModule;
|
|
15490
15511
|
const { code, ast, preamble, tips, errors, helpers, map } = compileTemplate({
|
|
15491
15512
|
filename,
|
|
15492
15513
|
ast: sfc.template.ast,
|
|
@@ -15499,6 +15520,7 @@ function compileScript(sfc, options) {
|
|
|
15499
15520
|
ssrCssVars: sfc.cssVars,
|
|
15500
15521
|
vapor,
|
|
15501
15522
|
compilerOptions: {
|
|
15523
|
+
dynamicSharedData: options.dynamicSharedData,
|
|
15502
15524
|
...options.templateOptions && options.templateOptions.compilerOptions,
|
|
15503
15525
|
inline: true,
|
|
15504
15526
|
isTS: ctx.isTS,
|
|
@@ -15538,7 +15560,10 @@ function compileScript(sfc, options) {
|
|
|
15538
15560
|
const dynamicSharedDataComponentOptionsCode = options.dynamicSharedData ? `_useSharedDataComponentOptions({ bundleKey: __className, sharedDataClassId: 0 })` : `_useSharedDataComponentOptions()`;
|
|
15539
15561
|
if (componentType === "page") {
|
|
15540
15562
|
setupPreambleLines.unshift(`const __sharedDataScope = _useSharedDataScope(__sharedData)`);
|
|
15541
|
-
|
|
15563
|
+
if (options.dynamicSharedData) {
|
|
15564
|
+
setupPreambleLines.unshift(`const __sharedData = __sharedDataRenderer == 'component' ? _withSharedDataComponent(useSharedDataComponent<__SHARED_DATA_CLASS_NAME_TYPE>(_useSharedDataScope(), ${dynamicSharedDataComponentOptionsCode})${optionsCode}) : _withSharedDataPage(useSharedDataPage<__SHARED_DATA_CLASS_NAME_TYPE>(_useSharedDataPageId(), ${dynamicSharedDataOptionsCode})${optionsCode})`);
|
|
15565
|
+
setupPreambleLines.unshift(`const __sharedDataRenderer = _useSharedDataRenderer()`);
|
|
15566
|
+
} else setupPreambleLines.unshift(`const __sharedData = _withSharedDataPage(useSharedDataPage<__SHARED_DATA_CLASS_NAME_TYPE>(_useSharedDataRenderer() == 'component' ? _useSharedDataScope() : _useSharedDataPageId(), ${dynamicSharedDataOptionsCode})${optionsCode})`);
|
|
15542
15567
|
} else if (componentType === "component") {
|
|
15543
15568
|
setupPreambleLines.unshift(`const __sharedData = _withSharedDataComponent(useSharedDataComponent<__SHARED_DATA_CLASS_NAME_TYPE>(__sharedDataScope, ${dynamicSharedDataComponentOptionsCode})${optionsCode})`);
|
|
15544
15569
|
setupPreambleLines.unshift(`const __sharedDataScope = _useSharedDataScope()`);
|
|
@@ -27341,7 +27341,10 @@ function transformNativeElement(node, propsResult, singleRoot, context, getEffec
|
|
|
27341
27341
|
if (singleRoot) {
|
|
27342
27342
|
template += ` gen-flag-flatten=""`;
|
|
27343
27343
|
const rootElementTagName = context.options.rootElementTagName;
|
|
27344
|
-
if (rootElementTagName)
|
|
27344
|
+
if (rootElementTagName) {
|
|
27345
|
+
template += ` custom-tag-name="${rootElementTagName}"`;
|
|
27346
|
+
if (context.options.rootElementFromUniModule) template += ` gen-root-custom-native="${rootElementTagName}"`;
|
|
27347
|
+
}
|
|
27345
27348
|
}
|
|
27346
27349
|
}
|
|
27347
27350
|
const dynamicProps = [];
|
|
@@ -40893,6 +40896,18 @@ function processDefineSlots(ctx, node, declId) {
|
|
|
40893
40896
|
//#endregion
|
|
40894
40897
|
//#region packages/compiler-sfc/src/script/defineOptions.ts
|
|
40895
40898
|
const DEFINE_OPTIONS = "defineOptions";
|
|
40899
|
+
function isUniModuleImportSource(source) {
|
|
40900
|
+
return /^@\/uni_modules?\//.test(source);
|
|
40901
|
+
}
|
|
40902
|
+
function resolveRootElementClassBindingName(node) {
|
|
40903
|
+
const value = unwrapTSNode(node);
|
|
40904
|
+
if (value.type === "Identifier") return value.name;
|
|
40905
|
+
if (value.type !== "ObjectExpression") return;
|
|
40906
|
+
for (const prop of value.properties) if (prop.type === "ObjectProperty" && prop.key.type === "Identifier" && prop.key.name === "class") {
|
|
40907
|
+
const classValue = unwrapTSNode(prop.value);
|
|
40908
|
+
if (classValue.type === "Identifier") return classValue.name;
|
|
40909
|
+
}
|
|
40910
|
+
}
|
|
40896
40911
|
function processDefineOptions(ctx, node) {
|
|
40897
40912
|
if (!isCallOf(node, DEFINE_OPTIONS)) return false;
|
|
40898
40913
|
if (ctx.hasDefineOptionsCall) ctx.error(`duplicate ${DEFINE_OPTIONS}() call`, node);
|
|
@@ -40926,6 +40941,13 @@ function processDefineOptions(ctx, node) {
|
|
|
40926
40941
|
break;
|
|
40927
40942
|
case "rootElement":
|
|
40928
40943
|
hasRootElementOption = true;
|
|
40944
|
+
if (prop.type === "ObjectProperty") {
|
|
40945
|
+
const bindingName = resolveRootElementClassBindingName(prop.value);
|
|
40946
|
+
if (bindingName) {
|
|
40947
|
+
const binding = ctx.userImports[bindingName];
|
|
40948
|
+
if (binding && !binding.isType && isUniModuleImportSource(binding.source)) ctx.rootElementFromUniModule = true;
|
|
40949
|
+
}
|
|
40950
|
+
}
|
|
40929
40951
|
break;
|
|
40930
40952
|
}
|
|
40931
40953
|
}
|
|
@@ -41326,6 +41348,8 @@ function compileScript(sfc, options) {
|
|
|
41326
41348
|
}
|
|
41327
41349
|
if (ctx.rootElementTagName) compilerOptions.rootElementTagName = ctx.rootElementTagName;
|
|
41328
41350
|
else delete compilerOptions.rootElementTagName;
|
|
41351
|
+
if (ctx.rootElementFromUniModule) compilerOptions.rootElementFromUniModule = true;
|
|
41352
|
+
else delete compilerOptions.rootElementFromUniModule;
|
|
41329
41353
|
const { code, ast, preamble, tips, errors, helpers, map } = compileTemplate(_objectSpread2(_objectSpread2({
|
|
41330
41354
|
filename,
|
|
41331
41355
|
ast: sfc.template.ast,
|
|
@@ -41337,7 +41361,7 @@ function compileScript(sfc, options) {
|
|
|
41337
41361
|
isProd: options.isProd,
|
|
41338
41362
|
ssrCssVars: sfc.cssVars,
|
|
41339
41363
|
vapor,
|
|
41340
|
-
compilerOptions: _objectSpread2(_objectSpread2({}, options.templateOptions && options.templateOptions.compilerOptions), {}, {
|
|
41364
|
+
compilerOptions: _objectSpread2(_objectSpread2({ dynamicSharedData: options.dynamicSharedData }, options.templateOptions && options.templateOptions.compilerOptions), {}, {
|
|
41341
41365
|
inline: true,
|
|
41342
41366
|
isTS: ctx.isTS,
|
|
41343
41367
|
bindingMetadata: ctx.bindingMetadata,
|
|
@@ -41376,7 +41400,10 @@ function compileScript(sfc, options) {
|
|
|
41376
41400
|
const dynamicSharedDataComponentOptionsCode = options.dynamicSharedData ? `_useSharedDataComponentOptions({ bundleKey: __className, sharedDataClassId: 0 })` : `_useSharedDataComponentOptions()`;
|
|
41377
41401
|
if (componentType === "page") {
|
|
41378
41402
|
setupPreambleLines.unshift(`const __sharedDataScope = _useSharedDataScope(__sharedData)`);
|
|
41379
|
-
|
|
41403
|
+
if (options.dynamicSharedData) {
|
|
41404
|
+
setupPreambleLines.unshift(`const __sharedData = __sharedDataRenderer == 'component' ? _withSharedDataComponent(useSharedDataComponent<__SHARED_DATA_CLASS_NAME_TYPE>(_useSharedDataScope(), ${dynamicSharedDataComponentOptionsCode})${optionsCode}) : _withSharedDataPage(useSharedDataPage<__SHARED_DATA_CLASS_NAME_TYPE>(_useSharedDataPageId(), ${dynamicSharedDataOptionsCode})${optionsCode})`);
|
|
41405
|
+
setupPreambleLines.unshift(`const __sharedDataRenderer = _useSharedDataRenderer()`);
|
|
41406
|
+
} else setupPreambleLines.unshift(`const __sharedData = _withSharedDataPage(useSharedDataPage<__SHARED_DATA_CLASS_NAME_TYPE>(_useSharedDataRenderer() == 'component' ? _useSharedDataScope() : _useSharedDataPageId(), ${dynamicSharedDataOptionsCode})${optionsCode})`);
|
|
41380
41407
|
} else if (componentType === "component") {
|
|
41381
41408
|
setupPreambleLines.unshift(`const __sharedData = _withSharedDataComponent(useSharedDataComponent<__SHARED_DATA_CLASS_NAME_TYPE>(__sharedDataScope, ${dynamicSharedDataComponentOptionsCode})${optionsCode})`);
|
|
41382
41409
|
setupPreambleLines.unshift(`const __sharedDataScope = _useSharedDataScope()`);
|
|
@@ -2477,7 +2477,10 @@ function transformNativeElement(node, propsResult, singleRoot, context, getEffec
|
|
|
2477
2477
|
if (singleRoot) {
|
|
2478
2478
|
template += ` gen-flag-flatten=""`;
|
|
2479
2479
|
const rootElementTagName = context.options.rootElementTagName;
|
|
2480
|
-
if (rootElementTagName)
|
|
2480
|
+
if (rootElementTagName) {
|
|
2481
|
+
template += ` custom-tag-name="${rootElementTagName}"`;
|
|
2482
|
+
if (context.options.rootElementFromUniModule) template += ` gen-root-custom-native="${rootElementTagName}"`;
|
|
2483
|
+
}
|
|
2481
2484
|
}
|
|
2482
2485
|
}
|
|
2483
2486
|
const dynamicProps = [];
|
|
@@ -21417,7 +21417,10 @@ function transformNativeElement(node, propsResult, singleRoot, context, getEffec
|
|
|
21417
21417
|
if (singleRoot) {
|
|
21418
21418
|
template += ` gen-flag-flatten=""`;
|
|
21419
21419
|
const rootElementTagName = context.options.rootElementTagName;
|
|
21420
|
-
if (rootElementTagName)
|
|
21420
|
+
if (rootElementTagName) {
|
|
21421
|
+
template += ` custom-tag-name="${rootElementTagName}"`;
|
|
21422
|
+
if (context.options.rootElementFromUniModule) template += ` gen-root-custom-native="${rootElementTagName}"`;
|
|
21423
|
+
}
|
|
21421
21424
|
}
|
|
21422
21425
|
}
|
|
21423
21426
|
const dynamicProps = [];
|