chore: tmp comments to verify loading order - cleanup after confirmed

This commit is contained in:
Nathan Walker
2025-07-14 08:47:45 -07:00
parent 49413e5873
commit 4fe0003eb6
4 changed files with 40 additions and 34 deletions

View File

@@ -12,6 +12,12 @@ import * as wgc from '../wgc';
import * as cryptoImpl from '../wgc/crypto';
import * as subtleCryptoImpl from '../wgc/crypto/SubtleCrypto';
console.log('here in globals/index!');
console.log(`typeof __dirname:`, typeof __dirname);
// commonjs builds will have __dirname defined, but es6 modules will not
global.__dirname = typeof __dirname !== 'undefined' ? __dirname : import.meta.dirname;
console.log('global.__dirname', global.__dirname);
if (typeof global.__metadata === 'undefined') {
/**
* TS decorator metadata helper.
@@ -408,34 +414,11 @@ function isTestingEnv() {
return typeof jest !== 'undefined' || global.__UNIT_TEST__;
}
if (typeof global.__metadata === 'undefined') {
/**
* TS decorator metadata helper.
* @param metadataKey the metadata key (e.g. "design:type")
* @param metadataValue the metadata value (e.g. the constructor function)
* @returns a decorator function, or undefined if Reflect.metadata isnt available
*/
global.__metadata = (metadataKey, metadataValue) => {
if (
typeof Reflect === 'object' &&
// @ts-expect-error
typeof Reflect.metadata === 'function'
) {
// Delegate to the reflect-metadata shim
// @ts-expect-error
return Reflect.metadata(metadataKey, metadataValue);
}
// no-op if no Reflect.metadata
};
}
console.log('global.NativeScriptHasInitGlobal:', global.NativeScriptHasInitGlobal);
console.log('isTestingEnv():', isTestingEnv());
if (!global.NativeScriptHasInitGlobal && !isTestingEnv()) {
initGlobal();
}
// if (!isTestingEnv()) {
// // ensure the Application instance is initialized before any other module imports it.
// require('@nativescript/core/application');
// }
// ensure the Application instance is initialized before any other module imports it.
import '@nativescript/core/application';
import '../application';

View File

@@ -1,3 +1,5 @@
// @ts-ignore apps resolve this at runtime with path alias in project bundlers
import appConfig from '~/package.json';
/* eslint-disable prefer-rest-params */
declare let __startCPUProfiler: any;
declare let __stopCPUProfiler: any;
@@ -158,8 +160,9 @@ export function enable(mode: InstrumentationMode = 'counters') {
}
try {
// const appConfig = require('~/package.json');
// @ts-ignore
const appConfig = await import('~/package.json');
// const appConfig = await import('~/package.json');
console.log('profiling appConfig:', appConfig);
if (appConfig && appConfig.profiling) {
enable(appConfig.profiling);

View File

@@ -16,13 +16,25 @@ import { CssAnimationParser } from './css-animation-parser';
import { sanitizeModuleName } from '../../utils/common';
import { resolveModuleName } from '../../module-name-resolver';
import { cleanupImportantFlags } from './css-utils';
import { cssTreeParse } from '../../css/css-tree-parser';
import { CSS3Parser } from '../../css/CSS3Parser';
import { CSSNativeScript } from '../../css/CSSNativeScript';
import { parse as parseCss } from '../../css/lib/parse';
// @ts-ignore apps resolve this at runtime with path alias in project bundlers
import appConfig from '~/package.json';
// if (!global.__dirname) {
// global.__dirname = typeof __dirname !== 'undefined' ? __dirname : import.meta.dirname;
// }
// const appPackagePath = path.join(global.__dirname, 'package.json');
console.log('style-scope appConfig:', appConfig);
let parser: 'rework' | 'nativescript' | 'css-tree' = 'css-tree';
try {
console.log('style-scope here??');
// @ts-ignore
const appConfig = await import('~/package.json');
console.log('style-scope appConfig:', appConfig);
// const appConfig = require('~/package.json');
// console.log('style-scope appConfig:', appConfig);
if (appConfig) {
if (appConfig.cssParser === 'rework') {
parser = 'rework';
@@ -238,17 +250,13 @@ class CSSSource {
private async parseCSSAst() {
if (this._source) {
if (__CSS_PARSER__ === 'css-tree') {
const { cssTreeParse } = await import('../../css/css-tree-parser');
this._ast = cssTreeParse(this._source, this._file);
} else if (__CSS_PARSER__ === 'nativescript') {
const { CSS3Parser } = await import('../../css/CSS3Parser');
const { CSSNativeScript } = await import('../../css/CSSNativeScript');
const cssparser = new CSS3Parser(this._source);
const stylesheet = cssparser.parseAStylesheet();
const cssNS = new CSSNativeScript();
this._ast = cssNS.parseStylesheet(stylesheet);
} else if (__CSS_PARSER__ === 'rework') {
const { parse: parseCss } = await import('../../css');
this._ast = parseCss(this._source, { source: this._file });
}
}
@@ -558,6 +566,9 @@ export class CssState {
}
}
/**
* Checks whether style scope and CSS state selectors are in sync.
*/
public isSelectorsLatestVersionApplied(): boolean {
const view = this.viewRef.get();
if (!view) {
@@ -923,6 +934,9 @@ export class StyleScope {
return this.getSelectorsVersion();
}
/**
* Increase the application CSS selector version.
*/
public _increaseApplicationCssSelectorVersion(): void {
applicationCssSelectorVersion++;
}

View File

@@ -92,7 +92,13 @@ export function dataSerialize(data: any, wrapPrimitives: boolean = false) {
}
function getCurrentAppPath(): string {
const currentDir = import.meta.dirname;
if (!global.__dirname) {
global.__dirname = typeof __dirname !== 'undefined' ? __dirname : import.meta.dirname;
}
console.log('getCurrentAppPath __dirname:', __dirname);
const currentDir = global.__dirname;
console.log('getCurrentAppPath global.__dirname:', global.__dirname);
console.log('getCurrentAppPath currentDir:', currentDir);
const tnsModulesIndex = currentDir.indexOf('/tns_modules');
// Module not hosted in ~/tns_modules when bundled. Use current dir.