@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.
Files changed (3) hide show
  1. package/dist/build.js +28 -10
  2. package/package.json +1 -1
  3. 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
- new RegExp(
83
- `^import (w+|{[^}]+}) from "([^"]+.${ext})";`,
84
- "gm"
85
- ),
86
- (line) => line.replace(`.${ext}"`, '.js"')
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 content_promise = null;
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 content = function(){
119
- if(content_promise) return content_promise;
120
- content_promise = fs.promises.readFile("${args.path}", "utf-8");
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sealcode/sealgen",
3
- "version": "0.12.11",
3
+ "version": "0.12.12",
4
4
  "description": "Module to automate adding routes and collections to a sealious application",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
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
- new RegExp(
92
- `^import (\w+|{[^}]+}) from "([^"]+.${ext})";`,
93
- "gm"
94
- ),
95
- (line) =>
96
- line.replace(`.${ext}"`, '.js"')
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 content_promise = null;
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 content = function(){
134
- if(content_promise) return content_promise;
135
- content_promise = fs.promises.readFile("${args.path}", "utf-8");
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,