titanfiber 1.0.92 → 1.0.93
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/_console.pkg.js +4 -0
- package/cli.min.js +11 -11
- package/inline.min.js +27 -0
- package/package.json +3 -2
- package/script.min.js +63 -0
- package/main.min.js +0 -109
- /package/{main.pkg.js → script.pkg.js} +0 -0
package/_console.pkg.js
ADDED
package/cli.min.js
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
|
+
require("./cli.pkg.js");
|
|
1
2
|
|
|
2
3
|
|
|
3
4
|
|
|
4
5
|
|
|
5
6
|
|
|
7
|
+
//Harness for CLI scripts with useful globals:
|
|
8
|
+
// 1. args (parsed from command line)
|
|
9
|
+
// "-i <value>" -> args.i //value
|
|
10
|
+
// 2. pause() (t.node.pause)
|
|
11
|
+
// 3. Flags:
|
|
12
|
+
// -np = Ignore pause() (for embedding in other scripts)
|
|
13
|
+
// -cwd = Set cwd
|
|
6
14
|
|
|
7
|
-
exports = module.exports = function cli(options, main) {
|
|
8
|
-
require("./cli.pkg.js");
|
|
9
15
|
|
|
10
16
|
|
|
11
17
|
|
|
12
18
|
|
|
13
19
|
|
|
14
|
-
|
|
15
|
-
|
|
20
|
+
globalThis.args = t.node.parseArgs();
|
|
21
|
+
globalThis.pause = t.node.pause;
|
|
16
22
|
|
|
17
23
|
|
|
18
24
|
|
|
19
25
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
return main(options);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
26
|
+
require("./script.min.js");
|
|
27
27
|
|
|
28
28
|
|
|
29
29
|
|
package/inline.min.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
//where is this used?
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
//Auto-pack the current script text (not file-based).
|
|
12
|
+
//Enables use in scripts without a source file (eg. node -e <js>).
|
|
13
|
+
//example: node -e "require('titanfiber').inline(); t.s.is(1);"
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
globalThis.__titanfiberOptions = {inline:true};
|
|
17
|
+
require("./script.min.js");
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "titanfiber",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.93",
|
|
4
4
|
"description": "",
|
|
5
5
|
"exports": {
|
|
6
|
-
".": "./
|
|
6
|
+
".": "./script.min.js",
|
|
7
7
|
"./build": "./build.min.js",
|
|
8
|
+
"./build/stable": "./buildStable.min.js",
|
|
8
9
|
"./cli": "./cli.min.js",
|
|
9
10
|
"./inline": "./inline.min.js",
|
|
10
11
|
"./repl": "./repl.min.js"
|
package/script.min.js
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
require("./script.pkg.js");
|
|
2
|
+
var options = globalThis.__titanfiberOptions ?? {};
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
//Auto-pack the current file if needed, and load the new items.
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
//Can disable dynamic to use static package,
|
|
15
|
+
// if growth over time is not desired.
|
|
16
|
+
//if(options.dynamic == null) { options.dynamic = true; }
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
var scriptPath = t.node.getScriptPath();
|
|
20
|
+
//options.scriptPath is a temp patch for JS Exe SideLoader,
|
|
21
|
+
// since it currently returns null there even with normal Node file mode (node <file>).
|
|
22
|
+
//var scriptPath = options.scriptPath ?? t.node.getScriptPath();
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
var scriptText = scriptPath ? t.fs.loadText(scriptPath) : process._eval;
|
|
26
|
+
//if(options.inline) { scriptText = process._eval; }
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
if(!scriptPath && (scriptText == null)) {
|
|
30
|
+
throw new Error("titanfiber requires either scriptPath or scriptText.");
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
var localT = {};
|
|
35
|
+
//var dynPackagePath = options.packagePath;
|
|
36
|
+
//if(!dynPackagePath) {
|
|
37
|
+
|
|
38
|
+
//Defaulting to storing pkg in temp folder for cleanliness.
|
|
39
|
+
// This is nice for .exe.js scripts to be self-contained.
|
|
40
|
+
//if(scriptPath && (options.tempDir !== false)) {
|
|
41
|
+
if(scriptPath) {
|
|
42
|
+
//name is included for readability.
|
|
43
|
+
dynPackagePath = t.titan.getTempDir()+"TitanFiber/"+t.path.baseName(scriptPath)+"_"+t.fs.getID(scriptPath)+"/main.pkg.json";
|
|
44
|
+
} else {
|
|
45
|
+
dynPackagePath = t.titan.getPackagePath(null, false, true, options);
|
|
46
|
+
}
|
|
47
|
+
options.packagePath = dynPackagePath;
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
if(t.fs.exists(dynPackagePath) && !t.titan.hasNewCompile(dynPackagePath)) {
|
|
52
|
+
t.titan._loadDynamicDeps(dynPackagePath, localT, options);
|
|
53
|
+
}
|
|
54
|
+
t.titan.autoPackAndLoadJSON(scriptPath, scriptText, localT, options);
|
|
55
|
+
globalThis.t = localT;
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
|
package/main.min.js
DELETED
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
//Improvements:
|
|
6
|
-
//1. Update to allow the same package location control as titan-shell
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
//Auto-pack the current file if needed, and load the new items.
|
|
13
|
-
function main(options) {
|
|
14
|
-
require("./main.pkg.js");
|
|
15
|
-
if(!options) { options = {}; }
|
|
16
|
-
//Can disable dynamic to use static package,
|
|
17
|
-
// if growth over time is not desired.
|
|
18
|
-
if(options.dynamic == null) { options.dynamic = true; }
|
|
19
|
-
//shane - options.scriptPath is a temp patch for JS Exe SideLoader,
|
|
20
|
-
// since it currently returns null there even with normal Node file mode (node <file>).
|
|
21
|
-
var scriptPath = options.scriptPath ?? t.node.getScriptPath();
|
|
22
|
-
|
|
23
|
-
var scriptText = scriptPath ? t.fs.loadText(scriptPath) : process._eval;
|
|
24
|
-
//if(options.inline) { scriptText = process._eval; }
|
|
25
|
-
|
|
26
|
-
var localT = {};
|
|
27
|
-
var dynPackagePath = options.packagePath;
|
|
28
|
-
if(!dynPackagePath) {
|
|
29
|
-
//Defaulting to storing pkg in temp folder for cleanliness.
|
|
30
|
-
// This is nice for .exe.js scripts to be self-contained.
|
|
31
|
-
if(scriptPath && (options.tempDir !== false)) {
|
|
32
|
-
//name is included for readability.
|
|
33
|
-
dynPackagePath = t.titan.getTempDir()+"TitanFiber/"+t.path.baseName(scriptPath)+"_"+t.fs.getID(scriptPath)+"/main.pkg.json";
|
|
34
|
-
} else {
|
|
35
|
-
dynPackagePath = t.titan.getPackagePath(scriptPath, false, true, options);
|
|
36
|
-
}
|
|
37
|
-
options.packagePath = dynPackagePath;
|
|
38
|
-
}
|
|
39
|
-
if(t.fs.exists(dynPackagePath) && !t.titan.hasNewCompile(dynPackagePath)) {
|
|
40
|
-
t.titan._loadDynamicDeps(dynPackagePath, localT, options);
|
|
41
|
-
}
|
|
42
|
-
t.titan.autoPackAndLoadJSON(scriptPath, scriptText, localT, options);
|
|
43
|
-
globalThis.t = localT;
|
|
44
|
-
}
|
|
45
|
-
//enables require("titanfiber")();
|
|
46
|
-
exports = module.exports = main;
|
|
47
|
-
exports.file = main;
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
//where is this used?
|
|
51
|
-
//Auto-pack the current script text (not file-based).
|
|
52
|
-
//Enables use in scripts without a source file (eg. node -e <js>).
|
|
53
|
-
//example: node -e "require('titanfiber').inline(); t.s.is(1);"
|
|
54
|
-
function inline(options) {
|
|
55
|
-
if(!options) { options = {}; }
|
|
56
|
-
options.inline = true;
|
|
57
|
-
return main(options);
|
|
58
|
-
}
|
|
59
|
-
exports.inline = inline;
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
//shane2
|
|
63
|
-
function build(options) {
|
|
64
|
-
return require("./build.min.js")(options, main);
|
|
65
|
-
}
|
|
66
|
-
exports.build = build;
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
//Harness for CLI scripts with useful globals:
|
|
70
|
-
// 1. args (parsed from command line)
|
|
71
|
-
// "-i <value>" -> args.i //value
|
|
72
|
-
// 2. pause() (t.node.pause)
|
|
73
|
-
// 3. Flags:
|
|
74
|
-
// -np = Ignore pause() (for embedding in other scripts)
|
|
75
|
-
// -cwd = Set cwd
|
|
76
|
-
function cli(options) {
|
|
77
|
-
return require("./cli.min.js")(options, main);
|
|
78
|
-
}
|
|
79
|
-
exports.cli = cli;
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
//shane2
|
|
83
|
-
//Enables use in non-Titan REPL (t as proxy to live-load items).
|
|
84
|
-
function repl(options) {
|
|
85
|
-
//declare global t as proxy to live-load.
|
|
86
|
-
//for use in node REPL.
|
|
87
|
-
// require("titanfiber").repl(); or .live(),
|
|
88
|
-
// enables use of t.x.x functions.
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
}
|
|
94
|
-
exports.repl = repl;
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
File without changes
|