Skip to content

Commit f78211d

Browse files
chore(docs): v0.3.1 API docs & examples
1 parent 6e3ae22 commit f78211d

File tree

6 files changed

+91
-40
lines changed

6 files changed

+91
-40
lines changed

docs/api/README.md

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
### Type aliases
1818

19+
* [CustomBlockCallback](README.md#customblockcallback)
1920
* [File](README.md#file)
2021

2122
### Variables
@@ -32,11 +33,21 @@
3233

3334
## Type aliases
3435

36+
### CustomBlockCallback
37+
38+
Ƭ **CustomBlockCallback**: (component: [Module](interfaces/module.md)) => undefined
39+
40+
*Defined in [index.ts:91](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/6e3ae22/src/index.ts#L91)*
41+
42+
CustomBlockCallback function type
43+
44+
___
45+
3546
### File
3647

3748
Ƭ **File**: string \| { content: string ; extname: string }
3849

39-
*Defined in [index.ts:84](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/f3c303d/src/index.ts#L84)*
50+
*Defined in [index.ts:85](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/6e3ae22/src/index.ts#L85)*
4051

4152
Represents the content of the file or the content and the extension name.
4253

@@ -46,7 +57,7 @@ Represents the content of the file or the content and the extension name.
4657

4758
`Const` **version**: string = process.env.VERSION
4859

49-
*Defined in [index.ts:343](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/f3c303d/src/index.ts#L343)*
60+
*Defined in [index.ts:372](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/6e3ae22/src/index.ts#L372)*
5061

5162
the version of the library (process.env.VERSION is set by webpack, at compile-time)
5263

@@ -56,7 +67,7 @@ the version of the library (process.env.VERSION is set by webpack, at compile-ti
5667

5768
**loadModule**(`path`: string, `options_?`: [Options](interfaces/options.md)): Promise<[Module](interfaces/module.md)\>
5869

59-
*Defined in [index.ts:819](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/f3c303d/src/index.ts#L819)*
70+
*Defined in [index.ts:865](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/6e3ae22/src/index.ts#L865)*
6071

6172
This is the main function.
6273
This function is intended to be used only to load the entry point of your application.
@@ -110,7 +121,7 @@ A Promise of the component
110121

111122
`Const` **defaultPathHandlers**: object
112123

113-
*Defined in [index.ts:766](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/f3c303d/src/index.ts#L766)*
124+
*Defined in [index.ts:812](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/6e3ae22/src/index.ts#L812)*
114125

115126
Default implementation of PathHandlers
116127

docs/api/interfaces/cache.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
**get**(`key`: string): Promise<string\>
2323

24-
*Defined in [index.ts:67](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/f3c303d/src/index.ts#L67)*
24+
*Defined in [index.ts:68](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/6e3ae22/src/index.ts#L68)*
2525

2626
#### Parameters:
2727

@@ -37,7 +37,7 @@ ___
3737

3838
**set**(`key`: string, `value`: string): Promise<void\>
3939

40-
*Defined in [index.ts:68](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/f3c303d/src/index.ts#L68)*
40+
*Defined in [index.ts:69](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/6e3ae22/src/index.ts#L69)*
4141

4242
#### Parameters:
4343

docs/api/interfaces/modulehandler.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ see [additionalModuleHandlers](options.md#additionalmodulehandlers)
1515

1616
▸ (`source`: string, `path`: string, `options`: [Options](options.md)): Promise<[Module](module.md)\>
1717

18-
*Defined in [index.ts:326](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/f3c303d/src/index.ts#L326)*
18+
*Defined in [index.ts:355](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/6e3ae22/src/index.ts#L355)*
1919

2020
Used by the library when it does not know how to handle a given file type (eg. `.json` files).
2121
see [additionalModuleHandlers](options.md#additionalmodulehandlers)

docs/api/interfaces/options.md

Lines changed: 48 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
### Methods
2323

2424
* [addStyle](options.md#addstyle)
25+
* [customBlockHandler](options.md#customblockhandler)
2526
* [getFile](options.md#getfile)
2627
* [loadModule](options.md#loadmodule)
2728
* [log](options.md#log)
@@ -32,7 +33,7 @@
3233

3334
`Optional` **additionalBabelPlugins**: any[]
3435

35-
*Defined in [index.ts:202](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/f3c303d/src/index.ts#L202)*
36+
*Defined in [index.ts:209](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/6e3ae22/src/index.ts#L209)*
3637

3738
Additional babel plugins. [TBD]
3839

@@ -47,7 +48,7 @@ ___
4748

4849
`Optional` **additionalModuleHandlers**: Record<string, [ModuleHandler](modulehandler.md)\>
4950

50-
*Defined in [index.ts:209](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/f3c303d/src/index.ts#L209)*
51+
*Defined in [index.ts:216](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/6e3ae22/src/index.ts#L216)*
5152

5253
Additional module type handlers. see [ModuleHandler](modulehandler.md)
5354

@@ -57,7 +58,7 @@ ___
5758

5859
`Optional` **compiledCache**: [Cache](cache.md)
5960

60-
*Defined in [index.ts:249](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/f3c303d/src/index.ts#L249)*
61+
*Defined in [index.ts:256](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/6e3ae22/src/index.ts#L256)*
6162

6263
[get](cache.md#get)() and [set](cache.md#set)() functions of this object are called when the lib needs to save or load already compiled code. get and set functions must return a `Promise` (or can be `async`).
6364
Since compilation consume a lot of CPU, is is always a good idea to provide this object.
@@ -101,7 +102,7 @@ ___
101102

102103
`Optional` **delimiters**: SFCTemplateCompileOptions[\"compilerOptions\"][\"delimiters\"]
103104

104-
*Defined in [index.ts:191](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/f3c303d/src/index.ts#L191)*
105+
*Defined in [index.ts:198](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/6e3ae22/src/index.ts#L198)*
105106

106107
Sets the delimiters used for text interpolation within the template.
107108
Typically this is used to avoid conflicting with server-side frameworks that also use mustache syntax.
@@ -145,7 +146,7 @@ ___
145146

146147
`Optional` **moduleCache**: Record<string, [Module](module.md)\>
147148

148-
*Defined in [index.ts:108](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/f3c303d/src/index.ts#L108)*
149+
*Defined in [index.ts:115](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/6e3ae22/src/index.ts#L115)*
149150

150151
Initial cache that will contain resolved dependencies. All new modules go here.
151152
`vue` must initially be contained in this object.
@@ -169,7 +170,7 @@ ___
169170

170171
**pathHandlers**: [PathHandlers](pathhandlers.md)
171172

172-
*Defined in [index.ts:295](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/f3c303d/src/index.ts#L295)*
173+
*Defined in [index.ts:302](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/6e3ae22/src/index.ts#L302)*
173174

174175
Abstact path handling
175176

@@ -179,7 +180,7 @@ Abstact path handling
179180

180181
**addStyle**(`style`: string, `scopeId`: string): void
181182

182-
*Defined in [index.ts:151](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/f3c303d/src/index.ts#L151)*
183+
*Defined in [index.ts:158](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/6e3ae22/src/index.ts#L158)*
183184

184185
Called by the library when CSS style must be added in the HTML document.
185186

@@ -207,11 +208,48 @@ Name | Type | Description |
207208

208209
___
209210

211+
### customBlockHandler
212+
213+
**customBlockHandler**(`block`: SFCBlock, `filename`: string, `options`: [Options](options.md)): Promise<[CustomBlockCallback](../README.md#customblockcallback) \| undefined\>
214+
215+
*Defined in [index.ts:324](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/6e3ae22/src/index.ts#L324)*
216+
217+
Called for each custom block.
218+
219+
#### Parameters:
220+
221+
Name | Type |
222+
------ | ------ |
223+
`block` | SFCBlock |
224+
`filename` | string |
225+
`options` | [Options](options.md) |
226+
227+
**Returns:** Promise<[CustomBlockCallback](../README.md#customblockcallback) \| undefined\>
228+
229+
A Promise of the module or undefined
230+
231+
```javascript
232+
...
233+
customBlockHandler(block, filename, options) {
234+
235+
if ( block.type !== 'i18n' )
236+
return;
237+
238+
return (component) => {
239+
240+
component.i18n = JSON.parse(block.content);
241+
}
242+
}
243+
...
244+
```
245+
246+
___
247+
210248
### getFile
211249

212250
**getFile**(`path`: string): Promise<[File](../README.md#file)\>
213251

214-
*Defined in [index.ts:129](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/f3c303d/src/index.ts#L129)*
252+
*Defined in [index.ts:136](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/6e3ae22/src/index.ts#L136)*
215253

216254
Called by the library when it needs a file.
217255

@@ -244,7 +282,7 @@ ___
244282

245283
`Optional`**loadModule**(`path`: string, `options`: [Options](options.md)): Promise<[Module](module.md) \| undefined\>
246284

247-
*Defined in [index.ts:288](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/f3c303d/src/index.ts#L288)*
285+
*Defined in [index.ts:295](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/6e3ae22/src/index.ts#L295)*
248286

249287
Called when the lib requires a module. Do return `undefined` to let the library handle this.
250288

@@ -277,7 +315,7 @@ ___
277315

278316
`Optional`**log**(`type`: string, ...`data`: any[]): void
279317

280-
*Defined in [index.ts:267](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/f3c303d/src/index.ts#L267)*
318+
*Defined in [index.ts:274](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/6e3ae22/src/index.ts#L274)*
281319

282320
Called by the library when there is somthing to log (eg. scripts compilation errors, template compilation errors, template compilation tips, style compilation errors, ...)
283321

docs/api/interfaces/pathhandlers.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
**extname**(`filepath`: string): string
2323

24-
*Defined in [index.ts:73](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/f3c303d/src/index.ts#L73)*
24+
*Defined in [index.ts:74](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/6e3ae22/src/index.ts#L74)*
2525

2626
#### Parameters:
2727

@@ -37,7 +37,7 @@ ___
3737

3838
**resolve**(`absoluteFilepath`: string, `dependencyPath`: string): string
3939

40-
*Defined in [index.ts:77](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/f3c303d/src/index.ts#L77)*
40+
*Defined in [index.ts:78](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/6e3ae22/src/index.ts#L78)*
4141

4242
#### Parameters:
4343

0 commit comments

Comments
 (0)