crelte 0.5.9 → 0.5.10

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.
@@ -2,9 +2,9 @@ import { CrelteRequest } from '../index.js';
2
2
  export interface Module {
3
3
  /** Svelte component */
4
4
  default: any;
5
- /** Handle of the block, this only works with { eager: true } */
5
+ /** Handle of the block, this only works with `{ eager: true }` */
6
6
  handle?: string | string[];
7
- /** If true the typeHandle will be avaiable for this component */
7
+ /** If true the typeHandle will be available for this component */
8
8
  keepTypeHandle?: boolean;
9
9
  loadData?: (cr: CrelteRequest, block: any, opts: BlockOptions) => Promise<any>;
10
10
  }
@@ -71,7 +71,7 @@ export declare function blockModules(modules: Record<string, AsyncModule>, opts?
71
71
  * };
72
72
  * ```
73
73
  */
74
- export declare function loadBlocksData(cr: CrelteRequest, blocks: any[], modules: BlockModules): Promise<Blocks>;
74
+ export declare function loadBlocksData(cr: CrelteRequest, blocks: any[], modules: BlockModules): Promise<BlocksInstance>;
75
75
  /**
76
76
  * Creates a new Blocks instance
77
77
  *
@@ -80,13 +80,14 @@ export declare function loadBlocksData(cr: CrelteRequest, blocks: any[], modules
80
80
  * @param blocks the blocks data each block must have a typeHandle
81
81
  * @param modules the modules created with `blockModules`
82
82
  */
83
- export declare function newBlocks(blocks: any[], modules: BlockModules): Promise<Blocks>;
84
- export default class Blocks {
83
+ export declare function newBlocks(blocks: any[], modules: BlockModules): Promise<BlocksInstance>;
84
+ export default class BlocksInstance {
85
85
  blocks: any[];
86
86
  data: any[];
87
87
  modules: Map<string, Module>;
88
88
  constructor(blocks: any[], modules: Map<string, Module>);
89
89
  loadData(cr: CrelteRequest): Promise<void>;
90
+ get length(): number;
90
91
  each(): {
91
92
  mod: any;
92
93
  props: any;
@@ -1 +1 @@
1
- {"version":3,"file":"Blocks.d.ts","sourceRoot":"","sources":["../../src/blocks/Blocks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,C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AC,CAAC;gBAEjB,MAAM,EAAE,GAAG,EAAE,EAAE,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC;IAMjD,QAAQ,CAAC,EAAE,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAkBhD,IAAI,MAAM,IAAI,MAAM,CAEnB;IAED,IAAI,IAAI;QAAE,GAAG,EAAE,GAAG,CAAC;QAAC,KAAK,EAAE,GAAG,CAAA;KAAE,EAAE;CAclC"}
@@ -101,9 +101,9 @@ export async function newBlocks(blocks, modules) {
101
101
  requiredModules.add(block.typeHandle);
102
102
  }
103
103
  const loadedModules = await modules.load(requiredModules);
104
- return new Blocks(blocks, loadedModules);
104
+ return new BlocksInstance(blocks, loadedModules);
105
105
  }
106
- export default class Blocks {
106
+ export default class BlocksInstance {
107
107
  blocks;
108
108
  data;
109
109
  modules;
@@ -125,6 +125,9 @@ export default class Blocks {
125
125
  return {};
126
126
  }));
127
127
  }
128
+ get length() {
129
+ return this.blocks.length;
130
+ }
128
131
  each() {
129
132
  return this.blocks.map((block, i) => {
130
133
  const mod = this.modules.get(block.typeHandle);
@@ -1,4 +1,4 @@
1
- <script lang="ts">import { BlocksInstance } from "./index.js";
1
+ <script lang="ts">import {} from "./index.js";
2
2
  export let blocks;
3
3
  </script>
4
4
 
@@ -1,4 +1,4 @@
1
- import { BlocksInstance } from './index.js';
1
+ import { type BlocksInstance } from './index.js';
2
2
  interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
3
3
  new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
4
4
  $$bindings?: Bindings;
@@ -1 +1 @@
1
- {"version":3,"file":"Blocks.svelte.d.ts","sourceRoot":"","sources":["../../src/blocks/Blocks.svelte.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AA6C5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MAAM,EAAE,GAAG,CAAC,GAAG,GAAG,EAAE,OAAO,GAAG,EAAE,EAAE,QAAQ,GAAG,MAAM;IACpM,KAAK,OAAO,EAAE,OAAO,QAAQ,EAAE,2BAA2B,CAAC,KAAK,CAAC,GAAG,OAAO,QAAQ,EAAE,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,GAAG;QAAE,UAAU,CAAC,EAAE,QAAQ,CAAA;KAAE,GAAG,OAAO,CAAC;IACjK,CAAC,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,GAAG;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,KAAK,CAAA;KAAC,GAAG,OAAO,GAAG;QAAE,IAAI,CAAC,EAAE,GAAG,CAAC;QAAC,GAAG,CAAC,EAAE,GAAG,CAAA;KAAE,CAAC;IAC9G,YAAY,CAAC,EAAE,QAAQ,CAAC;CAC3B;AAKD,QAAA,MAAM,MAAM;;YAViC,cAAc;;;kBAUuD,CAAC;AACjG,KAAK,MAAM,GAAG,YAAY,CAAC,OAAO,MAAM,CAAC,CAAC;AAC5C,eAAe,MAAM,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "crelte",
3
- "version": "0.5.9",
3
+ "version": "0.5.10",
4
4
  "author": "Crelte <support@crelte.com>",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -1,21 +1,5 @@
1
1
  <script lang="ts">
2
- import { BlocksInstance } from './index.js';
3
-
4
- /*
5
- usage:
6
-
7
- const mods = blockModules(import.meta.glob('./contentDetail/*.svelte'));
8
-
9
- export const loadData = {
10
- blocks: (cr, entry) => loadBlocksData(cr, entry.blocks, mods)
11
- };
12
-
13
- export let blocks;
14
-
15
- // provide entry if wanted, all $$restProps will be passed to the children
16
- <Blocks {blocks} {entry} />
17
-
18
- */
2
+ import { type BlocksInstance } from './index.js';
19
3
 
20
4
  export let blocks: BlocksInstance;
21
5
  </script>
@@ -5,10 +5,10 @@ export interface Module {
5
5
  /** Svelte component */
6
6
  default: any;
7
7
 
8
- /** Handle of the block, this only works with { eager: true } */
8
+ /** Handle of the block, this only works with `{ eager: true }` */
9
9
  handle?: string | string[];
10
10
 
11
- /** If true the typeHandle will be avaiable for this component */
11
+ /** If true the typeHandle will be available for this component */
12
12
  keepTypeHandle?: boolean;
13
13
 
14
14
  loadData?: (
@@ -147,7 +147,7 @@ export async function loadBlocksData(
147
147
  cr: CrelteRequest,
148
148
  blocks: any[],
149
149
  modules: BlockModules,
150
- ): Promise<Blocks> {
150
+ ): Promise<BlocksInstance> {
151
151
  const nBlocks = await newBlocks(blocks, modules);
152
152
 
153
153
  await nBlocks.loadData(cr);
@@ -166,7 +166,7 @@ export async function loadBlocksData(
166
166
  export async function newBlocks(
167
167
  blocks: any[],
168
168
  modules: BlockModules,
169
- ): Promise<Blocks> {
169
+ ): Promise<BlocksInstance> {
170
170
  // define all required modules
171
171
  const requiredModules: Set<string> = new Set();
172
172
 
@@ -178,10 +178,10 @@ export async function newBlocks(
178
178
 
179
179
  const loadedModules = await modules.load(requiredModules);
180
180
 
181
- return new Blocks(blocks, loadedModules);
181
+ return new BlocksInstance(blocks, loadedModules);
182
182
  }
183
183
 
184
- export default class Blocks {
184
+ export default class BlocksInstance {
185
185
  blocks: any[];
186
186
  data: any[];
187
187
  modules: Map<string, Module>;
@@ -192,7 +192,7 @@ export default class Blocks {
192
192
  this.data = blocks.map(() => null);
193
193
  }
194
194
 
195
- async loadData(cr: CrelteRequest) {
195
+ async loadData(cr: CrelteRequest): Promise<void> {
196
196
  this.data = await Promise.all(
197
197
  this.blocks.map((block, i) => {
198
198
  const mod = this.modules.get(block.typeHandle)!;
@@ -210,6 +210,10 @@ export default class Blocks {
210
210
  );
211
211
  }
212
212
 
213
+ get length(): number {
214
+ return this.blocks.length;
215
+ }
216
+
213
217
  each(): { mod: any; props: any }[] {
214
218
  return this.blocks.map((block, i) => {
215
219
  const mod = this.modules.get(block.typeHandle)!;