@primate/core 0.2.3 → 0.2.4

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.
@@ -13,6 +13,7 @@ export default class App {
13
13
  app_html: "app.html";
14
14
  build: "build";
15
15
  client: "client";
16
+ lib: "lib";
16
17
  components: "components";
17
18
  config: "config";
18
19
  error_html: "error.html";
@@ -30,6 +31,7 @@ export default class App {
30
31
  readonly app_html: FileRef;
31
32
  readonly build: FileRef;
32
33
  readonly client: FileRef;
34
+ readonly lib: FileRef;
33
35
  readonly components: FileRef;
34
36
  readonly config: FileRef;
35
37
  readonly error_html: FileRef;
@@ -22,6 +22,7 @@ const toContextString = (array) => array
22
22
  const BIND_CONTEXTS = [
23
23
  "config",
24
24
  "routes",
25
+ "lib",
25
26
  "components",
26
27
  "stores",
27
28
  "locales",
@@ -1,3 +1,3 @@
1
- type BindingContext = "components" | "config" | "locales" | "modules" | "routes" | "stores";
1
+ type BindingContext = "lib" | "components" | "config" | "locales" | "modules" | "routes" | "stores";
2
2
  export type { BindingContext as default };
3
3
  //# sourceMappingURL=BindingContext.d.ts.map
@@ -29,11 +29,15 @@ export default class BuildApp extends App {
29
29
  contents: "",
30
30
  resolveDir: this.root.path,
31
31
  },
32
+ conditions: ["style", "browser", "default", "module"],
32
33
  resolveExtensions: [".ts", ".js", ...extensions],
33
34
  tsconfigRaw: {
34
35
  compilerOptions: {
35
36
  baseUrl: "${configDir}",
36
37
  paths: {
38
+ "#lib/*": [
39
+ "lib/*", ...extensions.map(e => `lib/*${e}`),
40
+ ],
37
41
  "#component/*": [
38
42
  "components/*", ...extensions.map(e => `components/*${e}`),
39
43
  ],
@@ -13,6 +13,7 @@ import pema from "pema";
13
13
  import array from "pema/array";
14
14
  import boolean from "pema/boolean";
15
15
  import string from "pema/string";
16
+ const contexts = ["lib", "components"];
16
17
  async function normalize(path) {
17
18
  return `p_${await hash(path)}`;
18
19
  }
@@ -168,16 +169,16 @@ export default class FrontendModule extends Module {
168
169
  });
169
170
  }
170
171
  const components_filter = new RegExp(`^${name}:components`);
172
+ const components_base = app.root.join(location.components);
171
173
  build.onResolve({ filter: components_filter }, ({ path }) => {
172
174
  return { namespace: `${name}`, path };
173
175
  });
174
176
  build.onLoad({ filter: components_filter }, async () => {
175
- const components = await app.root
176
- .join(location.components)
177
+ const components = await components_base
177
178
  .collect(c => fileExtensions.includes(c.fullExtension));
178
179
  let contents = "";
179
180
  for (const component of components) {
180
- const { path } = component.debase(component.directory, "/");
181
+ const { path } = component.debase(components_base, "/");
181
182
  contents += `export { default as ${await normalize(path)} }
182
183
  from "#component/${path}";\n`;
183
184
  }
@@ -206,10 +207,10 @@ export default class FrontendModule extends Module {
206
207
  init(app, next) {
207
208
  this.fileExtensions.forEach(e => {
208
209
  app.bind(e, async (file, { context }) => {
209
- assert(context === "components", `${this.name}: only components supported`);
210
+ assert(contexts.includes(context), `${this.name}: only components or lib supported`);
210
211
  if (this.compile.server) {
211
- const original = file.debase(app.runpath("stage", "components"));
212
- const source = app.path.components.join(original);
212
+ const original = file.debase(app.runpath("stage", context));
213
+ const source = app.path[context].join(original);
213
214
  const code = await this.compile.server(await source.text());
214
215
  const bundled = await bundle({
215
216
  code,
@@ -157,6 +157,10 @@ const post = async (app) => {
157
157
  await app.stage(app.path.locales, "locales", file => `export { default } from "#stage/locale${file}";`);
158
158
  // stage app config after locales so #locale imports can be resolved
159
159
  await app.stage(app.path.config, "config", file => `export { default } from "#stage/config${file}";`);
160
+ // component library
161
+ await app.stage(app.path.lib, "lib", file => `
162
+ export * from "#stage/lib${file}";
163
+ `);
160
164
  // stage components
161
165
  await app.stage(app.path.components, "components", file => `
162
166
  import * as component from "#stage/component${file}";
@@ -223,10 +227,12 @@ const post = async (app) => {
223
227
  "#database/*": "./config/database/*.js",
224
228
  "#session": "./config/session.js",
225
229
  "#i18n": "./config/i18n.js",
230
+ "#lib/*": "./lib/*.js",
226
231
  "#component/*": "./components/*.js",
227
232
  "#locale/*": "./locales/*.js",
228
233
  "#module/*": "./modules/*.js",
229
234
  "#route/*": "./routes/*.js",
235
+ "#stage/lib/*": "./stage/lib/*.js",
230
236
  "#stage/component/*": "./stage/components/*.js",
231
237
  "#stage/locale/*": "./stage/locales/*.js",
232
238
  "#stage/config/*": "./stage/config/*.js",
@@ -2,6 +2,7 @@ declare const _default: {
2
2
  readonly app_html: "app.html";
3
3
  readonly build: "build";
4
4
  readonly client: "client";
5
+ readonly lib: "lib";
5
6
  readonly components: "components";
6
7
  readonly config: "config";
7
8
  readonly error_html: "error.html";
@@ -5,6 +5,8 @@ export default {
5
5
  build: "build",
6
6
  // client build
7
7
  client: "client",
8
+ // component library
9
+ lib: "lib",
8
10
  // renderable components
9
11
  components: "components",
10
12
  // config
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@primate/core",
3
- "version": "0.2.3",
3
+ "version": "0.2.4",
4
4
  "description": "The universal web framework",
5
5
  "homepage": "https://primate.run",
6
6
  "bugs": "https://github.com/primate-run/primate/issues",