@sealcode/sealgen 0.12.11 → 0.12.12
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/build.js +28 -10
- package/package.json +1 -1
- package/src/build.ts +28 -11
package/dist/build.js
CHANGED
|
@@ -78,12 +78,18 @@ async function build_ts() {
|
|
|
78
78
|
"utf8"
|
|
79
79
|
);
|
|
80
80
|
for (const ext of embeddable_file_extensions) {
|
|
81
|
+
const regex = new RegExp(
|
|
82
|
+
`^import (\\w+|{[^}]+}) from "([^"]+.${ext})";`,
|
|
83
|
+
"gm"
|
|
84
|
+
);
|
|
81
85
|
contents = contents.replaceAll(
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
86
|
+
regex,
|
|
87
|
+
(line) => {
|
|
88
|
+
return line.replace(
|
|
89
|
+
`.${ext}"`,
|
|
90
|
+
'.js"'
|
|
91
|
+
);
|
|
92
|
+
}
|
|
87
93
|
);
|
|
88
94
|
}
|
|
89
95
|
contents = removeNamedImports(contents);
|
|
@@ -113,13 +119,25 @@ async function build_ts() {
|
|
|
113
119
|
)}";
|
|
114
120
|
|
|
115
121
|
import fs from "fs";
|
|
116
|
-
let
|
|
122
|
+
let buffer_promise = null;
|
|
123
|
+
|
|
124
|
+
export const getBuffer = function(){
|
|
125
|
+
if(buffer_promise) return buffer_promise;
|
|
126
|
+
buffer_promise = fs.promises.readFile("${args.path}");
|
|
127
|
+
return buffer_promise;
|
|
128
|
+
}
|
|
117
129
|
|
|
118
|
-
export const
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
return content_promise;
|
|
130
|
+
export const getContent = async function(){
|
|
131
|
+
const buffer = await getBuffer();
|
|
132
|
+
return buffer.toString("utf-8");
|
|
122
133
|
}
|
|
134
|
+
|
|
135
|
+
export const getBase64 = async function(){
|
|
136
|
+
const buffer = await getBuffer();
|
|
137
|
+
return buffer.toString("base64");
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export default { getContent, url, getBase64, getBuffer };
|
|
123
141
|
`;
|
|
124
142
|
return {
|
|
125
143
|
contents
|
package/package.json
CHANGED
package/src/build.ts
CHANGED
|
@@ -87,13 +87,18 @@ async function build_ts() {
|
|
|
87
87
|
"utf8"
|
|
88
88
|
);
|
|
89
89
|
for (const ext of embeddable_file_extensions) {
|
|
90
|
+
const regex = new RegExp(
|
|
91
|
+
`^import (\\w+|{[^}]+}) from "([^"]+.${ext})";`,
|
|
92
|
+
"gm"
|
|
93
|
+
);
|
|
90
94
|
contents = contents.replaceAll(
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
95
|
+
regex,
|
|
96
|
+
(line) => {
|
|
97
|
+
return line.replace(
|
|
98
|
+
`.${ext}"`,
|
|
99
|
+
'.js"'
|
|
100
|
+
);
|
|
101
|
+
}
|
|
97
102
|
);
|
|
98
103
|
}
|
|
99
104
|
|
|
@@ -128,13 +133,25 @@ async function build_ts() {
|
|
|
128
133
|
)}";
|
|
129
134
|
|
|
130
135
|
import fs from "fs";
|
|
131
|
-
let
|
|
136
|
+
let buffer_promise = null;
|
|
137
|
+
|
|
138
|
+
export const getBuffer = function(){
|
|
139
|
+
if(buffer_promise) return buffer_promise;
|
|
140
|
+
buffer_promise = fs.promises.readFile("${args.path}");
|
|
141
|
+
return buffer_promise;
|
|
142
|
+
}
|
|
132
143
|
|
|
133
|
-
export const
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
return content_promise;
|
|
144
|
+
export const getContent = async function(){
|
|
145
|
+
const buffer = await getBuffer();
|
|
146
|
+
return buffer.toString("utf-8");
|
|
137
147
|
}
|
|
148
|
+
|
|
149
|
+
export const getBase64 = async function(){
|
|
150
|
+
const buffer = await getBuffer();
|
|
151
|
+
return buffer.toString("base64");
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export default { getContent, url, getBase64, getBuffer };
|
|
138
155
|
`;
|
|
139
156
|
return {
|
|
140
157
|
contents,
|