mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
Merge remote-tracking branch 'origin/main' into feat/v9-prerelease
This commit is contained in:
2
.github/workflows/npm_release_core.yml
vendored
2
.github/workflows/npm_release_core.yml
vendored
@@ -45,7 +45,7 @@ jobs:
|
||||
|
||||
# TODO: build ui-mobile-base first
|
||||
- name: Build @nativescript/core
|
||||
run: npx nx run core:build.npm
|
||||
run: npx nx build core
|
||||
|
||||
- name: Publish @nativescript/core
|
||||
working-directory: dist/packages/core
|
||||
|
||||
@@ -12,9 +12,16 @@ import { calc } from '@csstools/css-calc';
|
||||
export { unsetValue } from './property-shared';
|
||||
|
||||
const cssPropertyNames: string[] = [];
|
||||
const HAS_OWN = Object.prototype.hasOwnProperty;
|
||||
const symbolPropertyMap = {};
|
||||
const cssSymbolPropertyMap = {};
|
||||
|
||||
// Hoisted regex/constants for hot paths to avoid re-allocation
|
||||
const CSS_VARIABLE_NAME_RE = /^--[^,\s]+?$/;
|
||||
const DIP_RE = /([0-9]+(\.[0-9]+)?)dip\b/g;
|
||||
const UNSET_RE = /unset/g;
|
||||
const INFINITY_RE = /infinity/g;
|
||||
|
||||
const inheritableProperties = new Array<InheritedProperty<any, any>>();
|
||||
const inheritableCssProperties = new Array<InheritedCssProperty<any, any>>();
|
||||
|
||||
@@ -50,7 +57,7 @@ export function _getStyleProperties(): CssProperty<any, any>[] {
|
||||
}
|
||||
|
||||
export function isCssVariable(property: string) {
|
||||
return /^--[^,\s]+?$/.test(property);
|
||||
return CSS_VARIABLE_NAME_RE.test(property);
|
||||
}
|
||||
|
||||
export function isCssCalcExpression(value: string) {
|
||||
@@ -119,27 +126,31 @@ export function _evaluateCssCalcExpression(value: string) {
|
||||
} else {
|
||||
return value;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
function _replaceDip(value: string) {
|
||||
return value.replace(/([0-9]+(\.[0-9]+)?)dip\b/g, '$1');
|
||||
return value.replace(DIP_RE, '$1');
|
||||
}
|
||||
|
||||
function _replaceKeywordsWithValues(value: string) {
|
||||
let cssValue = value;
|
||||
if (cssValue.includes('unset')) {
|
||||
cssValue = cssValue.replace(/unset/g, '0');
|
||||
cssValue = cssValue.replace(UNSET_RE, '0');
|
||||
}
|
||||
if (cssValue.includes('infinity')) {
|
||||
cssValue = cssValue.replace(/infinity/g, '999999');
|
||||
cssValue = cssValue.replace(INFINITY_RE, '999999');
|
||||
}
|
||||
return cssValue;
|
||||
}
|
||||
|
||||
function getPropertiesFromMap(map): Property<any, any>[] | CssProperty<any, any>[] {
|
||||
const props = [];
|
||||
Object.getOwnPropertySymbols(map).forEach((symbol) => props.push(map[symbol]));
|
||||
|
||||
const symbols = Object.getOwnPropertySymbols(map);
|
||||
const len = symbols.length;
|
||||
const props = new Array(len);
|
||||
for (let i = 0; i < len; i++) {
|
||||
props[i] = map[symbols[i]];
|
||||
}
|
||||
return props;
|
||||
}
|
||||
|
||||
@@ -240,13 +251,11 @@ export class Property<T extends ViewBase, U> implements TypedPropertyDescriptor<
|
||||
if (this._suspendedUpdates) {
|
||||
this._suspendedUpdates[propertyName] = property;
|
||||
}
|
||||
} else if (defaultValueKey in this) {
|
||||
this[setNative](this[defaultValueKey]);
|
||||
delete this[defaultValueKey];
|
||||
} else {
|
||||
if (defaultValueKey in this) {
|
||||
this[setNative](this[defaultValueKey]);
|
||||
delete this[defaultValueKey];
|
||||
} else {
|
||||
this[setNative](defaultValue);
|
||||
}
|
||||
this[setNative](defaultValue);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -424,13 +433,11 @@ export class CoercibleProperty<T extends ViewBase, U> extends Property<T, U> imp
|
||||
if (this._suspendedUpdates) {
|
||||
this._suspendedUpdates[propertyName] = property;
|
||||
}
|
||||
} else if (defaultValueKey in this) {
|
||||
this[setNative](this[defaultValueKey]);
|
||||
delete this[defaultValueKey];
|
||||
} else {
|
||||
if (defaultValueKey in this) {
|
||||
this[setNative](this[defaultValueKey]);
|
||||
delete this[defaultValueKey];
|
||||
} else {
|
||||
this[setNative](defaultValue);
|
||||
}
|
||||
this[setNative](defaultValue);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -577,7 +584,10 @@ export class CssProperty<T extends Style, U> {
|
||||
const propertyName = options.name;
|
||||
this.name = propertyName;
|
||||
|
||||
cssPropertyNames.push(options.cssName);
|
||||
// Guard against undefined cssName
|
||||
if (options.cssName) {
|
||||
cssPropertyNames.push(options.cssName);
|
||||
}
|
||||
|
||||
this.cssName = `css:${options.cssName}`;
|
||||
this.cssLocalName = options.cssName;
|
||||
@@ -657,13 +667,11 @@ export class CssProperty<T extends Style, U> {
|
||||
if (view._suspendedUpdates) {
|
||||
view._suspendedUpdates[propertyName] = property;
|
||||
}
|
||||
} else if (defaultValueKey in this) {
|
||||
view[setNative](this[defaultValueKey]);
|
||||
delete this[defaultValueKey];
|
||||
} else {
|
||||
if (defaultValueKey in this) {
|
||||
view[setNative](this[defaultValueKey]);
|
||||
delete this[defaultValueKey];
|
||||
} else {
|
||||
view[setNative](defaultValue);
|
||||
}
|
||||
view[setNative](defaultValue);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -743,13 +751,11 @@ export class CssProperty<T extends Style, U> {
|
||||
if (view._suspendedUpdates) {
|
||||
view._suspendedUpdates[propertyName] = property;
|
||||
}
|
||||
} else if (defaultValueKey in this) {
|
||||
view[setNative](this[defaultValueKey]);
|
||||
delete this[defaultValueKey];
|
||||
} else {
|
||||
if (defaultValueKey in this) {
|
||||
view[setNative](this[defaultValueKey]);
|
||||
delete this[defaultValueKey];
|
||||
} else {
|
||||
view[setNative](defaultValue);
|
||||
}
|
||||
view[setNative](defaultValue);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -856,7 +862,9 @@ export class CssAnimationProperty<T extends Style, U> implements CssAnimationPro
|
||||
const propertyName = options.name;
|
||||
this.name = propertyName;
|
||||
|
||||
cssPropertyNames.push(options.cssName);
|
||||
if (options.cssName) {
|
||||
cssPropertyNames.push(options.cssName);
|
||||
}
|
||||
|
||||
CssAnimationProperty.properties[propertyName] = this;
|
||||
if (options.cssName && options.cssName !== propertyName) {
|
||||
@@ -1143,21 +1151,19 @@ export class InheritedCssProperty<T extends Style, U> extends CssProperty<T, U>
|
||||
if (view._suspendedUpdates) {
|
||||
view._suspendedUpdates[propertyName] = property;
|
||||
}
|
||||
} else {
|
||||
if (unsetNativeValue) {
|
||||
if (defaultValueKey in this) {
|
||||
view[setNative](this[defaultValueKey]);
|
||||
delete this[defaultValueKey];
|
||||
} else {
|
||||
view[setNative](defaultValue);
|
||||
}
|
||||
} else if (unsetNativeValue) {
|
||||
if (defaultValueKey in this) {
|
||||
view[setNative](this[defaultValueKey]);
|
||||
delete this[defaultValueKey];
|
||||
} else {
|
||||
if (!(defaultValueKey in this)) {
|
||||
this[defaultValueKey] = view[getDefault] ? view[getDefault]() : defaultValue;
|
||||
}
|
||||
|
||||
view[setNative](value);
|
||||
view[setNative](defaultValue);
|
||||
}
|
||||
} else {
|
||||
if (!(defaultValueKey in this)) {
|
||||
this[defaultValueKey] = view[getDefault] ? view[getDefault]() : defaultValue;
|
||||
}
|
||||
|
||||
view[setNative](value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1356,6 +1362,7 @@ export function applyPendingNativeSetters(view: ViewBase): void {
|
||||
// TODO: Check what happens if a view was suspended and its value was reset, or set back to default!
|
||||
const suspendedUpdates = view._suspendedUpdates;
|
||||
for (const propertyName in suspendedUpdates) {
|
||||
if (!HAS_OWN.call(suspendedUpdates, propertyName)) continue;
|
||||
const property = <PropertyInterface>suspendedUpdates[propertyName];
|
||||
const setNative = property.setNative;
|
||||
if (view[setNative]) {
|
||||
@@ -1523,9 +1530,11 @@ export function propagateInheritableCssProperties(parentStyle: Style, childStyle
|
||||
export function getSetProperties(view: ViewBase): [string, any][] {
|
||||
const result = [];
|
||||
|
||||
Object.getOwnPropertyNames(view).forEach((prop) => {
|
||||
const ownProps = Object.getOwnPropertyNames(view);
|
||||
for (let i = 0; i < ownProps.length; i++) {
|
||||
const prop = ownProps[i];
|
||||
result.push([prop, view[prop]]);
|
||||
});
|
||||
}
|
||||
|
||||
const symbols = Object.getOwnPropertySymbols(view);
|
||||
for (const symbol of symbols) {
|
||||
@@ -1545,7 +1554,9 @@ export function getComputedCssValues(view: ViewBase): [string, any][] {
|
||||
const result = [];
|
||||
const style = view.style;
|
||||
for (const prop of cssPropertyNames) {
|
||||
result.push([prop, style[prop]]);
|
||||
if (prop !== undefined && prop !== null) {
|
||||
result.push([prop, style[prop]]);
|
||||
}
|
||||
}
|
||||
|
||||
// Add these to enable box model in chrome-devtools styles tab
|
||||
|
||||
@@ -75,8 +75,10 @@ export type { AccessibilityDecrementEventData, AccessibilityIncrementEventData }
|
||||
export { addTaggedAdditionalCSS, removeTaggedAdditionalCSS, resolveFileNameFromUrl } from './styling/style-scope';
|
||||
export { Background } from './styling/background';
|
||||
export type { CacheMode } from './styling/background';
|
||||
export { parseCSSShadow, ShadowCSSValues } from './styling/css-shadow';
|
||||
export { parseCSSStroke, StrokeCSSValues } from './styling/css-stroke';
|
||||
export { parseCSSShadow } from './styling/css-shadow';
|
||||
export type { ShadowCSSValues } from './styling/css-shadow';
|
||||
export { parseCSSStroke } from './styling/css-stroke';
|
||||
export type { StrokeCSSValues } from './styling/css-stroke';
|
||||
export { animationTimingFunctionConverter, timeConverter } from './styling/converters';
|
||||
export { Font, FontStyle, FontWeight, FontVariationSettings } from './styling/font';
|
||||
export type { FontStyleType, FontWeightType, FontVariationSettingsType } from './styling/font-interfaces';
|
||||
|
||||
@@ -137,8 +137,17 @@ export default function (config: Config, env: IWebpackEnv = _env): Config {
|
||||
// Ensure imports of the Node 'module' builtin resolve to our polyfill
|
||||
module: require.resolve('../polyfills/module.js'),
|
||||
},
|
||||
// Allow extension-less ESM imports (fixes "fully specified" errors)
|
||||
// Example: '../timer' -> resolves to index.<platform>.js without requiring explicit extension
|
||||
fullySpecified: false,
|
||||
});
|
||||
|
||||
// As an extra guard, ensure rule-level resolve also allows extension-less imports
|
||||
config.module
|
||||
.rule('esm-extensionless')
|
||||
.test(/\.(mjs|js|ts|tsx)$/)
|
||||
.resolve.set('fullySpecified', false);
|
||||
|
||||
const getSourceMapType = (map: string | boolean): Config.DevTool => {
|
||||
const defaultSourceMap = 'inline-source-map';
|
||||
|
||||
@@ -295,10 +304,6 @@ export default function (config: Config, env: IWebpackEnv = _env): Config {
|
||||
});
|
||||
} else {
|
||||
// Set up ESM output
|
||||
// NOTE: this fixes all worker bundling issues
|
||||
// however it causes issues with angular lazy loading.
|
||||
// TODO: still need to investigate the right combination of webpack settings there
|
||||
// TODO: test if standalone lazy loaded routes work, maybe it's just with loadChildren modules?
|
||||
config.output.chunkFilename('[name].mjs');
|
||||
|
||||
// now re‑add exactly what you want:
|
||||
@@ -546,6 +551,10 @@ export default function (config: Config, env: IWebpackEnv = _env): Config {
|
||||
.use('sass-loader')
|
||||
.loader('sass-loader')
|
||||
.options({
|
||||
// helps ensure proper project compatibility
|
||||
// particularly in cases of workspaces
|
||||
// which may have different nested Sass implementations
|
||||
// via transient dependencies
|
||||
implementation: require('sass'),
|
||||
});
|
||||
|
||||
|
||||
@@ -12,7 +12,8 @@ export default function (config: Config, env: IWebpackEnv = _env): Config {
|
||||
const entryPath = getEntryPath();
|
||||
const virtualEntryPath = path.resolve(
|
||||
__dirname,
|
||||
// Note: not sure we'll need this but just an idea if we do.
|
||||
// Note: this is possible if needed
|
||||
// at moment it's not but just leaving as note for future
|
||||
// `../stubs/virtual-entry-typescript.${env.commonjs ? 'js' : 'mjs'}`,
|
||||
`../stubs/virtual-entry-typescript.js`,
|
||||
);
|
||||
|
||||
@@ -24,15 +24,10 @@ export default function loader(content: string, map: any) {
|
||||
return this.callback(null, `${content}\n${hmrRuntime}`, map);
|
||||
}
|
||||
|
||||
const relativePath = relative(
|
||||
opts.appPath ?? this.rootContext,
|
||||
this.resourcePath,
|
||||
).replace(/\\/g, '/');
|
||||
|
||||
const hmrCode = this.hot
|
||||
? dedent`
|
||||
/* NATIVESCRIPT-HOT-LOADER */
|
||||
if(module.hot) {
|
||||
if(module.hot?.accept) {
|
||||
module.hot.accept()
|
||||
}
|
||||
`
|
||||
|
||||
@@ -6,16 +6,6 @@ import { join, extname, relative } from 'path';
|
||||
import { fileURLToPath } from 'url';
|
||||
import { createRequire } from 'module';
|
||||
|
||||
console.log('__COMMONJS__:', __COMMONJS__);
|
||||
|
||||
// const context = require.context("~/", /* deep: */ true, /* filter: */ /\.(xml|js|(?<!\.d\.)ts|s?css)$/);
|
||||
|
||||
// const modules = import.meta.glob(
|
||||
// // adjust the pattern to your layout:
|
||||
// "/src/**/*.@(xml|js|ts|scss|css)"
|
||||
// // { eager: true } // uncomment to import immediately
|
||||
// );
|
||||
console.log('typeof import.meta.glob:', typeof import.meta.glob);
|
||||
if (typeof import.meta.glob !== 'undefined') {
|
||||
// Vite environment
|
||||
const modules = import.meta.glob(
|
||||
|
||||
Reference in New Issue
Block a user