Skip to content

Commit 2856b79

Browse files
chore(docs): v0.4.1 API docs & examples
1 parent e87df0d commit 2856b79

File tree

9 files changed

+162
-52
lines changed

9 files changed

+162
-52
lines changed

docs/api/README.md

Lines changed: 50 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
### Interfaces
1010

1111
* [Cache](interfaces/cache.md)
12+
* [CustomBlock](interfaces/customblock.md)
1213
* [Module](interfaces/module.md)
14+
* [ModuleExport](interfaces/moduleexport.md)
1315
* [ModuleHandler](interfaces/modulehandler.md)
1416
* [Options](interfaces/options.md)
1517
* [PathHandlers](interfaces/pathhandlers.md)
@@ -18,13 +20,16 @@
1820

1921
* [CustomBlockCallback](README.md#customblockcallback)
2022
* [File](README.md#file)
23+
* [LoadModule](README.md#loadmodule)
2124

2225
### Variables
2326

2427
* [version](README.md#version)
28+
* [vueVersion](README.md#vueversion)
2529

2630
### Functions
2731

32+
* [createSFCModule](README.md#createsfcmodule)
2833
* [loadModule](README.md#loadmodule)
2934

3035
### Object literals
@@ -35,9 +40,9 @@
3540

3641
### CustomBlockCallback
3742

38-
Ƭ **CustomBlockCallback**: (component: [Module](interfaces/module.md)) => undefined
43+
Ƭ **CustomBlockCallback**: (component: [ModuleExport](interfaces/moduleexport.md)) => void
3944

40-
*Defined in [index.ts:91](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/6e3ae22/src/index.ts#L91)*
45+
*Defined in [types.ts:66](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/e87df0d/src/types.ts#L66)*
4146

4247
CustomBlockCallback function type
4348

@@ -47,27 +52,64 @@ ___
4752

4853
Ƭ **File**: string \| { content: string ; extname: string }
4954

50-
*Defined in [index.ts:85](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/6e3ae22/src/index.ts#L85)*
55+
*Defined in [types.ts:60](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/e87df0d/src/types.ts#L60)*
5156

5257
Represents the content of the file or the content and the extension name.
5358

59+
___
60+
61+
### LoadModule
62+
63+
Ƭ **LoadModule**: (path: string, options: [Options](interfaces/options.md)) => Promise<[ModuleExport](interfaces/moduleexport.md)\>
64+
65+
*Defined in [types.ts:332](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/e87df0d/src/types.ts#L332)*
66+
5467
## Variables
5568

5669
### version
5770

5871
`Const` **version**: string = process.env.VERSION
5972

60-
*Defined in [index.ts:372](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/6e3ae22/src/index.ts#L372)*
73+
*Defined in [tools.ts:39](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/e87df0d/src/tools.ts#L39)*
74+
75+
*Defined in [index.ts:11](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/e87df0d/src/index.ts#L11)*
6176

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

79+
___
80+
81+
### vueVersion
82+
83+
`Const` **vueVersion**: string
84+
85+
*Defined in [createSFCModule.ts:4](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/e87df0d/src/createSFCModule.ts#L4)*
86+
6487
## Functions
6588

89+
### createSFCModule
90+
91+
**createSFCModule**(`source`: string, `filename`: string, `options`: [Options](interfaces/options.md), `loadModule`: [LoadModule](README.md#loadmodule)): Promise<[ModuleExport](interfaces/moduleexport.md)\>
92+
93+
*Defined in [createSFCModule.ts:3](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/e87df0d/src/createSFCModule.ts#L3)*
94+
95+
#### Parameters:
96+
97+
Name | Type |
98+
------ | ------ |
99+
`source` | string |
100+
`filename` | string |
101+
`options` | [Options](interfaces/options.md) |
102+
`loadModule` | [LoadModule](README.md#loadmodule) |
103+
104+
**Returns:** Promise<[ModuleExport](interfaces/moduleexport.md)\>
105+
106+
___
107+
66108
### loadModule
67109

68-
**loadModule**(`path`: string, `options_?`: [Options](interfaces/options.md)): Promise<[Module](interfaces/module.md)\>
110+
**loadModule**(`path`: string, `options_?`: [Options](interfaces/options.md)): Promise<[ModuleExport](interfaces/moduleexport.md)\>
69111

70-
*Defined in [index.ts:865](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/6e3ae22/src/index.ts#L865)*
112+
*Defined in [index.ts:109](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/e87df0d/src/index.ts#L109)*
71113

72114
This is the main function.
73115
This function is intended to be used only to load the entry point of your application.
@@ -80,7 +122,7 @@ Name | Type | Default value | Description |
80122
`path` | string | - | The path of the `.vue` file. If path is not a path (eg. an string ID), your [getFile](interfaces/options.md#getfile) function must return a [File](README.md#file) object. |
81123
`options_` | [Options](interfaces/options.md) | throwNotDefined('options') | - |
82124

83-
**Returns:** Promise<[Module](interfaces/module.md)\>
125+
**Returns:** Promise<[ModuleExport](interfaces/moduleexport.md)\>
84126

85127
A Promise of the component
86128

@@ -121,7 +163,7 @@ A Promise of the component
121163

122164
`Const` **defaultPathHandlers**: object
123165

124-
*Defined in [index.ts:812](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/6e3ae22/src/index.ts#L812)*
166+
*Defined in [index.ts:56](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/e87df0d/src/index.ts#L56)*
125167

126168
Default implementation of PathHandlers
127169

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:68](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/6e3ae22/src/index.ts#L68)*
24+
*Defined in [types.ts:19](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/e87df0d/src/types.ts#L19)*
2525

2626
#### Parameters:
2727

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

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

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

4242
#### Parameters:
4343

docs/api/interfaces/customblock.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
**[vue3-sfc-loader](../README.md)**
2+
3+
> [Globals](../README.md) / CustomBlock
4+
5+
# Interface: CustomBlock
6+
7+
A custom block
8+
9+
## Hierarchy
10+
11+
* **CustomBlock**
12+
13+
## Index
14+
15+
### Properties
16+
17+
* [attrs](customblock.md#attrs)
18+
* [content](customblock.md#content)
19+
* [type](customblock.md#type)
20+
21+
## Properties
22+
23+
### attrs
24+
25+
**attrs**: Record<string, string \| true\>
26+
27+
*Defined in [types.ts:75](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/e87df0d/src/types.ts#L75)*
28+
29+
___
30+
31+
### content
32+
33+
**content**: string
34+
35+
*Defined in [types.ts:74](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/e87df0d/src/types.ts#L74)*
36+
37+
___
38+
39+
### type
40+
41+
**type**: string
42+
43+
*Defined in [types.ts:73](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/e87df0d/src/types.ts#L73)*

docs/api/interfaces/module.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,17 @@ This just represents a loaded js module
99
## Hierarchy
1010

1111
* **Module**
12+
13+
## Index
14+
15+
### Properties
16+
17+
* [exports](module.md#exports)
18+
19+
## Properties
20+
21+
### exports
22+
23+
**exports**: [ModuleExport](moduleexport.md)
24+
25+
*Defined in [types.ts:93](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/e87df0d/src/types.ts#L93)*

docs/api/interfaces/moduleexport.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
**[vue3-sfc-loader](../README.md)**
2+
3+
> [Globals](../README.md) / ModuleExport
4+
5+
# Interface: ModuleExport
6+
7+
This just represents a loaded js module exports
8+
9+
## Hierarchy
10+
11+
* **ModuleExport**

docs/api/interfaces/modulehandler.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ see [additionalModuleHandlers](options.md#additionalmodulehandlers)
1313

1414
## Callable
1515

16-
▸ (`source`: string, `path`: string, `options`: [Options](options.md)): Promise<[Module](module.md)\>
16+
▸ (`source`: string, `path`: string, `options`: [Options](options.md)): Promise<[ModuleExport](moduleexport.md)\>
1717

18-
*Defined in [index.ts:355](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/6e3ae22/src/index.ts#L355)*
18+
*Defined in [types.ts:52](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/e87df0d/src/types.ts#L52)*
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)
@@ -28,4 +28,4 @@ Name | Type | Description |
2828
`path` | string | The path of the file |
2929
`options` | [Options](options.md) | The options **example:** ```javascript ... additionalModuleHandlers: { '.json': (source, path, options) => JSON.parse(source), } ... ``` |
3030

31-
**Returns:** Promise<[Module](module.md)\>
31+
**Returns:** Promise<[ModuleExport](moduleexport.md)\>

docs/api/interfaces/options.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434
`Optional` **additionalBabelPlugins**: any[]
3535

36-
*Defined in [index.ts:209](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/6e3ae22/src/index.ts#L209)*
36+
*Defined in [types.ts:212](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/e87df0d/src/types.ts#L212)*
3737

3838
Additional babel plugins. [TBD]
3939

@@ -48,7 +48,7 @@ ___
4848

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

51-
*Defined in [index.ts:216](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/6e3ae22/src/index.ts#L216)*
51+
*Defined in [types.ts:219](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/e87df0d/src/types.ts#L219)*
5252

5353
Additional module type handlers. see [ModuleHandler](modulehandler.md)
5454

@@ -58,7 +58,7 @@ ___
5858

5959
`Optional` **compiledCache**: [Cache](cache.md)
6060

61-
*Defined in [index.ts:256](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/6e3ae22/src/index.ts#L256)*
61+
*Defined in [types.ts:259](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/e87df0d/src/types.ts#L259)*
6262

6363
[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`).
6464
Since compilation consume a lot of CPU, is is always a good idea to provide this object.
@@ -100,9 +100,9 @@ ___
100100

101101
### delimiters
102102

103-
`Optional` **delimiters**: SFCTemplateCompileOptions[\"compilerOptions\"][\"delimiters\"]
103+
`Optional` **delimiters**: [string, string]
104104

105-
*Defined in [index.ts:198](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/6e3ae22/src/index.ts#L198)*
105+
*Defined in [types.ts:201](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/e87df0d/src/types.ts#L201)*
106106

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

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

149-
*Defined in [index.ts:115](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/6e3ae22/src/index.ts#L115)*
149+
*Defined in [types.ts:118](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/e87df0d/src/types.ts#L118)*
150150

151151
Initial cache that will contain resolved dependencies. All new modules go here.
152152
`vue` must initially be contained in this object.
@@ -170,17 +170,17 @@ ___
170170

171171
**pathHandlers**: [PathHandlers](pathhandlers.md)
172172

173-
*Defined in [index.ts:302](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/6e3ae22/src/index.ts#L302)*
173+
*Defined in [types.ts:305](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/e87df0d/src/types.ts#L305)*
174174

175175
Abstact path handling
176176

177177
## Methods
178178

179179
### addStyle
180180

181-
**addStyle**(`style`: string, `scopeId`: string): void
181+
**addStyle**(`style`: string, `scopeId`: string \| undefined): void
182182

183-
*Defined in [index.ts:158](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/6e3ae22/src/index.ts#L158)*
183+
*Defined in [types.ts:161](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/e87df0d/src/types.ts#L161)*
184184

185185
Called by the library when CSS style must be added in the HTML document.
186186

@@ -189,7 +189,7 @@ Called by the library when CSS style must be added in the HTML document.
189189
Name | Type | Description |
190190
------ | ------ | ------ |
191191
`style` | string | The CSS style chunk |
192-
`scopeId` | string | The scope ID of the CSS style chunk |
192+
`scopeId` | string \| undefined | The scope ID of the CSS style chunk |
193193

194194
**Returns:** void
195195

@@ -210,17 +210,17 @@ ___
210210

211211
### customBlockHandler
212212

213-
**customBlockHandler**(`block`: SFCBlock, `filename`: string, `options`: [Options](options.md)): Promise<[CustomBlockCallback](../README.md#customblockcallback) \| undefined\>
213+
`Optional`**customBlockHandler**(`block`: [CustomBlock](customblock.md), `filename`: string, `options`: [Options](options.md)): Promise<[CustomBlockCallback](../README.md#customblockcallback) \| undefined\>
214214

215-
*Defined in [index.ts:324](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/6e3ae22/src/index.ts#L324)*
215+
*Defined in [types.ts:327](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/e87df0d/src/types.ts#L327)*
216216

217217
Called for each custom block.
218218

219219
#### Parameters:
220220

221221
Name | Type |
222222
------ | ------ |
223-
`block` | SFCBlock |
223+
`block` | [CustomBlock](customblock.md) |
224224
`filename` | string |
225225
`options` | [Options](options.md) |
226226

@@ -249,7 +249,7 @@ ___
249249

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

252-
*Defined in [index.ts:136](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/6e3ae22/src/index.ts#L136)*
252+
*Defined in [types.ts:139](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/e87df0d/src/types.ts#L139)*
253253

254254
Called by the library when it needs a file.
255255

@@ -282,7 +282,7 @@ ___
282282

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

285-
*Defined in [index.ts:295](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/6e3ae22/src/index.ts#L295)*
285+
*Defined in [types.ts:298](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/e87df0d/src/types.ts#L298)*
286286

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

@@ -315,7 +315,7 @@ ___
315315

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

318-
*Defined in [index.ts:274](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/6e3ae22/src/index.ts#L274)*
318+
*Defined in [types.ts:277](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/e87df0d/src/types.ts#L277)*
319319

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

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:74](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/6e3ae22/src/index.ts#L74)*
24+
*Defined in [types.ts:25](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/e87df0d/src/types.ts#L25)*
2525

2626
#### Parameters:
2727

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

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

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

4242
#### Parameters:
4343

0 commit comments

Comments
 (0)