Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Migrate build to Vite #2959

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
106 changes: 106 additions & 0 deletions docs/histoire-setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
import { defineSetupVue2 } from '@histoire/plugin-vue2'

import Vue from 'vue'
import './assets/additional.css'
import './assets/icons.css'

/**
* From server util.js
*
* @param {string} t The string to chunkify
* @return {Array}
*/
function chunkify(t) {
// Adapted from http://my.opera.com/GreyWyvern/blog/show.dml/1671288
const tz = []
let x = 0
let y = -1
let n = 0
let c

while (x < t.length) {
c = t.charAt(x) // only include the dot in strings

const m = !n && (c === '.' || (c >= '0' && c <= '9'))

if (m !== n) {
// next chunk
y++
tz[y] = ''
n = m
}

tz[y] += c
x++
}

return tz
}

window.OC = {
getCurrentUser() {
return {
uid: 'admin',
displayName: 'Administrator',
}
},
generateUrl() {
return 'https://nextcloud.com/wp-content/themes/next/assets/img/common/nextcloud-square-logo.png'
},
getLanguage() {
return 'en'
},
isUserAdmin() {
return true
},
config: {},
Util: {
/**
* Compare two strings to provide a natural sort
*
* @param {string} a first string to compare
* @param {string} b second string to compare
* @return {number} -1 if b comes before a, 1 if a comes before b
* or 0 if the strings are identical
*/
naturalSortCompare: function naturalSortCompare(a, b) {
let x
const aa = chunkify(a)
const bb = chunkify(b)

for (x = 0; aa[x] && bb[x]; x++) {
if (aa[x] !== bb[x]) {
const aNum = Number(aa[x])
const bNum = Number(bb[x]) // note: == is correct here

/* eslint-disable-next-line */
if (aNum == aa[x] && bNum == bb[x]) {
return aNum - bNum
} else {
// Note: This locale setting isn't supported by all browsers but for the ones
// that do there will be more consistency between client-server sorting
return aa[x].localeCompare(bb[x], OC.getLanguage())
}
}
}

return aa.length - bb.length
},
},
webroot: '',
}

window.OCA = {}
window.appName = 'nextcloud-vue'

window.NextcloudVueDocs = {
tags: '<?xml version="1.0"?><d:multistatus xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns" xmlns:oc="http://owncloud.org/ns" xmlns:nc="http://nextcloud.org/ns"><d:response><d:href>/remote.php/dav/systemtags/</d:href><d:propstat><d:prop><oc:id/><oc:display-name/><oc:user-visible/><oc:user-assignable/><oc:can-assign/></d:prop><d:status>HTTP/1.1 404 Not Found</d:status></d:propstat></d:response><d:response><d:href>/remote.php/dav/systemtags/7</d:href><d:propstat><d:prop><oc:id>7</oc:id><oc:display-name>tag1</oc:display-name><oc:user-visible>true</oc:user-visible><oc:user-assignable>true</oc:user-assignable><oc:can-assign>true</oc:can-assign></d:prop><d:status>HTTP/1.1 200 OK</d:status></d:propstat></d:response><d:response><d:href>/remote.php/dav/systemtags/2</d:href><d:propstat><d:prop><oc:id>2</oc:id><oc:display-name>tag2</oc:display-name><oc:user-visible>false</oc:user-visible><oc:user-assignable>true</oc:user-assignable><oc:can-assign>true</oc:can-assign></d:prop><d:status>HTTP/1.1 200 OK</d:status></d:propstat></d:response><d:response><d:href>/remote.php/dav/systemtags/3</d:href><d:propstat><d:prop><oc:id>3</oc:id><oc:display-name>tag3</oc:display-name><oc:user-visible>true</oc:user-visible><oc:user-assignable>true</oc:user-assignable><oc:can-assign>true</oc:can-assign></d:prop><d:status>HTTP/1.1 200 OK</d:status></d:propstat></d:response><d:response><d:href>/remote.php/dav/systemtags/4</d:href><d:propstat><d:prop><oc:id>4</oc:id><oc:display-name>important</oc:display-name><oc:user-visible>true</oc:user-visible><oc:user-assignable>true</oc:user-assignable><oc:can-assign>true</oc:can-assign></d:prop><d:status>HTTP/1.1 200 OK</d:status></d:propstat></d:response><d:response><d:href>/remote.php/dav/systemtags/1</d:href><d:propstat><d:prop><oc:id>1</oc:id><oc:display-name>secret</oc:display-name><oc:user-visible>true</oc:user-visible><oc:user-assignable>false</oc:user-assignable><oc:can-assign>true</oc:can-assign></d:prop><d:status>HTTP/1.1 200 OK</d:status></d:propstat></d:response><d:response><d:href>/remote.php/dav/systemtags/5</d:href><d:propstat><d:prop><oc:id>5</oc:id><oc:display-name>test</oc:display-name><oc:user-visible>true</oc:user-visible><oc:user-assignable>false</oc:user-assignable><oc:can-assign>true</oc:can-assign></d:prop><d:status>HTTP/1.1 200 OK</d:status></d:propstat></d:response><d:response><d:href>/remote.php/dav/systemtags/6</d:href><d:propstat><d:prop><oc:id>6</oc:id><oc:display-name>test2</oc:display-name><oc:user-visible>false</oc:user-visible><oc:user-assignable>false</oc:user-assignable><oc:can-assign>true</oc:can-assign></d:prop><d:status>HTTP/1.1 200 OK</d:status></d:propstat></d:response></d:multistatus>',
}

export const setupVue2 = defineSetupVue2(({ story, variant }) => {
Vue.prototype.OC = window.OC
Vue.prototype.OCA = window.OCA

// App options
return {}
})
13 changes: 13 additions & 0 deletions histoire.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { defineConfig } from 'histoire'
import { HstVue } from '@histoire/plugin-vue2'

export default defineConfig({
setupFile: './docs/histoire-setup.js',
plugins: [
HstVue(),
],
theme: {
title: '@nextcloud/vue',
logoHref: 'https://github.com/nextcloud/nextcloud-vue',
},
})
8 changes: 8 additions & 0 deletions jsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"vueCompilerOptions": {
"target": 2.7
},
"include": [
"./src/**/*"
]
}
Loading