Skip to content

Commit 6591f22

Browse files
author
Franck Freiburger
committed
chore(docs): v0.9.4 API docs & examples
1 parent 4e48c3e commit 6591f22

File tree

2 files changed

+85
-84
lines changed

2 files changed

+85
-84
lines changed

docs/api/README.md

Lines changed: 47 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@
3434
* [buildTemplateProcessor](README.md#buildtemplateprocessor)
3535
* [createSFCModule](README.md#createsfcmodule)
3636
* [defaultGetResource](README.md#defaultgetresource)
37-
* [defaultHandleModule](README.md#defaulthandlemodule)
3837
* [defaultPathResolve](README.md#defaultpathresolve)
38+
* [handleModuleInternal](README.md#handlemoduleinternal)
3939
* [loadModule](README.md#loadmodule)
4040
* [loadModuleInternal](README.md#loadmoduleinternal)
4141

@@ -49,7 +49,7 @@
4949

5050
Ƭ **AbstractPath**: { toString: () => string }
5151

52-
*Defined in [types.ts:32](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/6b952ea/src/types.ts#L32)*
52+
*Defined in [types.ts:32](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/4e48c3e/src/types.ts#L32)*
5353

5454
An abstract way to specify a path. It could be a simple string or a object like an URL. An AbstractPath must always be convertible to a string.
5555

@@ -65,7 +65,7 @@ ___
6565

6666
Ƭ **Cache**: { get: (key: string) => Promise<string \| undefined\> ; set: (key: string, value: string) => Promise<void\> }
6767

68-
*Defined in [types.ts:20](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/6b952ea/src/types.ts#L20)*
68+
*Defined in [types.ts:20](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/4e48c3e/src/types.ts#L20)*
6969

7070
#### Type declaration:
7171

@@ -80,15 +80,15 @@ ___
8080

8181
Ƭ **ContentData**: string \| ArrayBuffer
8282

83-
*Defined in [types.ts:71](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/6b952ea/src/types.ts#L71)*
83+
*Defined in [types.ts:71](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/4e48c3e/src/types.ts#L71)*
8484

8585
___
8686

8787
### CustomBlock
8888

8989
Ƭ **CustomBlock**: { attrs: Record<string, string \| true\> ; content: string ; type: string }
9090

91-
*Defined in [types.ts:109](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/6b952ea/src/types.ts#L109)*
91+
*Defined in [types.ts:109](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/4e48c3e/src/types.ts#L109)*
9292

9393
A custom block
9494

@@ -106,7 +106,7 @@ ___
106106

107107
Ƭ **CustomBlockCallback**: (component: [ModuleExport](README.md#moduleexport)) => void
108108

109-
*Defined in [types.ts:103](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/6b952ea/src/types.ts#L103)*
109+
*Defined in [types.ts:103](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/4e48c3e/src/types.ts#L103)*
110110

111111
CustomBlockCallback function type
112112

@@ -116,7 +116,7 @@ ___
116116

117117
Ƭ **File**: { getContentData: (asBinary: Boolean) => Promise<[ContentData](README.md#contentdata)\> ; type: string }
118118

119-
*Defined in [types.ts:77](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/6b952ea/src/types.ts#L77)*
119+
*Defined in [types.ts:77](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/4e48c3e/src/types.ts#L77)*
120120

121121
Represents a file content and the extension name.
122122

@@ -133,15 +133,15 @@ ___
133133

134134
Ƭ **LangProcessor**: (source: string, preprocessOptions?: any) => Promise<string\> \| string
135135

136-
*Defined in [types.ts:429](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/6b952ea/src/types.ts#L429)*
136+
*Defined in [types.ts:439](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/4e48c3e/src/types.ts#L439)*
137137

138138
___
139139

140140
### Module
141141

142142
Ƭ **Module**: { exports: [ModuleExport](README.md#moduleexport) }
143143

144-
*Defined in [types.ts:128](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/6b952ea/src/types.ts#L128)*
144+
*Defined in [types.ts:128](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/4e48c3e/src/types.ts#L128)*
145145

146146
This just represents a loaded js module
147147

@@ -157,15 +157,15 @@ ___
157157

158158
Ƭ **ModuleCacheId**: string
159159

160-
*Defined in [types.ts:26](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/6b952ea/src/types.ts#L26)*
160+
*Defined in [types.ts:26](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/4e48c3e/src/types.ts#L26)*
161161

162162
___
163163

164164
### ModuleExport
165165

166166
Ƭ **ModuleExport**: {} \| null
167167

168-
*Defined in [types.ts:123](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/6b952ea/src/types.ts#L123)*
168+
*Defined in [types.ts:123](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/4e48c3e/src/types.ts#L123)*
169169

170170
This just represents a loaded js module exports
171171

@@ -175,7 +175,7 @@ ___
175175

176176
Ƭ **ModuleHandler**: (type: string, getContentData: File[\"getContentData\"], path: [AbstractPath](README.md#abstractpath), options: [Options](README.md#options)) => Promise<[ModuleExport](README.md#moduleexport) \| null\>
177177

178-
*Defined in [types.ts:68](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/6b952ea/src/types.ts#L68)*
178+
*Defined in [types.ts:68](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/4e48c3e/src/types.ts#L68)*
179179

180180
Used by the library when it needs to handle a does not know how to handle a given file type (eg. `.json` files).
181181

@@ -198,9 +198,9 @@ ___
198198

199199
### Options
200200

201-
Ƭ **Options**: { additionalBabelParserPlugins?: babel\_ParserPlugin[] ; additionalBabelPlugins?: Record<string, any\> ; compiledCache?: [Cache](README.md#cache) ; delimiters?: [string, string] ; devMode?: boolean ; handleModule?: [ModuleHandler](README.md#modulehandler) ; isCustomElement: (tag: string) => boolean \| undefined ; moduleCache: Record<[ModuleCacheId](README.md#modulecacheid), LoadingType<[ModuleExport](README.md#moduleexport)\> \| [ModuleExport](README.md#moduleexport)\> ; pathResolve: [PathResolve](README.md#pathresolve) ; whitespace?: \"preserve\" \| \"condense\" ; addStyle: (style: string, scopeId: string \| undefined) => void ; createCJSModule: (refPath: [AbstractPath](README.md#abstractpath), source: string, options: [Options](README.md#options)) => [Module](README.md#module) ; customBlockHandler?: (block: [CustomBlock](README.md#customblock), filename: [AbstractPath](README.md#abstractpath), options: [Options](README.md#options)) => Promise<[CustomBlockCallback](README.md#customblockcallback) \| undefined\> ; getFile: (path: [AbstractPath](README.md#abstractpath)) => Promise<[File](README.md#file) \| [ContentData](README.md#contentdata)\> ; getResource: (pathCx: [PathContext](README.md#pathcontext), options: [Options](README.md#options)) => [Resource](README.md#resource) ; loadModule?: (path: [AbstractPath](README.md#abstractpath), options: [Options](README.md#options)) => Promise<[ModuleExport](README.md#moduleexport) \| undefined\> ; log?: (type: string, ...data: any[]) => void }
201+
Ƭ **Options**: { additionalBabelParserPlugins?: babel\_ParserPlugin[] ; additionalBabelPlugins?: Record<string, any\> ; compiledCache?: [Cache](README.md#cache) ; delimiters?: [string, string] ; devMode?: boolean ; handleModule?: [ModuleHandler](README.md#modulehandler) ; isCustomElement: (tag: string) => boolean \| undefined ; moduleCache: Record<[ModuleCacheId](README.md#modulecacheid), LoadingType<[ModuleExport](README.md#moduleexport)\> \| [ModuleExport](README.md#moduleexport)\> ; pathResolve: [PathResolve](README.md#pathresolve) ; whitespace?: \"preserve\" \| \"condense\" ; addStyle: (style: string, scopeId: string \| undefined) => void ; createCJSModule: (refPath: [AbstractPath](README.md#abstractpath), source: string, options: [Options](README.md#options)) => [Module](README.md#module) ; customBlockHandler?: (block: [CustomBlock](README.md#customblock), filename: [AbstractPath](README.md#abstractpath), options: [Options](README.md#options)) => Promise<[CustomBlockCallback](README.md#customblockcallback) \| undefined\> ; getFile: (path: [AbstractPath](README.md#abstractpath)) => Promise<[File](README.md#file) \| [ContentData](README.md#contentdata)\> ; getResource: (pathCx: [PathContext](README.md#pathcontext), options: [Options](README.md#options)) => [Resource](README.md#resource) ; loadModule?: (path: [AbstractPath](README.md#abstractpath), options: [Options](README.md#options)) => Promise<[ModuleExport](README.md#moduleexport) \| undefined\> ; log?: (type: string, ...data: any[]) => void ; processStyles: (srcRaw: string, lang: string \| undefined, filename: [AbstractPath](README.md#abstractpath), options: [Options](README.md#options)) => Promise<string\> }
202202

203-
*Defined in [types.ts:139](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/6b952ea/src/types.ts#L139)*
203+
*Defined in [types.ts:139](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/4e48c3e/src/types.ts#L139)*
204204

205205
#### Type declaration:
206206

@@ -214,7 +214,7 @@ Name | Type | Description |
214214
`handleModule?` | [ModuleHandler](README.md#modulehandler) | Handle additional module types (eg. '.svg', '.json' ). see [ModuleHandler](README.md#modulehandler) |
215215
`isCustomElement` | (tag: string) => boolean \| undefined | Specifies a check method to recognize native custom elements. see. https://vuejs.org/api/application.html#app-config-compileroptions-iscustomelement note: this option has no effect on vue2 |
216216
`moduleCache` | Record<[ModuleCacheId](README.md#modulecacheid), LoadingType<[ModuleExport](README.md#moduleexport)\> \| [ModuleExport](README.md#moduleexport)\> | Initial cache that will contain resolved dependencies. All new modules go here. `vue` must initially be contained in this object. [moduleCache](README.md#modulecache) is mandatory and should be shared between options objects used for you application (note that you can also pass the same options object through multiple loadModule calls) It is recommended to provide a prototype-less object (`Object.create(null)`) to avoid potential conflict with `Object` properties (constructor, __proto__, hasOwnProperty, ...). ​ * The library take the ownership of [moduleCache](README.md#modulecache) when [loadModule](README.md#loadmodule) is called. See also [[options.loadModule]]. **example:** ```javascript ... moduleCache: Object.assign(Object.create(null), { vue: Vue, }), ... ``` |
217-
`pathResolve` | [PathResolve](README.md#pathresolve) | Abstact path handling |
217+
`pathResolve` | [PathResolve](README.md#pathresolve) | Abstact path handling *(optional)* |
218218
`whitespace?` | \"preserve\" \| \"condense\" | Whitespace handling strategy see https://github.com/vuejs/vue/tree/dev/packages/vue-template-compiler#options |
219219
`addStyle` | (style: string, scopeId: string \| undefined) => void | - |
220220
`createCJSModule` | (refPath: [AbstractPath](README.md#abstractpath), source: string, options: [Options](README.md#options)) => [Module](README.md#module) | - |
@@ -223,14 +223,15 @@ Name | Type | Description |
223223
`getResource` | (pathCx: [PathContext](README.md#pathcontext), options: [Options](README.md#options)) => [Resource](README.md#resource) | - |
224224
`loadModule?` | (path: [AbstractPath](README.md#abstractpath), options: [Options](README.md#options)) => Promise<[ModuleExport](README.md#moduleexport) \| undefined\> | - |
225225
`log?` | (type: string, ...data: any[]) => void | - |
226+
`processStyles` | (srcRaw: string, lang: string \| undefined, filename: [AbstractPath](README.md#abstractpath), options: [Options](README.md#options)) => Promise<string\> | - |
226227

227228
___
228229

229230
### PathContext
230231

231232
Ƭ **PathContext**: { refPath: [AbstractPath](README.md#abstractpath) \| undefined ; relPath: [AbstractPath](README.md#abstractpath) }
232233

233-
*Defined in [types.ts:41](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/6b952ea/src/types.ts#L41)*
234+
*Defined in [types.ts:41](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/4e48c3e/src/types.ts#L41)*
234235

235236
A PathContext represents a path (relPath) relative to an abolute path (refPath)
236237
Note that relPath is not necessary relative, but when it is, relPath is relative to refPath.
@@ -248,7 +249,7 @@ ___
248249

249250
Ƭ **PathResolve**: (pathCx: [PathContext](README.md#pathcontext)) => [AbstractPath](README.md#abstractpath)
250251

251-
*Defined in [types.ts:50](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/6b952ea/src/types.ts#L50)*
252+
*Defined in [types.ts:50](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/4e48c3e/src/types.ts#L50)*
252253

253254
relative to absolute module path resolution
254255

@@ -258,7 +259,7 @@ ___
258259

259260
Ƭ **Resource**: { getContent: () => Promise<[File](README.md#file)\> ; id: [ModuleCacheId](README.md#modulecacheid) ; path: [AbstractPath](README.md#abstractpath) }
260261

261-
*Defined in [types.ts:88](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/6b952ea/src/types.ts#L88)*
262+
*Defined in [types.ts:88](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/4e48c3e/src/types.ts#L88)*
262263

263264
Represents a resource.
264265

@@ -276,9 +277,9 @@ Name | Type | Description |
276277

277278
`Const` **version**: string = process.env.VERSION as string
278279

279-
*Defined in [tools.ts:49](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/6b952ea/src/tools.ts#L49)*
280+
*Defined in [tools.ts:49](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/4e48c3e/src/tools.ts#L49)*
280281

281-
*Defined in [index.ts:26](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/6b952ea/src/index.ts#L26)*
282+
*Defined in [index.ts:26](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/4e48c3e/src/index.ts#L26)*
282283

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

@@ -288,7 +289,7 @@ ___
288289

289290
`Const` **vueVersion**: string = process.env.VUE\_VERSION as string
290291

291-
*Defined in [index.ts:32](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/6b952ea/src/index.ts#L32)*
292+
*Defined in [index.ts:32](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/4e48c3e/src/index.ts#L32)*
292293

293294
the version of Vue that is expected by the library
294295

@@ -298,7 +299,7 @@ the version of Vue that is expected by the library
298299

299300
**buildTemplateProcessor**(`processor`: [LangProcessor](README.md#langprocessor)): object
300301

301-
*Defined in [index.ts:194](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/6b952ea/src/index.ts#L194)*
302+
*Defined in [index.ts:194](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/4e48c3e/src/index.ts#L194)*
302303

303304
Convert a function to template processor interface (consolidate)
304305

@@ -320,7 +321,7 @@ ___
320321

321322
**createSFCModule**(`source`: string, `filename`: [AbstractPath](README.md#abstractpath), `options`: [Options](README.md#options)): Promise<[ModuleExport](README.md#moduleexport)\>
322323

323-
*Defined in [createSFCModule.ts:3](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/6b952ea/src/createSFCModule.ts#L3)*
324+
*Defined in [createSFCModule.ts:3](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/4e48c3e/src/createSFCModule.ts#L3)*
324325

325326
#### Parameters:
326327

@@ -338,7 +339,7 @@ ___
338339

339340
**defaultGetResource**(`pathCx`: [PathContext](README.md#pathcontext), `options`: [Options](README.md#options)): [Resource](README.md#resource)
340341

341-
*Defined in [index.ts:74](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/6b952ea/src/index.ts#L74)*
342+
*Defined in [index.ts:74](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/4e48c3e/src/index.ts#L74)*
342343

343344
Default getResource implementation
344345
by default, getContent() use the file extension as file type.
@@ -354,54 +355,54 @@ Name | Type |
354355

355356
___
356357

357-
### defaultHandleModule
358+
### defaultPathResolve
358359

359-
**defaultHandleModule**(`type`: string, `getContentData`: File[\"getContentData\"], `path`: [AbstractPath](README.md#abstractpath), `options`: [Options](README.md#options)): Promise<[ModuleExport](README.md#moduleexport) \| undefined\>
360+
`Const`**defaultPathResolve**(`__namedParameters`: { refPath: [AbstractPath](README.md#abstractpath) ; relPath: [AbstractPath](README.md#abstractpath) }): string \| [AbstractPath](README.md#abstractpath)
360361

361-
*Defined in [tools.ts:399](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/6b952ea/src/tools.ts#L399)*
362+
*Defined in [index.ts:51](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/4e48c3e/src/index.ts#L51)*
362363

363-
Default implementation of handleModule
364+
Default resolve implementation
365+
resolve() should handle 3 situations :
366+
- resolve a relative path ( eg. import './details.vue' )
367+
- resolve an absolute path ( eg. import '/components/card.vue' )
368+
- resolve a module name ( eg. import { format } from 'date-fns' )
364369

365370
#### Parameters:
366371

367372
Name | Type |
368373
------ | ------ |
369-
`type` | string |
370-
`getContentData` | File[\"getContentData\"] |
371-
`path` | [AbstractPath](README.md#abstractpath) |
372-
`options` | [Options](README.md#options) |
374+
`__namedParameters` | { refPath: [AbstractPath](README.md#abstractpath) ; relPath: [AbstractPath](README.md#abstractpath) } |
373375

374-
**Returns:** Promise<[ModuleExport](README.md#moduleexport) \| undefined\>
376+
**Returns:** string \| [AbstractPath](README.md#abstractpath)
375377

376378
___
377379

378-
### defaultPathResolve
380+
### handleModuleInternal
379381

380-
`Const`**defaultPathResolve**(`__namedParameters`: { refPath: [AbstractPath](README.md#abstractpath) ; relPath: [AbstractPath](README.md#abstractpath) }): string \| [AbstractPath](README.md#abstractpath)
382+
**handleModuleInternal**(`type`: string, `getContentData`: File[\"getContentData\"], `path`: [AbstractPath](README.md#abstractpath), `options`: [Options](README.md#options)): Promise<[ModuleExport](README.md#moduleexport) \| undefined\>
381383

382-
*Defined in [index.ts:51](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/6b952ea/src/index.ts#L51)*
384+
*Defined in [tools.ts:399](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/4e48c3e/src/tools.ts#L399)*
383385

384-
Default resolve implementation
385-
resolve() should handle 3 situations :
386-
- resolve a relative path ( eg. import './details.vue' )
387-
- resolve an absolute path ( eg. import '/components/card.vue' )
388-
- resolve a module name ( eg. import { format } from 'date-fns' )
386+
Default implementation of handleModule
389387

390388
#### Parameters:
391389

392390
Name | Type |
393391
------ | ------ |
394-
`__namedParameters` | { refPath: [AbstractPath](README.md#abstractpath) ; relPath: [AbstractPath](README.md#abstractpath) } |
392+
`type` | string |
393+
`getContentData` | File[\"getContentData\"] |
394+
`path` | [AbstractPath](README.md#abstractpath) |
395+
`options` | [Options](README.md#options) |
395396

396-
**Returns:** string \| [AbstractPath](README.md#abstractpath)
397+
**Returns:** Promise<[ModuleExport](README.md#moduleexport) \| undefined\>
397398

398399
___
399400

400401
### loadModule
401402

402403
**loadModule**(`path`: [AbstractPath](README.md#abstractpath), `options?`: [Options](README.md#options)): Promise<[ModuleExport](README.md#moduleexport)\>
403404

404-
*Defined in [index.ts:155](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/6b952ea/src/index.ts#L155)*
405+
*Defined in [index.ts:155](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/4e48c3e/src/index.ts#L155)*
405406

406407
This is the main function.
407408
This function is intended to be used only to load the entry point of your application.
@@ -455,7 +456,7 @@ ___
455456

456457
**loadModuleInternal**(`pathCx`: [PathContext](README.md#pathcontext), `options`: [Options](README.md#options)): Promise<[ModuleExport](README.md#moduleexport)\>
457458

458-
*Defined in [tools.ts:276](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/6b952ea/src/tools.ts#L276)*
459+
*Defined in [tools.ts:276](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/4e48c3e/src/tools.ts#L276)*
459460

460461
#### Parameters:
461462

@@ -472,6 +473,6 @@ Name | Type |
472473

473474
`Const` **targetBrowserBabelPlugins**: object
474475

475-
*Defined in [tools.ts:211](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/6b952ea/src/tools.ts#L211)*
476+
*Defined in [tools.ts:211](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/4e48c3e/src/tools.ts#L211)*
476477

477478
#### Properties:

0 commit comments

Comments
 (0)