@docfy/ember 0.11.0 → 0.12.1
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.
- package/LICENSE.md +21 -0
- package/declarations/components/docfy-link.d.ts +20 -1
- package/declarations/components/docfy-link.d.ts.map +1 -1
- package/dist/components/docfy-demo.js +5 -6
- package/dist/components/docfy-demo.js.map +1 -1
- package/dist/components/docfy-link.js +47 -15
- package/dist/components/docfy-link.js.map +1 -1
- package/dist/components/docfy-output.js +0 -1
- package/dist/components/docfy-output.js.map +1 -1
- package/dist/components/docfy-previous-and-next-page.js +0 -1
- package/dist/components/docfy-previous-and-next-page.js.map +1 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/dist/routing.js +0 -1
- package/dist/routing.js.map +1 -1
- package/dist/services/docfy.js +0 -1
- package/dist/services/docfy.js.map +1 -1
- package/package.json +5 -4
- package/declarations/utils/nested.d.ts +0 -11
- package/declarations/utils/nested.d.ts.map +0 -1
- package/dist/output.d.ts +0 -2
- package/dist/output.d.ts.map +0 -1
- package/dist/output.js +0 -17
- package/dist/output.js.map +0 -1
package/LICENSE.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020 Josemar Luedke
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -12,9 +12,28 @@ interface DocfyLinkSignature {
|
|
|
12
12
|
default: [];
|
|
13
13
|
};
|
|
14
14
|
}
|
|
15
|
+
/**
|
|
16
|
+
* A link to a Docfy page.
|
|
17
|
+
*
|
|
18
|
+
* Docfy addresses pages by URL, and `@to` is already the router's path, so
|
|
19
|
+
* neither the href nor the active state needs the target route resolved.
|
|
20
|
+
*
|
|
21
|
+
* That matters under Embroider's `splitAtRoutes`: `RouterService#recognize()`
|
|
22
|
+
* resolves the matched route handlers, and resolving a route inside a split
|
|
23
|
+
* bundle makes `@embroider/router` fetch that bundle. Calling it from a getter
|
|
24
|
+
* meant that merely rendering a link downloaded the page it pointed at, so a
|
|
25
|
+
* page linking to every section pulled the whole documentation site up front.
|
|
26
|
+
* Recognition now happens in `navigate`, where the bundle is about to be needed
|
|
27
|
+
* anyway.
|
|
28
|
+
*/
|
|
15
29
|
export default class DocfyLink extends Component<DocfyLinkSignature> {
|
|
16
30
|
router: RouterService;
|
|
17
|
-
|
|
31
|
+
/**
|
|
32
|
+
* `@to` as the router would produce it. Docfy gives index pages a trailing
|
|
33
|
+
* slash (`/docs/getting-started/`) where `urlFor` did not, so it is dropped
|
|
34
|
+
* here to keep the rendered href unchanged.
|
|
35
|
+
*/
|
|
36
|
+
get path(): string;
|
|
18
37
|
get href(): string;
|
|
19
38
|
get isActive(): boolean;
|
|
20
39
|
navigate(event: MouseEvent): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"docfy-link.d.ts","sourceRoot":"","sources":["../../src/components/docfy-link.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,oBAAoB,CAAC;AAI3C,OAAO,KAAK,aAAa,MAAM,+BAA+B,CAAC;AAE/D,UAAU,aAAa;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,UAAU,kBAAkB;IAC1B,IAAI,EAAE,aAAa,CAAC;IACpB,OAAO,EAAE,iBAAiB,CAAC;IAC3B,MAAM,EAAE;QACN,OAAO,EAAE,EAAE,CAAC;KACb,CAAC;CACH;
|
|
1
|
+
{"version":3,"file":"docfy-link.d.ts","sourceRoot":"","sources":["../../src/components/docfy-link.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,oBAAoB,CAAC;AAI3C,OAAO,KAAK,aAAa,MAAM,+BAA+B,CAAC;AAE/D,UAAU,aAAa;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,UAAU,kBAAkB;IAC1B,IAAI,EAAE,aAAa,CAAC;IACpB,OAAO,EAAE,iBAAiB,CAAC;IAC3B,MAAM,EAAE;QACN,OAAO,EAAE,EAAE,CAAC;KACb,CAAC;CACH;AASD;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,OAAO,OAAO,SAAU,SAAQ,SAAS,CAAC,kBAAkB,CAAC;IACvC,MAAM,EAAE,aAAa,CAAC;IAEjD;;;;OAIG;IACH,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,IAAI,IAAI,IAAI,MAAM,CASjB;IAED,IAAI,QAAQ,IAAI,OAAO,CAgBtB;IAGD,QAAQ,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI;CAmClC"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
import Component from '@glimmer/component';
|
|
3
2
|
import { tracked } from '@glimmer/tracking';
|
|
4
3
|
import { action } from '@ember/object';
|
|
@@ -21,14 +20,14 @@ const docfyEq = helper(function docfyEq(params) {
|
|
|
21
20
|
|
|
22
21
|
class DocfyDemoDescription extends Component {
|
|
23
22
|
static {
|
|
24
|
-
setComponentTemplate(precompileTemplate("
|
|
23
|
+
setComponentTemplate(precompileTemplate("<div class=\"docfy-demo__description\" data-test-id=\"demo-description\" ...attributes>\n <div class=\"docfy-demo__description__header\" data-test-id=\"demo-header\">\n {{#if @title}}\n <h3 class=\"docfy-demo__description__header__title\" data-test-id=\"demo-title\">\n <a href=\"#{{@id}}\">\n <span class=\"icon icon-link\"></span>\n </a>\n {{@title}}\n </h3>\n {{/if}}\n {{#if @editUrl}}\n <a href={{@editUrl}} target=\"_blank\" rel=\"noopener noreferrer\" class=\"docfy-demo__description__header__edit-url\" data-test-id=\"demo-edit-url\">\n Edit this demo\n </a>\n {{/if}}\n </div>\n\n <div class=\"docfy-demo__description__content\" data-test-id=\"demo-content\">\n {{yield}}\n </div>\n</div>", {
|
|
25
24
|
strictMode: true
|
|
26
25
|
}), this);
|
|
27
26
|
}
|
|
28
27
|
}
|
|
29
28
|
// Example subcomponent
|
|
30
29
|
|
|
31
|
-
const DocfyDemoExample = setComponentTemplate(precompileTemplate("
|
|
30
|
+
const DocfyDemoExample = setComponentTemplate(precompileTemplate("<div class=\"docfy-demo__example__container\" data-test-id=\"demo-example__container\" ...attributes>\n <div class=\"docfy-demo__example not-prose\" data-test-id=\"demo-example\" ...attributes>\n {{yield}}\n </div>\n</div>", {
|
|
32
31
|
strictMode: true
|
|
33
32
|
}), templateOnly());
|
|
34
33
|
// Snippet subcomponent
|
|
@@ -53,7 +52,7 @@ class DocfyDemoSnippet extends Component {
|
|
|
53
52
|
return this.id === this.args.active;
|
|
54
53
|
}
|
|
55
54
|
static {
|
|
56
|
-
setComponentTemplate(precompileTemplate("
|
|
55
|
+
setComponentTemplate(precompileTemplate("{{#if this.isActive}}\n <div class=\"docfy-demo__snippet\" data-test-id=\"demo-snippet\" data-test-snippet-name=\"{{@name}}\" ...attributes>\n {{yield}}\n </div>\n{{/if}}", {
|
|
57
56
|
strictMode: true
|
|
58
57
|
}), this);
|
|
59
58
|
}
|
|
@@ -89,7 +88,7 @@ class DocfyDemoSnippets extends Component {
|
|
|
89
88
|
n(this.prototype, "setActiveSnippet", [action]);
|
|
90
89
|
}
|
|
91
90
|
static {
|
|
92
|
-
setComponentTemplate(precompileTemplate("
|
|
91
|
+
setComponentTemplate(precompileTemplate("<div class=\"docfy-demo__snippets\" data-test-id=\"demo-snippets\">\n <div class=\"docfy-demo__snippets__tabs\" data-test-id=\"demo-tabs\">\n {{#each this.snippets as |snippet|}}\n <button type=\"button\" class=\"docfy-demo__snippets__tabs__button\n {{if (docfyEq this.active snippet.id) \"docfy-demo__snippets__tabs__button--active\"}}\" data-test-id=\"demo-tab-button\" data-test-snippet-name=\"{{snippet.name}}\" data-test-is-active=\"{{if (docfyEq this.active snippet.id) \"true\" \"false\"}}\" {{on \"click\" (fn this.setActiveSnippet snippet.id)}}>\n {{snippet.name}}\n </button>\n {{/each}}\n </div>\n\n {{yield (component DocfyDemoSnippet registerSnippet=this.registerSnippet active=this.active)}}\n</div>", {
|
|
93
92
|
strictMode: true,
|
|
94
93
|
scope: () => ({
|
|
95
94
|
docfyEq,
|
|
@@ -104,7 +103,7 @@ class DocfyDemoSnippets extends Component {
|
|
|
104
103
|
|
|
105
104
|
class DocfyDemo extends Component {
|
|
106
105
|
static {
|
|
107
|
-
setComponentTemplate(precompileTemplate("
|
|
106
|
+
setComponentTemplate(precompileTemplate("<div id={{@id}} class=\"docfy-demo\" data-test-id=\"docfy-demo\" data-test-demo-id=\"{{@id}}\" ...attributes>\n {{yield (hash Example=DocfyDemoExample Description=(component DocfyDemoDescription id=@id) Snippet=DocfyDemoSnippet Snippets=DocfyDemoSnippets)}}\n</div>", {
|
|
108
107
|
strictMode: true,
|
|
109
108
|
scope: () => ({
|
|
110
109
|
hash,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"docfy-demo.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"docfy-demo.js","sources":["../../src/components/docfy-demo.gts"],"sourcesContent":["import Component from '@glimmer/component';\nimport { tracked } from '@glimmer/tracking';\nimport { action } from '@ember/object';\nimport { guidFor } from '@ember/object/internals';\nimport { schedule } from '@ember/runloop';\nimport { helper } from '@ember/component/helper';\nimport { on } from '@ember/modifier';\nimport { fn } from '@ember/helper';\nimport { hash } from '@ember/helper';\nimport type Owner from '@ember/owner';\nimport type { TOC } from '@ember/component/template-only';\n\n// Helper function for equality comparison\nconst docfyEq = helper(function docfyEq(params: unknown[]): boolean {\n return params[0] === params[1];\n});\n\n// Shared type for snippet registration\ninterface SnippetRegisterArgs {\n id: string;\n name: string;\n}\n\n// Description subcomponent\ninterface DocfyDemoDescriptionArgs {\n id?: string;\n title?: string;\n editUrl?: string;\n}\n\ninterface DocfyDemoDescriptionSignature {\n Args: DocfyDemoDescriptionArgs;\n Element: HTMLDivElement;\n Blocks: {\n default: [];\n };\n}\n\nclass DocfyDemoDescription extends Component<DocfyDemoDescriptionSignature> {\n <template>\n <div\n class=\"docfy-demo__description\"\n data-test-id=\"demo-description\"\n ...attributes\n >\n <div class=\"docfy-demo__description__header\" data-test-id=\"demo-header\">\n {{#if @title}}\n <h3\n class=\"docfy-demo__description__header__title\"\n data-test-id=\"demo-title\"\n >\n <a href=\"#{{@id}}\">\n <span class=\"icon icon-link\"></span>\n </a>\n {{@title}}\n </h3>\n {{/if}}\n {{#if @editUrl}}\n <a\n href={{@editUrl}}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n class=\"docfy-demo__description__header__edit-url\"\n data-test-id=\"demo-edit-url\"\n >\n Edit this demo\n </a>\n {{/if}}\n </div>\n\n <div class=\"docfy-demo__description__content\" data-test-id=\"demo-content\">\n {{yield}}\n </div>\n </div>\n </template>\n}\n\n// Example subcomponent\ninterface DocfyDemoExampleSignature {\n Element: HTMLDivElement;\n Blocks: {\n default: [];\n };\n}\n\nconst DocfyDemoExample: TOC<DocfyDemoExampleSignature> = <template>\n <div\n class=\"docfy-demo__example__container\"\n data-test-id=\"demo-example__container\"\n ...attributes\n >\n <div\n class=\"docfy-demo__example not-prose\"\n data-test-id=\"demo-example\"\n ...attributes\n >\n {{yield}}\n </div>\n </div>\n</template>;\n\n// Snippet subcomponent\ninterface DocfyDemoSnippetArgs {\n name: string;\n active: string;\n registerSnippet: (snippet: SnippetRegisterArgs) => void;\n}\n\ninterface DocfyDemoSnippetSignature {\n Args: DocfyDemoSnippetArgs;\n Element: HTMLDivElement;\n Blocks: {\n default: [];\n };\n}\n\nclass DocfyDemoSnippet extends Component<DocfyDemoSnippetSignature> {\n id = guidFor(this);\n\n constructor(owner: Owner, args: DocfyDemoSnippetArgs) {\n super(owner, args);\n\n if (typeof this.args.registerSnippet === 'function') {\n let name = this.args.name || '';\n name = name.charAt(0).toUpperCase() + name.slice(1);\n\n this.args.registerSnippet({\n id: this.id,\n name,\n });\n }\n }\n\n get isActive(): boolean {\n if (typeof this.args.registerSnippet !== 'function') {\n return true;\n }\n\n return this.id === this.args.active;\n }\n\n <template>\n {{#if this.isActive}}\n <div\n class=\"docfy-demo__snippet\"\n data-test-id=\"demo-snippet\"\n data-test-snippet-name=\"{{@name}}\"\n ...attributes\n >\n {{yield}}\n </div>\n {{/if}}\n </template>\n}\n\n// Snippets subcomponent\ninterface DocfyDemoSnippetsSignature {\n Blocks: {\n default: [any];\n };\n}\n\nclass DocfyDemoSnippets extends Component<DocfyDemoSnippetsSignature> {\n @tracked snippets: SnippetRegisterArgs[] = [];\n @tracked active?: string;\n\n @action registerSnippet(snippet: SnippetRegisterArgs): void {\n schedule('render', this, () => {\n this.snippets = [...this.snippets, snippet];\n if (!this.active) {\n this.active = snippet.id;\n }\n });\n }\n\n @action setActiveSnippet(id: string): void {\n this.active = id;\n }\n\n <template>\n <div class=\"docfy-demo__snippets\" data-test-id=\"demo-snippets\">\n <div class=\"docfy-demo__snippets__tabs\" data-test-id=\"demo-tabs\">\n {{#each this.snippets as |snippet|}}\n <button\n type=\"button\"\n class=\"docfy-demo__snippets__tabs__button\n {{if\n (docfyEq this.active snippet.id)\n 'docfy-demo__snippets__tabs__button--active'\n }}\"\n data-test-id=\"demo-tab-button\"\n data-test-snippet-name=\"{{snippet.name}}\"\n data-test-is-active=\"{{if\n (docfyEq this.active snippet.id)\n 'true'\n 'false'\n }}\"\n {{on \"click\" (fn this.setActiveSnippet snippet.id)}}\n >\n {{snippet.name}}\n </button>\n {{/each}}\n </div>\n\n {{yield\n (component\n DocfyDemoSnippet\n registerSnippet=this.registerSnippet\n active=this.active\n )\n }}\n </div>\n </template>\n}\n\n// Main DocfyDemo component\ninterface DocfyDemoArgs {\n id: string;\n}\n\ninterface DocfyDemoSignature {\n Args: DocfyDemoArgs;\n Element: HTMLDivElement;\n Blocks: {\n default: [\n {\n Example: TOC<DocfyDemoExampleSignature>;\n Description: any;\n Snippet: any;\n Snippets: typeof DocfyDemoSnippets;\n },\n ];\n };\n}\n\nexport default class DocfyDemo extends Component<DocfyDemoSignature> {\n <template>\n <div\n id={{@id}}\n class=\"docfy-demo\"\n data-test-id=\"docfy-demo\"\n data-test-demo-id=\"{{@id}}\"\n ...attributes\n >\n {{yield\n (hash\n Example=DocfyDemoExample\n Description=(component DocfyDemoDescription id=@id)\n Snippet=DocfyDemoSnippet\n Snippets=DocfyDemoSnippets\n )\n }}\n </div>\n </template>\n}\n"],"names":["docfyEq","helper","params","DocfyDemoDescription","Component","setComponentTemplate","precompileTemplate","strictMode","DocfyDemoExample","templateOnly","DocfyDemoSnippet","id","guidFor","constructor","owner","args","registerSnippet","name","charAt","toUpperCase","slice","isActive","active","DocfyDemoSnippets","g","prototype","tracked","i","sn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CAAAN,SAAA,EAAA,kBAAA,EAAA,CAFCO,MAAA,CAAA,CAAA;AAAA;AAID,EAAA;IAAA3B,oBAAA,CAAAC,kBAAA,CAAA,8uBAAA,EAiCA;MAAAC,UAAA,EAAA,IAAA;AAAA2B,MAAAA,KAAA,EAAAA,OAAA;QAAAlC,OAAA;QAAAmC,EAAA;QAAAC,EAAA;AAAA1B,QAAAA;AAAA,OAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;AAEA;;AAoBe,MAAM2B,kBAAkBjC,SAAA,CAAU;AAC/C,EAAA;IAAAC,oBAAA,CAAAC,kBAAA,CAAA,4QAAA,EAiBA;MAAAC,UAAA,EAAA,IAAA;AAAA2B,MAAAA,KAAA,EAAAA,OAAA;QAAAI,IAAA;QAAA9B,gBAAA;QAAAL,oBAAA;QAAAO,gBAAA;AAAAa,QAAAA;AAAA,OAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;;;;"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
import Component from '@glimmer/component';
|
|
3
2
|
import { service } from '@ember/service';
|
|
4
3
|
import { action } from '@ember/object';
|
|
@@ -7,22 +6,40 @@ import { precompileTemplate } from '@ember/template-compilation';
|
|
|
7
6
|
import { setComponentTemplate } from '@ember/component';
|
|
8
7
|
import { g, i, n } from 'decorator-transforms/runtime';
|
|
9
8
|
|
|
9
|
+
/** Drop a trailing slash and any query string, so URLs compare by path. */function normalizePath(url) {
|
|
10
|
+
const path = url.split(/[?#]/)[0] ?? '';
|
|
11
|
+
return path.length > 1 ? path.replace(/\/+$/, '') : path;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* A link to a Docfy page.
|
|
15
|
+
*
|
|
16
|
+
* Docfy addresses pages by URL, and `@to` is already the router's path, so
|
|
17
|
+
* neither the href nor the active state needs the target route resolved.
|
|
18
|
+
*
|
|
19
|
+
* That matters under Embroider's `splitAtRoutes`: `RouterService#recognize()`
|
|
20
|
+
* resolves the matched route handlers, and resolving a route inside a split
|
|
21
|
+
* bundle makes `@embroider/router` fetch that bundle. Calling it from a getter
|
|
22
|
+
* meant that merely rendering a link downloaded the page it pointed at, so a
|
|
23
|
+
* page linking to every section pulled the whole documentation site up front.
|
|
24
|
+
* Recognition now happens in `navigate`, where the bundle is about to be needed
|
|
25
|
+
* anyway.
|
|
26
|
+
*/
|
|
10
27
|
class DocfyLink extends Component {
|
|
11
28
|
static {
|
|
12
29
|
g(this.prototype, "router", [service('router')]);
|
|
13
30
|
}
|
|
14
31
|
#router = (i(this, "router"), void 0);
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
32
|
+
/**
|
|
33
|
+
* `@to` as the router would produce it. Docfy gives index pages a trailing
|
|
34
|
+
* slash (`/docs/getting-started/`) where `urlFor` did not, so it is dropped
|
|
35
|
+
* here to keep the rendered href unchanged.
|
|
36
|
+
*/
|
|
37
|
+
get path() {
|
|
38
|
+
return normalizePath(this.args.to);
|
|
20
39
|
}
|
|
21
40
|
get href() {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
url = this.router.urlFor(this.routeName);
|
|
25
|
-
}
|
|
41
|
+
const rootURL = this.router.rootURL?.replace(/\/+$/, '') ?? '';
|
|
42
|
+
const url = `${rootURL}${this.path}`;
|
|
26
43
|
if (this.args.anchor) {
|
|
27
44
|
return `${url}#${this.args.anchor}`;
|
|
28
45
|
} else {
|
|
@@ -30,22 +47,37 @@ class DocfyLink extends Component {
|
|
|
30
47
|
}
|
|
31
48
|
}
|
|
32
49
|
get isActive() {
|
|
33
|
-
|
|
50
|
+
const {
|
|
51
|
+
currentURL
|
|
52
|
+
} = this.router;
|
|
53
|
+
if (!currentURL) {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
// `currentURL` is root-relative, but strip `rootURL` defensively so this
|
|
57
|
+
// holds however the router reports it.
|
|
58
|
+
const rootURL = this.router.rootURL?.replace(/\/+$/, '') ?? '';
|
|
59
|
+
const current = rootURL && currentURL.startsWith(rootURL) ? currentURL.slice(rootURL.length) : currentURL;
|
|
60
|
+
return normalizePath(current) === this.path;
|
|
34
61
|
}
|
|
35
62
|
navigate(event) {
|
|
36
63
|
if (event.ctrlKey || event.metaKey) {
|
|
37
64
|
return;
|
|
38
65
|
}
|
|
39
|
-
if (this.
|
|
40
|
-
|
|
41
|
-
|
|
66
|
+
if (this.args.anchor) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
// An unrecognised `@to` is left to the browser, as before.
|
|
70
|
+
if (!this.router.recognize(this.path)) {
|
|
71
|
+
return;
|
|
42
72
|
}
|
|
73
|
+
event.preventDefault();
|
|
74
|
+
this.router.transitionTo(this.path);
|
|
43
75
|
}
|
|
44
76
|
static {
|
|
45
77
|
n(this.prototype, "navigate", [action]);
|
|
46
78
|
}
|
|
47
79
|
static {
|
|
48
|
-
setComponentTemplate(precompileTemplate("
|
|
80
|
+
setComponentTemplate(precompileTemplate("<a class=\"docfy-link {{if this.isActive @activeClass}}\" ...attributes href={{this.href}} data-test-docfy-link data-test-to={{@to}} data-test-anchor={{@anchor}} data-test-is-active={{this.isActive}} {{on \"click\" this.navigate}}>\n {{yield}}\n</a>", {
|
|
49
81
|
strictMode: true,
|
|
50
82
|
scope: () => ({
|
|
51
83
|
on
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"docfy-link.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"docfy-link.js","sources":["../../src/components/docfy-link.gts"],"sourcesContent":["import Component from '@glimmer/component';\nimport { service } from '@ember/service';\nimport { action } from '@ember/object';\nimport { on } from '@ember/modifier';\nimport type RouterService from '@ember/routing/router-service';\n\ninterface DocfyLinkArgs {\n to: string;\n anchor?: string;\n activeClass?: string;\n}\n\ninterface DocfyLinkSignature {\n Args: DocfyLinkArgs;\n Element: HTMLAnchorElement;\n Blocks: {\n default: [];\n };\n}\n\n/** Drop a trailing slash and any query string, so URLs compare by path. */\nfunction normalizePath(url: string): string {\n const path = url.split(/[?#]/)[0] ?? '';\n\n return path.length > 1 ? path.replace(/\\/+$/, '') : path;\n}\n\n/**\n * A link to a Docfy page.\n *\n * Docfy addresses pages by URL, and `@to` is already the router's path, so\n * neither the href nor the active state needs the target route resolved.\n *\n * That matters under Embroider's `splitAtRoutes`: `RouterService#recognize()`\n * resolves the matched route handlers, and resolving a route inside a split\n * bundle makes `@embroider/router` fetch that bundle. Calling it from a getter\n * meant that merely rendering a link downloaded the page it pointed at, so a\n * page linking to every section pulled the whole documentation site up front.\n * Recognition now happens in `navigate`, where the bundle is about to be needed\n * anyway.\n */\nexport default class DocfyLink extends Component<DocfyLinkSignature> {\n @service('router') declare router: RouterService;\n\n /**\n * `@to` as the router would produce it. Docfy gives index pages a trailing\n * slash (`/docs/getting-started/`) where `urlFor` did not, so it is dropped\n * here to keep the rendered href unchanged.\n */\n get path(): string {\n return normalizePath(this.args.to);\n }\n\n get href(): string {\n const rootURL = this.router.rootURL?.replace(/\\/+$/, '') ?? '';\n const url = `${rootURL}${this.path}`;\n\n if (this.args.anchor) {\n return `${url}#${this.args.anchor}`;\n } else {\n return url;\n }\n }\n\n get isActive(): boolean {\n const { currentURL } = this.router;\n\n if (!currentURL) {\n return false;\n }\n\n // `currentURL` is root-relative, but strip `rootURL` defensively so this\n // holds however the router reports it.\n const rootURL = this.router.rootURL?.replace(/\\/+$/, '') ?? '';\n const current =\n rootURL && currentURL.startsWith(rootURL)\n ? currentURL.slice(rootURL.length)\n : currentURL;\n\n return normalizePath(current) === this.path;\n }\n\n @action\n navigate(event: MouseEvent): void {\n if (event.ctrlKey || event.metaKey) {\n return;\n }\n\n if (this.args.anchor) {\n return;\n }\n\n // An unrecognised `@to` is left to the browser, as before.\n if (!this.router.recognize(this.path)) {\n return;\n }\n\n event.preventDefault();\n this.router.transitionTo(this.path);\n }\n\n <template>\n <a\n class=\"docfy-link {{if this.isActive @activeClass}}\"\n ...attributes\n href={{this.href}}\n data-test-docfy-link\n data-test-to={{@to}}\n data-test-anchor={{@anchor}}\n data-test-is-active={{this.isActive}}\n {{on \"click\" this.navigate}}\n >\n {{yield}}\n </a>\n </template>\n}\n"],"names":["normalizePath","url","path","split","length","replace","DocfyLink","Component","g","prototype","service","i","args","to","href","rootURL","router","anchor","isActive","currentURL","current","startsWith","slice","navigate","event","ctrlKey","metaKey","recognize","preventDefault","transitionTo","n","action","setComponentTemplate","precompileTemplate","strictMode","scope","on"],"mappings":";;;;;;;;AAoBA,2EACA,SAASA,aAAAA,CAAcC,GAAW,EAAS;AACzC,EAAA,MAAMC,OAAOD,GAAA,CAAIE,KAAK,CAAC,MAAA,CAAO,CAAC,EAAE,IAAI,EAAA;AAErC,EAAA,OAAOD,IAAA,CAAKE,MAAM,GAAG,CAAA,GAAIF,KAAKG,OAAO,CAAC,QAAQ,EAAA,CAAA,GAAMH,IAAA;AACtD;AAEA;;;;;;;;;;;;;;AAce,MAAMI,SAAA,SAAkBC,SAAA,CAAU;AAAA,EAAA;AAAAC,IAAAA,CAAA,MAAAC,SAAA,EAAA,QAAA,EAAA,CAC9CC,OAAA,CAAQ,QAAA,CAAA,CAAA,CAAA;AAAA;EAAA,OAAA,IAAAC,CAAA,CAAA,IAAA,EAAA,QAAA,CAAA,EAAA,MAAA;AAET;;;;;EAKA,IAAIT,IAAAA,GAAe;AACjB,IAAA,OAAOF,aAAA,CAAc,IAAI,CAACY,IAAI,CAACC,EAAE,CAAA;AACnC,EAAA;EAEA,IAAIC,IAAAA,GAAe;AACjB,IAAA,MAAMC,OAAA,GAAU,IAAI,CAACC,MAAM,CAACD,OAAO,EAAEV,OAAA,CAAQ,MAAA,EAAQ,EAAA,CAAA,IAAO,EAAA;IAC5D,MAAMJ,MAAM,CAAA,EAAGc,OAAA,GAAU,IAAI,CAACb,IAAI,CAAA,CAAE;AAEpC,IAAA,IAAI,IAAI,CAACU,IAAI,CAACK,MAAM,EAAE;MACpB,OAAO,C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4PAAA,EAaA;MAAAC,UAAA,EAAA,IAAA;AAAAC,MAAAA,KAAA,EAAAA,OAAA;AAAAC,QAAAA;AAAA,OAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"docfy-output.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"docfy-output.js","sources":["../../src/components/docfy-output.gts"],"sourcesContent":["import Component from '@glimmer/component';\nimport { service } from '@ember/service';\nimport type RouterService from '@ember/routing/router-service';\n\nimport type DocfyService from '../services/docfy';\nimport type { NestedPageMetadata, PageMetadata } from '@docfy/core/lib/types';\n\ninterface DocfyOutputSignature {\n Args: {\n type?: 'flat' | 'nested';\n fromCurrentURL?: boolean;\n url?: string;\n scope?: string;\n };\n Blocks: {\n default: [\n output: NestedPageMetadata | PageMetadata[] | PageMetadata | undefined,\n ];\n };\n}\n\nexport default class DocfyOutput extends Component<DocfyOutputSignature> {\n @service('router') declare router: RouterService;\n @service('docfy') declare docfy: DocfyService;\n\n get output(): NestedPageMetadata | PageMetadata[] | PageMetadata | undefined {\n if (this.args.url) {\n return this.docfy.findByUrl(this.args.url, this.args.scope);\n }\n\n if (this.args.fromCurrentURL) {\n const currentURL = this.router.currentURL;\n if (!currentURL) return undefined;\n return this.docfy.findByUrl(currentURL, this.args.scope);\n }\n\n if (this.args.scope) {\n return this.docfy.findNestedChildrenByName(this.args.scope);\n }\n\n if (this.args.type === 'flat') {\n return this.docfy.flat;\n } else {\n return this.docfy.nested;\n }\n }\n\n <template>{{yield this.output}}</template>\n}\n"],"names":["DocfyOutput","Component","g","prototype","service","i","output","args","url","docfy","findByUrl","scope","fromCurrentURL","currentURL","router","undefined","findNestedChildrenByName","type","flat","nested","setComponentTemplate","precompileTemplate","strictMode"],"mappings":";;;;;;AAqBe,MAAMA,oBAAoBC,SAAA,CAAU;AAAA,EAAA;AAAAC,IAAAA,CAAA,MAA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CAAA,uBAAA,EAA+B;MAAAC,UAAA,EAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AAC3C;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"docfy-previous-and-next-page.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"docfy-previous-and-next-page.js","sources":["../../src/components/docfy-previous-and-next-page.gts"],"sourcesContent":["import Component from '@glimmer/component';\nimport { service } from '@ember/service';\nimport type DocfyService from '../services/docfy';\nimport type { PageMetadata } from '@docfy/core/lib/types';\n\ninterface DocfyPreviousAndNextPageArgs {\n scope?: string;\n}\n\ninterface DocfyPreviousAndNextPageSignature {\n Args: DocfyPreviousAndNextPageArgs;\n Element: HTMLDivElement;\n Blocks: {\n default: [\n previous: PageMetadata | undefined,\n next: PageMetadata | undefined,\n ];\n };\n}\n\nexport default class DocfyPreviousAndNextPage extends Component<DocfyPreviousAndNextPageSignature> {\n @service('docfy') declare docfy: DocfyService;\n\n get previous(): PageMetadata | undefined {\n return this.docfy.previousPage(this.args.scope);\n }\n\n get next(): PageMetadata | undefined {\n return this.docfy.nextPage(this.args.scope);\n }\n\n <template>{{yield this.previous this.next}}</template>\n}\n"],"names":["DocfyPreviousAndNextPage","Component","g","prototype","service","i","previous","docfy","previousPage","args","scope","next","nextPage","setComponentTemplate","precompileTemplate","strictMode"],"mappings":";;;;;;AAoBe,MAAMA,iCAAiCC,SAAA,CAAU;AAAA,EAAA;AAAAC,IAAAA,CAAA,MAAAC,SAAA,EAAA,OAAA,EAAA,CAC7DC,OAAA,CAAQ,OAAA,CAAA,CAAA,CAAA;AAAA;EAAA,MAAA,IAAAC,CAAA,CAAA,IAAA,EAAA,OAAA,CAAA,EAAA,MAAA;EAET,IAAIC,QAAAA,GAAqC;IACvC,OAAO,IAAI,CAACC,KAAK,CAACC,YAAY,CAAC,IAAI,CAACC,IAAI,CAACC,KAAK,CAAA;AAChD,EAAA;EAEA,IAAIC,IAAAA,GAAiC;IACnC,OAAO,IAAI,CAACJ,KAAK,CAACK,QAAQ,CAAC,IAAI,CAACH,IAAI,CAACC,KAAK,CAAA;AAC5C,EAAA;AAEA,EAAA;IAAAG,oBAAA,CAAAC,kBAAA,CAAA,mCAAA,EAA2C;MAAAC,UAAA,EAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACvD;;;;"}
|
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;"}
|
package/dist/routing.js
CHANGED
package/dist/routing.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routing.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"routing.js","sources":["../src/routing.ts"],"sourcesContent":["import output from '@docfy/ember/output:virtual';\nimport type { NestedPageMetadata } from '@docfy/core/lib/types';\n\ninterface RouterDSL {\n route(name: string, callback?: () => void): void;\n}\n\nfunction addFromNested(context: RouterDSL, nested: NestedPageMetadata): void {\n function add(this: RouterDSL): void {\n nested.pages.forEach((page) => {\n const url = page.relativeUrl;\n if (typeof url === 'string') {\n if (url !== '') {\n this.route(url);\n }\n }\n });\n\n nested.children.forEach((node) => {\n addFromNested(this, node);\n });\n }\n\n if (nested.name === '/') {\n add.call(context);\n } else {\n context.route(nested.name, add);\n }\n}\n\nexport function addDocfyRoutes(context: RouterDSL): void {\n addFromNested(context, output.nested);\n}\n"],"names":["addFromNested","context","nested","add","pages","forEach","page","url","relativeUrl","route","children","node","name","call","addDocfyRoutes","output"],"mappings":";;AAOA,SAASA,aAAaA,CAACC,OAAkB,EAAEC,MAA0B,EAAQ;EAC3E,SAASC,GAAGA,GAAwB;AAClCD,IAAAA,MAAM,CAACE,KAAK,CAACC,OAAO,CAAEC,IAAI,IAAK;AAC7B,MAAA,MAAMC,GAAG,GAAGD,IAAI,CAACE,WAAW;AAC5B,MAAA,IAAI,OAAOD,GAAG,KAAK,QAAQ,EAAE;QAC3B,IAAIA,GAAG,KAAK,EAAE,EAAE;AACd,UAAA,IAAI,CAACE,KAAK,CAACF,GAAG,CAAC;AACjB,QAAA;AACF,MAAA;AACF,IAAA,CAAC,CAAC;AAEFL,IAAAA,MAAM,CAACQ,QAAQ,CAACL,OAAO,CAAEM,IAAI,IAAK;AAChCX,MAAAA,aAAa,CAAC,IAAI,EAAEW,IAAI,CAAC;AAC3B,IAAA,CAAC,CAAC;AACJ,EAAA;AAEA,EAAA,IAAIT,MAAM,CAACU,IAAI,KAAK,GAAG,EAAE;AACvBT,IAAAA,GAAG,CAACU,IAAI,CAACZ,OAAO,CAAC;AACnB,EAAA,CAAC,MAAM;IACLA,OAAO,CAACQ,KAAK,CAACP,MAAM,CAACU,IAAI,EAAET,GAAG,CAAC;AACjC,EAAA;AACF;AAEO,SAASW,cAAcA,CAACb,OAAkB,EAAQ;AACvDD,EAAAA,aAAa,CAACC,OAAO,EAAEc,MAAM,CAACb,MAAM,CAAC;AACvC;;;;"}
|
package/dist/services/docfy.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"docfy.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"docfy.js","sources":["../../src/services/docfy.ts"],"sourcesContent":["import Service from '@ember/service';\nimport { service } from '@ember/service';\nimport { cached } from '@glimmer/tracking';\nimport output from '@docfy/ember/output:virtual';\nimport type RouterService from '@ember/routing/router-service';\nimport type { NestedPageMetadata, PageMetadata } from '@docfy/core/lib/types';\n\nfunction flatNested(\n output?: NestedPageMetadata,\n pages: PageMetadata[] = [],\n): PageMetadata[] {\n if (typeof output === 'undefined') {\n return [];\n }\n\n pages.push(...output.pages);\n\n output.children.forEach((child) => {\n flatNested(child, pages);\n });\n\n return pages;\n}\n\nexport default class DocfyService extends Service {\n @service('router') declare router: RouterService;\n\n @cached\n get currentPage() {\n const currentURL = this.router.currentURL;\n return currentURL ? this.findByUrl(currentURL) : undefined;\n }\n\n get flat(): PageMetadata[] {\n return flatNested(this.nested);\n }\n\n get nested(): NestedPageMetadata {\n return output.nested;\n }\n\n findNestedChildrenByName(\n scope: string,\n previousNested: NestedPageMetadata | undefined | null = null,\n ): NestedPageMetadata | undefined {\n if (previousNested === null) {\n previousNested = this.nested;\n }\n const parts = scope.split('/');\n const name = parts.shift();\n\n const foundScope = previousNested?.children.find((item) => {\n return item.name === name;\n });\n\n if (parts.length > 0) {\n return this.findNestedChildrenByName(parts.join('/'), foundScope);\n }\n\n return foundScope;\n }\n\n findByUrl(url: string, scopeByNestedName?: string): PageMetadata | undefined {\n let pages = this.flat;\n\n if (typeof scopeByNestedName === 'string') {\n pages = flatNested(this.findNestedChildrenByName(scopeByNestedName));\n }\n\n const cleanedUrl = url.split('#')[0] || '';\n const finalUrl = cleanedUrl.replace(/\\/$/, '');\n\n return pages.find((item) => {\n return item.url === finalUrl || item.url === `${finalUrl}/`;\n });\n }\n\n previousPage(scopeByNestedName?: string): PageMetadata | undefined {\n return this.findPreviousOrNextPage(true, scopeByNestedName);\n }\n\n nextPage(scopeByNestedName?: string): PageMetadata | undefined {\n return this.findPreviousOrNextPage(false, scopeByNestedName);\n }\n\n private findPreviousOrNextPage(\n isPrevious: boolean,\n scopeByNestedName?: string,\n ): PageMetadata | undefined {\n const currentPage = this.currentPage;\n let pages = this.flat;\n\n if (typeof scopeByNestedName === 'string') {\n pages = flatNested(this.findNestedChildrenByName(scopeByNestedName));\n }\n\n const index = pages.findIndex((page) => {\n return page === currentPage;\n });\n\n if (index > -1) {\n if (isPrevious) {\n return pages[index - 1];\n } else {\n return pages[index + 1];\n }\n }\n return undefined;\n }\n}\n"],"names":["flatNested","output","pages","push","children","forEach","child","DocfyService","Service","g","prototype","service","i","currentPage","currentURL","router","findByUrl","undefined","n","cached","flat","nested","findNestedChildrenByName","scope","previousNested","parts","split","name","shift","foundScope","find","item","length","join","url","scopeByNestedName","cleanedUrl","finalUrl","replace","previousPage","findPreviousOrNextPage","nextPage","isPrevious","index","findIndex","page"],"mappings":";;;;;AAOA,SAASA,UAAUA,CACjBC,MAA2B,EAC3BC,KAAqB,GAAG,EAAE,EACV;AAChB,EAAA,IAAI,OAAOD,MAAM,KAAK,WAAW,EAAE;AACjC,IAAA,OAAO,EAAE;AACX,EAAA;AAEAC,EAAAA,KAAK,CAACC,IAAI,CAAC,GAAGF,MAAM,CAACC,KAAK,CAAC;AAE3BD,EAAAA,MAAM,CAACG,QAAQ,CAACC,OAAO,CAAEC,KAAK,IAAK;AACjCN,IAAAA,UAAU,CAACM,KAAK,EAAEJ,KAAK,CAAC;AAC1B,EAAA,CAAC,CAAC;AAEF,EAAA,OAAOA,KAAK;AACd;AAEe,MAAMK,YAAY,SAASC,OAAO,CAAC;AAAA,EAAA;AAAAC,IAAAA,CAAA,MAAAC,SAAA,EAAA,QAAA,EAAA,CAC/CC,OAAO,CAAC,QAAQ,CAAC,CAAA,CAAA;AAAA;EAAA,OAAA,IAAAC,CAAA,CAAA,IAAA,EAAA,QAAA,CAAA,EAAA,MAAA;EAElB,IACIC,WAAWA,GAAG;AAChB,IAAA,MAAMC,UAAU,GAAG,IAAI,CAACC,MAAM,CAACD,UAAU;IACzC,OAAOA,UAAU,GAAG,IAAI,CAACE,SAAS,CAACF,UAAU,CAAC,GAAGG,SAAS;AAC5D,EAAA;AAAC,EAAA;IAAAC,CAAA,CAAA,IAAA,CAAAR,SAAA,EAAA,aAAA,EAAA,CAJAS,MAAM,CAAA,CAAA;AAAA;EAMP,IAAIC,IAAIA,GAAmB;AACzB,IAAA,OAAOpB,UAAU,CAAC,IAAI,CAACqB,MAAM,CAAC;AAChC,EAAA;EAEA,IAAIA,MAAMA,GAAuB;IAC/B,OAAOpB,MAAM,CAACoB,MAAM;AACtB,EAAA;AAEAC,EAAAA,wBAAwBA,CAC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A,CAAG;AAC7D,IAAA,CAAC,CAAC;AACJ,EAAA;EAEAE,YAAYA,CAACJ,iBAA0B,EAA4B;AACjE,IAAA,OAAO,IAAI,CAACK,sBAAsB,CAAC,IAAI,EAAEL,iBAAiB,CAAC;AAC7D,EAAA;EAEAM,QAAQA,CAACN,iBAA0B,EAA4B;AAC7D,IAAA,OAAO,IAAI,CAACK,sBAAsB,CAAC,KAAK,EAAEL,iBAAiB,CAAC;AAC9D,EAAA;AAEQK,EAAAA,sBAAsBA,CAC5BE,UAAmB,EACnBP,iBAA0B,EACA;AAC1B,IAAA,MAAMtB,WAAW,GAAG,IAAI,CAACA,WAAW;AACpC,IAAA,IAAIX,KAAK,GAAG,IAAI,CAACkB,IAAI;AAErB,IAAA,IAAI,OAAOe,iBAAiB,KAAK,QAAQ,EAAE;MACzCjC,KAAK,GAAGF,UAAU,CAAC,IAAI,CAACsB,wBAAwB,CAACa,iBAAiB,CAAC,CAAC;AACtE,IAAA;AAEA,IAAA,MAAMQ,KAAK,GAAGzC,KAAK,CAAC0C,SAAS,CAAEC,IAAI,IAAK;MACtC,OAAOA,IAAI,KAAKhC,WAAW;AAC7B,IAAA,CAAC,CAAC;AAEF,IAAA,IAAI8B,KAAK,GAAG,EAAE,EAAE;AACd,MAAA,IAAID,UAAU,EAAE;AACd,QAAA,OAAOxC,KAAK,CAACyC,KAAK,GAAG,CAAC,CAAC;AACzB,MAAA,CAAC,MAAM;AACL,QAAA,OAAOzC,KAAK,CAACyC,KAAK,GAAG,CAAC,CAAC;AACzB,MAAA;AACF,IAAA;AACA,IAAA,OAAO1B,SAAS;AAClB,EAAA;AACF;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docfy/ember",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.1",
|
|
4
4
|
"description": "The default blueprint for Embroider v2 addons.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ember-addon"
|
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
"compile": "rollup --config",
|
|
19
19
|
"format": "prettier . --cache --write",
|
|
20
20
|
"format:check": "prettier . --cache --check",
|
|
21
|
-
"lint": "concurrently \"
|
|
22
|
-
"lint:fix": "concurrently \"
|
|
21
|
+
"lint": "concurrently \"pnpm:lint:js\" \"pnpm:lint:hbs\" \"pnpm:lint:types\" \"pnpm:lint:format\" --names \"lint:\" --prefixColors auto",
|
|
22
|
+
"lint:fix": "concurrently \"pnpm:lint:*:fix\" --names \"fix:\" --prefixColors auto && pnpm format",
|
|
23
23
|
"lint:format": "prettier . --cache --check",
|
|
24
24
|
"lint:hbs": "ember-template-lint . --no-error-on-unmatched-pattern",
|
|
25
25
|
"lint:js": "eslint . --cache",
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
"prepack": "rollup --config"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
+
"@docfy/core": "^0.12.0",
|
|
32
33
|
"@embroider/addon-shim": "^1.8.9",
|
|
33
34
|
"@embroider/macros": "^1.18.1",
|
|
34
35
|
"decorator-transforms": "^2.3.0"
|
|
@@ -104,5 +105,5 @@
|
|
|
104
105
|
]
|
|
105
106
|
}
|
|
106
107
|
},
|
|
107
|
-
"gitHead": "
|
|
108
|
+
"gitHead": "1988a45f449abc4c71643f07deeae07947a38fe2"
|
|
108
109
|
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { NestedPageMetadata } from '@docfy/core/lib/types';
|
|
2
|
-
/**
|
|
3
|
-
* Find a nested section by scope path (e.g., 'docs' or 'docs/category1').
|
|
4
|
-
* This is a shared utility used by both the routing module and the DocfyService.
|
|
5
|
-
*
|
|
6
|
-
* @param scope - The scope path to search for (e.g., 'docs', 'docs/category1/components')
|
|
7
|
-
* @param nested - The nested structure to search in
|
|
8
|
-
* @returns The found NestedPageMetadata or undefined if not found
|
|
9
|
-
*/
|
|
10
|
-
export declare function findNestedByScope(scope: string, nested: NestedPageMetadata): NestedPageMetadata | undefined;
|
|
11
|
-
//# sourceMappingURL=nested.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"nested.d.ts","sourceRoot":"","sources":["../../src/utils/nested.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAEhE;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,kBAAkB,GACzB,kBAAkB,GAAG,SAAS,CAqBhC"}
|
package/dist/output.d.ts
DELETED
package/dist/output.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"output.d.ts","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
package/dist/output.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* The actual output.js file is generated at build time. This is a temporary
|
|
3
|
-
* placeholder to resolve the import until the proper build-time generation
|
|
4
|
-
* is set up.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
const output = {
|
|
8
|
-
nested: {
|
|
9
|
-
name: '',
|
|
10
|
-
route: '',
|
|
11
|
-
pages: [],
|
|
12
|
-
children: []
|
|
13
|
-
}
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export default output;
|
|
17
|
-
//# sourceMappingURL=output.js.map
|
package/dist/output.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"output.js","sources":["../src/output.d.ts"],"sourcesContent":["/*\n * The actual output.js file is generated at build time. This is only to\n * provide typing.\n */\nimport type { NestedPageMetadata } from '@docfy/core/lib/types';\n\ninterface Output {\n nested: NestedPageMetadata;\n}\n\ndeclare const output: Output;\n\nexport default output;\n"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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