xpine 0.0.46 → 0.0.48
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/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +22 -5
- package/dist/src/build/typescript-builder.d.ts +6 -3
- package/dist/src/build/typescript-builder.d.ts.map +1 -1
- package/dist/src/scripts/xpine-build.js +16 -5
- package/dist/src/scripts/xpine-dev.js +16 -5
- package/dist/src/util/web.d.ts +2 -0
- package/dist/src/util/web.d.ts.map +1 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -238,7 +238,10 @@ function removeClientScriptInTSXFile(pathName, source) {
|
|
|
238
238
|
clientDataStart
|
|
239
239
|
};
|
|
240
240
|
}
|
|
241
|
-
function
|
|
241
|
+
function pathExistsAsIndex(pathName) {
|
|
242
|
+
return fs.existsSync(path2.join(pathName, "./index.js")) || fs.existsSync(path2.join(pathName, "./index.ts")) || fs.existsSync(path2.join(pathName, "./index.jsx")) || fs.existsSync(path2.join(pathName, "./index.tsx"));
|
|
243
|
+
}
|
|
244
|
+
function getImportsToAbsolutePaths(child, source, pathName, convertPathsToJS = false) {
|
|
242
245
|
const output = [];
|
|
243
246
|
child.forEachChild((child2) => {
|
|
244
247
|
if (child2.kind === ts.SyntaxKind.StringLiteral) {
|
|
@@ -246,15 +249,23 @@ function getImportsToAbsolutePaths(child, source, pathName) {
|
|
|
246
249
|
const importPath = text.replace(/[\"\']/g, "");
|
|
247
250
|
const isRelativeImport = importPath.startsWith(".") || importPath.startsWith("/");
|
|
248
251
|
if (!isRelativeImport) return;
|
|
252
|
+
let result = path2.join(path2.dirname(pathName), importPath);
|
|
253
|
+
if (convertPathsToJS) {
|
|
254
|
+
if (pathExistsAsIndex(result)) {
|
|
255
|
+
result = path2.join(result, "./index.js");
|
|
256
|
+
} else {
|
|
257
|
+
result += ".js";
|
|
258
|
+
}
|
|
259
|
+
}
|
|
249
260
|
output.push({
|
|
250
261
|
old: importPath,
|
|
251
|
-
new:
|
|
262
|
+
new: result
|
|
252
263
|
});
|
|
253
264
|
}
|
|
254
265
|
});
|
|
255
266
|
return output;
|
|
256
267
|
}
|
|
257
|
-
function getXpineOnLoadFunction(pathName, source,
|
|
268
|
+
function getXpineOnLoadFunction(pathName, source, options) {
|
|
258
269
|
const value = {
|
|
259
270
|
imports: "",
|
|
260
271
|
fn: ""
|
|
@@ -262,7 +273,7 @@ function getXpineOnLoadFunction(pathName, source, onLoadFileResult) {
|
|
|
262
273
|
source.forEachChild((child) => {
|
|
263
274
|
if (child.kind == ts.SyntaxKind.ImportDeclaration) {
|
|
264
275
|
let importText = child.getText(source);
|
|
265
|
-
const importOutput = getImportsToAbsolutePaths(child, source, pathName);
|
|
276
|
+
const importOutput = getImportsToAbsolutePaths(child, source, pathName, options?.convertPathsToJS);
|
|
266
277
|
for (const importItem of importOutput) {
|
|
267
278
|
importText = importText.replace(importItem.old, importItem.new);
|
|
268
279
|
}
|
|
@@ -1033,7 +1044,7 @@ async function buildOnLoadFile(componentData, isDev2) {
|
|
|
1033
1044
|
return a.path.localeCompare(b.path);
|
|
1034
1045
|
});
|
|
1035
1046
|
for (const file of onLoadFiles) {
|
|
1036
|
-
const result = getXpineOnLoadFunction(file.path, file.source,
|
|
1047
|
+
const result = getXpineOnLoadFunction(file.path, file.source, { convertPathsToJS: true });
|
|
1037
1048
|
onLoadFileResult.fn += result.fn;
|
|
1038
1049
|
onLoadFileResult.imports += result.imports;
|
|
1039
1050
|
}
|
|
@@ -1206,6 +1217,11 @@ var html = class {
|
|
|
1206
1217
|
function JSXRuntime() {
|
|
1207
1218
|
return true;
|
|
1208
1219
|
}
|
|
1220
|
+
|
|
1221
|
+
// src/util/web.ts
|
|
1222
|
+
function getCurrentBreakpoint() {
|
|
1223
|
+
return window.getComputedStyle(document.documentElement).getPropertyValue("--active-breakpoint")?.replace(/[\'\"]/g, "")?.trim() || "";
|
|
1224
|
+
}
|
|
1209
1225
|
export {
|
|
1210
1226
|
JSXRuntime,
|
|
1211
1227
|
addToContextArray,
|
|
@@ -1222,6 +1238,7 @@ export {
|
|
|
1222
1238
|
filePathToURLPath,
|
|
1223
1239
|
fromRoot,
|
|
1224
1240
|
getComponentDynamicPaths,
|
|
1241
|
+
getCurrentBreakpoint,
|
|
1225
1242
|
getTokenFromRequest,
|
|
1226
1243
|
html,
|
|
1227
1244
|
logSize,
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
|
-
import { OnLoadFileResult } from '../scripts/build';
|
|
3
2
|
type ImportDeclaration = {
|
|
4
3
|
node: ts.Node;
|
|
5
4
|
importPath: string;
|
|
@@ -26,9 +25,13 @@ export declare function removeClientScriptInTSXFile(pathName: string, source: ts
|
|
|
26
25
|
clientDataStart: number;
|
|
27
26
|
};
|
|
28
27
|
export declare function createStaticFile(pathName: string, source: ts.SourceFile): void;
|
|
29
|
-
export declare function
|
|
28
|
+
export declare function pathExistsAsIndex(pathName: string): any;
|
|
29
|
+
export declare function getImportsToAbsolutePaths(child: ts.Node, source: ts.SourceFile, pathName: string, convertPathsToJS?: boolean): any[];
|
|
30
30
|
export declare function printRecursiveFrom(node: ts.Node, indentLevel: number, sourceFile: ts.SourceFile): void;
|
|
31
|
-
|
|
31
|
+
type GetXpineOnLoadFunctionOptions = {
|
|
32
|
+
convertPathsToJS?: boolean;
|
|
33
|
+
};
|
|
34
|
+
export declare function getXpineOnLoadFunction(pathName: string, source: ts.SourceFile, options?: GetXpineOnLoadFunctionOptions): {
|
|
32
35
|
imports: string;
|
|
33
36
|
fn: string;
|
|
34
37
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typescript-builder.d.ts","sourceRoot":"","sources":["../../../src/build/typescript-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"typescript-builder.d.ts","sourceRoot":"","sources":["../../../src/build/typescript-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAO5B,KAAK,iBAAiB,GAAG;IACvB,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;CACpB,CAAA;AAGD,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,EAAE,UAAU,EAAE,EAAE,CAAC,UAAU,EAAE,kBAAkB,GAAE,iBAAiB,EAAO,uBAiB/H;AAED,wBAAgB,yBAAyB,CAAC,cAAc,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,UAO3H;AAED,KAAK,mBAAmB,GAAG;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,eAAe,EAAE,OAAO,CAAC;IACzB,SAAS,EAAE,OAAO,CAAC;CACpB,CAAA;AAED,wBAAgB,8BAA8B,CAC5C,I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MhE"}
|
|
@@ -233,7 +233,10 @@ function removeClientScriptInTSXFile(pathName, source) {
|
|
|
233
233
|
clientDataStart
|
|
234
234
|
};
|
|
235
235
|
}
|
|
236
|
-
function
|
|
236
|
+
function pathExistsAsIndex(pathName) {
|
|
237
|
+
return fs.existsSync(path2.join(pathName, "./index.js")) || fs.existsSync(path2.join(pathName, "./index.ts")) || fs.existsSync(path2.join(pathName, "./index.jsx")) || fs.existsSync(path2.join(pathName, "./index.tsx"));
|
|
238
|
+
}
|
|
239
|
+
function getImportsToAbsolutePaths(child, source, pathName, convertPathsToJS = false) {
|
|
237
240
|
const output = [];
|
|
238
241
|
child.forEachChild((child2) => {
|
|
239
242
|
if (child2.kind === ts.SyntaxKind.StringLiteral) {
|
|
@@ -241,15 +244,23 @@ function getImportsToAbsolutePaths(child, source, pathName) {
|
|
|
241
244
|
const importPath = text.replace(/[\"\']/g, "");
|
|
242
245
|
const isRelativeImport = importPath.startsWith(".") || importPath.startsWith("/");
|
|
243
246
|
if (!isRelativeImport) return;
|
|
247
|
+
let result = path2.join(path2.dirname(pathName), importPath);
|
|
248
|
+
if (convertPathsToJS) {
|
|
249
|
+
if (pathExistsAsIndex(result)) {
|
|
250
|
+
result = path2.join(result, "./index.js");
|
|
251
|
+
} else {
|
|
252
|
+
result += ".js";
|
|
253
|
+
}
|
|
254
|
+
}
|
|
244
255
|
output.push({
|
|
245
256
|
old: importPath,
|
|
246
|
-
new:
|
|
257
|
+
new: result
|
|
247
258
|
});
|
|
248
259
|
}
|
|
249
260
|
});
|
|
250
261
|
return output;
|
|
251
262
|
}
|
|
252
|
-
function getXpineOnLoadFunction(pathName, source,
|
|
263
|
+
function getXpineOnLoadFunction(pathName, source, options) {
|
|
253
264
|
const value = {
|
|
254
265
|
imports: "",
|
|
255
266
|
fn: ""
|
|
@@ -257,7 +268,7 @@ function getXpineOnLoadFunction(pathName, source, onLoadFileResult) {
|
|
|
257
268
|
source.forEachChild((child) => {
|
|
258
269
|
if (child.kind == ts.SyntaxKind.ImportDeclaration) {
|
|
259
270
|
let importText = child.getText(source);
|
|
260
|
-
const importOutput = getImportsToAbsolutePaths(child, source, pathName);
|
|
271
|
+
const importOutput = getImportsToAbsolutePaths(child, source, pathName, options?.convertPathsToJS);
|
|
261
272
|
for (const importItem of importOutput) {
|
|
262
273
|
importText = importText.replace(importItem.old, importItem.new);
|
|
263
274
|
}
|
|
@@ -826,7 +837,7 @@ async function buildOnLoadFile(componentData, isDev3) {
|
|
|
826
837
|
return a.path.localeCompare(b.path);
|
|
827
838
|
});
|
|
828
839
|
for (const file of onLoadFiles) {
|
|
829
|
-
const result = getXpineOnLoadFunction(file.path, file.source,
|
|
840
|
+
const result = getXpineOnLoadFunction(file.path, file.source, { convertPathsToJS: true });
|
|
830
841
|
onLoadFileResult.fn += result.fn;
|
|
831
842
|
onLoadFileResult.imports += result.imports;
|
|
832
843
|
}
|
|
@@ -240,7 +240,10 @@ function removeClientScriptInTSXFile(pathName, source) {
|
|
|
240
240
|
clientDataStart
|
|
241
241
|
};
|
|
242
242
|
}
|
|
243
|
-
function
|
|
243
|
+
function pathExistsAsIndex(pathName) {
|
|
244
|
+
return fs.existsSync(path2.join(pathName, "./index.js")) || fs.existsSync(path2.join(pathName, "./index.ts")) || fs.existsSync(path2.join(pathName, "./index.jsx")) || fs.existsSync(path2.join(pathName, "./index.tsx"));
|
|
245
|
+
}
|
|
246
|
+
function getImportsToAbsolutePaths(child, source, pathName, convertPathsToJS = false) {
|
|
244
247
|
const output = [];
|
|
245
248
|
child.forEachChild((child2) => {
|
|
246
249
|
if (child2.kind === ts.SyntaxKind.StringLiteral) {
|
|
@@ -248,15 +251,23 @@ function getImportsToAbsolutePaths(child, source, pathName) {
|
|
|
248
251
|
const importPath = text.replace(/[\"\']/g, "");
|
|
249
252
|
const isRelativeImport = importPath.startsWith(".") || importPath.startsWith("/");
|
|
250
253
|
if (!isRelativeImport) return;
|
|
254
|
+
let result = path2.join(path2.dirname(pathName), importPath);
|
|
255
|
+
if (convertPathsToJS) {
|
|
256
|
+
if (pathExistsAsIndex(result)) {
|
|
257
|
+
result = path2.join(result, "./index.js");
|
|
258
|
+
} else {
|
|
259
|
+
result += ".js";
|
|
260
|
+
}
|
|
261
|
+
}
|
|
251
262
|
output.push({
|
|
252
263
|
old: importPath,
|
|
253
|
-
new:
|
|
264
|
+
new: result
|
|
254
265
|
});
|
|
255
266
|
}
|
|
256
267
|
});
|
|
257
268
|
return output;
|
|
258
269
|
}
|
|
259
|
-
function getXpineOnLoadFunction(pathName, source,
|
|
270
|
+
function getXpineOnLoadFunction(pathName, source, options) {
|
|
260
271
|
const value = {
|
|
261
272
|
imports: "",
|
|
262
273
|
fn: ""
|
|
@@ -264,7 +275,7 @@ function getXpineOnLoadFunction(pathName, source, onLoadFileResult) {
|
|
|
264
275
|
source.forEachChild((child) => {
|
|
265
276
|
if (child.kind == ts.SyntaxKind.ImportDeclaration) {
|
|
266
277
|
let importText = child.getText(source);
|
|
267
|
-
const importOutput = getImportsToAbsolutePaths(child, source, pathName);
|
|
278
|
+
const importOutput = getImportsToAbsolutePaths(child, source, pathName, options?.convertPathsToJS);
|
|
268
279
|
for (const importItem of importOutput) {
|
|
269
280
|
importText = importText.replace(importItem.old, importItem.new);
|
|
270
281
|
}
|
|
@@ -833,7 +844,7 @@ async function buildOnLoadFile(componentData, isDev2) {
|
|
|
833
844
|
return a.path.localeCompare(b.path);
|
|
834
845
|
});
|
|
835
846
|
for (const file of onLoadFiles) {
|
|
836
|
-
const result = getXpineOnLoadFunction(file.path, file.source,
|
|
847
|
+
const result = getXpineOnLoadFunction(file.path, file.source, { convertPathsToJS: true });
|
|
837
848
|
onLoadFileResult.fn += result.fn;
|
|
838
849
|
onLoadFileResult.imports += result.imports;
|
|
839
850
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web.d.ts","sourceRoot":"","sources":["../../../src/util/web.ts"],"names":[],"mappings":"AAAA,wBAAgB,oBAAoB,WAEnC"}
|